BV OLED: add and use generic text drawing function

This commit is contained in:
King Kévin 2018-07-01 15:26:11 +02:00
parent 863af91eca
commit 7fc6551dfe
2 changed files with 116 additions and 408 deletions

View File

@ -27,6 +27,7 @@
#include "global.h" // global utilities
#include "busvoodoo_oled.h" // own definitions
#include "oled_ssd1306.h" // OLED display utilities
#include "font.h" // font glyphs
/** if the OLED display is present and setup */
static bool busvoodoo_oled_present = false;
@ -34,302 +35,10 @@ static bool busvoodoo_oled_present = false;
/** display pixel buffer */
static uint8_t busvoodoo_oled_display[128*8] = {0};
/** 8x5 px monospace bitmap font (starting with space, first byte is glyph left column, MSb is glyph top pixel) */
static const uint8_t font_king8[95][5] = {
{0x00, 0x00, 0x00, 0x00, 0x00, }, // ' '
{0x00, 0x00, 0x5f, 0x00, 0x00, }, // '!'
{0x00, 0x03, 0x00, 0x03, 0x00, }, // '"'
{0x14, 0x3e, 0x14, 0x3e, 0x14, }, // '#'
{0x24, 0x2a, 0x7f, 0x2a, 0x12, }, // '$'
{0x63, 0x13, 0x08, 0x64, 0x63, }, // '%'
{0x36, 0x49, 0x56, 0x20, 0x50, }, // '&'
{0x00, 0x03, 0x00, 0x00, 0x00, }, // '''
{0x00, 0x3c, 0x42, 0x81, 0x00, }, // '('
{0x00, 0x81, 0x42, 0x3c, 0x00, }, // ')'
{0x2a, 0x1c, 0x3e, 0x1c, 0x2a, }, // '*'
{0x08, 0x08, 0x3e, 0x08, 0x08, }, // '+'
{0x00, 0x40, 0x30, 0x00, 0x00, }, // ','
{0x00, 0x08, 0x08, 0x08, 0x00, }, // '-'
{0x00, 0x00, 0x30, 0x00, 0x00, }, // '.'
{0x60, 0x10, 0x08, 0x04, 0x03, }, // '/'
{0x3e, 0x51, 0x49, 0x45, 0x3e, }, // '0'
{0x00, 0x42, 0x7f, 0x40, 0x00, }, // '1'
{0x00, 0x61, 0x51, 0x49, 0x46, }, // '2'
{0x00, 0x41, 0x49, 0x49, 0x36, }, // '3'
{0x18, 0x14, 0x12, 0x7f, 0x10, }, // '4'
{0x27, 0x45, 0x45, 0x45, 0x39, }, // '5'
{0x3e, 0x49, 0x49, 0x49, 0x30, }, // '6'
{0x01, 0x71, 0x09, 0x05, 0x03, }, // '7'
{0x36, 0x49, 0x49, 0x49, 0x36, }, // '8'
{0x06, 0x49, 0x49, 0x49, 0x3e, }, // '9'
{0x00, 0x00, 0x36, 0x00, 0x00, }, // ':'
{0x00, 0x40, 0x36, 0x00, 0x00, }, // ';'
{0x00, 0x08, 0x14, 0x22, 0x00, }, // '<'
{0x00, 0x14, 0x14, 0x14, 0x00, }, // '='
{0x00, 0x22, 0x14, 0x08, 0x00, }, // '>'
{0x02, 0x01, 0x59, 0x05, 0x02, }, // '?'
{0x3e, 0x41, 0x5d, 0x55, 0x5e, }, // '@'
{0x7e, 0x09, 0x09, 0x09, 0x7e, }, // 'A'
{0x7f, 0x49, 0x49, 0x49, 0x36, }, // 'B'
{0x3e, 0x41, 0x41, 0x41, 0x41, }, // 'C'
{0x7f, 0x41, 0x41, 0x41, 0x3e, }, // 'D'
{0x7f, 0x49, 0x49, 0x49, 0x41, }, // 'E'
{0x7f, 0x09, 0x09, 0x09, 0x01, }, // 'F'
{0x3e, 0x41, 0x41, 0x49, 0x39, }, // 'G'
{0x7f, 0x08, 0x08, 0x08, 0x7f, }, // 'H'
{0x00, 0x41, 0x7f, 0x41, 0x00, }, // 'I'
{0x00, 0x41, 0x41, 0x3f, 0x00, }, // 'J'
{0x7f, 0x08, 0x14, 0x22, 0x41, }, // 'K'
{0x7f, 0x40, 0x40, 0x40, 0x40, }, // 'L'
{0x7f, 0x02, 0x04, 0x02, 0x7f, }, // 'M'
{0x7f, 0x04, 0x08, 0x10, 0x7f, }, // 'N'
{0x3e, 0x41, 0x41, 0x41, 0x3e, }, // 'O'
{0x7f, 0x09, 0x09, 0x09, 0x06, }, // 'P'
{0x3e, 0x41, 0x51, 0x21, 0x5e, }, // 'Q'
{0x7f, 0x09, 0x19, 0x29, 0x46, }, // 'R'
{0x46, 0x49, 0x49, 0x49, 0x31, }, // 'S'
{0x01, 0x01, 0x7f, 0x01, 0x01, }, // 'T'
{0x3f, 0x40, 0x40, 0x40, 0x3f, }, // 'U'
{0x07, 0x18, 0x60, 0x18, 0x07, }, // 'V'
{0x1f, 0x60, 0x18, 0x60, 0x1f, }, // 'W'
{0x63, 0x14, 0x08, 0x14, 0x63, }, // 'X'
{0x03, 0x04, 0x78, 0x04, 0x03, }, // 'Y'
{0x61, 0x51, 0x49, 0x45, 0x43, }, // 'Z'
{0x00, 0x7f, 0x41, 0x41, 0x00, }, // '['
{0x03, 0x04, 0x08, 0x10, 0x60, }, // '\'
{0x00, 0x41, 0x41, 0x7f, 0x00, }, // ']'
{0x00, 0x04, 0x02, 0x04, 0x00, }, // '^'
{0x40, 0x40, 0x40, 0x40, 0x40, }, // '_'
{0x00, 0x02, 0x04, 0x00, 0x00, }, // '`'
{0x20, 0x54, 0x54, 0x78, 0x00, }, // 'a'
{0x7e, 0x48, 0x48, 0x30, 0x00, }, // 'b'
{0x38, 0x44, 0x44, 0x44, 0x00, }, // 'c'
{0x30, 0x48, 0x48, 0x7e, 0x00, }, // 'd'
{0x38, 0x54, 0x54, 0x18, 0x00, }, // 'e'
{0x08, 0x7c, 0x0a, 0x02, 0x00, }, // 'f'
{0x18, 0xa4, 0xa4, 0x78, 0x00, }, // 'g'
{0x7e, 0x08, 0x08, 0x70, 0x00, }, // 'h'
{0x00, 0x08, 0x7a, 0x00, 0x00, }, // 'i'
{0x80, 0x80, 0x7a, 0x00, 0x00, }, // 'j'
{0x7e, 0x10, 0x28, 0x44, 0x00, }, // 'k'
{0x00, 0x02, 0x3e, 0x40, 0x00, }, // 'l'
{0x7c, 0x04, 0x78, 0x04, 0x78, }, // 'm'
{0x00, 0x7c, 0x04, 0x78, 0x00, }, // 'n'
{0x38, 0x44, 0x44, 0x38, 0x00, }, // 'o'
{0xfc, 0x24, 0x24, 0x18, 0x00, }, // 'p'
{0x18, 0x24, 0x24, 0xfc, 0x00, }, // 'q'
{0x7c, 0x08, 0x04, 0x08, 0x00, }, // 'r'
{0x48, 0x54, 0x54, 0x24, 0x00, }, // 's'
{0x3e, 0x48, 0x48, 0x40, 0x00, }, // 't'
{0x3c, 0x40, 0x40, 0x7c, 0x00, }, // 'u'
{0x1c, 0x20, 0x40, 0x20, 0x1c, }, // 'v'
{0x3c, 0x40, 0x30, 0x40, 0x3c, }, // 'w'
{0x6c, 0x10, 0x10, 0x6c, 0x00, }, // 'x'
{0x0c, 0x90, 0x90, 0x7c, 0x00, }, // 'y'
{0x64, 0x54, 0x54, 0x4c, 0x00, }, // 'z'
{0x08, 0x36, 0x41, 0x00, 0x00, }, // '{'
{0x00, 0x00, 0x7f, 0x00, 0x00, }, // '|'
{0x00, 0x41, 0x36, 0x08, 0x00, }, // '}'
{0x04, 0x02, 0x06, 0x04, 0x02, }, // '~'
};
/** 10x6 px monospace bitmap font (starting with space, first element is glyph left column, MSb is glyph top pixel) */
static const uint16_t font_king10[97][6] = {
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, // ' '
{0x0000, 0x0000, 0x01be, 0x0000, 0x0000, 0x0000, }, // '!'
{0x0000, 0x0006, 0x0000, 0x0006, 0x0000, 0x0000, }, // '"'
{0x0050, 0x01fc, 0x0050, 0x01fc, 0x0050, 0x0000, }, // '#'
{0x008c, 0x0092, 0x01ff, 0x0092, 0x0062, 0x0000, }, // '$'
{0x018c, 0x004c, 0x0020, 0x0010, 0x00c8, 0x00c6, }, // '%'
{0x00ec, 0x0112, 0x0112, 0x012c, 0x00c0, 0x0120, }, // '&'
{0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, }, // '''
{0x0000, 0x0078, 0x0186, 0x0201, 0x0000, 0x0000, }, // '('
{0x0000, 0x0201, 0x0186, 0x0078, 0x0000, 0x0000, }, // ')'
{0x0024, 0x0018, 0x003c, 0x0018, 0x0024, 0x0000, }, // '*'
{0x0010, 0x0010, 0x007c, 0x0010, 0x0010, 0x0000, }, // '+'
{0x0000, 0x0000, 0x0200, 0x0180, 0x0000, 0x0000, }, // ','
{0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, }, // '-'
{0x0000, 0x0000, 0x0000, 0x0180, 0x0000, 0x0000, }, // '.'
{0x0300, 0x00c0, 0x0030, 0x000c, 0x0003, 0x0000, }, // '/'
{0x00fe, 0x0121, 0x0111, 0x0109, 0x0105, 0x00fe, }, // '0'
{0x0000, 0x0008, 0x0004, 0x0002, 0x01ff, 0x0000, }, // '1'
{0x0181, 0x0141, 0x0121, 0x0111, 0x0109, 0x0106, }, // '2'
{0x0101, 0x0101, 0x0111, 0x0111, 0x0111, 0x00ee, }, // '3'
{0x0030, 0x0028, 0x0024, 0x0022, 0x01ff, 0x0020, }, // '4'
{0x008f, 0x0109, 0x0109, 0x0109, 0x0109, 0x00f1, }, // '5'
{0x00fe, 0x0111, 0x0111, 0x0111, 0x0111, 0x00e0, }, // '6'
{0x0001, 0x0001, 0x01f1, 0x0009, 0x0005, 0x0003, }, // '7'
{0x00ee, 0x0111, 0x0111, 0x0111, 0x0111, 0x00ee, }, // '8'
{0x000e, 0x0111, 0x0111, 0x0111, 0x0111, 0x00fe, }, // '9'
{0x0000, 0x0000, 0x00cc, 0x0000, 0x0000, 0x0000, }, // ':'
{0x0000, 0x0100, 0x00cc, 0x0000, 0x0000, 0x0000, }, // ';'
{0x0000, 0x0010, 0x0028, 0x0044, 0x0082, 0x0000, }, // '<'
{0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0000, }, // '='
{0x0000, 0x0082, 0x0044, 0x0028, 0x0010, 0x0000, }, // '>'
{0x0002, 0x0001, 0x0161, 0x0011, 0x0009, 0x0006, }, // '?'
{0x0078, 0x0084, 0x0132, 0x014a, 0x014a, 0x017c, }, // '@'
{0x01fe, 0x0011, 0x0011, 0x0011, 0x0011, 0x01fe, }, // 'A'
{0x01ff, 0x0111, 0x0111, 0x0111, 0x0111, 0x00ee, }, // 'B'
{0x00fe, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, }, // 'C'
{0x01ff, 0x0101, 0x0101, 0x0101, 0x0101, 0x00fe, }, // 'D'
{0x01ff, 0x0111, 0x0111, 0x0111, 0x0111, 0x0101, }, // 'E'
{0x01ff, 0x0011, 0x0011, 0x0011, 0x0011, 0x0001, }, // 'F'
{0x00fe, 0x0101, 0x0101, 0x0101, 0x0111, 0x00f1, }, // 'G'
{0x01ff, 0x0010, 0x0010, 0x0010, 0x0010, 0x01ff, }, // 'H'
{0x0101, 0x0101, 0x01ff, 0x0101, 0x0101, 0x0000, }, // 'I'
{0x0101, 0x0101, 0x0101, 0x0081, 0x007f, 0x0000, }, // 'J'
{0x01ff, 0x0010, 0x0028, 0x0044, 0x0082, 0x0101, }, // 'K'
{0x01ff, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, }, // 'L'
{0x01ff, 0x0002, 0x0004, 0x0004, 0x0002, 0x01ff, }, // 'M'
{0x01ff, 0x0004, 0x0008, 0x0010, 0x0020, 0x01ff, }, // 'N'
{0x00fe, 0x0101, 0x0101, 0x0101, 0x0101, 0x00fe, }, // 'O'
{0x01ff, 0x0011, 0x0011, 0x0011, 0x0011, 0x000e, }, // 'P'
{0x00fe, 0x0101, 0x0101, 0x0141, 0x0081, 0x017e, }, // 'Q'
{0x01ff, 0x0011, 0x0031, 0x0051, 0x0091, 0x010e, }, // 'R'
{0x010e, 0x0111, 0x0111, 0x0111, 0x0111, 0x00e1, }, // 'S'
{0x0001, 0x0001, 0x01ff, 0x0001, 0x0001, 0x0000, }, // 'T'
{0x00ff, 0x0100, 0x0100, 0x0100, 0x0100, 0x00ff, }, // 'U'
{0x001f, 0x0060, 0x0180, 0x0180, 0x0060, 0x001f, }, // 'V'
{0x00ff, 0x0100, 0x00c0, 0x00c0, 0x0100, 0x00ff, }, // 'W'
{0x01c7, 0x0028, 0x0010, 0x0010, 0x0028, 0x01c7, }, // 'X'
{0x0007, 0x0008, 0x01f0, 0x0008, 0x0007, 0x0000, }, // 'Y'
{0x01c1, 0x0121, 0x0111, 0x0109, 0x0105, 0x0103, }, // 'Z'
{0x0000, 0x01ff, 0x0101, 0x0101, 0x0101, 0x0000, }, // '['
{0x0000, 0x0003, 0x000c, 0x0030, 0x00c0, 0x0300, }, // '\'
{0x0000, 0x0101, 0x0101, 0x0101, 0x01ff, 0x0000, }, // ']'
{0x0008, 0x0004, 0x0002, 0x0004, 0x0008, 0x0000, }, // '^'
{0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, }, // '_'
{0x0000, 0x0002, 0x0004, 0x0008, 0x0000, 0x0000, }, // '`'
{0x0080, 0x0150, 0x0150, 0x0150, 0x01e0, 0x0000, }, // 'a'
{0x01fe, 0x0110, 0x0110, 0x0110, 0x00e0, 0x0000, }, // 'b'
{0x00e0, 0x0110, 0x0110, 0x0110, 0x0110, 0x0000, }, // 'c'
{0x00e0, 0x0110, 0x0110, 0x0110, 0x01fe, 0x0000, }, // 'd'
{0x00e0, 0x0150, 0x0150, 0x0150, 0x0060, 0x0000, }, // 'e'
{0x0010, 0x01fc, 0x0012, 0x0012, 0x0002, 0x0000, }, // 'f'
{0x0060, 0x0290, 0x0290, 0x0290, 0x01e0, 0x0000, }, // 'g'
{0x01fe, 0x0010, 0x0010, 0x0010, 0x01e0, 0x0000, }, // 'h'
{0x0000, 0x0010, 0x01f4, 0x0000, 0x0000, 0x0000, }, // 'i'
{0x0000, 0x0200, 0x0210, 0x01f4, 0x0000, 0x0000, }, // 'j'
{0x01fe, 0x0020, 0x0050, 0x0188, 0x0000, 0x0000, }, // 'k'
{0x0000, 0x0002, 0x00fe, 0x0100, 0x0000, 0x0000, }, // 'l'
{0x01f0, 0x0010, 0x01e0, 0x0010, 0x01e0, 0x0000, }, // 'm'
{0x0000, 0x01f0, 0x0010, 0x0010, 0x01e0, 0x0000, }, // 'n'
{0x00e0, 0x0110, 0x0110, 0x0110, 0x00e0, 0x0000, }, // 'o'
{0x03f0, 0x0090, 0x0090, 0x0090, 0x0060, 0x0000, }, // 'p'
{0x0060, 0x0090, 0x0090, 0x0090, 0x03f0, 0x0000, }, // 'q'
{0x01f0, 0x0020, 0x0010, 0x0010, 0x0020, 0x0000, }, // 'r'
{0x0120, 0x0150, 0x0150, 0x0150, 0x0090, 0x0000, }, // 's'
{0x0000, 0x00fe, 0x0108, 0x0108, 0x0100, 0x0000, }, // 't'
{0x00f0, 0x0100, 0x0100, 0x0100, 0x01f0, 0x0000, }, // 'u'
{0x0030, 0x00c0, 0x0100, 0x00c0, 0x0030, 0x0000, }, // 'v'
{0x00f0, 0x0100, 0x00e0, 0x0100, 0x00f0, 0x0000, }, // 'w'
{0x0110, 0x00a0, 0x0040, 0x00a0, 0x0110, 0x0000, }, // 'x'
{0x0070, 0x0280, 0x0280, 0x0280, 0x01f0, 0x0000, }, // 'y'
{0x0110, 0x0190, 0x0150, 0x0130, 0x0110, 0x0000, }, // 'z'
{0x0000, 0x0010, 0x00ee, 0x0101, 0x0000, 0x0000, }, // '{'
{0x0000, 0x0000, 0x01ff, 0x0000, 0x0000, 0x0000, }, // '|'
{0x0000, 0x0101, 0x00ee, 0x0010, 0x0000, 0x0000, }, // '}'
{0x0010, 0x0008, 0x0008, 0x0010, 0x0010, 0x0008, }, // '~'
};
/** 14*9 px monospace bitmap font (starting with space, first element is glyph left column, MSb is glyph top pixel) */
static const uint16_t font_king14[95][9] = {
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }, // ' '
{0x0000, 0x0000, 0x0000, 0x19fe, 0x19fe, 0x0000, 0x0000, 0x0000, 0x0000, }, // '!'
{0x0000, 0x001c, 0x001c, 0x0000, 0x0000, 0x001c, 0x001c, 0x0000, 0x0000, }, // '"'
{0x0330, 0x0ffc, 0x0ffc, 0x0330, 0x0330, 0x0ffc, 0x0ffc, 0x0330, 0x0000, }, // '#'
{0x0638, 0x0e7c, 0x1cee, 0x18c6, 0x3fff, 0x18c6, 0x1dce, 0x0f9c, 0x0718, }, // '$'
{0x1e08, 0x1f1c, 0x03b6, 0x01dc, 0x02e8, 0x0770, 0x0db8, 0x071f, 0x020f, }, // '%'
{0x079c, 0x1ffe, 0x1863, 0x1863, 0x1cfe, 0x0f9c, 0x0700, 0x0d80, 0x18c0, }, // '&'
{0x0000, 0x0000, 0x0000, 0x001c, 0x001c, 0x0000, 0x0000, 0x0000, 0x0000, }, // '''
{0x0000, 0x0000, 0x07f8, 0x0ffc, 0x1c0e, 0x3807, 0x3003, 0x0000, 0x0000, }, // '('
{0x0000, 0x0000, 0x3003, 0x3807, 0x1c0e, 0x0ffc, 0x03f0, 0x0000, 0x0000, }, // ')'
{0x0ccc, 0x06d8, 0x03f0, 0x0ffc, 0x0ffc, 0x03f0, 0x06d8, 0x0ccc, 0x0000, }, // '*'
{0x0000, 0x00e0, 0x00e0, 0x03f8, 0x03f8, 0x03f8, 0x00e0, 0x00e0, 0x0000, }, // '+'
{0x0000, 0x0000, 0x3000, 0x3800, 0x1e00, 0x0e00, 0x0000, 0x0000, 0x0000, }, // ','
{0x0000, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x0000, }, // '-'
{0x0000, 0x0000, 0x0000, 0x0c00, 0x0c00, 0x0000, 0x0000, 0x0000, 0x0000, }, // '.'
{0x3000, 0x3c00, 0x0f00, 0x03c0, 0x00f0, 0x003c, 0x000f, 0x0003, 0x0000, }, // '/'
{0x0ffc, 0x1ffe, 0x3303, 0x3183, 0x30c3, 0x3063, 0x3033, 0x1ffe, 0x0ffc, }, // '0'
{0x0000, 0x0000, 0x0018, 0x001c, 0x001e, 0x3fff, 0x3fff, 0x0000, 0x0000, }, // '1'
{0x3c0e, 0x3e0f, 0x3f03, 0x3383, 0x31c3, 0x30e3, 0x3073, 0x303f, 0x301e, }, // '2'
{0x3003, 0x3003, 0x30c3, 0x30c3, 0x30c3, 0x30c3, 0x39e7, 0x1ffe, 0x0f3c, }, // '3'
{0x03c0, 0x03e0, 0x0370, 0x0338, 0x031c, 0x030e, 0x3fff, 0x3fff, 0x0300, }, // '4'
{0x0e3f, 0x1e3f, 0x3833, 0x3033, 0x3033, 0x3033, 0x3873, 0x1fe3, 0x0fc3, }, // '5'
{0x0ffc, 0x1ffe, 0x38e7, 0x3063, 0x3063, 0x3063, 0x38e3, 0x1fc3, 0x0f80, }, // '6'
{0x0003, 0x0003, 0x0003, 0x3fc3, 0x3fe3, 0x0073, 0x003b, 0x001f, 0x000f, }, // '7'
{0x0fbc, 0x1ffe, 0x39e7, 0x30c3, 0x30c3, 0x30c3, 0x39e7, 0x1ffe, 0x0f3c, }, // '8'
{0x007c, 0x30fe, 0x31c7, 0x3183, 0x3183, 0x3183, 0x39c7, 0x1ffe, 0x0ffc, }, // '9'
{0x0000, 0x0000, 0x0000, 0x0e38, 0x0e38, 0x0000, 0x0000, 0x0000, 0x0000, }, // ':'
{0x0000, 0x0000, 0x3000, 0x3800, 0x1e38, 0x0e38, 0x0000, 0x0000, 0x0000, }, // ';'
{0x0000, 0x00e0, 0x01f0, 0x03b8, 0x071c, 0x0e0e, 0x1c07, 0x1803, 0x0000, }, // '<'
{0x0000, 0x0630, 0x0630, 0x0630, 0x0630, 0x0630, 0x0630, 0x0630, 0x0000, }, // '='
{0x0000, 0x1803, 0x1c07, 0x0e0e, 0x071c, 0x03b8, 0x01f0, 0x00e0, 0x0000, }, // '>'
{0x000c, 0x000e, 0x0007, 0x3703, 0x3783, 0x01c3, 0x00e7, 0x007e, 0x003c, }, // '?'
{0x07f8, 0x0ffc, 0x1c0e, 0x19e6, 0x1bf6, 0x1b36, 0x1b3e, 0x1bfc, 0x19f8, }, // '@'
{0x3ffc, 0x3ffe, 0x00c7, 0x00c3, 0x00c3, 0x00c3, 0x00c7, 0x3ffe, 0x3ffc, }, // 'A'
{0x3fff, 0x3fff, 0x30c3, 0x30c3, 0x30c3, 0x30c3, 0x39e7, 0x1ffe, 0x0f3c, }, // 'B'
{0x0ffc, 0x1ffe, 0x3807, 0x3003, 0x3003, 0x3003, 0x3003, 0x3003, 0x3003, }, // 'C'
{0x3fff, 0x3fff, 0x3003, 0x3003, 0x3003, 0x3807, 0x1c0e, 0x0ffc, 0x07f8, }, // 'D'
{0x3fff, 0x3fff, 0x30c3, 0x30c3, 0x30c3, 0x30c3, 0x30c3, 0x3003, 0x3003, }, // 'E'
{0x3fff, 0x3fff, 0x0063, 0x0063, 0x0063, 0x0063, 0x0063, 0x0003, 0x0003, }, // 'F'
{0x1ffe, 0x3fff, 0x3807, 0x3003, 0x3003, 0x30c3, 0x30c3, 0x3fc7, 0x1fc6, }, // 'G'
{0x3fff, 0x3fff, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x3fff, 0x3fff, }, // 'H'
{0x3003, 0x3003, 0x3003, 0x3fff, 0x3fff, 0x3003, 0x3003, 0x3003, 0x0000, }, // 'I'
{0x0000, 0x3003, 0x3803, 0x1c03, 0x0e03, 0x07ff, 0x03ff, 0x0000, 0x0000, }, // 'J'
{0x3fff, 0x3fff, 0x01e0, 0x03f0, 0x0738, 0x0e1c, 0x1c0e, 0x3807, 0x3003, }, // 'K'
{0x3fff, 0x3fff, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, }, // 'L'
{0x3fff, 0x3fff, 0x000e, 0x001c, 0x0038, 0x001c, 0x000e, 0x3fff, 0x3fff, }, // 'M'
{0x3fff, 0x3fff, 0x0038, 0x0070, 0x00e0, 0x01c0, 0x0380, 0x3fff, 0x3fff, }, // 'N'
{0x0ffc, 0x1ffe, 0x3807, 0x3003, 0x3003, 0x3003, 0x3807, 0x1ffe, 0x0ffc, }, // 'O'
{0x3fff, 0x3fff, 0x0183, 0x0183, 0x0183, 0x0183, 0x01c7, 0x00fe, 0x007c, }, // 'P'
{0x0ffc, 0x1ffe, 0x3003, 0x3003, 0x3603, 0x3e03, 0x1c03, 0x3ffe, 0x37fc, }, // 'Q'
{0x3fff, 0x3fff, 0x01c3, 0x03c3, 0x07c3, 0x0ec3, 0x1ce7, 0x387e, 0x303c, }, // 'R'
{0x303c, 0x307e, 0x30e7, 0x30c3, 0x30c3, 0x30c3, 0x39c3, 0x1f83, 0x0f03, }, // 'S'
{0x0003, 0x0003, 0x0003, 0x3fff, 0x3fff, 0x3fff, 0x0003, 0x0003, 0x0003, }, // 'T'
{0x0fff, 0x1fff, 0x3800, 0x3000, 0x3000, 0x3000, 0x3800, 0x1fff, 0x0fff, }, // 'U'
{0x03ff, 0x07ff, 0x0f00, 0x1e00, 0x3c00, 0x1e00, 0x0f00, 0x07ff, 0x03ff, }, // 'V'
{0x0fff, 0x1fff, 0x3c00, 0x1e00, 0x0f00, 0x1e00, 0x3c00, 0x1fff, 0x0fff, }, // 'W'
{0x3e1f, 0x3f3f, 0x03f0, 0x01e0, 0x00c0, 0x01e0, 0x03f0, 0x3f3f, 0x3e1f, }, // 'X'
{0x003f, 0x007f, 0x00e0, 0x3fc0, 0x3f80, 0x3fc0, 0x00e0, 0x007f, 0x003f, }, // 'Y'
{0x3c03, 0x3e03, 0x3703, 0x3383, 0x31c3, 0x30e3, 0x3073, 0x303f, 0x301f, }, // 'Z'
{0x0000, 0x0000, 0x3fff, 0x3fff, 0x3003, 0x3003, 0x3003, 0x3003, 0x0000, }, // '['
{0x0003, 0x000f, 0x003c, 0x00f0, 0x03c0, 0x0f00, 0x3c00, 0x3000, 0x0000, }, // '\'
{0x0000, 0x0000, 0x3003, 0x3003, 0x3003, 0x3003, 0x3fff, 0x3fff, 0x0000, }, // ']'
{0x0000, 0x0070, 0x0038, 0x001c, 0x000e, 0x001c, 0x0038, 0x0070, 0x0000, }, // '^'
{0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, }, // '_'
{0x0000, 0x0000, 0x0006, 0x000e, 0x001c, 0x0038, 0x0030, 0x0000, 0x0000, }, // '`'
{0x0000, 0x0e00, 0x1f60, 0x1b60, 0x1b60, 0x1b60, 0x1fe0, 0x1fc0, 0x0000, }, // 'a'
{0x0000, 0x1ffc, 0x1ffc, 0x18c0, 0x18c0, 0x18c0, 0x1fc0, 0x0f80, 0x0000, }, // 'b'
{0x0000, 0x0fc0, 0x1fe0, 0x1860, 0x1860, 0x1860, 0x1860, 0x1860, 0x0000, }, // 'c'
{0x0000, 0x0f80, 0x1fc0, 0x18c0, 0x18c0, 0x18c0, 0x18c0, 0x1ffc, 0x1ffc, }, // 'd'
{0x0000, 0x0fc0, 0x1fe0, 0x1b60, 0x1b60, 0x1b60, 0x1be0, 0x01c0, 0x0000, }, // 'e'
{0x0000, 0x00c0, 0x00c0, 0x1ff8, 0x1ffc, 0x00cc, 0x00cc, 0x000c, 0x0000, }, // 'f'
{0x0000, 0x01e0, 0x33f0, 0x3330, 0x3330, 0x3330, 0x3ff0, 0x1fe0, 0x0000, }, // 'g'
{0x0000, 0x1ffc, 0x1ffc, 0x00c0, 0x00c0, 0x00c0, 0x1fc0, 0x1f80, 0x0000, }, // 'h'
{0x0000, 0x0000, 0x0000, 0x00c0, 0x1fd8, 0x1fd8, 0x0000, 0x0000, 0x0000, }, // 'i'
{0x0000, 0x0000, 0x3000, 0x3860, 0x1fec, 0x0fec, 0x0000, 0x0000, 0x0000, }, // 'j'
{0x0000, 0x1ffc, 0x1ffc, 0x0780, 0x0fc0, 0x1ce0, 0x1860, 0x1020, 0x0000, }, // 'k'
{0x0000, 0x0004, 0x0ffc, 0x1ffc, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, }, // 'l'
{0x0000, 0x1fe0, 0x1fe0, 0x0060, 0x1fc0, 0x0060, 0x1fe0, 0x1fc0, 0x0000, }, // 'm'
{0x0000, 0x1fe0, 0x1fe0, 0x0060, 0x0060, 0x0060, 0x1fe0, 0x1fc0, 0x0000, }, // 'n'
{0x0000, 0x0fc0, 0x1fe0, 0x1860, 0x1860, 0x1860, 0x1fe0, 0x0fc0, 0x0000, }, // 'o'
{0x0000, 0x3ff0, 0x3ff0, 0x0630, 0x0630, 0x0630, 0x07f0, 0x03e0, 0x0000, }, // 'p'
{0x0000, 0x03e0, 0x07f0, 0x0630, 0x0630, 0x0630, 0x3ff0, 0x3ff0, 0x0000, }, // 'q'
{0x0000, 0x1fe0, 0x1fe0, 0x00c0, 0x0060, 0x0060, 0x00e0, 0x00c0, 0x0000, }, // 'r'
{0x0000, 0x19c0, 0x1be0, 0x1b60, 0x1b60, 0x1b60, 0x1f60, 0x0e60, 0x0000, }, // 's'
{0x0000, 0x0000, 0x0ffc, 0x1ffc, 0x18c0, 0x18c0, 0x18c0, 0x1800, 0x0000, }, // 't'
{0x0000, 0x0fe0, 0x1fe0, 0x1800, 0x1800, 0x1800, 0x1fe0, 0x1fe0, 0x0000, }, // 'u'
{0x0000, 0x03e0, 0x07e0, 0x0e00, 0x1c00, 0x0e00, 0x07e0, 0x03e0, 0x0000, }, // 'v'
{0x0000, 0x0fe0, 0x1fe0, 0x1800, 0x0f80, 0x1800, 0x1fe0, 0x0fe0, 0x0000, }, // 'w'
{0x0000, 0x18e0, 0x1de0, 0x0f80, 0x0700, 0x0f80, 0x1de0, 0x18e0, 0x0000, }, // 'x'
{0x0000, 0x03e0, 0x37e0, 0x3600, 0x3600, 0x3600, 0x3fe0, 0x1fe0, 0x0000, }, // 'y'
{0x0000, 0x1860, 0x1c60, 0x1e60, 0x1b60, 0x19e0, 0x18e0, 0x1860, 0x0000, }, // 'z'
{0x0000, 0x00c0, 0x01e0, 0x0ffc, 0x1f3e, 0x3807, 0x3003, 0x0000, 0x0000, }, // '{'
{0x0000, 0x0000, 0x0000, 0x3ffe, 0x3ffe, 0x0000, 0x0000, 0x0000, 0x0000, }, // '|'
{0x0000, 0x3003, 0x3807, 0x1f3e, 0x0ffc, 0x01e0, 0x00c0, 0x0000, 0x0000, }, // '}'
{0x0060, 0x0070, 0x0038, 0x0038, 0x0030, 0x0070, 0x0070, 0x0038, 0x0018, }, // '~'
};
/** look-up table to swap the bit order in a byte
* @remark this is useful for the OLED screen since the top pixel is the MSb
*/
static const uint8_t bit_order_switch_lut[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, };
void busvoodoo_oled_setup(void)
{
@ -353,6 +62,59 @@ void busvoodoo_oled_clear(void)
}
}
#include "print.h"
void busvoodoo_oled_text_pos(uint8_t column, uint8_t row, enum font_name font_name, const char *text)
{
// sanity checks
if (column>=128) {
return;
}
if (row>=64) {
return;
}
if (font_name>=FONT_MAX) {
return;
}
if (NULL==text) {
return;
}
const struct font_s *font = &fonts[font_name]; // get selected font
while (*text && column<128) {
char c = *text;
if (c>=' ' && c<' '+FONT_GLYPH_NUMBERS) {
for (uint8_t i=0; i<font->width; i++) { // draw glyph from left to right
uint8_t col = column+i; // calculate destination column position
if (col>=128) {
break; // end of screen reached
}
uint16_t glyph_column = font->glyphs[font->width*(c-' ')+i]; // get glyph column to draw
// draw bottom part of glyph
uint16_t pixel_byte_row = 128*((row/8)-0)+col;
uint8_t glyph_byte_row = (glyph_column<<(7-(row%8)))>>0;
glyph_byte_row = bit_order_switch_lut[glyph_byte_row];
busvoodoo_oled_display[pixel_byte_row] |= glyph_byte_row;
// draw middle part of glyph
if (row>=8 && font->height>8-(row%8)) {
pixel_byte_row -= 128;
glyph_byte_row = (glyph_column<<(7-(row%8)))>>8;
glyph_byte_row = bit_order_switch_lut[glyph_byte_row];
busvoodoo_oled_display[pixel_byte_row] |= glyph_byte_row;
}
// draw top part of glyph
if (row>=16 && font->height>8+(row%8)) {
pixel_byte_row -= 128;
glyph_byte_row = ((uint32_t)glyph_column<<(7-(row%8)))>>16;
glyph_byte_row = bit_order_switch_lut[glyph_byte_row];
busvoodoo_oled_display[pixel_byte_row] |= glyph_byte_row;
}
}
}
text++; // go to next character
column += font->width+1;
}
}
void busvoodoo_oled_text_left(char* text)
{
// clear top (yellow) display part
@ -365,20 +127,7 @@ void busvoodoo_oled_text_left(char* text)
return;
}
uint8_t column = 1; // on which column to draw
while (*text && column<128) { // draw until end or text or screen
char c = ' '; // default character to draw
if (*text>' ' && *text<' '+LENGTH(font_king14)) { // we have a glyph for this character
c = *text;
}
for (uint8_t col=0; col<LENGTH(font_king14[0]) && column<128; col++) { // go through glyph columns
busvoodoo_oled_display[128*0+column] = (font_king14[c-' '][col])<<1; // draw upper section
busvoodoo_oled_display[128*1+column] = (font_king14[c-' '][col])>>7; // draw lower section
column++; // go to next screen column
}
text++; // go to next character
column++; // insert space between glyphs
}
busvoodoo_oled_text_pos(1, 14, FONT_KING14, text); // draw text on the left of top line
}
void busvoodoo_oled_text_right(char* text)
@ -388,19 +137,12 @@ void busvoodoo_oled_text_right(char* text)
return;
}
int8_t column = 127; // start drawing on left most column
for (int8_t i=strlen(text)-1; i>=0 && column>=0; i--) { // draw text from right to left
char c = ' '; // default character to draw
if (text[i]>' ' && text[i]<' '+LENGTH(font_king14)) { // we have a glyph for this character
c = text[i];
}
for (int8_t col=LENGTH(font_king14[0])-1; col>=0 && column>=0; col--) { // go through glyph columns
busvoodoo_oled_display[128*0+column] = (font_king14[c-' '][col])<<1; // draw upper section
busvoodoo_oled_display[128*1+column] = (font_king14[c-' '][col])>>7; // draw lower section
column--; // go to next screen column
}
column--; // insert space between glyphs
// calculate column on which to start drawing
uint8_t column = 0;
if ((fonts[FONT_KING14].width+1)*strlen(text)<128) {
column = 128-(fonts[FONT_KING14].width+1)*strlen(text);
}
busvoodoo_oled_text_pos(column, 14, FONT_KING14, text); // draw text on the right of the top line
}
void busvoodoo_oled_text_pinout(const char* pins[10], bool io_connector)
@ -483,104 +225,62 @@ void busvoodoo_oled_text_pinout(const char* pins[10], bool io_connector)
} else if (0==strlen(pins[pin])) {
// leave blank
} else if (strlen(pins[pin])<4) {
// calculate start position (from the left) based on number of characters to put in 24 px box
uint16_t column = 2+2+24*(4-pin/2)+(24-7*strlen(pins[pin])-strlen(pins[pin])-1)/2+1;
for (uint8_t i=0; i<strlen(pins[pin]); i++) {
char c = ' '; // default character to draw
if (pins[pin][i]>' ' && pins[pin][i]<' '+LENGTH(font_king10)) { // we have a glyph for this character
c = pins[pin][i];
// calculate start position on x-axis based on number of characters to put in 24x20 px box
uint8_t column = 2+2+24*(4-pin/2)+(24-(fonts[FONT_KING10].width+1)*strlen(pins[pin])-1)/2+1;
if (0==pin%2) {
if (io_connector) {
busvoodoo_oled_text_pos(column, 16+2+1+20/2+fonts[FONT_KING10].height/2, FONT_KING10, pins[pin]); // draw pin name
} else {
busvoodoo_oled_text_pos(column, 16+2+20/2+fonts[FONT_KING10].height/2, FONT_KING10, pins[pin]); // draw pin name
}
for (uint8_t col=0; col<LENGTH(font_king10[0]) && column<128; col++) { // go through glyph columns
if (0==pin%2) {
if (io_connector) {
busvoodoo_oled_display[128*3+column] |= (font_king10[c-' '][col]>>0)<<0;
busvoodoo_oled_display[128*4+column] |= (font_king10[c-' '][col]>>8)<<0;
} else {
busvoodoo_oled_display[128*2+column] |= (font_king10[c-' '][col]>>0)<<6;
busvoodoo_oled_display[128*3+column] |= (font_king10[c-' '][col]>>2)<<0;
}
} else {
if (io_connector) {
busvoodoo_oled_display[128*5+column] |= (font_king10[c-' '][col]>>0)<<6;
busvoodoo_oled_display[128*6+column] |= (font_king10[c-' '][col]>>2)<<0;
} else {
busvoodoo_oled_display[128*6+column] |= (font_king10[c-' '][col]>>0)<<0;
busvoodoo_oled_display[128*7+column] |= (font_king10[c-' '][col]>>8)<<0;
}
}
column++; // go to next screen column
} else {
if (io_connector) {
busvoodoo_oled_text_pos(column, 16+2+1+20+1+1+20/2+fonts[FONT_KING10].height/2, FONT_KING10, pins[pin]); // draw pin name
} else {
busvoodoo_oled_text_pos(column, 16+2+20+1+2+1+20/2+fonts[FONT_KING10].height/2, FONT_KING10, pins[pin]); // draw pin name
}
column++; // insert space between glyphs
}
} else if (4==strlen(pins[pin])) {
uint16_t column = 2+2+24*(4-pin/2); // start position on x-axis (for 4 characters on a 24 px box)
for (uint8_t i=0; i<strlen(pins[pin]); i++) {
char c = ' '; // default character to draw
if (pins[pin][i]>' ' && pins[pin][i]<' '+LENGTH(font_king8)) { // we have a glyph for this character
c = pins[pin][i];
if (0==pin%2) {
if (io_connector) {
busvoodoo_oled_text_pos(column, 16+2+1+20/2+fonts[FONT_KING8].height/2, FONT_KING8, pins[pin]); // draw pin name
} else {
busvoodoo_oled_text_pos(column, 16+2+20/2+fonts[FONT_KING8].height/2, FONT_KING8, pins[pin]); // draw pin name
}
for (uint8_t col=0; col<LENGTH(font_king8[0]) && column<128; col++) { // go through glyph columns
if (0==pin%2) {
if (io_connector) {
busvoodoo_oled_display[128*3+column] |= (font_king8[c-' '][col]>>0)<<1;
busvoodoo_oled_display[128*4+column] |= (font_king8[c-' '][col]>>7)<<0;
} else {
busvoodoo_oled_display[128*2+column] |= (font_king8[c-' '][col]>>0)<<7;
busvoodoo_oled_display[128*3+column] |= (font_king8[c-' '][col]>>1)<<0;
}
} else {
if (io_connector) {
busvoodoo_oled_display[128*5+column] |= (font_king8[c-' '][col]>>0)<<7;
busvoodoo_oled_display[128*6+column] |= (font_king8[c-' '][col]>>1)<<0;
} else {
busvoodoo_oled_display[128*6+column] |= (font_king8[c-' '][col]>>0)<<1;
busvoodoo_oled_display[128*7+column] |= (font_king8[c-' '][col]>>7)<<0;
}
}
column++; // go to next screen column
} else {
if (io_connector) {
busvoodoo_oled_text_pos(column, 16+2+1+20+1+1+20/2+fonts[FONT_KING8].height/2, FONT_KING8, pins[pin]); // draw pin name
} else {
busvoodoo_oled_text_pos(column, 16+2+20+1+2+1+20/2+fonts[FONT_KING8].height/2, FONT_KING8, pins[pin]); // draw pin name
}
column++; // insert space between glyphs
}
} else {
uint16_t column = 2+2+24*(4-pin/2); // start position on x-axis (for 4 characters on a 24 px box)
for (uint8_t i=0; i<4; i++) { // go through 4 characters per line
char c_top = ' '; // default character to draw on top line
if (pins[pin][i]>' ' && pins[pin][i]<' '+LENGTH(font_king8)) { // we have a glyph for this character
c_top = pins[pin][i]; // get glyph to draw
char line_top[5] = {0, 0, 0, 0, 0};
for (uint8_t c=0; c<4 && c<strlen(pins[pin]); c++) {
line_top[c] = pins[pin][c];
}
char line_bottom[5] = {0, 0, 0, 0, 0};
for (uint8_t c=4; c<8 && c<strlen(pins[pin]); c++) {
line_bottom[c-4] = pins[pin][c];
}
if (0==pin%2) {
if (io_connector) {
busvoodoo_oled_text_pos(column, 16+2+1+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_top); // draw pin name
busvoodoo_oled_text_pos(column, 16+2+1+20/2+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_bottom); // draw pin name
} else {
busvoodoo_oled_text_pos(column, 16+2+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_top); // draw pin name
busvoodoo_oled_text_pos(column, 16+2+20/2+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_bottom); // draw pin name
}
char c_bottom = ' '; // default character to draw for bottom line
if ((uint8_t)(4+i)<strlen(pins[pin]) && pins[pin][4+i]>' ' && pins[pin][4+i]<' '+LENGTH(font_king8)) { // we have a glyph for this character
c_bottom = pins[pin][4+i]; // get glyph to draw
} else {
if (io_connector) {
busvoodoo_oled_text_pos(column, 16+2+1+20+1+1+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_top); // draw pin name
busvoodoo_oled_text_pos(column, 16+2+1+20+1+1+20/2+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_bottom); // draw pin name
} else {
busvoodoo_oled_text_pos(column, 16+2+20+1+2+1+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_top); // draw pin name
busvoodoo_oled_text_pos(column, 16+2+20+1+2+1+1+20/2+20/4+fonts[FONT_KING8].height/2, FONT_KING8, line_bottom); // draw pin name
}
for (uint8_t col=0; col<LENGTH(font_king8[0]) && column<128; col++) { // go through glyph columns
if (0==pin%2) {
if (io_connector) {
busvoodoo_oled_display[128*2+column] |= (font_king8[c_top-' '][col]>>0)<<4;
busvoodoo_oled_display[128*3+column] |= (font_king8[c_top-' '][col]>>4)<<0;
busvoodoo_oled_display[128*3+column] |= (font_king8[c_bottom-' '][col]>>0)<<6;
busvoodoo_oled_display[128*4+column] |= (font_king8[c_bottom-' '][col]>>2)<<0;
} else {
busvoodoo_oled_display[128*2+column] |= (font_king8[c_top-' '][col]>>0)<<2;
busvoodoo_oled_display[128*3+column] |= (font_king8[c_top-' '][col]>>6)<<0;
busvoodoo_oled_display[128*3+column] |= (font_king8[c_bottom-' '][col]>>0)<<4;
busvoodoo_oled_display[128*4+column] |= (font_king8[c_bottom-' '][col]>>4)<<0;
}
} else {
if (io_connector) {
busvoodoo_oled_display[128*5+column] |= (font_king8[c_top-' '][col]>>0)<<2;
busvoodoo_oled_display[128*6+column] |= (font_king8[c_top-' '][col]>>6)<<0;
busvoodoo_oled_display[128*6+column] |= (font_king8[c_bottom-' '][col]>>0)<<4;
busvoodoo_oled_display[128*7+column] |= (font_king8[c_bottom-' '][col]>>4)<<0;
} else {
busvoodoo_oled_display[128*5+column] |= (font_king8[c_top-' '][col]>>0)<<4;
busvoodoo_oled_display[128*6+column] |= (font_king8[c_top-' '][col]>>4)<<0;
busvoodoo_oled_display[128*6+column] |= (font_king8[c_bottom-' '][col]>>0)<<6;
busvoodoo_oled_display[128*7+column] |= (font_king8[c_bottom-' '][col]>>2)<<0;
}
}
column++; // go to next screen column
}
column++; // insert space between glyphs
}
}
}

View File

@ -18,6 +18,7 @@
* @date 2018
* @note peripherals used: I2C @ref oled_ssd1306_i2c
*/
#include "font.h"
/** setup OLED display */
void busvoodoo_oled_setup(void);
@ -25,6 +26,13 @@ void busvoodoo_oled_setup(void);
* @note update the display to clear it
*/
void busvoodoo_oled_clear(void);
/** draw text in display buffer
* @param[in] column display column where to start drawing the text (0 is left)
* @param[in] row display row where to put the lower end of the characters (0 is top)
* @param[in] font_name name of the font to use to draw the text
* @param[in] text text string to draw
*/
void busvoodoo_oled_text_pos(uint8_t column, uint8_t row, enum font_name font_name, const char *text);
/** draw mode text on top (yellow) left side in display buffer
* @warning this clears the top line, including the text on the right side
* @note update the display to display the text