diff options
Diffstat (limited to 'sw/Core/Src/lpzw.h')
| -rwxr-xr-x | sw/Core/Src/lpzw.h | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/sw/Core/Src/lpzw.h b/sw/Core/Src/lpzw.h deleted file mode 100755 index d61b717..0000000 --- a/sw/Core/Src/lpzw.h +++ /dev/null @@ -1,144 +0,0 @@ -#pragma once -// api for kay -// i2cbuf is a global ram 512 byte buffer ready to be sent over I2C. -// if you want to get fancy and send sub rectangles you need to start doing commands to the i2c controller -// so I ignored that for now -extern uint8_t i2cbuf[4][128]; - -void clearscreen(); // just sets i2cbuf to 0 -void drawlpzwlogo(int y); // y is the vertical position -int drawstr24(int x, int y, const char* txt); // draws a string 'txt' at position x,y. 0,0 is top left. clipped! returns string width in pixels -int strwidth24(const char* txt); // returns width of a string in pixels - -//////////////////// -// implementation: - -uint8_t i2cbuf[4][128]; -static const uint8_t logo32x32_rotated_pins_top[] PROGMEM = { -0xc0,0x70,0x38,0x1c,0x8e,0xc7,0x73,0x3b,0xbf,0xff,0x77,0x33,0x7b,0xfb,0xdb,0x9b,0x1b,0x1b,0x1b,0x1b,0x33,0x67,0xcf,0x9f,0x33,0x63,0xc7,0x8e,0x1c,0x30,0xe0,0xc0, -0x9f,0xce,0xe6,0x73,0x39,0x0f,0x07,0x03,0x01,0x00,0x1f,0x3f,0x3c,0x38,0x21,0x23,0x23,0xe3,0xe3,0x83,0xff,0xff,0x19,0x19,0xff,0xfe,0x1c,0x39,0x73,0xee,0xdf,0x9f, -0xf9,0x73,0x67,0xce,0x9c,0xf0,0xe0,0xc0,0x80,0x00,0xf8,0xfc,0x3c,0x1c,0x84,0xc4,0xc4,0xc7,0xc7,0xc1,0xff,0xff,0x98,0x98,0xff,0x7f,0x38,0x9c,0xce,0x77,0xfb,0xf9, -0x03,0x0e,0x1c,0x38,0x71,0xe3,0xce,0xdc,0xfd,0xff,0xee,0xcc,0xde,0xdf,0xdb,0xd9,0xd8,0xd8,0xd8,0xd8,0xcc,0xe6,0xf3,0xf9,0xcc,0xc6,0xe3,0x71,0x38,0x0c,0x07,0x03, -}; -/* -static const uint8_t logo32x32_rotated_pins_bottom[] PROGMEM = { -0xc0,0xe0,0x30,0x1c,0x8e,0xc7,0x63,0x33,0x9f,0xcf,0x67,0x33,0x1b,0x1b,0x1b,0x1b,0x9b,0xdb,0xfb,0x7b,0x33,0x77,0xff,0xbf,0x3b,0x73,0xc7,0x8e,0x1c,0x38,0x70,0xc0, -0x9f,0xdf,0xee,0x73,0x39,0x1c,0xfe,0xff,0x19,0x19,0xff,0xff,0x83,0xe3,0xe3,0x23,0x23,0x21,0x38,0x3c,0x3f,0x1f,0x00,0x01,0x03,0x07,0x0f,0x39,0x73,0xe6,0xce,0x9f, -0xf9,0xfb,0x77,0xce,0x9c,0x38,0x7f,0xff,0x98,0x98,0xff,0xff,0xc1,0xc7,0xc7,0xc4,0xc4,0x84,0x1c,0x3c,0xfc,0xf8,0x00,0x80,0xc0,0xe0,0xf0,0x9c,0xce,0x67,0x73,0xf9, -0x03,0x07,0x0c,0x38,0x71,0xe3,0xc6,0xcc,0xf9,0xf3,0xe6,0xcc,0xd8,0xd8,0xd8,0xd8,0xd9,0xdb,0xdf,0xde,0xcc,0xee,0xff,0xfd,0xdc,0xce,0xe3,0x71,0x38,0x1c,0x0e,0x03, -}; -*/ -#define FONT24_WIDTH 58 -static const uint16_t font24_xpos[] PROGMEM = { -0,2,7,16,24,32,42,43,46,49,56,68,70,77,79,84,91,95,102,109,117,124,131,138,145,152,154,157,169,181,193,200,218,227,235,242,250,257,264,272,279,281,288,297,304,315,323,331,338,347,356,364,372,380,389,403,412,420,427,430,434,438,450,461 }; -static const uint8_t font24[24][FONT24_WIDTH] PROGMEM = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x4f,0x11,0x7c,0xe2,0x00,0x04,0x11,0x00,0x00,0x80,0xe1,0x3b,0x9e,0x0f,0xe3,0xc7,0xf8,0x7b,0x3c,0x00,0x00,0x00,0x00,0x00,0x78,0xe0,0x0f,0x60,0xe0,0xf7,0xf1,0xff,0xff,0x7c,0xe3,0x07,0x86,0xc1,0x03,0x1e,0xe6,0xf1,0xe3,0xe3,0xcf,0xf7,0x3f,0x3c,0xf8,0x18,0x37,0x3c,0xfc,0x3b,0x3e,0x18,0x00,0x00, -0x4f,0x11,0xfe,0xa6,0x00,0x0c,0x11,0x00,0x00,0x00,0xf1,0x7b,0xbf,0x1f,0xe3,0xc7,0xf8,0xff,0x7e,0x00,0x00,0x00,0x00,0x00,0xfc,0x18,0x38,0x60,0xf0,0xff,0xfb,0xff,0xff,0xfe,0xe3,0x07,0x86,0xc1,0x03,0x1f,0xf7,0xfb,0xf3,0xf7,0xef,0xff,0x3f,0x3c,0xdc,0x18,0x33,0x36,0xfc,0x23,0x0f,0x38,0x00,0x00, -0x4f,0x13,0xd7,0xa4,0xf8,0x0c,0xfd,0x00,0x00,0x00,0x31,0xff,0xf3,0x18,0x07,0xc4,0x19,0xcf,0x67,0x00,0x00,0x00,0x00,0x00,0xce,0x0c,0x60,0xe0,0x38,0x1e,0x1b,0x83,0xc1,0xc7,0xe3,0x07,0x8c,0xc1,0x07,0x1f,0x3f,0x1e,0x33,0x36,0x7c,0x8c,0x31,0x6c,0xcc,0x18,0x63,0x66,0x3c,0x20,0x0f,0x24,0x00,0x00, -0x4f,0x13,0xd3,0xe4,0x98,0x9d,0x38,0x00,0x00,0x00,0x31,0x9e,0xf1,0x18,0x06,0x84,0x19,0x8f,0xc7,0x00,0x00,0x00,0x00,0x00,0xc6,0x06,0xc0,0xe0,0x18,0x1e,0x1f,0x83,0xc1,0xc3,0xe3,0x07,0x8c,0xc1,0x87,0x1f,0x1f,0x1e,0x1b,0x36,0x3c,0x8c,0x31,0x6c,0xcc,0x18,0x63,0x66,0x36,0x20,0x0d,0x64,0x00,0x00, -0x03,0x32,0xd0,0x4c,0x88,0x91,0x7c,0x00,0x00,0x00,0x33,0x9e,0xc1,0x00,0x06,0x84,0x31,0x8c,0xc7,0x00,0x00,0x00,0x00,0x00,0x06,0xd2,0x87,0xf1,0x18,0x06,0x0f,0x83,0xc1,0xc0,0xe3,0x07,0x88,0xc1,0x87,0x9f,0x1f,0x0e,0x1b,0x36,0x0c,0x8c,0x31,0x6c,0xcc,0x3c,0x63,0x63,0x66,0x20,0x0d,0x42,0x00,0x00, -0x83,0x7f,0xd0,0x08,0x98,0x91,0x96,0x20,0x00,0x00,0x33,0x9e,0xc3,0x00,0x06,0x84,0x33,0x8c,0xc7,0x20,0x00,0x00,0x00,0x00,0x05,0x73,0x8c,0xb1,0x18,0x06,0x0f,0x83,0xc1,0xc0,0xe3,0x07,0x98,0xc1,0x8f,0x9f,0x1f,0x0e,0x1b,0x36,0x0c,0x8c,0x31,0x6c,0xcc,0x3c,0xc3,0xc3,0x66,0x20,0x0d,0xc2,0x00,0x00, -0x03,0x22,0xf0,0x08,0x98,0xd1,0x10,0x20,0x00,0x00,0x32,0x1e,0xc3,0x00,0xcc,0x06,0x33,0xcc,0x47,0xe0,0x00,0x00,0x00,0xe0,0x0d,0x33,0x18,0xb1,0x39,0x06,0x0f,0x83,0xc1,0xc0,0xe3,0x07,0x90,0xc1,0xcf,0x9f,0x1f,0x1e,0x1b,0x36,0x0c,0x8e,0x31,0x6c,0xcc,0x3c,0xc3,0xc1,0xe3,0xa0,0x0d,0x81,0x00,0x00, -0x03,0x22,0x78,0x10,0xf0,0xf0,0x00,0x20,0x00,0x00,0x32,0x1e,0x83,0x83,0xec,0xe7,0x63,0xf8,0x66,0x80,0x03,0x00,0x00,0x38,0x1c,0x23,0x10,0x91,0xf1,0x07,0x0f,0xfb,0xc1,0xc0,0xff,0x07,0xf8,0xc1,0xcb,0xde,0x1e,0x1e,0x1b,0x76,0x8e,0x87,0x31,0x4c,0xc6,0x24,0x83,0xc1,0xc3,0xa0,0x8d,0x81,0x01,0x00, -0x03,0x22,0x3e,0x10,0xe0,0xf0,0x00,0x20,0x00,0x00,0x32,0x1e,0x86,0xc3,0x6c,0xe6,0x67,0xf8,0x7e,0x00,0x1e,0xfe,0x1f,0x0e,0x18,0x63,0x30,0x9b,0xf1,0x07,0x0f,0xfb,0xfd,0xcf,0xff,0x07,0xf8,0xc1,0xdb,0xde,0x1e,0xfe,0x1b,0xe6,0xef,0x83,0x31,0xcc,0x86,0x24,0x81,0x81,0xc3,0xa0,0x8d,0x00,0x01,0x00, -0x02,0x22,0x1e,0x10,0xe0,0xf0,0x00,0x20,0xc0,0x1f,0x36,0x1e,0xc6,0xc1,0x78,0x70,0x66,0xcc,0x3f,0x0b,0x70,0x00,0x80,0x03,0x18,0x62,0x30,0x99,0x39,0x06,0x0f,0x83,0xc1,0xcf,0xe3,0x07,0xf8,0xc1,0x7b,0x5e,0x1e,0xf6,0x1b,0xc6,0xee,0x80,0x31,0xcc,0x86,0xa5,0xc1,0x81,0x81,0xa1,0xcc,0x00,0x03,0x00, -0x02,0x66,0x16,0x20,0xf0,0xf1,0x00,0xff,0xcf,0x1f,0x36,0x1e,0xcc,0xc0,0x78,0x30,0xe6,0x8c,0x0d,0x1f,0xc0,0x01,0xe0,0x00,0x30,0x46,0x30,0x19,0x19,0x06,0x0f,0x83,0xc1,0xc3,0xe3,0x07,0xcc,0xc1,0x73,0x7e,0x1e,0x06,0x1b,0x66,0x6c,0x80,0x31,0xcc,0x86,0xe7,0xc1,0x83,0x81,0xa1,0x0c,0x00,0x00,0x00, -0x02,0xff,0x13,0x20,0x32,0xf1,0x00,0xff,0x0f,0x00,0x36,0x1e,0xcc,0xc0,0x78,0x30,0xc6,0x8c,0x0d,0x00,0xc0,0x01,0xe0,0x00,0x30,0xc4,0x30,0xf9,0x1b,0x06,0x0f,0x83,0xc1,0xc3,0xe3,0x07,0xcc,0xc1,0x73,0x7e,0x1e,0x06,0x1b,0x66,0x3c,0x80,0x31,0xcc,0x83,0xe7,0xe1,0x83,0x81,0xa1,0x0c,0x00,0x00,0x00, -0x00,0x64,0x13,0x26,0x1a,0xf3,0x00,0x20,0x00,0x00,0x34,0x1e,0xd8,0xd8,0x79,0x30,0xc6,0x8c,0x19,0x00,0x70,0x00,0x80,0x03,0x30,0x78,0x9f,0xf9,0x1b,0x06,0x0f,0x83,0xc1,0xc3,0xe3,0x07,0x8e,0xc1,0x33,0x3e,0x1e,0x06,0x1b,0x66,0x3c,0x80,0x31,0x8c,0x83,0xe7,0x61,0x86,0x01,0xe3,0x0c,0x00,0x00,0x00, -0x00,0x44,0xd3,0x4a,0x0e,0xd3,0x00,0x20,0x00,0x00,0x34,0x1e,0xf8,0xf8,0x7f,0x3c,0xc6,0x8c,0x19,0x00,0x1e,0xfe,0x1f,0x0e,0x00,0x22,0xc4,0x0c,0x1b,0x1e,0x1b,0x83,0xc1,0xc3,0xe3,0x0d,0x86,0xc1,0x23,0x3e,0x1e,0x06,0x7b,0x36,0x3c,0x8c,0x31,0x8c,0x83,0xc3,0x61,0x86,0x01,0xe3,0x0c,0x00,0x00,0x00, -0x00,0x44,0xd6,0x49,0x0c,0x93,0x00,0x20,0x00,0x00,0x34,0x1f,0xf0,0xd8,0x61,0x76,0x86,0xcd,0x39,0x80,0x03,0x00,0x00,0x38,0x00,0x0c,0x60,0x0c,0x3b,0x1e,0x1b,0x83,0xc1,0xc7,0xe3,0x0d,0x86,0xc1,0x03,0x3e,0x3e,0x07,0x73,0x36,0x6c,0x8c,0x71,0x86,0x03,0xc3,0x31,0x86,0x01,0x63,0x0c,0x00,0x00,0x00, -0x03,0x44,0xfe,0x4a,0xde,0x91,0x00,0x20,0x30,0x60,0xfc,0x9b,0xbf,0xdf,0xe0,0xe7,0x87,0xfd,0x30,0xff,0x00,0x00,0x00,0xe0,0x31,0x38,0x38,0x0c,0xf6,0xff,0xfb,0xff,0xc1,0x7e,0xe3,0xfd,0x83,0xff,0x03,0x1e,0xf6,0x03,0xfb,0x37,0xec,0x8f,0xe1,0x87,0x03,0xc3,0x30,0x8c,0xf1,0x67,0x0c,0x00,0x00,0x00, -0x03,0x44,0x7c,0x8e,0xf3,0x88,0x01,0x20,0x30,0x60,0xec,0x99,0xbf,0xcf,0xc0,0xc3,0x83,0x79,0x30,0x3f,0x00,0x00,0x00,0x00,0x31,0xe0,0x0f,0x0c,0xe6,0xf7,0xf1,0xff,0xc1,0x3c,0xe3,0xf9,0x83,0xff,0x03,0x1e,0xe6,0x01,0xef,0x1b,0xcc,0x87,0xc1,0x83,0x01,0xc3,0x38,0x8c,0xf1,0x67,0x0c,0x00,0x00,0x00, -0x00,0x00,0x10,0x00,0x00,0x08,0x01,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x0c,0x00,0x00,0x00, -0x00,0x00,0x10,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0c,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x1c,0x00,0xfc,0x1f, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -}; - -void clearscreen() { - for (int y = 0; y < 128 * 4; ++y) i2cbuf[0][y] = 0; -} -void drawlpzwlogo(int y) { - if (y < -32 || y >= 128) return; - const uint8_t* src = logo32x32_rotated_pins_top; - int h = 32; - if (y + h > 128) h = 128 - y; - if (y < 0) { - h += y; - src -= y; - y = 0; - } - for (int r = 0; r < 4; ++r) { - uint8_t* dst = &i2cbuf[r][y]; - for (int yy = 0; yy < h; ++yy) *dst++ = *src++; - src += 32 - h; - } -} -int drawchar24_internal(int dstx, int dsty, int c); -int drawstr24(int x, int y, const char* txt) { // returns width of string - // character drawer is flipped in x. so lets figure that out first; - x = 32 - x; - int startx = x; - for (; *txt; ++txt) - x -= drawchar24_internal(x, y, *txt); - return startx - x; -} -int strwidth24(const char* txt) { - int w = 0; - for (; *txt; ++txt) { - char c = *txt; - if (c < 33 || c >= 0x60) - w += 4; - else - w += font24_xpos[c - 32] - font24_xpos[c - 33] + 1; - } - return w; -} -int drawchar24_internal(int dstx, int dsty, int c) { // nb x is flipped here, for internal use only. returns char width - if (c < 33 || c >= 0x60) - return 4; // space size - c -= 33; - int x1 = font24_xpos[c]; - int x2 = font24_xpos[c + 1]; - int xw = x2 - x1; - int srcbyte = (x1 >> 3); - uint8_t* src = &font24[0][srcbyte]; - uint8_t shift = (x1 & 7); - uint32_t mask = (1 << (x2 - x1)) - 1; - dstx -= xw; // because we are flipped, we need to pre-advance x! - if (dstx >= 32 || dstx < -xw || dsty < -24 || dsty >= 128) - return xw + 1; // offscreen - if (dstx < 0) { - shift -= dstx; - mask >>= -dstx; - dstx = 0; - } - uint8_t dstshift = dstx & 7; - uint8_t* dst = &i2cbuf[(dstx >> 3)][dsty]; - int dsth = 24; - if (dsty < 0) { - dsth += dsty; // decrease h - dst -= dsty; // advance dst - src -= FONT24_WIDTH * dsty; // advance src - dsty = 0; // clipped! - } - if (dsty + dsth > 128) dsth = 128 - dsty; - for (int y = 0; y < dsth; ++y) { - uint32_t pixels = *(uint32_t*)src; - src += FONT24_WIDTH; - pixels >>= shift; - pixels &= mask; - pixels <<= dstshift; - for (int x = 0; x < 4; ++x) { - *dst |= (uint8_t)pixels; - pixels >>= 8; - dst += 128; - } - dst -= 128 * 4 - 1; - } - return xw + 1; -} - |
