diff --git a/Font5x7.c b/Font5x7.c index ee4f40b..a82086c 100644 --- a/Font5x7.c +++ b/Font5x7.c @@ -1,2565 +1,2438 @@ -/* Generated by convbdf on Tue Oct 3 00:24:24 MDT 2000. */ -/* Font information: - name: "-Misc-Fixed-Medium-R-Normal--7-70-75-75-C-50-ISO8859-1" - pixel size: 7 - ascent: 6 - descent: 1 -*/ +/* + * Font size 5x7 pixels + * most font glyph have width 5 pixels + */ #include +/* + * Check 1 byte of char bitmap data for get width + */ + +#define FONT_GET_DATA(ch) (&x5x7_bits[ch*7]) +#define FONT_GET_WIDTH(ch) (7-x5x7_bits[ch*7]&3) +#define FONT_GET_HEIGHT 7 + +#define CHAR5x7_WIDTH_MASK 0x03 +#define CHAR5x7_WIDTH_4px 0x03 +#define CHAR5x7_WIDTH_5px 0x02 +#define CHAR5x7_WIDTH_6px 0x01 +#define CHAR5x7_WIDTH_7px 0x00 + /* Font character bitmap data. */ -const uint8_t x5x7_bits [] = +const uint8_t x5x7_bits[127*7] = { /* Character (0x00): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - |**** | - |**** | - |**** | - |**** | - |**** | - | | - +----------------+ */ - 0xf0, - 0xf0, - 0xf0, - 0xf0, - 0xf0, - 0xf0, - 0x00, + width=5 + +--------+ + |**** | + |**** | + |**** | + |**** | + |**** | + |**** | + | | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b11110000, + 0b11110000, + 0b11110000, + 0b11110000, + 0b11110000, + 0b00000000, /* Character (0x01): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | * | - | *** | - |***** | - | *** | - | * | - | | - +----------------+ */ - 0x00, - 0x20, - 0x70, - 0xf8, - 0x70, - 0x20, - 0x00, + width=5 + +--------+ + | | + | * | + | *** | + |***** | + | *** | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b01110000, + 0b11111000, + 0b01110000, + 0b00100000, + 0b00000000, /* Character (0x02): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * * | - |* * | - | * * | - |* * | - | * * | - |* * | - | | - +----------------+ */ - 0x50, - 0xa0, - 0x50, - 0xa0, - 0x50, - 0xa0, - 0x00, + width=5 + +--------+ + | * * | + |* * * | + | * * | + |* * * | + | * * | + |* * * | + | * * | + +--------+ */ + 0b01010000|CHAR5x7_WIDTH_5px, + 0b10101000, + 0b01010000, + 0b10101000, + 0b01010000, + 0b10101000, + 0b01010000, /* Character (0x03): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |*** | - |* * | - |* * | - | *** | - | * | - | * | - +----------------+ */ - 0xa0, - 0xe0, - 0xa0, - 0xa0, - 0x70, - 0x20, - 0x20, + width=5 + +--------+ + |* * | + |*** | + |* * | + |* * | + | *** | + | * | + | * | + +--------+ */ + 0b10100000|CHAR5x7_WIDTH_5px, + 0b11100000, + 0b10100000, + 0b10100000, + 0b01110000, + 0b00100000, + 0b00100000, /* Character (0x04): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | ** | - | * * | - | * * | - |* * | - |**** | - | | - +----------------+ */ - 0x10, - 0x30, - 0x50, - 0x50, - 0x90, - 0xF0, - 0x00, + width=7 + +--------+ + | | + | ** | + | ** | + | * * | + | * * | + |* * | + |****** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_7px, + 0b00110000, + 0b00110000, + 0b01001000, + 0b01001000, + 0b10000100, + 0b11111100, /* Character (0x05): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |** | - |* | - |** | - | ** | - | * * | - | ** | - | * * | - +----------------+ */ - 0xc0, - 0x80, - 0xc0, - 0x60, - 0x50, - 0x60, - 0x50, + width=5 + +--------+ + |** | + |* | + |** | + | ** | + | * * | + | ** | + | * * | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b11000000, + 0b01100000, + 0b01010000, + 0b01100000, + 0b01010000, /* Character (0x06): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - |* | - |** | - | ** | - | * | - | ** | - | * | - +----------------+ */ - 0x80, - 0x80, - 0xc0, - 0x30, - 0x20, - 0x30, - 0x20, + width=5 + +--------+ + |* | + |* | + |** | + | ** | + | * | + | ** | + | * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b11000000, + 0b00110000, + 0b00100000, + 0b00110000, + 0b00100000, /* Character (0x07): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * * | - | * | - | | - | | - | | - | | - +----------------+ */ - 0x20, - 0x50, - 0x20, - 0x00, - 0x00, - 0x00, - 0x00, + width=5 + +--------+ + | * | + | * * | + | * | + | | + | | + | | + | | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b01010000, + 0b00100000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, /* Character (0x08): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | *** | - | * | - | | - | *** | - | | - | | - +----------------+ */ - 0x20, - 0x70, - 0x20, - 0x00, - 0x70, - 0x00, - 0x00, + width=5 + +--------+ + | | + | * | + | *** | + | * | + | | + | *** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b01110000, + 0b00100000, + 0b00000000, + 0b01110000, + 0b00000000, /* Character (0x09): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |** * | - |* ** | - |* * | - | * | - | * | - | ** | - +----------------+ */ - 0x90, - 0xd0, - 0xb0, - 0x90, - 0x20, - 0x20, - 0x30, + width=5 + +--------+ + |* * | + |** * | + |* ** | + |* * | + | * | + | * | + | ** | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b11010000, + 0b10110000, + 0b10010000, + 0b00100000, + 0b00100000, + 0b00110000, /* Character (0x0a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |* * | - | * | - | *** | - | * | - | * | - +----------------+ */ - 0xa0, - 0xa0, - 0xa0, - 0x40, - 0x70, - 0x20, - 0x20, + width=5 + +--------+ + |* * | + |* * | + |* * | + | * | + | *** | + | * | + | * | + +--------+ */ + 0b10100000|CHAR5x7_WIDTH_5px, + 0b10100000, + 0b10100000, + 0b01000000, + 0b01110000, + 0b00100000, + 0b00100000, /* Character (0x0b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - |*** | - | | - | | - | | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0xe0, - 0x00, - 0x00, - 0x00, + width=5 + +--------+ + | * | + | * | + | * | + |*** | + | | + | | + | | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b11100000, + 0b00000000, + 0b00000000, + 0b00000000, /* Character (0x0c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - |*** | - | * | - | * | - | * | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0xe0, - 0x20, - 0x20, - 0x20, + width=5 + +--------+ + | | + | | + | | + |*** | + | * | + | * | + | * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b11100000, + 0b00100000, + 0b00100000, + 0b00100000, /* Character (0x0d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | *** | - | * | - | * | - | * | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x38, - 0x20, - 0x20, - 0x20, + width=5 + +--------+ + | | + | | + | | + | *** | + | * | + | * | + | * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00111000, + 0b00100000, + 0b00100000, + 0b00100000, /* Character (0x0e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | *** | - | | - | | - | | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0x38, - 0x00, - 0x00, - 0x00, + width=5 + +--------+ + | * | + | * | + | * | + | *** | + | | + | | + | | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b00111000, + 0b00000000, + 0b00000000, + 0b00000000, /* Character (0x0f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - |***** | - | * | - | * | - | * | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0xf8, - 0x20, - 0x20, - 0x20, + width=5 + +--------+ + | * | + | * | + | * | + |***** | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b11111000, + 0b00100000, + 0b00100000, + 0b00100000, /* Character (0x10): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - |***** | - | | - | | - | | - | | - | | - +----------------+ */ - 0x00, - 0xf8, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + width=5 + +--------+ + | | + |***** | + | | + | | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, /* Character (0x11): - bbw=6, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |***** | - | | - | | - | | - | | - +----------------+ */ - 0x00, - 0x00, - 0xf8, - 0x00, - 0x00, - 0x00, - 0x00, + width=5 + +--------+ + | | + | | + |***** | + | | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, /* Character (0x12): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - |***** | - | | - | | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0xf8, - 0x00, - 0x00, - 0x00, + width=5 + +--------+ + | | + | | + | | + |***** | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, /* Character (0x13): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | | - |***** | - | | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x00, - 0xf8, - 0x00, - 0x00, + width=5 + +--------+ + | | + | | + | | + | | + |***** | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, /* Character (0x14): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | | - | | - |***** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xf8, - 0x00, + width=5 + +--------+ + | | + | | + | | + | | + | | + |***** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, /* Character (0x15): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | *** | - | * | - | * | - | * | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0x38, - 0x20, - 0x20, - 0x20, + width=5 + +--------+ + | * | + | * | + | * | + | *** | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b00111000, + 0b00100000, + 0b00100000, + 0b00100000, /* Character (0x16): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - |*** | - | * | - | * | - | * | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0xe0, - 0x20, - 0x20, - 0x20, + width=5 + +--------+ + | ** | + | *** | + | *** | + | *** | + | *** | + | *** | + | ** | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b11100000, + 0b00100000, + 0b00100000, + 0b00100000, /* Character (0x17): - bbw=6, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - |***** | - | | - | | - | | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0xf8, - 0x00, - 0x00, - 0x00, + width=6 + +--------+ + | | + |** | + |**** | + |****** | + |**** | + |** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b11000000, + 0b11110000, + 0b00011100, + 0b11110000, + 0b11000000, + 0b00000000, /* Character (0x18): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - |***** | - | * | - | * | - | * | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0xf8, - 0x20, - 0x20, - 0x20, + width=5 + +--------+ + |* | + |** | + |*** | + |**** | + |*** | + |** | + |* | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b11000000, + 0b11100000, + 0b11110000, + 0b11100000, + 0b11000000, + 0b10000000, /* Character (0x19): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | * | - | * | - | * | - | * | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, + width=7 + +--------+ + | | + | ** ** | + |* ** * | + |* * * | + |* ** * | + | ** ** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_7px, + 0b01101100, + 0b10110010, + 0b10010010, + 0b10011010, + 0b01101100, + 0b00000000, /* Character (0x1a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - |**** | - | * | - | * | - | | - | | - +----------------+ */ - 0x20, - 0x40, - 0xF8, - 0x40, - 0x20, - 0x00, - 0x00, + width=6 + +--------+ + | | + | * | + | * | + |***** | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b01000000, + 0b11111000, + 0b01000000, + 0b00100000, + 0b00000000, /* Character (0x1b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - |***** | - | * | - | * | - | | - | | - +----------------+ */ - 0x20, - 0x10, - 0xF8, - 0x10, - 0x20, - 0x00, - 0x00, + width=6 + +--------+ + | | + | * | + | * | + |***** | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00010000, + 0b11111000, + 0b00010000, + 0b00100000, + 0b00000000, /* Character (0x1c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |***** | - | * * | - | * * | - |* ** | - | | - +----------------+ */ - 0x00, - 0x00, - 0xf8, - 0x50, - 0x50, - 0x98, - 0x00, + width=6 + +--------+ + | | + |***** | + | * * | + | * * | + | * * | + | * * | + |* ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b11111000, + 0b01010000, + 0b01010000, + 0b01010000, + 0b01010000, + 0b10011000, /* Character (0x1d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - |* * | - |* * | - |*** | - |* | - +----------------+ */ - 0x00, - 0x00, - 0x90, - 0x90, - 0x90, - 0xe0, - 0x80, + width=6 + +--------+ + | | + |* * | + |* * | + |* * | + |** ** | + |* * * | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b10001000, + 0b11011000, + 0b10101000, + 0b10000000, + 0b10000000, /* Character (0x1e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | *** | - |* * | - |* * | - | * * | - |** ** | - | | - +----------------+ */ - 0x00, - 0x70, - 0x88, - 0x88, - 0x50, - 0xb8, - 0x00, + width=6 + +--------+ + | | + | *** | + |* * | + |* * | + |* * | + | * * | + |** ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b01110000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b01010000, + 0b11011000, /* Character (0x1f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* * | - | ** | - | | - | | - | | - +----------------+ */ - 0x60, - 0x90, - 0x90, - 0x60, - 0x00, - 0x00, - 0x00, - - /* Character (0x20): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | | - | | - | | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - - /* Character (0x21): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | * | - | | - | * | - | | - +----------------+ */ - 0x20, - 0x20, - 0x20, - 0x20, - 0x00, - 0x20, - 0x00, - - /* Character (0x22): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * * | - | * * | - | * * | - | | - | | - | | - | | - +----------------+ */ - 0x50, - 0x50, - 0x50, - 0x00, - 0x00, - 0x00, - 0x00, - - /* Character (0x23): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | * * | - |***** | - | * * | - |***** | - | * * | - | | - +----------------+ */ - 0x00, - 0x50, - 0xf8, - 0x50, - 0xf8, - 0x50, - 0x00, - - /* Character (0x24): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | *** | - |* * | - | *** | - | * * | - | *** | - | | - +----------------+ */ - 0x00, - 0x70, - 0xa0, - 0x70, - 0x28, - 0x70, - 0x00, - - /* Character (0x25): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - |* * | - | * | - | * | - |* * | - | * | - | | - +----------------+ */ - 0x80, - 0x90, - 0x20, - 0x40, - 0x90, - 0x10, - 0x00, - - /* Character (0x26): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | * | - |* * | - | * | - |* * | - | * * | - | | - +----------------+ */ - 0x00, - 0x40, - 0xa0, - 0x40, - 0xa0, - 0x50, - 0x00, - - /* Character (0x27): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - | * | - |* | - | | - | | - | | - | | - +----------------+ */ - 0x60, - 0x40, - 0x80, - 0x00, - 0x00, - 0x00, - 0x00, - - /* Character (0x28): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | * | - | * | - | * | - | | - +----------------+ */ - 0x20, - 0x40, - 0x40, - 0x40, - 0x40, - 0x20, - 0x00, - - /* Character (0x29): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | * | - | * | - | * | - | | - +----------------+ */ - 0x40, - 0x20, - 0x20, - 0x20, - 0x20, - 0x40, - 0x00, - - /* Character (0x2a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - |* * | - | * | - |*** | - | * | - |* * | - | | - +----------------+ */ - 0x00, - 0xa0, - 0x40, - 0xe0, - 0x40, - 0xa0, - 0x00, - - /* Character (0x2b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | * | - | * | - |***** | - | * | - | * | - | | - +----------------+ */ - 0x00, - 0x20, - 0x20, - 0xf8, - 0x20, - 0x20, - 0x00, - - /* Character (0x2c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | | - | ** | - | * | - |* | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x60, - 0x40, - 0x80, - - /* Character (0x2d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - |**** | - | | - | | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0xf0, - 0x00, - 0x00, - 0x00, - - /* Character (0x2e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | | - | ** | - | ** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x60, - 0x60, - 0x00, - - /* Character (0x2f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | * | - | * | - | * | - |* | - | | - | | - +----------------+ */ - 0x00, - 0x10, - 0x20, - 0x40, - 0x80, - 0x00, - 0x00, - - /* Character (0x30): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* ** | - |** * | - |* * | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0xb0, - 0xd0, - 0x90, - 0x60, - 0x00, - - /* Character (0x31): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - |** | - | * | - | * | - | * | - |*** | - | | - +----------------+ */ - 0x40, - 0xc0, - 0x40, - 0x40, - 0x40, - 0xe0, - 0x00, - - /* Character (0x32): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - | * | - | * | - | * | - |**** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x10, - 0x20, - 0x40, - 0xf0, - 0x00, - - /* Character (0x33): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - | * | - | ** | - | * | - |* * | - | ** | - | | - +----------------+ */ - 0xf0, - 0x10, - 0x60, - 0x10, - 0x90, - 0x60, - 0x00, - - /* Character (0x34): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | ** | - |* * | - |**** | - | * | - | * | - | | - +----------------+ */ - 0x20, - 0x60, - 0xa0, - 0xf0, - 0x20, - 0x20, - 0x00, - - /* Character (0x35): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - |* | - |*** | - | * | - |* * | - | ** | - | | - +----------------+ */ - 0xf0, - 0x80, - 0xe0, - 0x10, - 0x90, - 0x60, - 0x00, - - /* Character (0x36): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* | - |*** | - |* * | - |* * | - | ** | - | | - +----------------+ */ - 0x60, - 0x80, - 0xe0, - 0x90, - 0x90, - 0x60, - 0x00, - - /* Character (0x37): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - | * | - | * | - | * | - | * | - | * | - | | - +----------------+ */ - 0xf0, - 0x10, - 0x20, - 0x20, - 0x40, - 0x40, - 0x00, - - /* Character (0x38): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - | ** | - |* * | - |* * | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x60, - 0x90, - 0x90, - 0x60, - 0x00, - - /* Character (0x39): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* * | - | *** | - | * | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x90, - 0x70, - 0x10, - 0x60, - 0x00, - - /* Character (0x3a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | ** | - | ** | - | | - | ** | - | ** | - | | - +----------------+ */ - 0x00, - 0x60, - 0x60, - 0x00, - 0x60, - 0x60, - 0x00, - - /* Character (0x3b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | ** | - | ** | - | | - | ** | - | * | - |* | - +----------------+ */ - 0x00, - 0x60, - 0x60, - 0x00, - 0x60, - 0x40, - 0x80, - - /* Character (0x3c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | * | - | * | - |* | - | * | - | * | - | | - +----------------+ */ - 0x00, - 0x20, - 0x40, - 0x80, - 0x40, - 0x20, - 0x00, - - /* Character (0x3d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |**** | - | | - |**** | - | | - | | - +----------------+ */ - 0x00, - 0x00, - 0xf0, - 0x00, - 0xf0, - 0x00, - 0x00, - - /* Character (0x3e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - |* | - | * | - | * | - | * | - |* | - | | - +----------------+ */ - 0x00, - 0x80, - 0x40, - 0x20, - 0x40, - 0x80, - 0x00, - - /* Character (0x3f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - |* * | - | * | - | * | - | | - | * | - | | - +----------------+ */ - 0x40, - 0xa0, - 0x20, - 0x40, - 0x00, - 0x40, - 0x00, - - /* Character (0x40): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* ** | - |* ** | - |* | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0xb0, - 0xb0, - 0x80, - 0x60, - 0x00, - - /* Character (0x41): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* * | - |**** | - |* * | - |* * | - | | - +----------------+ */ - 0x60, - 0x90, - 0x90, - 0xf0, - 0x90, - 0x90, - 0x00, - - /* Character (0x42): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - |* * | - |*** | - |* * | - |* * | - |*** | - | | - +----------------+ */ - 0xe0, - 0x90, - 0xe0, - 0x90, - 0x90, - 0xe0, - 0x00, - - /* Character (0x43): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* | - |* | - |* * | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x80, - 0x80, - 0x90, - 0x60, - 0x00, - - /* Character (0x44): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - |* * | - |* * | - |* * | - |* * | - |*** | - | | - +----------------+ */ - 0xe0, - 0x90, - 0x90, - 0x90, - 0x90, - 0xe0, - 0x00, - - /* Character (0x45): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - |* | - |*** | - |* | - |* | - |**** | - | | - +----------------+ */ - 0xf0, - 0x80, - 0xe0, - 0x80, - 0x80, - 0xf0, - 0x00, - - /* Character (0x46): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - |* | - |*** | - |* | - |* | - |* | - | | - +----------------+ */ - 0xf0, - 0x80, - 0xe0, - 0x80, - 0x80, - 0x80, - 0x00, - - /* Character (0x47): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* | - |* ** | - |* * | - | *** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x80, - 0xb0, - 0x90, - 0x70, - 0x00, - - /* Character (0x48): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |**** | - |* * | - |* * | - |* * | - | | - +----------------+ */ - 0x90, - 0x90, - 0xf0, - 0x90, - 0x90, - 0x90, - 0x00, - - /* Character (0x49): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - | * | - | * | - | * | - | * | - |*** | - | | - +----------------+ */ - 0xe0, - 0x40, - 0x40, - 0x40, - 0x40, - 0xe0, - 0x00, - - /* Character (0x4a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | * | - |* * | - | ** | - | | - +----------------+ */ - 0x10, - 0x10, - 0x10, - 0x10, - 0x90, - 0x60, - 0x00, - - /* Character (0x4b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |** | - |** | - |* * | - |* * | - | | - +----------------+ */ - 0x90, - 0xa0, - 0xc0, - 0xc0, - 0xa0, - 0x90, - 0x00, - - /* Character (0x4c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - |* | - |* | - |* | - |* | - |**** | - | | - +----------------+ */ - 0x80, - 0x80, - 0x80, - 0x80, - 0x80, - 0xf0, - 0x00, - - /* Character (0x4d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |**** | - |**** | - |* * | - |* * | - |* * | - | | - +----------------+ */ - 0x90, - 0xf0, - 0xf0, - 0x90, - 0x90, - 0x90, - 0x00, - - /* Character (0x4e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |** * | - |** * | - |* ** | - |* ** | - |* * | - | | - +----------------+ */ - 0x90, - 0xd0, - 0xd0, - 0xb0, - 0xb0, - 0x90, - 0x00, - - /* Character (0x4f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* * | - |* * | - |* * | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x90, - 0x90, - 0x90, - 0x60, - 0x00, - - /* Character (0x50): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - |* * | - |* * | - |*** | - |* | - |* | - | | - +----------------+ */ - 0xe0, - 0x90, - 0x90, - 0xe0, - 0x80, - 0x80, - 0x00, - - /* Character (0x51): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - |* * | - |* * | - |** * | - | ** | - | * | - +----------------+ */ - 0x60, - 0x90, - 0x90, - 0x90, - 0xd0, - 0x60, - 0x10, - - /* Character (0x52): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - |* * | - |* * | - |*** | - |* * | - |* * | - | | - +----------------+ */ - 0xe0, - 0x90, - 0x90, - 0xe0, - 0xa0, - 0x90, - 0x00, - - /* Character (0x53): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | ** | - |* * | - | * | - | * | - |* * | - | ** | - | | - +----------------+ */ - 0x60, - 0x90, - 0x40, - 0x20, - 0x90, - 0x60, - 0x00, - - /* Character (0x54): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - | * | - | * | - | * | - | * | - | * | - | | - +----------------+ */ - 0xe0, - 0x40, - 0x40, - 0x40, - 0x40, - 0x40, - 0x00, - - /* Character (0x55): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |* * | - |* * | - |* * | - | ** | - | | - +----------------+ */ - 0x90, - 0x90, - 0x90, - 0x90, - 0x90, - 0x60, - 0x00, - - /* Character (0x56): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |* * | - |* * | - | ** | - | ** | - | | - +----------------+ */ - 0x90, - 0x90, - 0x90, - 0x90, - 0x60, - 0x60, - 0x00, - - /* Character (0x57): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |* * | - |**** | - |**** | - |* * | - | | - +----------------+ */ - 0x90, - 0x90, - 0x90, - 0xf0, - 0xf0, - 0x90, - 0x00, - - /* Character (0x58): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - | ** | - | ** | - |* * | - |* * | - | | - +----------------+ */ - 0x90, - 0x90, - 0x60, - 0x60, - 0x90, - 0x90, - 0x00, - - /* Character (0x59): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* * | - |* * | - |* * | - | * | - | * | - | * | - | | - +----------------+ */ - 0xa0, - 0xa0, - 0xa0, - 0x40, - 0x40, - 0x40, - 0x00, - - /* Character (0x5a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |**** | - | * | - | * | - | * | - |* | - |**** | - | | - +----------------+ */ - 0xf0, - 0x10, - 0x20, - 0x40, - 0x80, - 0xf0, - 0x00, - - /* Character (0x5b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - |* | - |* | - |* | - |* | - |*** | - | | - +----------------+ */ - 0xe0, - 0x80, - 0x80, - 0x80, - 0x80, - 0xe0, - 0x00, - - /* Character (0x5c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - |* | - | * | - | * | - | * | - | | - | | - +----------------+ */ - 0x00, - 0x80, - 0x40, - 0x20, - 0x10, - 0x00, - 0x00, - - /* Character (0x5d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |*** | - | * | - | * | - | * | - | * | - |*** | - | | - +----------------+ */ - 0xe0, - 0x20, - 0x20, - 0x20, - 0x20, - 0xe0, - 0x00, - - /* Character (0x5e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - |* * | - | | - | | - | | - | | - | | - +----------------+ */ - 0x40, - 0xa0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - - /* Character (0x5f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | | - | | - | | - |**** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0xf0, - 0x00, - - /* Character (0x60): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |** | - | * | - | * | - | | - | | - | | - | | - +----------------+ */ - 0xc0, - 0x40, - 0x20, - 0x00, - 0x00, - 0x00, - 0x00, - - /* Character (0x61): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | *** | - |* * | - |* ** | - | * * | - | | - +----------------+ */ - 0x00, - 0x00, - 0x70, - 0x90, - 0xb0, - 0x50, - 0x00, - - /* Character (0x62): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - |* | - |*** | - |* * | - |* * | - |*** | - | | - +----------------+ */ - 0x80, - 0x80, - 0xe0, - 0x90, - 0x90, - 0xe0, - 0x00, - - /* Character (0x63): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | ** | - |* | - |* | - | ** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x60, - 0x80, - 0x80, - 0x60, - 0x00, - - /* Character (0x64): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | *** | - |* * | - |* * | - | *** | - | | - +----------------+ */ - 0x10, - 0x10, - 0x70, - 0x90, - 0x90, - 0x70, - 0x00, - - /* Character (0x65): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | ** | - |* ** | - |** | - | ** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x60, - 0xb0, - 0xc0, - 0x60, - 0x00, - - /* Character (0x66): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * * | - | * | - |*** | - | * | - | * | - | | - +----------------+ */ - 0x20, - 0x50, - 0x40, - 0xe0, - 0x40, - 0x40, - 0x00, - - /* Character (0x67): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | *** | - |* * | - | ** | - |* | - | *** | - +----------------+ */ - 0x00, - 0x00, - 0x70, - 0x90, - 0x60, - 0x80, - 0x70, - - /* Character (0x68): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - |* | - |*** | - |* * | - |* * | - |* * | - | | - +----------------+ */ - 0x80, - 0x80, - 0xe0, - 0x90, - 0x90, - 0x90, - 0x00, - - /* Character (0x69): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | | - |** | - | * | - | * | - |*** | - | | - +----------------+ */ - 0x40, - 0x00, - 0xc0, - 0x40, - 0x40, - 0xe0, - 0x00, + width=5 + +--------+ + | ** | + |* * | + |* * | + | ** | + | | + | | + | | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b01100000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x20): ' ' + width=4 + +--------+ + | | + | | + | | + | | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x21): '!' + width=4 + +--------+ + | * | + | * | + | * | + | * | + | * | + | | + | * | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b01000000, + + /* Character (0x22): '"' + width=5 + +--------+ + | * * | + | * * | + | * * | + | | + | | + | | + | | + +--------+ */ + 0b01010000, + 0b01010000, + 0b01010000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x23): '#' + width=5 + +--------+ + | * * | + | * * | + |***** | + | * * | + |***** | + | * * | + | * * | + +--------+ */ + 0b01010000|CHAR5x7_WIDTH_6px, + 0b01010000, + 0b11111000, + 0b01010000, + 0b11111000, + 0b01010000, + 0b01010000, + + /* Character (0x24): '$' + width=5 + +--------+ + | * | + | **** | + |* * | + | *** | + | * * | + |**** | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_6px, + 0b01111000, + 0b10100000, + 0b01110000, + 0b00101000, + 0b11110000, + 0b00100000, + + /* Character (0x25): '%' + width=6 + +--------+ + |** | + |** * | + | * | + | * | + | * | + |* ** | + | ** | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_6px, + 0b11001000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10011000, + 0b00011000, + + /* Character (0x26): '&' + width=5 + +--------+ + | | + | * | + | * * | + | ** | + |* * * | + |* * | + | ** * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b01010000, + 0b01100000, + 0b10101000, + 0b10010000, + 0b01101000, + + /* Character (0x27): ''' + width=4 + +--------+ + | ** | + | * | + |* | + | | + | | + | | + | | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b10000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x28): '(' + width=4 + +--------+ + | * | + | * | + |* | + |* | + |* | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b01000000, + 0b00100000, + + /* Character (0x29): ')' + width=5 + +--------+ + |* | + | * | + | * | + | * | + | * | + | * | + |* | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01000000, + 0b10000000, + + /* Character (0x2a): '*' + width=6 + +--------+ + | | + | * | + |* * * | + | *** | + |* * * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b10101000, + 0b01110000, + 0b10101000, + 0b00100000, + 0b00000000, + + /* Character (0x2b): '+' + width=6 + +--------+ + | | + | * | + | * | + |***** | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00100000, + 0b11111000, + 0b00100000, + 0b00100000, + 0b00000000, + + /* Character (0x2c): ',' + width=4 + +--------+ + | | + | | + | | + | | + |** | + | * | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11000000, + 0b01000000, + 0b10000000, + + /* Character (0x2d): '-' + width=5 + +--------+ + | | + | | + | | + |**** | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b11110000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x2e): '.' + width=3 + +--------+ + | | + | | + | | + | | + | | + |** | + |** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11000000, + 0b11000000, + + /* Character (0x2f): '/' + width=4 + +--------+ + | * | + | * | + | * | + | * | + | * | + |* | + |* | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b00100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b10000000, + 0b10000000, + + /* Character (0x30): '0' + width=5 + +--------+ + | ** | + |* * | + |* ** | + |** * | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10110000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x31): '1' + width=5 + +--------+ + | * | + | ** | + | * | + | * | + | * | + | * | + | *** | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b01100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01110000, + + /* Character (0x32): '2' + width=5 + +--------+ + | ** | + |* * | + | * | + | * | + | * | + |* | + |**** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b11110000, + + /* Character (0x33): '3' + width=5 + +--------+ + | ** | + |* * | + | * | + | ** | + | * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b00010000, + 0b01100000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x34): '4' + width=5 + +--------+ + |* * | + |* * | + |* * | + |* * | + |**** | + | * | + | * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b11110000, + 0b00010000, + 0b00010000, + + /* Character (0x35): '5' + width=5 + +--------+ + |**** | + |* | + |*** | + | * | + | * | + |* * | + | ** | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b11100000, + 0b00010000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x36): '6' + width=5 + +--------+ + | ** | + |* * | + |* | + |*** | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x37): '7' + width=5 + +--------+ + |**** | + | * | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b00100000, + 0b00100000, + 0b01000000, + 0b01000000, + 0b01000000, + + /* Character (0x38): '8' + width=5 + +--------+ + | ** | + |* * | + |* * | + | ** | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b01100000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x39): '9' + width=5 + +--------+ + | ** | + |* * | + |* * | + | *** | + | * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x3a): ':' + width=3 + +--------+ + | | + |** | + |** | + | | + |** | + |** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b11000000, + 0b11000000, + 0b00000000, + 0b11000000, + 0b11000000, + 0b00000000, + + /* Character (0x3b): ';' + width=4 + +--------+ + | | + | ** | + | ** | + | | + | ** | + | * | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b01100000, + 0b01100000, + 0b00000000, + 0b01100000, + 0b01000000, + 0b10000000, + + /* Character (0x3c): '<' + width=5 + +--------+ + | | + | * | + | * | + |* | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b01000000, + 0b10000000, + 0b01000000, + 0b00100000, + 0b00000000, + + /* Character (0x3d): '=' + width=5 + +--------+ + | | + | | + |**** | + | | + |**** | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11110000, + 0b00000000, + 0b11110000, + 0b00000000, + 0b00000000, + + /* Character (0x3e): '>' + width=5 + +--------+ + | | + |* | + | * | + | * | + | * | + |* | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b01000000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b00000000, + + /* Character (0x3f): '?' + width=5 + +--------+ + | ** | + |* * | + | * | + | * | + | * | + | | + | * | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b00000000, + 0b01000000, + + /* Character (0x40): '@' + width=5 + +--------+ + | ** | + |* * | + |* ** | + |* ** | + |* | + |* | + | *** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10110000, + 0b10110000, + 0b10000000, + 0b10000000, + 0b01110000, + + /* Character (0x41): 'A' + width=5 + +--------+ + | ** | + |* * | + |* * | + |* * | + |**** | + |* * | + |* * | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b11110000, + 0b10010000, + 0b10010000, + + /* Character (0x42): 'B' + width=5 + +--------+ + |*** | + |* * | + |* * | + |*** | + |* * | + |* * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b11100000, + + /* Character (0x43): 'C' + width=5 + +--------+ + | ** | + |* * | + |* | + |* | + |* | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10010000, + 0b01100000, + + /* Character (0x44): 'D' + width=5 + +--------+ + |*** | + |* * | + |* * | + |* * | + |* * | + |* * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b11100000, + + /* Character (0x45): 'E' + width=5 + +--------+ + |**** | + |* | + |* | + |*** | + |* | + |* | + |**** | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10000000, + 0b11100000, + 0b10000000, + 0b10000000, + 0b11110000, + + /* Character (0x46): 'F' + width=5 + +--------+ + |**** | + |* | + |* | + |*** | + |* | + |* | + |* | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10000000, + 0b11100000, + 0b10000000, + 0b10000000, + 0b10000000, + + /* Character (0x47): 'G' + width=5 + +--------+ + | ** | + |* * | + |* | + |* ** | + |* * | + |* * | + | *** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b10110000, + 0b10010000, + 0b10010000, + 0b01110000, + + /* Character (0x48): 'H' + width=5 + +--------+ + |* * | + |* * | + |* * | + |**** | + |* * | + |* * | + |* * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11110000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x49): 'I' + width=4 + +--------+ + |*** | + | * | + | * | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b11100000, + + /* Character (0x4a): 'J' + width=5 + +--------+ + | *** | + | * | + | * | + | * | + | * | + |* * | + | ** | + +--------+ */ + 0b01110000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x4b): 'K' + width=5 + +--------+ + |* * | + |* * | + |* * | + |** | + |* * | + |* * | + |* * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x4c): 'L' + width=5 + +--------+ + |* | + |* | + |* | + |* | + |* | + |* | + |**** | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b11110000, + + /* Character (0x4d): 'M' + width=6 + +--------+ + |* * | + |** ** | + |* * * | + |* * * | + |* * | + |* * | + |* * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b11011000, + 0b10101000, + 0b10101000, + 0b10001000, + 0b10001000, + 0b10001000, + + /* Character (0x4e): 'N' + width=5 + +--------+ + |* * | + |* * | + |** * | + |* ** | + |* * | + |* * | + |* * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b11010000, + 0b10110000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x4f): 'O' + width=5 + +--------+ + | ** | + |* * | + |* * | + |* * | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x50): 'P' + width=5 + +--------+ + |*** | + |* * | + |* * | + |*** | + |* | + |* | + |* | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10000000, + 0b10000000, + 0b10000000, + + /* Character (0x51): 'Q' + width=5 + +--------+ + | ** | + |* * | + |* * | + |* * | + |* * | + |* * | + | * * | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10100000, + 0b01010000, + + /* Character (0x52): 'R' + width=5 + +--------+ + |*** | + |* * | + |* * | + |*** | + |* * | + |* * | + |* * | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x53): 'S' + width=5 + +--------+ + | ** | + |* * | + |* | + | ** | + | * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b01100000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x54): 'T' + width=6 + +--------+ + |***** | + | * | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b11111000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x55): 'U' + width=5 + +--------+ + |* * | + |* * | + |* * | + |* * | + |* * | + |* * | + | *** | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01110000, + + /* Character (0x56): 'V' + width=5 + +--------+ + |* * | + |* * | + |* * | + |* * | + |* * | + | ** | + | ** | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b01100000, + + /* Character (0x57): 'W' + width=6 + +--------+ + |* * | + |* * | + |* * | + |* * * | + |* * * | + |* * * | + | * * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b10101000, + 0b01010000, + + /* Character (0x58): 'X' + width=6 + +--------+ + |* * | + |* * | + | * * | + | * | + | * * | + |* * | + |* * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b01010000, + 0b00100000, + 0b01010000, + 0b10001000, + 0b10001000, + + /* Character (0x59): 'Y' + width=6 + +--------+ + |* * | + |* * | + |* * | + | * * | + | * | + | * | + | * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b10001000, + 0b01010000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x5a): 'Z' + width=5 + +--------+ + |**** | + | * | + | * | + | * | + |* | + |* | + |**** | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b10000000, + 0b11110000, + + /* Character (0x5b): '[' + width=4 + +--------+ + |*** | + |* | + |* | + |* | + |* | + |* | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_4px, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b11100000, + + /* Character (0x5c): '\' + width=4 + +--------+ + |* | + |* | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b10000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00100000, + 0b00100000, + + /* Character (0x5d): ']' + width=4 + +--------+ + |*** | + | * | + | * | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_4px, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b11100000, + + /* Character (0x5e): '^' + width=4 + +--------+ + | * | + |* * | + | | + | | + | | + | | + | | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_4px, + 0b10100000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x5f): '_' + width=5 + +--------+ + | | + | | + | | + | | + | | + | | + |***** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + + /* Character (0x60): '`' + width=4 + +--------+ + |** | + | * | + | * | + | | + | | + | | + | | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b00100000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x61): 'a' + width=5 + +--------+ + | | + | | + | *** | + |* * | + |* * | + |* ** | + | * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10010000, + 0b10010000, + 0b10110000, + 0b01010000, + + /* Character (0x62): 'b' + width=5 + +--------+ + |* | + |* | + |* * | + |** * | + |* * | + |* * | + |*** | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10100000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b11100000, + + /* Character (0x63): 'c' + width=5 + +--------+ + | | + | | + | *** | + |* | + |* | + |* | + | *** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b01110000, + + /* Character (0x64): 'd' + width=5 + +--------+ + | * | + | * | + | * * | + |* ** | + |* * | + |* * | + | *** | + +--------+ */ + 0b00010000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b01010000, + 0b10110000, + 0b10010000, + 0b10010000, + 0b01110000, + + /* Character (0x65): 'e' + width=5 + +--------+ + | | + | | + | ** | + |* * | + |**** | + |* | + | *** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01100000, + 0b10010000, + 0b11110000, + 0b10000000, + 0b01110000, + + /* Character (0x66): 'f' + width=5 + +--------+ + | * | + | * * | + | * | + |*** | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b01010000, + 0b01000000, + 0b11100000, + 0b01000000, + 0b01000000, + 0b01000000, + + /* Character (0x67): 'g' + width=5 + +--------+ + | | + | | + | *** | + |* * | + | *** | + | * | + | ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b01100000, + + /* Character (0x68): 'h' + width=5 + +--------+ + |* | + |* | + |* * | + |** * | + |* * | + |* * | + |* * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10100000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x69): 'i' + width=4 + +--------+ + | * | + | | + |** | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b11000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b11100000, /* Character (0x6a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | | - | * | - | * | - | * | - |* * | - | * | - +----------------+ */ - 0x20, - 0x00, - 0x20, - 0x20, - 0x20, - 0xa0, - 0x40, + width=4 + +--------+ + | * | + | | + | * | + | * | + | * | + |* * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b10100000, + 0b01000000, - /* Character (0x6b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - |* | - |* * | - |** | - |* * | - |* * | - | | - +----------------+ */ - 0x80, - 0x80, - 0xa0, - 0xc0, - 0xa0, - 0x90, - 0x00, + /* Character (0x6b): 'k' + width=5 + +--------+ + |* | + |* | + |* * | + |* * | + |** | + |* * | + |* * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10010000, + 0b10100000, + 0b11000000, + 0b10100000, + 0b10010000, - /* Character (0x6c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |** | - | * | - | * | - | * | - | * | - |*** | - | | - +----------------+ */ - 0xc0, - 0x40, - 0x40, - 0x40, - 0x40, - 0xe0, - 0x00, + /* Character (0x6c): 'l' + width=4 + +--------+ + |** | + | * | + | * | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b11100000, - /* Character (0x6d): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - |**** | - |* * | - |* * | - | | - +----------------+ */ - 0x00, - 0x00, - 0xa0, - 0xf0, - 0x90, - 0x90, - 0x00, + /* Character (0x6d): 'm' + width=6 + +--------+ + | | + | | + |**** | + |* * * | + |* * * | + |* * * | + |* * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00000000, + 0b11110000, + 0b10101000, + 0b10101000, + 0b10101000, + 0b10101000, - /* Character (0x6e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |*** | - |* * | - |* * | - |* * | - | | - +----------------+ */ - 0x00, - 0x00, - 0xe0, - 0x90, - 0x90, - 0x90, - 0x00, + /* Character (0x6e): 'n' + width=5 + +--------+ + | | + | | + |* * | + |** * | + |* * | + |* * | + |* * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10100000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b10010000, - /* Character (0x6f): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | ** | - |* * | - |* * | - | ** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x60, - 0x90, - 0x90, - 0x60, - 0x00, + /* Character (0x6f): 'o' + width=5 + +--------+ + | | + | | + | ** | + |* * | + |* * | + |* * | + | ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01100000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, - /* Character (0x70): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |*** | - |* * | - |* * | - |*** | - |* | - +----------------+ */ - 0x00, - 0x00, - 0xe0, - 0x90, - 0x90, - 0xe0, - 0x80, + /* Character (0x70): 'p' + width=5 + +--------+ + | | + | | + |*** | + |* * | + |* * | + |*** | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10000000, - /* Character (0x71): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | *** | - |* * | - |* * | - | *** | - | * | - +----------------+ */ - 0x00, - 0x00, - 0x70, - 0x90, - 0x90, - 0x70, - 0x10, + /* Character (0x71): 'q' + width=5 + +--------+ + | | + | | + | *** | + |* * | + |* * | + | *** | + | * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00010000, - /* Character (0x72): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |*** | - |* * | - |* | - |* | - | | - +----------------+ */ - 0x00, - 0x00, - 0xe0, - 0x90, - 0x80, - 0x80, - 0x00, + /* Character (0x72): 'r' + width=5 + +--------+ + | | + | | + |* * | + |** * | + |* | + |* | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10100000, + 0b11010000, + 0b10000000, + 0b10000000, + 0b10000000, - /* Character (0x73): - bbw=6, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - | *** | - |** | - | ** | - |*** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x70, - 0xc0, - 0x30, - 0xe0, - 0x00, + /* Character (0x73): 's' + width=5 + +--------+ + | | + | | + | *** | + |* | + | ** | + | * | + |*** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10000000, + 0b01100000, + 0b00010000, + 0b11100000, - /* Character (0x74): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - |*** | - | * | - | * | - | ** | - | | - +----------------+ */ - 0x40, - 0x40, - 0xe0, - 0x40, - 0x40, - 0x30, - 0x00, + /* Character (0x74): 't' + width=5 + +--------+ + | * | + | * | + |*** | + | * | + | * | + | * | + | ** | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_5px, + 0b01000000, + 0b11100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00110000, - /* Character (0x75): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - |* * | - |* * | - | *** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x90, - 0x90, - 0x90, - 0x70, - 0x00, + /* Character (0x75): 'u' + width=5 + +--------+ + | | + | | + |* * | + |* * | + |* * | + |* ** | + | * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10110000, + 0b01010000, - /* Character (0x76): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - |* * | - |* * | - | * | - | | - +----------------+ */ - 0x00, - 0x00, - 0xa0, - 0xa0, - 0xa0, - 0x40, - 0x00, + /* Character (0x76): 'v' + width=5 + +--------+ + | | + | | + |* * | + |* * | + |* * | + | ** | + | ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b01100000, - /* Character (0x77): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - |* * | - |**** | - |**** | - | | - +----------------+ */ - 0x00, - 0x00, - 0x90, - 0x90, - 0xf0, - 0xf0, - 0x00, + /* Character (0x77): 'w' + width=6 + +--------+ + | | + | | + |* * | + |* * | + |* * * | + |* * * | + | * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00000000, + 0b10001000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b01010000, - /* Character (0x78): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - | ** | - | ** | - |* * | - | | - +----------------+ */ - 0x00, - 0x00, - 0x90, - 0x60, - 0x60, - 0x90, - 0x00, + /* Character (0x78): 'x' + width=5 + +--------+ + | | + | | + |* * | + |* * | + | ** | + |* * | + |* * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b10010000, + 0b10010000, - /* Character (0x79): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |* * | - |* * | - | * * | - | * | - | * | - +----------------+ */ - 0x00, - 0x00, - 0x90, - 0x90, - 0x50, - 0x20, - 0x40, + /* Character (0x79): 'y' + width=5 + +--------+ + | | + | | + |* * | + |* * | + | *** | + | * | + |*** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b11100000, - /* Character (0x7a): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | | - | | - |**** | - | * | - | * | - |**** | - | | - +----------------+ */ - 0x00, - 0x00, - 0xf0, - 0x20, - 0x40, - 0xf0, - 0x00, + /* Character (0x7a): 'z' + width=5 + +--------+ + | | + | | + |**** | + | * | + | * | + |* | + |**** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11110000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b11110000, - /* Character (0x7b): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - |** | - | * | - | * | - | * | - | | - +----------------+ */ - 0x20, - 0x40, - 0xc0, - 0x40, - 0x40, - 0x20, - 0x00, + /* Character (0x7b): '{' + width=5 + +--------+ + | * | + | * | + | * | + |* | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b10000000, + 0b01000000, + 0b01000000, + 0b00100000, - /* Character (0x7c): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * | - | * | - | * | - | * | - | * | - | * | - | | - +----------------+ */ - 0x40, - 0x40, - 0x40, - 0x40, - 0x40, - 0x40, - 0x00, + /* Character (0x7c): '|' + width=5 + +--------+ + | * | + | * | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, - /* Character (0x7d): - bbw=6, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - |* | - | * | - | ** | - | * | - | * | - |* | - | | - +----------------+ */ - 0x80, - 0x40, - 0x60, - 0x40, - 0x40, - 0x80, - 0x00, + /* Character (0x7d): '}' + width=5 + +--------+ + |* | + | * | + | * | + | * | + | * | + | * | + |* | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b00100000, + 0b01000000, + 0b01000000, + 0b10000000, - /* Character (0x7e): - bbw=5, bbh=7, bbx=0, bby=-1, width=5 - +----------------+ - | * * | - |* * | - | | - | | - | | - | | - | | - +----------------+ */ - 0x50, - 0xa0, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, + /* Character (0x7e): '~' + width=5 + +--------+ + | | + | | + | * * | + |* * | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01010000, + 0b10100000, + 0b00000000, + 0b00000000, + 0b00000000, }; - -#if 0 -/* Character width data. */ -static UNS_8 x5x7_width [] = -{ - 5, /* (0x00) */ - 5, /* (0x01) */ - 5, /* (0x02) */ - 5, /* (0x03) */ - 5, /* (0x04) */ - 5, /* (0x05) */ - 5, /* (0x06) */ - 5, /* (0x07) */ - 5, /* (0x08) */ - 5, /* (0x09) */ - 5, /* (0x0a) */ - 5, /* (0x0b) */ - 5, /* (0x0c) */ - 5, /* (0x0d) */ - 5, /* (0x0e) */ - 5, /* (0x0f) */ - 5, /* (0x10) */ - 5, /* (0x11) */ - 5, /* (0x12) */ - 5, /* (0x13) */ - 5, /* (0x14) */ - 5, /* (0x15) */ - 5, /* (0x16) */ - 5, /* (0x17) */ - 5, /* (0x18) */ - 5, /* (0x19) */ - 5, /* (0x1a) */ - 5, /* (0x1b) */ - 5, /* (0x1c) */ - 5, /* (0x1d) */ - 5, /* (0x1e) */ - 5, /* (0x1f) */ - 5, /* (0x20) */ - 5, /* (0x21) */ - 5, /* (0x22) */ - 5, /* (0x23) */ - 5, /* (0x24) */ - 5, /* (0x25) */ - 5, /* (0x26) */ - 5, /* (0x27) */ - 5, /* (0x28) */ - 5, /* (0x29) */ - 5, /* (0x2a) */ - 5, /* (0x2b) */ - 5, /* (0x2c) */ - 5, /* (0x2d) */ - 5, /* (0x2e) */ - 5, /* (0x2f) */ - 5, /* (0x30) */ - 5, /* (0x31) */ - 5, /* (0x32) */ - 5, /* (0x33) */ - 5, /* (0x34) */ - 5, /* (0x35) */ - 5, /* (0x36) */ - 5, /* (0x37) */ - 5, /* (0x38) */ - 5, /* (0x39) */ - 5, /* (0x3a) */ - 5, /* (0x3b) */ - 5, /* (0x3c) */ - 5, /* (0x3d) */ - 5, /* (0x3e) */ - 5, /* (0x3f) */ - 5, /* (0x40) */ - 5, /* (0x41) */ - 5, /* (0x42) */ - 5, /* (0x43) */ - 5, /* (0x44) */ - 5, /* (0x45) */ - 5, /* (0x46) */ - 5, /* (0x47) */ - 5, /* (0x48) */ - 5, /* (0x49) */ - 5, /* (0x4a) */ - 5, /* (0x4b) */ - 5, /* (0x4c) */ - 5, /* (0x4d) */ - 5, /* (0x4e) */ - 5, /* (0x4f) */ - 5, /* (0x50) */ - 5, /* (0x51) */ - 5, /* (0x52) */ - 5, /* (0x53) */ - 5, /* (0x54) */ - 5, /* (0x55) */ - 5, /* (0x56) */ - 5, /* (0x57) */ - 5, /* (0x58) */ - 5, /* (0x59) */ - 5, /* (0x5a) */ - 5, /* (0x5b) */ - 5, /* (0x5c) */ - 5, /* (0x5d) */ - 5, /* (0x5e) */ - 5, /* (0x5f) */ - 5, /* (0x60) */ - 5, /* (0x61) */ - 5, /* (0x62) */ - 5, /* (0x63) */ - 5, /* (0x64) */ - 5, /* (0x65) */ - 5, /* (0x66) */ - 5, /* (0x67) */ - 5, /* (0x68) */ - 5, /* (0x69) */ - 5, /* (0x6a) */ - 5, /* (0x6b) */ - 5, /* (0x6c) */ - 5, /* (0x6d) */ - 5, /* (0x6e) */ - 5, /* (0x6f) */ - 5, /* (0x70) */ - 5, /* (0x71) */ - 5, /* (0x72) */ - 5, /* (0x73) */ - 5, /* (0x74) */ - 5, /* (0x75) */ - 5, /* (0x76) */ - 5, /* (0x77) */ - 5, /* (0x78) */ - 5, /* (0x79) */ - 5, /* (0x7a) */ - 5, /* (0x7b) */ - 5, /* (0x7c) */ - 5, /* (0x7d) */ - 5, /* (0x7e) */ -}; -#endif - -/* Font information structure */ -//const FONT_T font_x5x7 = {7, 0x00, 0x7E, x5x7_bits, x5x7_width}; - diff --git a/halconf.h b/halconf.h index 727be71..9a44c8b 100644 --- a/halconf.h +++ b/halconf.h @@ -132,7 +132,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL TRUE +#define HAL_USE_SERIAL FALSE #endif /** diff --git a/ili9341.c b/ili9341.c index 99b4627..9cd184d 100644 --- a/ili9341.c +++ b/ili9341.c @@ -21,6 +21,119 @@ #include "hal.h" #include "nanovna.h" +uint16_t spi_buffer[1024]; +// Default foreground & background colors +uint16_t foreground_color=DEFAULT_FG_COLOR; +uint16_t background_color=DEFAULT_BG_COLOR; + +// Display width and height definition +#define ILI9341_WIDTH 320 +#define ILI9341_HEIGHT 240 + +// Display commands list +#define ILI9341_NOP 0x00 +#define ILI9341_SOFTWARE_RESET 0x01 +#define ILI9341_READ_IDENTIFICATION 0x04 +#define ILI9341_READ_STATUS 0x09 +#define ILI9341_READ_POWER_MODE 0x0A +#define ILI9341_READ_MADCTL 0x0B +#define ILI9341_READ_PIXEL_FORMAT 0x0C +#define ILI9341_READ_IMAGE_FORMAT 0x0D +#define ILI9341_READ_SIGNAL_MODE 0x0E +#define ILI9341_READ_SELF_DIAGNOSTIC 0x0F +#define ILI9341_SLEEP_IN 0x10 +#define ILI9341_SLEEP_OUT 0x11 +#define ILI9341_PARTIAL_MODE_ON 0x12 +#define ILI9341_NORMAL_DISPLAY_MODE_ON 0x13 +#define ILI9341_INVERSION_OFF 0x20 +#define ILI9341_INVERSION_ON 0x21 +#define ILI9341_GAMMA_SET 0x26 +#define ILI9341_DISPLAY_OFF 0x28 +#define ILI9341_DISPLAY_ON 0x29 +#define ILI9341_COLUMN_ADDRESS_SET 0x2A +#define ILI9341_PAGE_ADDRESS_SET 0x2B +#define ILI9341_MEMORY_WRITE 0x2C +#define ILI9341_COLOR_SET 0x2D +#define ILI9341_MEMORY_READ 0x2E +#define ILI9341_PARTIAL_AREA 0x30 +#define ILI9341_VERTICAL_SCROLLING_DEF 0x33 +#define ILI9341_TEARING_LINE_OFF 0x34 +#define ILI9341_TEARING_LINE_ON 0x35 +#define ILI9341_MEMORY_ACCESS_CONTROL 0x36 +#define ILI9341_VERTICAL_SCROLLING 0x37 +#define ILI9341_IDLE_MODE_OFF 0x38 +#define ILI9341_IDLE_MODE_ON 0x39 +#define ILI9341_PIXEL_FORMAT_SET 0x3A +#define ILI9341_WRITE_MEMORY_CONTINUE 0x3C +#define ILI9341_READ_MEMORY_CONTINUE 0x3E +#define ILI9341_SET_TEAR_SCANLINE 0x44 +#define ILI9341_GET_SCANLINE 0x45 +#define ILI9341_WRITE_BRIGHTNESS 0x51 +#define ILI9341_READ_BRIGHTNESS 0x52 +#define ILI9341_WRITE_CTRL_DISPLAY 0x53 +#define ILI9341_READ_CTRL_DISPLAY 0x54 +#define ILI9341_WRITE_CA_BRIGHTNESS 0x55 +#define ILI9341_READ_CA_BRIGHTNESS 0x56 +#define ILI9341_WRITE_CA_MIN_BRIGHTNESS 0x5E +#define ILI9341_READ_CA_MIN_BRIGHTNESS 0x5F +#define ILI9341_READ_ID1 0xDA +#define ILI9341_READ_ID2 0xDB +#define ILI9341_READ_ID3 0xDC +#define ILI9341_RGB_INTERFACE_CONTROL 0xB0 +#define ILI9341_FRAME_RATE_CONTROL_1 0xB1 +#define ILI9341_FRAME_RATE_CONTROL_2 0xB2 +#define ILI9341_FRAME_RATE_CONTROL_3 0xB3 +#define ILI9341_DISPLAY_INVERSION_CONTROL 0xB4 +#define ILI9341_BLANKING_PORCH_CONTROL 0xB5 +#define ILI9341_DISPLAY_FUNCTION_CONTROL 0xB6 +#define ILI9341_ENTRY_MODE_SET 0xB7 +#define ILI9341_BACKLIGHT_CONTROL_1 0xB8 +#define ILI9341_BACKLIGHT_CONTROL_2 0xB9 +#define ILI9341_BACKLIGHT_CONTROL_3 0xBA +#define ILI9341_BACKLIGHT_CONTROL_4 0xBB +#define ILI9341_BACKLIGHT_CONTROL_5 0xBC +#define ILI9341_BACKLIGHT_CONTROL_7 0xBE +#define ILI9341_BACKLIGHT_CONTROL_8 0xBF +#define ILI9341_POWER_CONTROL_1 0xC0 +#define ILI9341_POWER_CONTROL_2 0xC1 +#define ILI9341_VCOM_CONTROL_1 0xC5 +#define ILI9341_VCOM_CONTROL_2 0xC7 +#define ILI9341_POWERA 0xCB +#define ILI9341_POWERB 0xCF +#define ILI9341_NV_MEMORY_WRITE 0xD0 +#define ILI9341_NV_PROTECTION_KEY 0xD1 +#define ILI9341_NV_STATUS_READ 0xD2 +#define ILI9341_READ_ID4 0xD3 +#define ILI9341_POSITIVE_GAMMA_CORRECTION 0xE0 +#define ILI9341_NEGATIVE_GAMMA_CORRECTION 0xE1 +#define ILI9341_DIGITAL_GAMMA_CONTROL_1 0xE2 +#define ILI9341_DIGITAL_GAMMA_CONTROL_2 0xE3 +#define ILI9341_DTCA 0xE8 +#define ILI9341_DTCB 0xEA +#define ILI9341_POWER_SEQ 0xED +#define ILI9341_3GAMMA_EN 0xF2 +#define ILI9341_INTERFACE_CONTROL 0xF6 +#define ILI9341_PUMP_RATIO_CONTROL 0xF7 + +// +// ILI9341_MEMORY_ACCESS_CONTROL registers +// +#define ILI9341_MADCTL_MY 0x80 +#define ILI9341_MADCTL_MX 0x40 +#define ILI9341_MADCTL_MV 0x20 +#define ILI9341_MADCTL_ML 0x10 +#define ILI9341_MADCTL_BGR 0x08 +#define ILI9341_MADCTL_MH 0x04 +#define ILI9341_MADCTL_RGB 0x00 + +#define DISPLAY_ROTATION_270 (ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR) +#define DISPLAY_ROTATION_90 (ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR) +#define DISPLAY_ROTATION_0 (ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR) +#define DISPLAY_ROTATION_180 (ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR) + +// +// Pin macros +// #define RESET_ASSERT palClearPad(GPIOA, 15) #define RESET_NEGATE palSetPad(GPIOA, 15) #define CS_LOW palClearPad(GPIOB, 6) @@ -28,487 +141,528 @@ #define DC_CMD palClearPad(GPIOB, 7) #define DC_DATA palSetPad(GPIOB, 7) -uint16_t spi_buffer[1024]; +//***************************************************************************** +//********************************** SPI bus ********************************** +//***************************************************************************** +// STM32 SPI transfer mode: +// in 8 bit mode: +// if you write *(uint8_t*)(&SPI1->DR) = (uint8_t) data, then data send as << data +// if you write *(uint16_t*)(&SPI1->DR) =(uint16_t) data, then data send as << dataLoByte, after send dataHiByte +// in 16 bit mode +// if you write *(uint16_t*)(&SPI1->DR) =(uint16_t) data, then data send as << data -void -ssp_wait(void) -{ - while (SPI1->SR & SPI_SR_BSY) - ; -} +// SPI init in 8 bit mode +#define SPI_CR2_8BIT 0x0700 +#define SPI_CR2_16BIT 0x0F00 -void -ssp_wait_slot(void) -{ - while ((SPI1->SR & 0x1800) == 0x1800) - ; -} +// SPI bus activity macros -void -ssp_senddata(uint8_t x) -{ - *(uint8_t*)(&SPI1->DR) = x; - while (SPI1->SR & SPI_SR_BSY) - ; -} +// The RXNE flag is set depending on the FRXTH bit value in the SPIx_CR2 register: +// • If FRXTH is set, RXNE goes high and stays high until the RXFIFO level is greater or equal to 1/4 (8-bit). +#define SPI_RX_IS_NOT_EMPTY (SPI1->SR&SPI_SR_RXNE) +#define SPI_RX_IS_EMPTY (((SPI1->SR&SPI_SR_RXNE) == 0)) -uint8_t -ssp_sendrecvdata(uint8_t x) -{ - while (!(SPI1->SR & SPI_SR_TXE)); - // clear OVR - while (SPI1->SR & SPI_SR_RXNE) (void)SPI1->DR; +// The TXE flag is set when transmission TXFIFO has enough space to store data to send. +// 0: Tx buffer not empty, bit is cleared automatically when the TXFIFO level becomes greater than 1/2 +// 1: Tx buffer empty, flag goes high and stays high until the TXFIFO level is lower or equal to 1/2 of the FIFO depth +#define SPI_TX_IS_NOT_EMPTY (((SPI1->SR&(SPI_SR_TXE)) == 0)) +#define SPI_TX_IS_EMPTY (SPI1->SR&SPI_SR_TXE) - *(uint8_t*)(&SPI1->DR) = x; - while (!(SPI1->SR & SPI_SR_RXNE)); - return SPI1->DR; -} +// When BSY is set, it indicates that a data transfer is in progress on the SPI (the SPI bus is busy). +#define SPI_IS_BUSY (SPI1->SR & SPI_SR_BSY) -void -ssp_senddata16(uint16_t x) -{ - ssp_wait_slot(); - SPI1->DR = x; - //while (SPI1->SR & SPI_SR_BSY) - // ; -} +// SPI send data macros +#define SPI_WRITE_8BIT(data) *(__IO uint8_t*)(&SPI1->DR) = (uint8_t) data +#define SPI_WRITE_16BIT(data) SPI1->DR = data -void -ssp_databit8(void) -{ - SPI1->CR2 = (SPI1->CR2 & 0xf0ff) | 0x0700; -//LPC_SSP1->CR0 = (LPC_SSP1->CR0 & 0xf0) | SSP_DATABIT_8; -} +// SPI read data macros +#define SPI_READ_DATA SPI1->DR -void -ssp_databit16(void) -{ - SPI1->CR2 = (SPI1->CR2 & 0xf0ff) | 0x0f00; - //LPC_SSP1->CR0 = (LPC_SSP1->CR0 & 0xf0) | SSP_DATABIT_16; -} - - -const stm32_dma_stream_t *dmatx; -uint32_t txdmamode; +#ifdef __USE_DISPLAY_DMA__ +static const stm32_dma_stream_t *dmatx = STM32_DMA_STREAM(STM32_SPI_SPI1_TX_DMA_STREAM); +static uint32_t txdmamode = STM32_DMA_CR_CHSEL(SPI1_TX_DMA_CHANNEL) // Select SPI1 Tx DMA + | STM32_DMA_CR_PL(STM32_SPI_SPI1_DMA_PRIORITY) // Set priority + | STM32_DMA_CR_DIR_M2P // Memory to Spi + | STM32_DMA_CR_DMEIE // + | STM32_DMA_CR_TEIE; static void spi_lld_serve_tx_interrupt(SPIDriver *spip, uint32_t flags) { (void)spip; (void)flags; } -void -spi_init(void) -{ - rccEnableSPI1(FALSE); +static const stm32_dma_stream_t *dmarx = STM32_DMA_STREAM(STM32_SPI_SPI1_RX_DMA_STREAM); +static uint32_t rxdmamode = STM32_DMA_CR_CHSEL(SPI1_RX_DMA_CHANNEL) + | STM32_DMA_CR_PL(STM32_SPI_SPI1_DMA_PRIORITY) + | STM32_DMA_CR_DIR_P2M + | STM32_DMA_CR_TCIE + | STM32_DMA_CR_DMEIE + | STM32_DMA_CR_TEIE; - dmatx = STM32_DMA_STREAM(STM32_SPI_SPI1_TX_DMA_STREAM); - txdmamode = STM32_DMA_CR_CHSEL(SPI1_TX_DMA_CHANNEL) | - STM32_DMA_CR_PL(STM32_SPI_SPI1_DMA_PRIORITY) | - STM32_DMA_CR_DIR_M2P | - STM32_DMA_CR_DMEIE | - STM32_DMA_CR_TEIE | - STM32_DMA_CR_PSIZE_HWORD | - STM32_DMA_CR_MSIZE_HWORD; - dmaStreamAllocate(dmatx, - STM32_SPI_SPI1_IRQ_PRIORITY, - (stm32_dmaisr_t)spi_lld_serve_tx_interrupt, - NULL); - dmaStreamSetPeripheral(dmatx, &SPI1->DR); - - SPI1->CR1 = 0; - SPI1->CR1 = SPI_CR1_MSTR | SPI_CR1_SSM | SPI_CR1_SSI;// | SPI_CR1_BR_1; - SPI1->CR2 = 0x0700 | SPI_CR2_TXDMAEN | SPI_CR2_FRXTH; - SPI1->CR1 |= SPI_CR1_SPE; +static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) { + (void)spip; + (void)flags; } -void -send_command(uint8_t cmd, int len, const uint8_t *data) +static void dmaStreamFlush(uint32_t len){ + while (len){ + // DMA data transfer limited by 65535 + uint16_t tx_size = len > 65535 ? 65535 : len; + dmaStreamSetTransactionSize(dmatx, tx_size); + dmaStreamEnable(dmatx); + len -= tx_size; + dmaWaitCompletion(dmatx); + } +} +#endif + +static void spi_init(void) +{ + rccEnableSPI1(FALSE); + SPI1->CR1 = 0; + SPI1->CR1 = SPI_CR1_MSTR // SPI is MASTER + | SPI_CR1_SSM // Software slave management (The external NSS pin is free for other application uses) + | SPI_CR1_SSI; // Internal slave select (This bit has an effect only when the SSM bit is set. Allow use NSS pin as I/O) + // | SPI_CR1_BR_1; // Baud rate control + + SPI1->CR2 = SPI_CR2_8BIT // SPI data size, set to 8 bit + | SPI_CR2_FRXTH; // SPI_SR_RXNE generated every 8 bit data +// | SPI_CR2_SSOE; // + +#ifdef __USE_DISPLAY_DMA__ + // Tx DMA init + dmaStreamAllocate(dmatx, STM32_SPI_SPI1_IRQ_PRIORITY, (stm32_dmaisr_t)spi_lld_serve_tx_interrupt, NULL); + dmaStreamSetPeripheral(dmatx, &SPI1->DR); + // Rx DMA init + dmaStreamAllocate(dmarx, STM32_SPI_SPI1_IRQ_PRIORITY, (stm32_dmaisr_t)spi_lld_serve_rx_interrupt, NULL); + dmaStreamSetPeripheral(dmarx, &SPI1->DR); + // Enable DMA on SPI + SPI1->CR2|= SPI_CR2_TXDMAEN // Tx DMA enable + | SPI_CR2_RXDMAEN; // Rx DMA enable +#endif + SPI1->CR1|= SPI_CR1_SPE; //SPI enable +} + +// Disable inline for this function +static void __attribute__ ((noinline)) send_command(uint8_t cmd, uint8_t len, const uint8_t *data) { CS_LOW; + // while (SPI_TX_IS_NOT_EMPTY); DC_CMD; - ssp_databit8(); - ssp_senddata(cmd); + SPI_WRITE_8BIT(cmd); + // Need wait transfer complete and set data bit + while (SPI_IS_BUSY); + // Send command data (if need) DC_DATA; while (len-- > 0) { - ssp_senddata(*data++); + while (SPI_TX_IS_NOT_EMPTY); + SPI_WRITE_8BIT(*data++); } //CS_HIGH; } -void -send_command16(uint8_t cmd, int data) -{ - CS_LOW; - DC_CMD; - ssp_databit8(); - ssp_senddata(cmd); - DC_DATA; - ssp_databit16(); - ssp_senddata16(data); - CS_HIGH; -} - -const uint8_t ili9341_init_seq[] = { +static const uint8_t ili9341_init_seq[] = { // cmd, len, data..., + // SW reset + ILI9341_SOFTWARE_RESET, 0, + // display off + ILI9341_DISPLAY_OFF, 0, // Power control B - 0xCF, 3, 0x00, 0x83, 0x30, + ILI9341_POWERB, 3, 0x00, 0x83, 0x30, // Power on sequence control - 0xED, 4, 0x64, 0x03, 0x12, 0x81, - //0xED, 4, 0x55, 0x01, 0x23, 0x01, + ILI9341_POWER_SEQ, 4, 0x64, 0x03, 0x12, 0x81, + //ILI9341_POWER_SEQ, 4, 0x55, 0x01, 0x23, 0x01, // Driver timing control A - 0xE8, 3, 0x85, 0x01, 0x79, - //0xE8, 3, 0x84, 0x11, 0x7a, + ILI9341_DTCA, 3, 0x85, 0x01, 0x79, + //ILI9341_DTCA, 3, 0x84, 0x11, 0x7a, // Power control A - 0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, + ILI9341_POWERA, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, // Pump ratio control - 0xF7, 1, 0x20, + ILI9341_PUMP_RATIO_CONTROL, 1, 0x20, // Driver timing control B - 0xEA, 2, 0x00, 0x00, + ILI9341_DTCB, 2, 0x00, 0x00, // POWER_CONTROL_1 - 0xC0, 1, 0x26, + ILI9341_POWER_CONTROL_1, 1, 0x26, // POWER_CONTROL_2 - 0xC1, 1, 0x11, + ILI9341_POWER_CONTROL_2, 1, 0x11, // VCOM_CONTROL_1 - 0xC5, 2, 0x35, 0x3E, + ILI9341_VCOM_CONTROL_1, 2, 0x35, 0x3E, // VCOM_CONTROL_2 - 0xC7, 1, 0xBE, + ILI9341_VCOM_CONTROL_2, 1, 0xBE, // MEMORY_ACCESS_CONTROL - //0x36, 1, 0x48, // portlait - 0x36, 1, 0x28, // landscape + //ILI9341_MEMORY_ACCESS_CONTROL, 1, 0x48, // portlait + ILI9341_MEMORY_ACCESS_CONTROL, 1, DISPLAY_ROTATION_0, // landscape // COLMOD_PIXEL_FORMAT_SET : 16 bit pixel - 0x3A, 1, 0x55, + ILI9341_PIXEL_FORMAT_SET, 1, 0x55, // Frame Rate - 0xB1, 2, 0x00, 0x1B, + ILI9341_FRAME_RATE_CONTROL_1, 2, 0x00, 0x1B, // Gamma Function Disable - 0xF2, 1, 0x08, + ILI9341_3GAMMA_EN, 1, 0x08, // gamma set for curve 01/2/04/08 - 0x26, 1, 0x01, + ILI9341_GAMMA_SET, 1, 0x01, // positive gamma correction - 0xE0, 15, 0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0x87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00, +// ILI9341_POSITIVE_GAMMA_CORRECTION, 15, 0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0x87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00, // negativ gamma correction - 0xE1, 15, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F, - +// ILI9341_NEGATIVE_GAMMA_CORRECTION, 15, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F, // Column Address Set - 0x2A, 4, 0x00, 0x00, 0x01, 0x3f, // width 320 +// ILI9341_COLUMN_ADDRESS_SET, 4, 0x00, 0x00, 0x01, 0x3f, // width 320 // Page Address Set - 0x2B, 4, 0x00, 0x00, 0x00, 0xef, // height 240 - +// ILI9341_PAGE_ADDRESS_SET, 4, 0x00, 0x00, 0x00, 0xef, // height 240 // entry mode - 0xB7, 1, 0x06, + ILI9341_ENTRY_MODE_SET, 1, 0x06, // display function control - 0xB6, 4, 0x0A, 0x82, 0x27, 0x00, - + ILI9341_DISPLAY_FUNCTION_CONTROL, 4, 0x0A, 0x82, 0x27, 0x00, + // Interface Control (set WEMODE=0) + ILI9341_INTERFACE_CONTROL, 3, 0x00, 0x00, 0x00, // control display - //0x53, 1, 0x0c, + //ILI9341_WRITE_CTRL_DISPLAY, 1, 0x0c, // diaplay brightness - //0x51, 1, 0xff, - + //ILI9341_WRITE_BRIGHTNESS, 1, 0xff, // sleep out - 0x11, 0, + ILI9341_SLEEP_OUT, 0, + // display on + ILI9341_DISPLAY_ON, 0, 0 // sentinel }; -void -ili9341_init(void) +void ili9341_init(void) { - spi_init(); - - DC_DATA; - RESET_ASSERT; - chThdSleepMilliseconds(10); - RESET_NEGATE; - - send_command(0x01, 0, NULL); // SW reset - chThdSleepMilliseconds(5); - send_command(0x28, 0, NULL); // display off - - const uint8_t *p; - for (p = ili9341_init_seq; *p; ) { - send_command(p[0], p[1], &p[2]); - p += 2 + p[1]; - chThdSleepMilliseconds(5); - } - - chThdSleepMilliseconds(100); - send_command(0x29, 0, NULL); // display on + spi_init(); + DC_DATA; + RESET_ASSERT; + chThdSleepMilliseconds(10); + RESET_NEGATE; + const uint8_t *p; + for (p = ili9341_init_seq; *p; ) { + send_command(p[0], p[1], &p[2]); + p += 2 + p[1]; + chThdSleepMilliseconds(5); + } } -void ili9341_pixel(int x, int y, int color) -{ - uint8_t xx[4] = { x >> 8, x, (x+1) >> 8, (x+1) }; - uint8_t yy[4] = { y >> 8, y, (y+1) >> 8, (y+1) }; - uint8_t cc[2] = { color >> 8, color }; - send_command(0x2A, 4, xx); - send_command(0x2B, 4, yy); - send_command(0x2C, 2, cc); - //send_command16(0x2C, color); -} - - - +#ifndef __USE_DISPLAY_DMA__ void ili9341_fill(int x, int y, int w, int h, int color) { uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; - int len = w * h; - send_command(0x2A, 4, xx); - send_command(0x2B, 4, yy); - send_command(0x2C, 0, NULL); - while (len-- > 0) - ssp_senddata16(color); + + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_WRITE, 0, NULL); + int32_t len = w * h; + while (len-- > 0){ + while (SPI_TX_IS_NOT_EMPTY); + SPI_WRITE_16BIT(color); + } } -#if 0 void ili9341_bulk(int x, int y, int w, int h) { uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; uint16_t *buf = spi_buffer; - int len = w * h; - send_command(0x2A, 4, xx); - send_command(0x2B, 4, yy); - send_command(0x2C, 0, NULL); - while (len-- > 0) - ssp_senddata16(*buf++); + + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_WRITE, 0, NULL); + int32_t len = w * h; + while (len-- > 0){ + while (SPI_TX_IS_NOT_EMPTY); + SPI_WRITE_16BIT(*buf++); + } +} + +static uint8_t ssp_sendrecvdata() +{ + // Start RX clock (by sending data) + SPI_WRITE_8BIT(0); + while(SPI_RX_IS_EMPTY && SPI_IS_BUSY) + ; + return SPI_READ_DATA; +} + +void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) +{ + uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; + uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_READ, 0, NULL); + + // Skip data from rx buffer + while (SPI_RX_IS_NOT_EMPTY) + (void) SPI_READ_DATA; + // require 8bit dummy clock + ssp_sendrecvdata(); + while (len-- > 0) { + // read data is always 18bit + uint8_t r = ssp_sendrecvdata(); + uint8_t g = ssp_sendrecvdata(); + uint8_t b = ssp_sendrecvdata(); + *out++ = RGB565(r,g,b); + } + CS_HIGH; } #else +// +// Use DMA for send data +// + +// Fill region by some color +void ili9341_fill(int x, int y, int w, int h, int color) +{ + uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; + uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_WRITE, 0, NULL); + + dmaStreamSetMemory0(dmatx, &color); + dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD); + dmaStreamFlush(w * h); +} +// Copy spi_buffer to region void ili9341_bulk(int x, int y, int w, int h) { uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; - int len = w * h; - - send_command(0x2A, 4, xx); - send_command(0x2B, 4, yy); - send_command(0x2C, 0, NULL); + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_WRITE, 0, NULL); + // Init Tx DMA mem->spi, set size, mode (spi and mem data size is 16 bit) dmaStreamSetMemory0(dmatx, spi_buffer); - dmaStreamSetTransactionSize(dmatx, len); - dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_MINC); - dmaStreamEnable(dmatx); - dmaWaitCompletion(dmatx); + dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC); + dmaStreamFlush(w * h); +} + +// Copy screen data to buffer +// Warning!!! buffer size must be greater then 3*len + 1 bytes +void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) +{ + uint8_t dummy_tx = 0; + uint8_t *rgbbuf=(uint8_t *)out; + uint16_t data_size = len * 3 + 1; + + uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; + uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_READ, 0, NULL); + // Skip SPI rx buffer + while (SPI_RX_IS_NOT_EMPTY) + (void) SPI_READ_DATA; + // Init Rx DMA buffer, size, mode (spi and mem data size is 8 bit) + dmaStreamSetMemory0(dmarx, rgbbuf); + dmaStreamSetTransactionSize(dmarx, data_size); + dmaStreamSetMode(dmarx, rxdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_MINC); + // Init dummy Tx DMA (for rx clock), size, mode (spi and mem data size is 8 bit) + dmaStreamSetMemory0(dmatx, &dummy_tx); + dmaStreamSetTransactionSize(dmatx, data_size); + dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE); + + // Start DMA exchange + dmaStreamEnable(dmatx); + dmaStreamEnable(dmarx); + // Wait DMA completion + dmaWaitCompletion(dmatx); + dmaWaitCompletion(dmarx); + CS_HIGH; + + // Parce recived data + // Skip dummy 8-bit read + rgbbuf++; + while (len-- > 0) { + uint8_t r, g, b; + // read data is always 18bit + r = rgbbuf[0]; + g = rgbbuf[1]; + b = rgbbuf[2]; + *out++ = RGB565(r,g,b); + rgbbuf+=3; + } } #endif -void -ili9341_read_memory_raw(uint8_t cmd, int len, uint16_t* out) +void setForegroundColor(uint16_t fg) {foreground_color = fg;} +void setBackgroundColor(uint16_t bg) {background_color = bg;} + +void ili9341_setRotation(uint8_t r) { +// static const uint8_t rotation_const[]={DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}; + send_command(ILI9341_MEMORY_ACCESS_CONTROL, 1, &r); +} + +void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap){ + uint16_t *buf = spi_buffer; + for(uint16_t c = 0; c < height; c++) { + uint8_t bits = *bitmap++; + for (uint16_t r = 0; r < width; r++) { + *buf++ = (0x80 & bits) ? foreground_color : background_color; + bits <<= 1; + } + } + ili9341_bulk(x, y, width, height); +} + +void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap){ + uint16_t *buf = spi_buffer; + for(uint16_t c = 0; c < height; c++) { + uint16_t bits = *bitmap++; + for (uint16_t r = 0; r < width; r++) { + *buf++ = (0x8000 & bits) ? foreground_color : background_color; + bits <<= 1; + } + } + ili9341_bulk(x, y, width, height); +} + +void ili9341_drawchar(uint8_t ch, int x, int y) { - uint8_t r, g, b; - send_command(cmd, 0, NULL); - ssp_databit8(); + blit8BitWidthBitmap(x, y, FONT_GET_WIDTH(ch), FONT_GET_HEIGHT, FONT_GET_DATA(ch)); +} - // consume old data - while (!(SPI1->SR & SPI_SR_TXE)); - // clear OVR - while (SPI1->SR & SPI_SR_RXNE) r = SPI1->DR; +void ili9341_drawstring(const char *str, int x, int y) +{ + while (*str) { + uint8_t ch = *str++; + const uint8_t *char_buf = FONT_GET_DATA(ch); + uint16_t w = FONT_GET_WIDTH(ch); + blit8BitWidthBitmap(x, y, w, FONT_GET_HEIGHT, char_buf); + x+=w; + } +} - // require 8bit dummy clock - r = ssp_sendrecvdata(0); +void ili9341_drawstringV(const char *str, int x, int y){ + ili9341_setRotation(DISPLAY_ROTATION_270); + ili9341_drawstring(str, ILI9341_HEIGHT-y, x); + ili9341_setRotation(DISPLAY_ROTATION_0); +} - while (len-- > 0) { - // read data is always 18bit - r = ssp_sendrecvdata(0); - g = ssp_sendrecvdata(0); - b = ssp_sendrecvdata(0); - *out++ = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); +int ili9341_drawchar_size(uint8_t ch, int x, int y, uint8_t size) +{ + uint16_t *buf = spi_buffer; + const uint8_t *char_buf = FONT_GET_DATA(ch); + uint16_t w=FONT_GET_WIDTH(ch); + for(int c = 0; c < FONT_GET_HEIGHT; c++, char_buf++){ + for (int i=0;i x1) { + SWAP(x0, x1); + SWAP(y0, y1); } - CS_HIGH; -} - -void -ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) -{ - uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; - uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; - - send_command(0x2A, 4, xx); - send_command(0x2B, 4, yy); - - ili9341_read_memory_raw(0x2E, len, out); -} - -void -ili9341_read_memory_continue(int len, uint16_t* out) -{ - ili9341_read_memory_raw(0x3E, len, out); -} - -void -ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg) -{ - uint16_t *buf = spi_buffer; - uint8_t bits; - int c, r; - for(c = 0; c < 7; c++) { - bits = x5x7_bits[(ch * 7) + c]; - for (r = 0; r < 5; r++) { - *buf++ = (0x80 & bits) ? fg : bg; - bits <<= 1; + while (x0 <= x1) { + int dx = x1 - x0 + 1; + int dy = y1 - y0; + if (dy >= 0) { + dy++; + if (dy > dx) { + dy /= dx; dx = 1; + } else { + dx /= dy; dy = 1; + } + } else { + dy--; + if (-dy > dx) { + dy /= dx; dx = 1; + } else { + dx /= -dy;dy = -1; + } + } + if (dy > 0) + ili9341_fill(x0, y0, dx, dy, foreground_color); + else + ili9341_fill(x0, y0+dy, dx, -dy, foreground_color); + x0 += dx; + y0 += dy; } - } - ili9341_bulk(x, y, 5, 7); -} - -void -ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg) -{ - while (*str) { - ili9341_drawchar_5x7(*str, x, y, fg, bg); - x += 5; - str++; - } -} - -void -ili9341_drawstring_5x7_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool invert) -{ - if (invert) - ili9341_drawstring_5x7(str, x, y, bg, fg); - else - ili9341_drawstring_5x7(str, x, y, fg, bg); -} - -void -ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size) -{ - uint16_t *buf = spi_buffer; - uint8_t bits; - int c, r; - for(c = 0; c < 7*size; c++) { - bits = x5x7_bits[(ch * 7) + (c / size)]; - for (r = 0; r < 5*size; r++) { - *buf++ = (0x80 & bits) ? fg : bg; - if (r % size == (size-1)) { - bits <<= 1; - } - } - } - ili9341_bulk(x, y, 5*size, 7*size); -} - -void -ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size) -{ - while (*str) { - ili9341_drawchar_size(*str, x, y, fg, bg, size); - x += 5 * size; - str++; - } -} - -#define SWAP(x,y) do { int z=x; x = y; y = z; } while(0) - -void -ili9341_line(int x0, int y0, int x1, int y1, uint16_t fg) -{ - if (x0 > x1) { - SWAP(x0, x1); - SWAP(y0, y1); - } - - while (x0 <= x1) { - int dx = x1 - x0 + 1; - int dy = y1 - y0; - if (dy >= 0) { - dy++; - if (dy > dx) { - dy /= dx; dx = 1; - } else { - dx /= dy; dy = 1; - } - } else { - dy--; - if (-dy > dx) { - dy /= dx; dx = 1; - } else { - dx /= -dy; dy = -1; - } - } - if (dy > 0) - ili9341_fill(x0, y0, dx, dy, fg); - else - ili9341_fill(x0, y0+dy, dx, -dy, fg); - x0 += dx; - y0 += dy; - } -} - - -const font_t NF20x22 = { 20, 22, 1, 3*22, (const uint8_t *)numfont20x22 }; - -void -ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint16_t bg) -{ - uint16_t *buf = spi_buffer; - const uint8_t *bitmap = &font->bitmap[font->slide * ch]; - int c, r; - - for (c = 0; c < font->height; c++) { - uint8_t bits = *bitmap++; - uint8_t m = 0x80; - for (r = 0; r < font->width; r++) { - *buf++ = (bits & m) ? fg : bg; - m >>= 1; - - if (m == 0) { - bits = *bitmap++; - m = 0x80; - } - } - } - ili9341_bulk(x, y, font->width, font->height); } #if 0 -const uint16_t colormap[] = { - RGB565(255,0,0), RGB565(0,255,0), RGB565(0,0,255), - RGB565(255,255,0), RGB565(0,255,255), RGB565(255,0,255) +static const uint16_t colormap[] = { + RGBHEX(0x00ff00), RGBHEX(0x0000ff), RGBHEX(0xff0000), + RGBHEX(0x00ffff), RGBHEX(0xff00ff), RGBHEX(0xffff00) }; -void -ili9341_test(int mode) +static void ili9341_pixel(int x, int y, int color) { - int x, y; - int i; - switch (mode) { - default: + uint8_t xx[4] = { x >> 8, x, (x+1) >> 8, (x+1) }; + uint8_t yy[4] = { y >> 8, y, (y+1) >> 8, (y+1) }; + uint8_t cc[2] = { color >> 8, color }; + send_command(ILI9341_COLUMN_ADDRESS_SET, 4, xx); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, yy); + send_command(ILI9341_MEMORY_WRITE, 2, cc); + //send_command16(ILI9341_MEMORY_WRITE, color); +} + +void ili9341_test(int mode) +{ + chMtxLock(&mutex_ili9341); + int x, y; + int i; + switch (mode) { + default: #if 1 - ili9341_fill(0, 0, 320, 240, 0); - for (y = 0; y < 240; y++) { - ili9341_fill(0, y, 320, 1, RGB565(y, (y + 120) % 256, 240-y)); - } - break; - case 1: - ili9341_fill(0, 0, 320, 240, 0); - for (y = 0; y < 240; y++) { - for (x = 0; x < 320; x++) { - ili9341_pixel(x, y, (y<<8)|x); - } - } - break; - case 2: - //send_command16(0x55, 0xff00); - ili9341_pixel(64, 64, 0xaa55); - break; + ili9341_fill(0, 0, 320, 240, 0); + for (y = 0; y < 240; y++) { + ili9341_fill(0, y, 320, 1, RGB(240-y, y, (y + 120) % 256)); + } + break; + case 1: + ili9341_fill(0, 0, 320, 240, 0); + for (y = 0; y < 240; y++) { + for (x = 0; x < 320; x++) { + ili9341_pixel(x, y, (y<<8)|x); + } + } + break; + case 2: + //send_command16(0x55, 0xff00); + ili9341_pixel(64, 64, 0xaa55); + break; #endif #if 1 - case 3: - for (i = 0; i < 10; i++) - ili9341_drawfont(i, &NF20x22, i*20, 120, colormap[i%6], 0x0000); - break; + case 3: + for (i = 0; i < 10; i++) + ili9341_drawfont(i, i*20, 120); + break; #endif #if 0 - case 4: - draw_grid(10, 8, 29, 29, 15, 0, 0xffff, 0); - break; + case 4: + draw_grid(10, 8, 29, 29, 15, 0, 0xffff, 0); + break; #endif - case 4: - ili9341_line(0, 0, 15, 100, 0xffff); - ili9341_line(0, 0, 100, 100, 0xffff); - ili9341_line(0, 15, 100, 0, 0xffff); - ili9341_line(0, 100, 100, 0, 0xffff); - break; - } + case 4: + ili9341_line(0, 0, 15, 100); + ili9341_line(0, 0, 100, 100); + ili9341_line(0, 15, 100, 0); + ili9341_line(0, 100, 100, 0); + break; + } + chMtxUnlock(&mutex_ili9341); } #endif diff --git a/main.c b/main.c index 3c480fc..07c8245 100644 --- a/main.c +++ b/main.c @@ -533,32 +533,21 @@ static void cmd_dump(BaseSequentialStream *chp, int argc, char *argv[]) static void cmd_capture(BaseSequentialStream *chp, int argc, char *argv[]) { // read pixel count at one time (PART*2 bytes required for read buffer) -#define PART 320 (void)argc; (void)argv; chMtxLock(&mutex); - // use uint16_t spi_buffer[1024] (defined in ili9341) for read buffer - uint16_t *buf = &spi_buffer[0]; - int len = 320 * 240; - int i; - ili9341_read_memory(0, 0, 320, 240, PART, buf); - for (i = 0; i < PART; i++) { - streamPut(chp, buf[i] >> 8); - streamPut(chp, buf[i] & 0xff); - } - - len -= PART; - while (len > 0) { - ili9341_read_memory_continue(PART, buf); - for (i = 0; i < PART; i++) { - streamPut(chp, buf[i] >> 8); - streamPut(chp, buf[i] & 0xff); + // read 2 row pixel time (read buffer limit by 2/3 + 1 from spi_buffer size) + for (int y=0; y < 240; y+=2) + { + // use uint16_t spi_buffer[1024] (defined in ili9341) for read buffer + uint8_t *buf = (uint8_t *)spi_buffer; + ili9341_read_memory(0, y, 320, 2, 2*320, spi_buffer); + for (int i = 0; i < 4*320; i++) { + streamPut(chp, *buf++); } - len -= PART; } - //*/ chMtxUnlock(&mutex); } @@ -602,10 +591,10 @@ static void cmd_sample(BaseSequentialStream *chp, int argc, char *argv[]) config_t config = { .magic = CONFIG_MAGIC, .dac_value = 1922, - .grid_color = 0x1084, - .menu_normal_color = 0xffff, - .menu_active_color = 0x7777, - .trace_color = { RGB565(0,255,255), RGB565(255,0,40), RGB565(0,0,255), RGB565(50,255,0) }, + .grid_color = DEFAULT_GRID_COLOR, + .menu_normal_color = DEFAULT_MENU_COLOR, + .menu_active_color = DEFAULT_MENU_ACTIVE_COLOR, + .trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR, DEFAULT_TRACE_4_COLOR }, // .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel .touch_cal = { 338, 522, 153, 192 }, // 2.8 inch LCD panel .default_loadcal = 0, @@ -618,10 +607,10 @@ properties_t current_props = { ._frequency1 = 900000000, // end = 900MHz ._sweep_points = 101, ._trace = {/*enable, type, channel, polar, scale, refpos*/ - { 1, TRC_LOGMAG, 0, 0, 1.0, 7.0 }, - { 1, TRC_LOGMAG, 1, 0, 1.0, 7.0 }, + { 1, TRC_LOGMAG, 0, 0, 1.0, 9.0 }, + { 1, TRC_LOGMAG, 1, 0, 1.0, 9.0 }, { 1, TRC_SMITH, 0, 1, 1.0, 0.0 }, - { 1, TRC_PHASE, 1, 0, 1.0, 4.0 } + { 1, TRC_PHASE, 1, 0, 1.0, 5.0 } }, ._markers = { { 1, 30, 0 }, { 0, 40, 0 }, { 0, 60, 0 }, { 0, 80, 0 } @@ -1431,17 +1420,17 @@ const struct { uint16_t refpos; float scale_unit; } trace_info[] = { - { "LOGMAG", 7, 10 }, - { "PHASE", 4, 90 }, - { "DELAY", 4, 1e-9 }, + { "LOGMAG", 9, 10 }, + { "PHASE", 5, 90 }, + { "DELAY", 5, 1e-9 }, { "SMITH", 0, 1 }, { "POLAR", 0, 1 }, { "LINEAR", 0, 0.125 }, { "SWR", 0, 1 }, - { "REAL", 4, 0.25 }, - { "IMAG", 4, 0.25 }, + { "REAL", 5, 0.25 }, + { "IMAG", 5, 0.25 }, { "R", 0, 100 }, - { "X", 4, 100 } + { "X", 5, 100 } }; const char * const trc_channel_name[] = { @@ -1552,6 +1541,11 @@ my_atof(const char *p) return x; } +typedef struct { + char *tracename; + uint8_t type; +} type_list; + static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[]) { int t; @@ -1586,34 +1580,29 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[]) chprintf(chp, "%d %s %s\r\n", t, type, channel); return; } + if (argc > 1) { - if (strcmp(argv[1], "logmag") == 0) { - set_trace_type(t, TRC_LOGMAG); - } else if (strcmp(argv[1], "phase") == 0) { - set_trace_type(t, TRC_PHASE); - } else if (strcmp(argv[1], "polar") == 0) { - set_trace_type(t, TRC_POLAR); - } else if (strcmp(argv[1], "smith") == 0) { - set_trace_type(t, TRC_SMITH); - } else if (strcmp(argv[1], "delay") == 0) { - set_trace_type(t, TRC_DELAY); - } else if (strcmp(argv[1], "linear") == 0) { - set_trace_type(t, TRC_LINEAR); - } else if (strcmp(argv[1], "swr") == 0) { - set_trace_type(t, TRC_SWR); - } else if (strcmp(argv[1], "real") == 0) { - set_trace_type(t, TRC_REAL); - } else if (strcmp(argv[1], "imag") == 0) { - set_trace_type(t, TRC_IMAG); - } else if (strcmp(argv[1], "r") == 0) { - set_trace_type(t, TRC_R); - } else if (strcmp(argv[1], "x") == 0) { - set_trace_type(t, TRC_X); - } else if (strcmp(argv[1], "linear") == 0) { - set_trace_type(t, TRC_LINEAR); - } else if (strcmp(argv[1], "off") == 0) { - set_trace_type(t, TRC_OFF); - } else if (strcmp(argv[1], "scale") == 0 && argc >= 3) { + static const type_list t_list[] = { + {"logmag", TRC_LOGMAG}, + {"phase", TRC_PHASE}, + {"polar", TRC_POLAR}, + {"smith", TRC_SMITH}, + {"delay", TRC_DELAY}, + {"linear", TRC_LINEAR}, + {"swr", TRC_SWR}, + {"real", TRC_REAL}, + {"imag", TRC_IMAG}, + {"r", TRC_R}, + {"x", TRC_X}, + {"off", TRC_OFF}, + }; + for (uint16_t i=0; i= 3) { //trace[t].scale = my_atof(argv[2]); set_trace_scale(t, my_atof(argv[2])); goto exit; @@ -1625,16 +1614,17 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[]) goto usage; } } + check_ch_num: if (argc > 2) { int src = atoi(argv[2]); if (src != 0 && src != 1) goto usage; trace[t].channel = src; - } + } exit: return; usage: - chprintf(chp, "trace {0|1|2|3|all} [logmag|phase|smith|linear|delay|swr|real|imag|r|x|off] [src]\r\n"); + chprintf(chp, "trace {0|1|2|3|all} [logmag|phase|polar|smith|linear|delay|swr|real|imag|r|x|off] [src]\r\n"); chprintf(chp, "trace {0|1|2|3} {scale|refpos} {value}\r\n"); } diff --git a/mcuconf.h b/mcuconf.h index 773537f..3db6404 100644 --- a/mcuconf.h +++ b/mcuconf.h @@ -117,7 +117,9 @@ #define STM32_I2C_BUSY_TIMEOUT 50 #define STM32_I2C_I2C1_IRQ_PRIORITY 3 #define STM32_I2C_I2C2_IRQ_PRIORITY 3 -#define STM32_I2C_USE_DMA TRUE + +// I2C1 rx operation use DMA3, some as SPI1 DMA Tx used by LCD +#define STM32_I2C_USE_DMA FALSE #define STM32_I2C_I2C1_DMA_PRIORITY 1 #define STM32_I2C_I2C2_DMA_PRIORITY 1 #define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) diff --git a/nanovna.h b/nanovna.h index 4dbb5a2..95c0187 100644 --- a/nanovna.h +++ b/nanovna.h @@ -19,6 +19,9 @@ */ #include "ch.h" +// Need enable HAL_USE_SPI in halconf.h +#define __USE_DISPLAY_DMA__ + /* * main.c */ @@ -129,7 +132,12 @@ extern void tlv320aic3204_select(int channel); #define OFFSETX 15 #define OFFSETY 0 #define WIDTH 291 -#define HEIGHT 233 +#define HEIGHT 230 + +// Smith/polar chart +#define P_CENTER_X 145 +#define P_CENTER_Y 115 +#define P_RADIUS 115 #define CELLOFFSETX 5 #define AREA_WIDTH_NORMAL (WIDTH + CELLOFFSETX*2) @@ -137,21 +145,29 @@ extern void tlv320aic3204_select(int channel); extern int area_width; extern int area_height; -#define GRIDY 29 +#define GRIDY 23 // font extern const uint8_t x5x7_bits []; -extern const uint8_t numfont20x22[][22 * 3]; +#define FONT_GET_DATA(ch) (&x5x7_bits[ch*7]) +#define FONT_GET_WIDTH(ch) (7-(x5x7_bits[ch*7]&3)) +#define FONT_GET_HEIGHT 7 + +extern const uint16_t numfont16x22[]; +#define NUM_FONT_GET_DATA(ch) (&numfont16x22[ch*22]) +#define NUM_FONT_GET_WIDTH 16 +#define NUM_FONT_GET_HEIGHT 22 #define S_DELTA "\004" +#define S_DEGREE "\037" +#define S_SARROW "\030" +#define S_INFINITY "\031" +#define S_LARROW "\032" +#define S_RARROW "\033" #define S_PI "\034" #define S_MICRO "\035" #define S_OHM "\036" -#define S_DEGREE "\037" -#define S_LARROW "\032" -#define S_RARROW "\033" - // trace #define TRACES_MAX 4 @@ -261,34 +277,46 @@ extern int16_t vbat; /* * ili9341.c */ -#define RGB565(b,r,g) ( (((b)<<8)&0xfc00) | (((r)<<2)&0x03e0) | (((g)>>3)&0x001f) ) +// SPI bus revert byte order +//gggBBBbb RRRrrGGG +#define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) ) +#define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) ) -typedef struct { - uint16_t width; - uint16_t height; - uint16_t scaley; - uint16_t slide; - const uint8_t *bitmap; -} font_t; +#define DEFAULT_FG_COLOR RGB565(255,255,255) +#define DEFAULT_BG_COLOR RGB565( 0, 0, 0) +#define DEFAULT_GRID_COLOR RGB565(128,128,128) +#define DEFAULT_MENU_COLOR RGB565(255,255,255) +#define DEFAULT_MENU_TEXT_COLOR RGB565( 0, 0, 0) +#define DEFAULT_MENU_ACTIVE_COLOR RGB565(180,255,180) +#define DEFAULT_TRACE_1_COLOR RGB565( 0,255,255) +#define DEFAULT_TRACE_2_COLOR RGB565(255, 0, 40) +#define DEFAULT_TRACE_3_COLOR RGB565( 0, 0,255) +#define DEFAULT_TRACE_4_COLOR RGB565( 50,255, 0) -extern const font_t NF20x22; +extern uint16_t foreground_color; +extern uint16_t background_color; extern uint16_t spi_buffer[1024]; void ili9341_init(void); +//void ili9341_setRotation(uint8_t r); void ili9341_test(int mode); void ili9341_bulk(int x, int y, int w, int h); void ili9341_fill(int x, int y, int w, int h, int color); -void ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg); -void ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg); -void ili9341_drawstring_5x7_inv(const char *str, int x, int y, uint16_t fg, uint16_t bg, bool inv); -void ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size); -void ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size); -void ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint16_t bg); +void setForegroundColor(uint16_t fg); +void setBackgroundColor(uint16_t fg); +void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap); +void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap); +void ili9341_drawchar(uint8_t ch, int x, int y); +void ili9341_drawstring(const char *str, int x, int y); +void ili9341_drawstringV(const char *str, int x, int y); +int ili9341_drawchar_size(uint8_t ch, int x, int y, uint8_t size); +void ili9341_drawstring_size(const char *str, int x, int y, uint8_t size); +void ili9341_drawfont(uint8_t ch, int x, int y); void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t* out); -void ili9341_read_memory_continue(int len, uint16_t* out); -void ili9341_line(int x0, int y0, int x1, int y1, uint16_t fg); - +void ili9341_line(int x0, int y0, int x1, int y1); +void show_version(void); +void show_logo(void); /* * flash.c @@ -405,14 +433,4 @@ int16_t adc_vbat_read(ADC_TypeDef *adc); */ #define PULSE do { palClearPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);} while(0) -// convert vbat [mV] to battery indicator -static inline uint8_t vbat2bati(int16_t vbat) -{ - if (vbat < 3200) return 0; - if (vbat < 3450) return 25; - if (vbat < 3700) return 50; - if (vbat < 4100) return 75; - return 100; -} - /*EOF*/ diff --git a/numfont20x22.c b/numfont20x22.c index a84d4dd..538c674 100644 --- a/numfont20x22.c +++ b/numfont20x22.c @@ -2,6 +2,8 @@ * Copyright (c) 2014-2019, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com * All rights reserved. * + * Converted to hex by @qrp73 [ https://github.com/qrp73 ] + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) @@ -20,605 +22,535 @@ #include -const uint8_t numfont20x22[][22 * 3] = { - { // 0 - 0b00000111, 0b11111100, 0b00001000, - 0b00011111, 0b11111111, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, +const uint16_t numfont16x22[] = { - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b11111100, 0b00000111, 0b11100000, - 0b01111110, 0b00001111, 0b11000000, - 0b01111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - 0b00011111, 0b11111111, 0b00000000, - 0b00000111, 0b11111100, 0b00001000, - }, - { // 1 - 0b00000000, 0b01111100, 0b00001000, - 0b00000000, 0b11111100, 0b00000000, - 0b00000000, 0b11111100, 0b00000000, - 0b00000001, 0b11111100, 0b00000000, - 0b00000111, 0b11111100, 0b00000000, - 0b00011111, 0b11111100, 0b00000000, - 0b00011111, 0b11111100, 0b00000000, - 0b00011111, 0b11111100, 0b00000000, + 0b0000000011110000, + 0b0000000111110000, + 0b0000001111110000, + 0b0000011111110000, + 0b0000111111110000, + 0b0000111111110000, + 0b0000111011110000, + 0b0000110011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000001111111100, + 0b0000001111111100, + 0b0000001111111100, - 0b00011111, 0b01111100, 0b00000000, - 0b00011111, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b0000000000011111, + 0b0000000000111111, + 0b0000000001111110, + 0b0000000011111100, + 0b0000000111111000, + 0b0000001111110000, + 0b0000011111100000, + 0b0000111111000000, + 0b0001111110000000, + 0b0011111100000000, + 0b0111111000000000, + 0b1111110000000000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - }, - { // 2 - 0b00000011, 0b11111000, 0b00001000, - 0b00001111, 0b11111110, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000111, 0b11100000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000011111, + 0b1111000000011111, + 0b0000000000011110, + 0b0000000000111110, + 0b0000000111111100, + 0b0000000111111000, + 0b0000000111111100, + 0b0000000001111110, + 0b0000000000011111, + 0b0000000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b00000000, 0b00001111, 0b11100000, - 0b00000000, 0b00111111, 0b11000000, - 0b00000000, 0b11111111, 0b10000000, - 0b00000011, 0b11111110, 0b00000000, - 0b00001111, 0b11111000, 0b00000000, - 0b00011111, 0b11100000, 0b00000000, - 0b00111111, 0b10000000, 0b00000000, - 0b01111111, 0b00000000, 0b00000000, + 0b0000000111111000, + 0b0000000111111000, + 0b0000001111111000, + 0b0000001111111000, + 0b0000011111111000, + 0b0000011111111000, + 0b0000111111111000, + 0b0000111101111000, + 0b0001111101111000, + 0b0001111001111000, + 0b0011111001111000, + 0b0011110001111000, + 0b0111110001111000, + 0b0111100001111000, + 0b1111100001111000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b0000000001111000, + 0b0000000001111000, + 0b0000000001111000, + 0b0000000001111000, - 0b11111110, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - }, - { // 3 - 0b00000011, 0b11111000, 0b00001000, - 0b00001111, 0b11111110, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000111, 0b11100000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111011111110000, + 0b1111111111111100, + 0b1111111111111110, + 0b1111110000111110, + 0b1111100000011111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b00000000, 0b00001111, 0b11000000, - 0b00000000, 0b11111111, 0b11000000, - 0b00000000, 0b11111111, 0b00000000, - 0b00000000, 0b11111111, 0b00000000, - 0b00000000, 0b11111111, 0b10000000, - 0b00000000, 0b00001111, 0b11000000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000000000, + 0b1111000000000000, + 0b1111011111110000, + 0b1111111111111100, + 0b1111111111111110, + 0b1111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111110, 0b00000111, 0b11100000, - 0b01111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - 0b00001111, 0b11111111, 0b00000000, - 0b00000001, 0b11111000, 0b00001000, - }, - { // 4 - 0b00000000, 0b00001111, 0b00001000, - 0b00000000, 0b00011111, 0b00000000, - 0b00000000, 0b00111111, 0b00000000, - 0b00000000, 0b01111111, 0b00000000, - 0b00000000, 0b11111111, 0b00000000, - 0b00000001, 0b11111111, 0b00000000, - 0b00000011, 0b11111111, 0b00000000, - 0b00000111, 0b11111111, 0b00000000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b0000000000011111, + 0b0000000000111110, + 0b0000000001111100, + 0b0000000011111000, + 0b0000000111110000, + 0b0000000111100000, + 0b0000001111100000, + 0b0000001111000000, + 0b0000011111000000, + 0b0000011110000000, + 0b0000011110000000, + 0b0000111110000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, - 0b00001111, 0b11011111, 0b00000000, - 0b00011111, 0b10011111, 0b00000000, - 0b00111111, 0b00011111, 0b00000000, - 0b01111110, 0b00011111, 0b00000000, - 0b11111100, 0b00011111, 0b00000000, - 0b11111000, 0b00011111, 0b00000000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, + 0b0000011111100000, + 0b0001111111111000, + 0b0011111111111100, + 0b0111110000111110, + 0b0111100000011110, + 0b0111100000011110, + 0b0111100000011110, + 0b0011110000111100, + 0b0001111111111000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111110000111110, + 0b0111100000011110, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b00000000, 0b00011111, 0b00000000, - 0b00000000, 0b00011111, 0b00000000, - 0b00000000, 0b00011111, 0b00000000, - 0b00000000, 0b00011111, 0b00000000, - }, - { // 5 - 0b11111111, 0b11111111, 0b11101000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11110000, 0b00000000, 0b00000000, - 0b11110000, 0b00000000, 0b00000000, - 0b11110000, 0b00000000, 0b00000000, - 0b11110011, 0b11111000, 0b00000000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111111, + 0b0111111111111111, + 0b0011111111111111, + 0b0000111111111111, + 0b0000000000001111, + 0b0000000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b11111111, 0b11111111, 0b00000000, - 0b11111111, 0b11111111, 0b10000000, - 0b11111111, 0b11111111, 0b11000000, - 0b11111110, 0b00001111, 0b11000000, - 0b00000000, 0b00000111, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000011100000000, + 0b0000111110000000, + 0b0000111110000000, + 0b0000011100000000, + 0b0000000000000000, - 0b11111000, 0b00000111, 0b11100000, - 0b11111110, 0b00011111, 0b11100000, - 0b01111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - 0b00001111, 0b11111111, 0b00000000, - 0b00000001, 0b11111000, 0b00001000, - }, - { // 6 - 0b00000011, 0b11111110, 0b00001000, - 0b00011111, 0b11111111, 0b10000000, - 0b00111111, 0b11111111, 0b11000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00000111, 0b11000000, - 0b11111100, 0b00000000, 0b00000000, - 0b11111000, 0b00000000, 0b00000000, - 0b11111000, 0b00000000, 0b00000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0011111111111100, + 0b0011111111111100, + 0b0011111111111100, + 0b0011111111111100, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, - 0b11111011, 0b11111000, 0b00000000, - 0b11111111, 0b11111111, 0b00000000, - 0b11111111, 0b11111111, 0b10000000, - 0b11111111, 0b11111111, 0b11000000, - 0b11111110, 0b00011111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000011, + 0b0000000000000111, + 0b0000000000001111, + 0b0000000000011111, + 0b0000000000111111, + 0b0000000000111111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, + 0b0110000011001111, + 0b1111000111101111, + 0b0111101111001111, + 0b0011111110001111, + 0b0001111100001111, + 0b0001111100001111, + 0b0011111110001111, + 0b0111101111001111, + 0b1111000111101111, + 0b0110000011001111, - 0b11111100, 0b00000111, 0b11100000, - 0b11111110, 0b00001111, 0b11100000, - 0b01111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - 0b00001111, 0b11111111, 0b00000000, - 0b00000001, 0b11111000, 0b00001000, - }, - { // 7 - 0b11111111, 0b11111111, 0b11101000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b00000000, 0b00000111, 0b11100000, - 0b00000000, 0b00001111, 0b11000000, - 0b00000000, 0b00011111, 0b10000000, - 0b00000000, 0b00111111, 0b00000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000111110, + 0b1111000001111100, + 0b1111000011111000, + 0b1111000111110000, + 0b1111001111100000, + 0b1111011111000000, + 0b1111111110000000, + 0b1111111100000000, + 0b1111111100000000, + 0b1111111110000000, + 0b1111011111000000, + 0b1111001111100000, + 0b1111000111110000, + 0b1111000011111000, + 0b1111000001111100, + 0b1111000000111110, - 0b00000000, 0b01111110, 0b00000000, - 0b00000000, 0b01111100, 0b00000000, - 0b00000000, 0b11111100, 0b00000000, - 0b00000000, 0b11111000, 0b00000000, - 0b00000001, 0b11111000, 0b00000000, - 0b00000001, 0b11110000, 0b00000000, - 0b00000001, 0b11110000, 0b00000000, - 0b00000011, 0b11110000, 0b00000000, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b1111100000011111, + 0b1111110000111111, + 0b1111110000111111, + 0b1111111001111111, + 0b1111111001111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111011111101111, + 0b1111011111101111, + 0b1111001111001111, + 0b1111001111001111, + 0b1111000110001111, + 0b1111000110001111, + 0b1111000000001111, + 0b1111000000001111, - 0b00000011, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - }, - { // 8 - 0b00000011, 0b11111000, 0b00001000, - 0b00001111, 0b11111110, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b01111100, 0b00000111, 0b11000000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000001111111, + 0b1111000001111111, + 0b1111000001111111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111111, + 0b0111111111111111, + 0b0011111111110111, + 0b0000111111100111, - 0b01111110, 0b00001111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - 0b00011111, 0b11111111, 0b00000000, - 0b00011111, 0b11111111, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000001000000, + 0b0000000011000000, + 0b0000000111000000, + 0b0000001111000000, + 0b0000011111000000, + 0b0000111111111111, + 0b0001111111111111, + 0b0011111111111111, + 0b0111111111111111, + 0b1111111111111111, + 0b0111111111111111, + 0b0011111111111111, + 0b0001111111111111, + 0b0000111111111111, + 0b0000011111000000, + 0b0000001111000000, + 0b0000000111000000, + 0b0000000011000000, + 0b0000000001000000, + 0b0000000000000000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111100, 0b00000111, 0b11100000, - 0b01111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - 0b00011111, 0b11111111, 0b00000000, - 0b00000111, 0b11111100, 0b00001000, - }, - { // 9 - 0b00000011, 0b11111000, 0b00001000, - 0b00001111, 0b11111110, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000111000111000, + 0b0001111101111100, + 0b0011111111111110, + 0b0111001111001110, + 0b1110000110000111, + 0b1110000110000111, + 0b1110000110000111, + 0b1110000110000111, + 0b1110000110000111, + 0b1110000110000111, + 0b0111001111001110, + 0b0111111111111110, + 0b0011111011111100, + 0b0001110001110000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, - 0b11111100, 0b00000011, 0b11100000, - 0b11111110, 0b00000111, 0b11100000, - 0b01111111, 0b11111111, 0b11100000, - 0b00111111, 0b11111111, 0b11100000, - 0b00001111, 0b11111111, 0b11100000, - 0b00000011, 0b11111111, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000011101111100, + 0b0000011101111110, + 0b0000001101100110, + 0b0000001101100110, + 0b0000001101100110, + 0b0011101101111100, + 0b0111111101111110, + 0b1110011101100111, + 0b1100001101100011, + 0b1100001101100011, + 0b1100001101100011, + 0b1100001101100011, + 0b1110011101100111, + 0b0111111101111110, + 0b0011101101111100, - 0b11111000, 0b00000111, 0b11100000, - 0b11111100, 0b00001111, 0b11000000, - 0b11111111, 0b11111111, 0b11000000, - 0b01111111, 0b11111111, 0b10000000, - 0b00111111, 0b11111111, 0b00000000, - 0b00001111, 0b11111100, 0b00001000, - }, - { // . (period) = \001 - 0b00000000, 0b00000000, 0b00001000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0001111111110000, + 0b0001111111110000, + 0b0001111111110000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0001111111110000, + 0b0001111111110000, + 0b0001111111110000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0000000000000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000001, 0b11000000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000001, 0b11000000, 0b00000000, - 0b00000000, 0b00000000, 0b00001000, - }, - { // - (minus) = \002 - 0b00000000, 0b00000000, 0b00001000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b1111000111110000, + 0b1111011111111100, + 0b1111111111111110, + 0b1111111000111110, + 0b1111110000011111, + 0b1111100000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b11000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00001000, - }, - { // x1 - 0b00000000, 0b00000000, 0b00001000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000001, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, - 0b00000000, 0b00000111, 0b11100000, - - 0b00000000, 0b00001111, 0b11100000, - 0b00000000, 0b00001111, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, - 0b00000000, 0b00000011, 0b11100000, - 0b00110000, 0b01100011, 0b11100000, - 0b11111000, 0b11110011, 0b11100000, - 0b01111101, 0b11100011, 0b11100000, - 0b00011111, 0b11000011, 0b11100000, - - 0b00001111, 0b10000011, 0b11100000, - 0b00001111, 0b10000011, 0b11100000, - 0b00011111, 0b11000011, 0b11100000, - 0b00111101, 0b11100011, 0b11100000, - 0b01111000, 0b11110011, 0b11100000, - 0b00110000, 0b01100011, 0b11101000, - }, - { // k - 0b01111100, 0b00000000, 0b00001000, - 0b01111100, 0b00000000, 0b00000000, - 0b01111100, 0b00000000, 0b00000000, - 0b01111100, 0b00000000, 0b00000000, - 0b01111100, 0b00000000, 0b00000000, - 0b01111100, 0b00000000, 0b00000000, - 0b01111100, 0b00011111, 0b10000000, - 0b01111100, 0b00111111, 0b00000000, - - 0b01111100, 0b01111110, 0b00000000, - 0b01111100, 0b11111100, 0b00000000, - 0b01111101, 0b11111000, 0b00000000, - 0b01111111, 0b11110000, 0b00000000, - 0b01111111, 0b11100000, 0b00000000, - 0b01111111, 0b11000000, 0b00000000, - 0b01111111, 0b11000000, 0b00000000, - 0b01111111, 0b11100000, 0b00000000, - - 0b01111111, 0b11110000, 0b00000000, - 0b01111101, 0b11111000, 0b00000000, - 0b01111100, 0b11111100, 0b00000000, - 0b01111100, 0b01111110, 0b00000000, - 0b01111100, 0b00111111, 0b00000000, - 0b01111100, 0b00011111, 0b10001000, - }, - { // M - 0b11111000, 0b00000011, 0b11101000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111110, 0b00001111, 0b11100000, - 0b11111110, 0b00001111, 0b11100000, - 0b11111111, 0b00011111, 0b11100000, - 0b11111111, 0b00011111, 0b11100000, - - 0b11111111, 0b10111111, 0b11100000, - 0b11111111, 0b10111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b11111011, 0b11111011, 0b11100000, - 0b11111011, 0b11111011, 0b11100000, - - 0b11111001, 0b11110011, 0b11100000, - 0b11111001, 0b11110011, 0b11100000, - 0b11111000, 0b11100011, 0b11100000, - 0b11111000, 0b11100011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11101000, - }, - { // G - 0b00000111, 0b11111100, 0b00001000, - 0b00011111, 0b11111111, 0b00000000, - 0b00111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b11000000, - 0b01111110, 0b00001111, 0b11000000, - 0b11111100, 0b00000111, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - 0b11111000, 0b00000011, 0b11100000, - - 0b11111000, 0b00000000, 0b00000000, - 0b11111000, 0b00000000, 0b00000000, - 0b11111000, 0b00000000, 0b00000000, - 0b11111000, 0b00000000, 0b00000000, - 0b11111000, 0b00011111, 0b11100000, - 0b11111000, 0b00011111, 0b11100000, - 0b11111000, 0b00011111, 0b11100000, - 0b11111000, 0b00011111, 0b11100000, - - 0b11111100, 0b00000111, 0b11100000, - 0b01111110, 0b00001111, 0b11100000, - 0b01111111, 0b11111111, 0b11100000, - 0b00111111, 0b11111111, 0b11100000, - 0b00011111, 0b11111111, 0b11100000, - 0b00000111, 0b11111011, 0b11101000, - - }, - { // BS - 0b00000000, 0b00000000, 0b00001000, - 0b00000000, 0b00100000, 0b00000000, - 0b00000000, 0b01100000, 0b00000000, - 0b00000000, 0b11100000, 0b00000000, - 0b00000001, 0b11100000, 0b00000000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000111, 0b11111111, 0b11100000, - 0b00001111, 0b11111111, 0b11100000, - - 0b00011111, 0b11111111, 0b11100000, - 0b00111111, 0b11111111, 0b11100000, - 0b01111111, 0b11111111, 0b11100000, - 0b11111111, 0b11111111, 0b11100000, - 0b01111111, 0b11111111, 0b11100000, - 0b00111111, 0b11111111, 0b11100000, - 0b00011111, 0b11111111, 0b11100000, - 0b00001111, 0b11111111, 0b11100000, - - 0b00000111, 0b11111111, 0b11100000, - 0b00000011, 0b11100000, 0b00000000, - 0b00000001, 0b11100000, 0b00000000, - 0b00000000, 0b11100000, 0b00000000, - 0b00000000, 0b01100000, 0b00000000, - 0b00000000, 0b00100000, 0b00001000, - }, - { // infinity = \003 - 0b00000000, 0b00000000, 0b00001000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000111, 0b10001111, 0b00000000, - 0b00001111, 0b11011111, 0b10000000, - 0b00011111, 0b11011111, 0b11000000, - - 0b00111000, 0b11110001, 0b11000000, - 0b01111000, 0b11100001, 0b11100000, - 0b01110000, 0b01100000, 0b11100000, - 0b01110000, 0b01100000, 0b11100000, - 0b01110000, 0b01100000, 0b11100000, - 0b01110000, 0b01100000, 0b11100000, - 0b01111000, 0b01110001, 0b11100000, - 0b00111000, 0b11110001, 0b11000000, - - 0b00111111, 0b10111111, 0b11000000, - 0b00011111, 0b10111111, 0b10000000, - 0b00001111, 0b00011110, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00001000, - }, - { // dB = \004 - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000011, 0b10111111, 0b00000000, - - 0b00000011, 0b10111111, 0b10000000, - 0b00000011, 0b10111111, 0b11000000, - 0b00000011, 0b10111001, 0b11100000, - 0b00000011, 0b10111000, 0b11100000, - 0b00111111, 0b10111001, 0b11100000, - 0b01111111, 0b10111111, 0b11100000, - 0b11111111, 0b10111111, 0b10000000, - 0b11110011, 0b10111111, 0b11000000, - - 0b11100011, 0b10111001, 0b11100000, - 0b11100011, 0b10111000, 0b11100000, - 0b11110011, 0b10111001, 0b11100000, - 0b01111111, 0b10111111, 0b11100000, - 0b01111111, 0b10111111, 0b11000000, - 0b00111101, 0b10111111, 0b00001000, - }, - { // plus/minus = \005 - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00011000, 0b00000000, - - 0b00011100, 0b00011000, 0b00000000, - 0b00011100, 0b00011000, 0b00000000, - 0b00011100, 0b00110000, 0b00000000, - 0b11111111, 0b10110111, 0b11110000, - 0b11111111, 0b10110111, 0b11110000, - 0b11111111, 0b10110111, 0b11110000, - 0b00011100, 0b00110000, 0b00000000, - 0b00011100, 0b01100000, 0b00000000, - - 0b00011100, 0b01100000, 0b00000000, - 0b00000000, 0b01100000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00001000, - }, - { // keypad = \007 - 0b00000000, 0b00000000, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00111101, 0b11101111, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00001000, - }, - { // nano - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - - 0b01111001, 0b11111100, 0b00000000, - 0b01111111, 0b11111111, 0b00000000, - 0b01111111, 0b11111111, 0b10000000, - 0b01111111, 0b11111111, 0b10000000, - 0b01111110, 0b00001111, 0b11000000, - 0b01111100, 0b00000111, 0b11000000, - 0b01111000, 0b00000011, 0b11000000, - 0b01111000, 0b00000011, 0b11000000, - - 0b01111000, 0b00000011, 0b11000000, - 0b01111000, 0b00000011, 0b11000000, - 0b01111000, 0b00000011, 0b11000000, - 0b01111000, 0b00000011, 0b11000000, - 0b01111000, 0b00000011, 0b11000000, - 0b01111000, 0b00000011, 0b11001000, - }, - { // pico - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, - 0b00111101, 0b11111100, 0b00000000, - 0b00111111, 0b11111111, 0b00000000, - - 0b00111111, 0b11111111, 0b10000000, - 0b00111111, 0b11111111, 0b11000000, - 0b00111111, 0b00000111, 0b11000000, - 0b00111110, 0b00000011, 0b11000000, - 0b00111110, 0b00000011, 0b11000000, - 0b00111110, 0b00000011, 0b11000000, - 0b00111111, 0b00000111, 0b11000000, - 0b00111111, 0b11111111, 0b11000000, - 0b00111111, 0b11111111, 0b10000000, - - 0b00111111, 0b11111111, 0b00000000, - 0b00111101, 0b11111100, 0b00000000, - 0b00111100, 0b00000000, 0b00000000, - 0b00111100, 0b00000000, 0b00000000, - 0b00111100, 0b00000000, 0b00001000, - }, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b1111001111110000, + 0b1111011111111100, + 0b1111111111111110, + 0b1111111000011111, + 0b1111110000001111, + 0b1111100000000111, + 0b1111100000000111, + 0b1111100000000111, + 0b1111110000001111, + 0b1111111000011111, + 0b1111111111111110, + 0b1111011111111100, + 0b1111001111110000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, }; diff --git a/plot.c b/plot.c index 25951c0..7d1b47c 100644 --- a/plot.c +++ b/plot.c @@ -8,7 +8,7 @@ #define SWAP(x,y) do { int z=x; x = y; y = z; } while(0) static void cell_draw_marker_info(int m, int n, int w, int h); -void frequency_string(char *buf, size_t len, uint32_t freq); +void frequency_string(char *buf, size_t len, uint32_t freq, char *prefix); void frequency_string_short(char *buf, size_t len, int32_t freq, char prefix); void markmap_all_markers(void); @@ -24,7 +24,7 @@ int16_t grid_offset; int16_t grid_width; int area_width = AREA_WIDTH_NORMAL; -int area_height = HEIGHT; +int area_height = HEIGHT+1; #define GRID_RECTANGULAR (1<<0) #define GRID_SMITH (1<<1) @@ -57,18 +57,24 @@ uint32_t trace_index[TRACES_MAX][101]; #define CELL_P(i, x, y) (((((x)&0x03e0UL)<<22) | (((y)&0x03e0UL)<<17)) == ((i)&0xffc00000UL)) +//#define floatToInt(v) ((int)(v)) +int floatToInt(float v){ + if (v < 0) return v-0.5; + if (v > 0) return v+0.5; + return 0; +} void update_grid(void) { int32_t gdigit = 100000000; int32_t fstart, fspan; int32_t grid; - if (frequency1 > 0) { + if (frequency0 < frequency1) { fstart = frequency0; fspan = frequency1 - frequency0; } else { - fspan = -frequency1; - fstart = frequency0 - fspan/2; + fstart = frequency1; + fspan = frequency0 - frequency1; } while (gdigit > 100) { @@ -103,15 +109,9 @@ circle_inout(int x, int y, int r) return 0; } - -#define P_CENTER_X 146 -#define P_CENTER_Y 116 -#define P_RADIUS 116 - static int polar_grid(int x, int y) { - int c = config.grid_color; int d; // offset to center @@ -121,30 +121,30 @@ polar_grid(int x, int y) // outer circle d = circle_inout(x, y, P_RADIUS); if (d < 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; // vertical and horizontal axis if (x == 0 || y == 0) - return c; + return 1; d = circle_inout(x, y, P_RADIUS / 5); - if (d == 0) return c; + if (d == 0) return 1; if (d > 0) return 0; d = circle_inout(x, y, P_RADIUS * 2 / 5); - if (d == 0) return c; + if (d == 0) return 1; if (d > 0) return 0; // cross sloping lines if (x == y || x == -y) - return c; + return 1; d = circle_inout(x, y, P_RADIUS * 3 / 5); - if (d == 0) return c; + if (d == 0) return 1; if (d > 0) return 0; d = circle_inout(x, y, P_RADIUS * 4 / 5); - if (d == 0) return c; + if (d == 0) return 1; return 0; } @@ -155,7 +155,6 @@ polar_grid(int x, int y) int smith_grid(int x, int y) { - int c = config.grid_color; int d; // offset to center @@ -167,46 +166,46 @@ smith_grid(int x, int y) if (d < 0) return 0; if (d == 0) - return c; + return 1; // horizontal axis if (y == 0) - return c; + return 1; // shift circle center to right origin x -= P_RADIUS; - // Constant Reactance Circle: 2j : R/2 = 58 - if (circle_inout(x, y+58, 58) == 0) - return c; - if (circle_inout(x, y-58, 58) == 0) - return c; + // Constant Reactance Circle: 2j : R/2 = P_RADIUS/2 + if (circle_inout(x, y+P_RADIUS/2, P_RADIUS/2) == 0) + return 1; + if (circle_inout(x, y-P_RADIUS/2, P_RADIUS/2) == 0) + return 1; - // Constant Resistance Circle: 3 : R/4 = 29 - d = circle_inout(x+29, y, 29); + // Constant Resistance Circle: 3 : R/4 = P_RADIUS/4 + d = circle_inout(x+P_RADIUS/4, y, P_RADIUS/4); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; - // Constant Reactance Circle: 1j : R = 116 - if (circle_inout(x, y+116, 116) == 0) - return c; - if (circle_inout(x, y-116, 116) == 0) - return c; + // Constant Reactance Circle: 1j : R = P_RADIUS + if (circle_inout(x, y+P_RADIUS, P_RADIUS) == 0) + return 1; + if (circle_inout(x, y-P_RADIUS, P_RADIUS) == 0) + return 1; - // Constant Resistance Circle: 1 : R/2 = 58 - d = circle_inout(x+58, y, 58); + // Constant Resistance Circle: 1 : R/2 + d = circle_inout(x+P_RADIUS/2, y, P_RADIUS/2); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; - // Constant Reactance Circle: 1/2j : R*2 = 232 - if (circle_inout(x, y+232, 232) == 0) - return c; - if (circle_inout(x, y-232, 232) == 0) - return c; + // Constant Reactance Circle: 1/2j : R*2 + if (circle_inout(x, y+P_RADIUS*2, P_RADIUS*2) == 0) + return 1; + if (circle_inout(x, y-P_RADIUS*2, P_RADIUS*2) == 0) + return 1; - // Constant Resistance Circle: 1/3 : R*3/4 = 87 - if (circle_inout(x+87, y, 87) == 0) - return c; + // Constant Resistance Circle: 1/3 : R*3/4 + if (circle_inout(x+P_RADIUS*3/4, y, P_RADIUS*3/4) == 0) + return 1; return 0; } @@ -214,7 +213,6 @@ smith_grid(int x, int y) int smith_grid2(int x, int y, float scale) { - int c = config.grid_color; int d; // offset to center @@ -226,92 +224,91 @@ smith_grid2(int x, int y, float scale) if (d < 0) return 0; if (d == 0) - return c; + return 1; // shift circle center to right origin x -= P_RADIUS * scale; // Constant Reactance Circle: 2j : R/2 = 58 if (circle_inout(x, y+58*scale, 58*scale) == 0) - return c; + return 1; if (circle_inout(x, y-58*scale, 58*scale) == 0) - return c; + return 1; #if 0 // Constant Resistance Circle: 3 : R/4 = 29 d = circle_inout(x+29*scale, y, 29*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; d = circle_inout(x-29*scale, y, 29*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; #endif // Constant Reactance Circle: 1j : R = 116 if (circle_inout(x, y+116*scale, 116*scale) == 0) - return c; + return 1; if (circle_inout(x, y-116*scale, 116*scale) == 0) - return c; + return 1; // Constant Resistance Circle: 1 : R/2 = 58 d = circle_inout(x+58*scale, y, 58*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; d = circle_inout(x-58*scale, y, 58*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; // Constant Reactance Circle: 1/2j : R*2 = 232 if (circle_inout(x, y+232*scale, 232*scale) == 0) - return c; + return 1; if (circle_inout(x, y-232*scale, 232*scale) == 0) - return c; + return 1; #if 0 // Constant Resistance Circle: 1/3 : R*3/4 = 87 d = circle_inout(x+87*scale, y, 87*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; d = circle_inout(x+87*scale, y, 87*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; #endif // Constant Resistance Circle: 0 : R d = circle_inout(x+P_RADIUS*scale, y, P_RADIUS*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; d = circle_inout(x-P_RADIUS*scale, y, P_RADIUS*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; // Constant Resistance Circle: -1/3 : R*3/2 = 174 d = circle_inout(x+174*scale, y, 174*scale); if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; d = circle_inout(x-174*scale, y, 174*scale); //if (d > 0) return 0; - if (d == 0) return c; + if (d == 0) return 1; return 0; } #endif const int cirs[][4] = { - { 0, 58/2, 58/2, 0 }, // Constant Reactance Circle: 2j : R/2 = 58 - { 29/2, 0, 29/2, 1 }, // Constant Resistance Circle: 3 : R/4 = 29 - { 0, 116/2, 116/2, 0 }, // Constant Reactance Circle: 1j : R = 116 - { 58/2, 0, 58/2, 1 }, // Constant Resistance Circle: 1 : R/2 = 58 - { 0, 232/2, 232/2, 0 }, // Constant Reactance Circle: 1/2j : R*2 = 232 - { 87/2, 0, 87/2, 1 }, // Constant Resistance Circle: 1/3 : R*3/4 = 87 - { 0, 464/2, 464/2, 0 }, // Constant Reactance Circle: 1/4j : R*4 = 464 - { 116/2, 0, 116/2, 1 }, // Constant Resistance Circle: 0 : R - { 174/2, 0, 174/2, 1 }, // Constant Resistance Circle: -1/3 : R*3/2 = 174 - { 0, 0, 0, 0 } // sentinel + { 0, 58/2, 58/2, 0 }, // Constant Reactance Circle: 2j : R/2 = 58 + { 29/2, 0, 29/2, 1 }, // Constant Resistance Circle: 3 : R/4 = 29 + { 0, 115/2, 115/2, 0 }, // Constant Reactance Circle: 1j : R = 115 + { 58/2, 0, 58/2, 1 }, // Constant Resistance Circle: 1 : R/2 = 58 + { 0, 230/2, 230/2, 0 }, // Constant Reactance Circle: 1/2j : R*2 = 230 + { 86/2, 0, 86/2, 1 }, // Constant Resistance Circle: 1/3 : R*3/4 = 86 + { 0, 460/2, 460/2, 0 }, // Constant Reactance Circle: 1/4j : R*4 = 460 + { 115/2, 0, 115/2, 1 }, // Constant Resistance Circle: 0 : R + { 173/2, 0, 173/2, 1 }, // Constant Resistance Circle: -1/3 : R*3/2 = 173 + { 0, 0, 0, 0 } // sentinel }; int smith_grid3(int x, int y) { - int c = config.grid_color; int d; // offset to center @@ -323,7 +320,7 @@ smith_grid3(int x, int y) if (d < 0) return 0; if (d == 0) - return c; + return 1; // shift circle center to right origin x -= P_RADIUS /2; @@ -332,12 +329,12 @@ smith_grid3(int x, int y) for (i = 0; cirs[i][2]; i++) { d = circle_inout(x+cirs[i][0], y+cirs[i][1], cirs[i][2]); if (d == 0) - return c; + return 1; if (d > 0 && cirs[i][3]) return 0; d = circle_inout(x-cirs[i][0], y-cirs[i][1], cirs[i][2]); if (d == 0) - return c; + return 1; if (d > 0 && cirs[i][3]) return 0; } @@ -348,7 +345,6 @@ smith_grid3(int x, int y) int rectangular_grid(int x, int y) { - int c = config.grid_color; //#define FREQ(x) (((x) * (fspan / 1000) / (WIDTH-1)) * 1000 + fstart) //int32_t n = FREQ(x-1) / fgrid; //int32_t m = FREQ(x) / fgrid; @@ -356,11 +352,11 @@ rectangular_grid(int x, int y) //if (((x * 6) % (WIDTH-1)) < 6) //if (((x - grid_offset) % grid_width) == 0) if (x == 0 || x == WIDTH-1) - return c; + return 1; if ((y % GRIDY) == 0) - return c; + return 1; if ((((x + grid_offset) * 10) % grid_width) < 10) - return c; + return 1; return 0; } #endif @@ -368,24 +364,22 @@ rectangular_grid(int x, int y) static int rectangular_grid_x(int x) { - int c = config.grid_color; if (x < 0) return 0; - if (x == 0 || x == WIDTH) - return c; + if (x == 0 || x == WIDTH-1) + return 1; if ((((x + grid_offset) * 10) % grid_width) < 10) - return c; + return 1; return 0; } static int rectangular_grid_y(int y) { - int c = config.grid_color; if (y < 0) return 0; if ((y % GRIDY) == 0) - return c; + return 1; return 0; } @@ -470,7 +464,7 @@ float linear(const float *v) float swr(const float *v) { float x = sqrtf(v[0]*v[0] + v[1]*v[1]); - if (x > 1) + if (x >= 1) return INFINITY; return (1 + x)/(1 - x); } @@ -489,24 +483,24 @@ float reactance(const float *v) { return zi; } -#define RADIUS ((HEIGHT-1)/2) void cartesian_scale(float re, float im, int *xp, int *yp, float scale) { //float scale = 4e-3; - int x = re * RADIUS * scale; - int y = im * RADIUS * scale; - if (x < -RADIUS) x = -RADIUS; - if (y < -RADIUS) y = -RADIUS; - if (x > RADIUS) x = RADIUS; - if (y > RADIUS) y = RADIUS; - *xp = WIDTH/2 + x; - *yp = HEIGHT/2 - y; + int x = floatToInt(re * P_RADIUS * scale); + int y = floatToInt(im * P_RADIUS * scale); + if (x < -P_RADIUS) x = -P_RADIUS; + if (y < -P_RADIUS) y = -P_RADIUS; + if (x > P_RADIUS) x = P_RADIUS; + if (y > P_RADIUS) y = P_RADIUS; + *xp = P_CENTER_X + x; + *yp = P_CENTER_Y - y; } float groupdelay_from_array(int i, float array[101][2]) { +/* if (i == 0) { float deltaf = frequencies[1] - frequencies[0]; return groupdelay(array[0], array[1], deltaf); @@ -517,6 +511,11 @@ groupdelay_from_array(int i, float array[101][2]) float deltaf = frequencies[i+1] - frequencies[i-1]; return groupdelay(array[i-1], array[i+1], deltaf); } +*/ + int bottom = (i == 0) ? 0 : i - 1; + int top = (i == 100) ? 100 : i + 1; + float deltaf = frequencies[top] - frequencies[bottom]; + return groupdelay(array[bottom], array[top], deltaf); } uint32_t @@ -525,7 +524,7 @@ trace_into_index(int x, int t, int i, float array[101][2]) int y = 0; float v = 0; float *coeff = array[i]; - float refpos = 8 - get_trace_refpos(t); + float refpos = 10 - get_trace_refpos(t); float scale = 1 / get_trace_scale(t); switch (trace[t].type) { case TRC_LOGMAG: @@ -563,8 +562,8 @@ trace_into_index(int x, int t, int i, float array[101][2]) break; } if (v < 0) v = 0; - if (v > 8) v = 8; - y = v * GRIDY; + if (v > 10) v = 10; + y = floatToInt(v * GRIDY); return INDEX(x +CELLOFFSETX, y, i); } @@ -579,42 +578,46 @@ string_value_with_prefix(char *buf, int len, float val, char unit) n++; len--; } - if (val < 1e-12) { - prefix = 'f'; - val *= 1e15; - } else if (val < 1e-9) { - prefix = 'p'; - val *= 1e12; - } else if (val < 1e-6) { - prefix = 'n'; - val *= 1e9; - } else if (val < 1e-3) { - prefix = S_MICRO[0]; - val *= 1e6; - } else if (val < 1) { - prefix = 'm'; - val *= 1e3; - } else if (val < 1e3) { - prefix = 0; - } else if (val < 1e6) { - prefix = 'k'; - val /= 1e3; - } else if (val < 1e9) { - prefix = 'M'; - val /= 1e6; - } else { - prefix = 'G'; - val /= 1e9; + if (val == INFINITY){ + prefix = S_INFINITY[0]; } + else { + if (val < 1e-12) { + prefix = 'f'; + val *= 1e15; + } else if (val < 1e-9) { + prefix = 'p'; + val *= 1e12; + } else if (val < 1e-6) { + prefix = 'n'; + val *= 1e9; + } else if (val < 1e-3) { + prefix = S_MICRO[0]; + val *= 1e6; + } else if (val < 1) { + prefix = 'm'; + val *= 1e3; + } else if (val < 1e3) { + prefix = 0; + } else if (val < 1e6) { + prefix = 'k'; + val /= 1e3; + } else if (val < 1e9) { + prefix = 'M'; + val /= 1e6; + } else { + prefix = 'G'; + val /= 1e9; + } - if (val < 10) { - n += chsnprintf(&buf[n], len, "%.2f", val); - } else if (val < 100) { - n += chsnprintf(&buf[n], len, "%.1f", val); - } else { - n += chsnprintf(&buf[n], len, "%d", (int)val); + if (val < 10) { + n += chsnprintf(&buf[n], len, "%.2f", val); + } else if (val < 100) { + n += chsnprintf(&buf[n], len, "%.1f", val); + } else { + n += chsnprintf(&buf[n], len, "%d", (int)val); + } } - if (prefix) buf[n++] = prefix; if (unit) @@ -644,7 +647,7 @@ format_smith_value(char *buf, int len, const float coeff[2], uint32_t frequency) case MS_LOG: { float v = logmag(coeff); if (v == -INFINITY) - chsnprintf(buf, len, "-INF dB"); + chsnprintf(buf, len, "-"S_INFINITY" dB"); else chsnprintf(buf, len, "%.1fdB %.1f" S_DEGREE, v, phase(coeff)); } @@ -667,13 +670,17 @@ format_smith_value(char *buf, int len, const float coeff[2], uint32_t frequency) n = string_value_with_prefix(buf, len, zr, S_OHM[0]); buf[n++] = ' '; - if (zi < 0) { - float c = -1 / (PI2 * frequency * zi); - string_value_with_prefix(buf+n, len-n, c, 'F'); - } else { - float l = zi / (PI2 * frequency); - string_value_with_prefix(buf+n, len-n, l, 'H'); + char prefix; + float value; + if (zi < 0){// Capacity + prefix = 'F'; + value = -1 / (PI2 * frequency * zi); } + else { + prefix = 'H'; + value = zi / (PI2 * frequency); + } + string_value_with_prefix(buf+n, len-n, value, prefix); break; } } @@ -705,7 +712,7 @@ trace_get_value_string(int t, char *buf, int len, float array[101][2], int i) case TRC_LOGMAG: v = logmag(coeff); if (v == -INFINITY) - chsnprintf(buf, len, "-INF dB"); + chsnprintf(buf, len, "-"S_INFINITY" dB"); else chsnprintf(buf, len, "%.2fdB", v); break; @@ -723,7 +730,10 @@ trace_get_value_string(int t, char *buf, int len, float array[101][2], int i) break; case TRC_SWR: v = swr(coeff); - chsnprintf(buf, len, "%.2f", v); + if (v == INFINITY) + chsnprintf(buf, len, S_INFINITY); + else + chsnprintf(buf, len, "%.2f", v); break; case TRC_SMITH: format_smith_value(buf, len, coeff, frequencies[i]); @@ -757,7 +767,7 @@ trace_get_value_string_delta(int t, char *buf, int len, float array[101][2], int case TRC_LOGMAG: v = logmag(coeff) - logmag(coeff_ref); if (v == -INFINITY) - chsnprintf(buf, len, S_DELTA "-INF dB"); + chsnprintf(buf, len, S_DELTA "-"S_INFINITY" dB"); else chsnprintf(buf, len, S_DELTA "%.2fdB", v); break; @@ -1123,31 +1133,85 @@ cell_draw_refpos(int m, int n, int w, int h) if (trace[t].type == TRC_SMITH || trace[t].type == TRC_POLAR) continue; int x = 0 - x0 +CELLOFFSETX; - int y = 8*GRIDY - (int)(get_trace_refpos(t) * GRIDY) - y0; + int y = 10*GRIDY - floatToInt((get_trace_refpos(t) * GRIDY)) - y0; if (x > -5 && x < w && y >= -3 && y < h+3) draw_refpos(w, h, x, y, config.trace_color[t]); } } -void -draw_marker(int w, int h, int x, int y, int c, int ch) +#define MARKER_WIDTH 7 +#define MARKER_HEIGHT 10 +#define X_MARKER_OFFSET 3 +#define Y_MARKER_OFFSET 10 +static const uint8_t marker_bitmap[]={ + // Marker 1 + 0b11111110, + 0b11101110, + 0b11001110, + 0b11101110, + 0b11101110, + 0b11101110, + 0b11000110, + 0b01111100, + 0b00111000, + 0b00010000, + // Marker 2 + 0b11111110, + 0b11000110, + 0b10111010, + 0b11111010, + 0b11000110, + 0b10111110, + 0b10000010, + 0b01111100, + 0b00111000, + 0b00010000, + // Marker 3 + 0b11111110, + 0b11000110, + 0b10111010, + 0b11100110, + 0b11111010, + 0b10111010, + 0b11000110, + 0b01111100, + 0b00111000, + 0b00010000, + // Marker 4 + 0b11111110, + 0b11110110, + 0b11100110, + 0b11010110, + 0b10110110, + 0b10110110, + 0b10000010, + 0b01110100, + 0b00111000, + 0b00010000, +}; + +static void draw_marker(int w, int h, int x, int y, int c, int ch) { - int i, j; - for (j = 10; j >= 0; j--) { - int j0 = j / 2; - for (i = -j0; i <= j0; i++) { - int x0 = x + i; - int y0 = y - j; - int cc = c; - if (j <= 9 && j > 2 && i >= -1 && i <= 3) { - uint16_t bits = x5x7_bits[(ch * 7) + (9-j)]; - if (bits & (0x80>>(i+1))) - cc = 0; - } - if (y0 >= 0 && y0 < h && x0 >= 0 && x0 < w) - spi_buffer[y0*w+x0] = cc; - } - } + int y0=y; + for (int j=0;j= 0 && x0 < w && y0 >= 0 && y0 < h) + { + if (bits&0x80) + spi_buffer[y0*w+x0] = c; + else if (force_color) + spi_buffer[y0*w+x0] = DEFAULT_BG_COLOR; + } + x0++; + bits<<=1; + } + } } void @@ -1276,22 +1340,21 @@ search_nearest_index(int x, int y, int t) void cell_draw_markers(int m, int n, int w, int h) { - int x0 = m * CELLWIDTH; - int y0 = n * CELLHEIGHT; - int t, i; - for (i = 0; i < MARKERS_MAX; i++) { - if (!markers[i].enabled) - continue; - for (t = 0; t < TRACES_MAX; t++) { - if (!trace[t].enabled) - continue; - uint32_t index = trace_index[t][markers[i].index]; - int x = CELL_X(index) - x0; - int y = CELL_Y(index) - y0; - if (x > -6 && x < w+6 && y >= 0 && y < h+12) - draw_marker(w, h, x, y, config.trace_color[t], '1' + i); - } - } + int t, i; + for (i = 0; i < MARKERS_MAX; i++) { + if (!markers[i].enabled) + continue; + for (t = 0; t < TRACES_MAX; t++) { + if (!trace[t].enabled) + continue; + uint32_t index = trace_index[t][markers[i].index]; + int x = CELL_X(index) - m * CELLWIDTH - X_MARKER_OFFSET; + int y = CELL_Y(index) - n * CELLHEIGHT - Y_MARKER_OFFSET; + + if (x >=-MARKER_WIDTH && x < w + MARKER_WIDTH && y >= -MARKER_HEIGHT && y < h + MARKER_HEIGHT) + draw_marker(w, h, x, y, config.trace_color[t], i); + } + } } void @@ -1372,34 +1435,37 @@ draw_cell(int m, int n) } PULSE; + memset(spi_buffer, DEFAULT_BG_COLOR, sizeof spi_buffer); + uint16_t c = config.grid_color; /* draw grid */ if (grid_mode & GRID_RECTANGULAR) { for (x = 0; x < w; x++) { - uint16_t c = rectangular_grid_x(x+x0off); - for (y = 0; y < h; y++) - spi_buffer[y * w + x] = c; + if (rectangular_grid_x(x+x0off)){ + for (y = 0; y < h; y++) + spi_buffer[y * w + x] = c; + } } for (y = 0; y < h; y++) { - uint16_t c = rectangular_grid_y(y+y0); - for (x = 0; x < w; x++) - if (x+x0off >= 0 && x+x0off <= WIDTH) - spi_buffer[y * w + x] |= c; + if (rectangular_grid_y(y+y0)){ + for (x = 0; x < w; x++) + if (x+x0off >= 0 && x+x0off < WIDTH) + spi_buffer[y * w + x] = c; + } } - } else { - memset(spi_buffer, 0, sizeof spi_buffer); } if (grid_mode & (GRID_SMITH|GRID_ADMIT|GRID_POLAR)) { for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { - uint16_t c = 0; + int n = 0; if (grid_mode & GRID_SMITH) - c = smith_grid(x+x0off, y+y0); + n = smith_grid(x+x0off, y+y0); else if (grid_mode & GRID_ADMIT) - c = smith_grid3(x+x0off, y+y0); - //c = smith_grid2(x+x0, y+y0, 0.5); + n = smith_grid3(x+x0off, y+y0); + //n = smith_grid2(x+x0, y+y0, 0.5); else if (grid_mode & GRID_POLAR) - c = polar_grid(x+x0off, y+y0); - spi_buffer[y * w + x] |= c; + n = polar_grid(x+x0off, y+y0); + if (n) + spi_buffer[y * w + x] = c; } } } @@ -1531,43 +1597,44 @@ request_to_draw_cells_behind_numeric_input(void) } -void -cell_drawchar_5x7(int w, int h, uint8_t ch, int x, int y, uint16_t fg, int invert) +int +cell_drawchar(int w, int h, uint8_t ch, int x, int y, int invert) { - uint8_t bits; - int c, r; - if (y <= -7 || y >= h || x <= -5 || x >= w) - return; - for(c = 0; c < 7; c++) { - if ((y + c) < 0 || (y + c) >= h) - continue; - bits = x5x7_bits[(ch * 7) + c]; - if (invert) - bits = ~bits; - for (r = 0; r < 5; r++) { - if ((x+r) >= 0 && (x+r) < w && (0x80 & bits)) - spi_buffer[(y+c)*w + (x+r)] = fg; - bits <<= 1; - } - } + uint8_t bits; + int c, r, ch_size; + const uint8_t *char_buf = FONT_GET_DATA(ch); + ch_size=FONT_GET_WIDTH(ch); + if (y <= -FONT_GET_HEIGHT || y >= h || x <= -ch_size || x >= w) + return ch_size; + for(c = 0; c < FONT_GET_HEIGHT; c++) { + bits = *char_buf++; + if ((y + c) < 0 || (y + c) >= h) + continue; + if (invert) + bits = ~bits; + for (r = 0; r < ch_size; r++) { + if ((x+r) >= 0 && (x+r) < w && (0x80 & bits)) + spi_buffer[(y+c)*w + (x+r)] = foreground_color; + bits <<= 1; + } + } + return ch_size; } void -cell_drawstring_5x7(int w, int h, char *str, int x, int y, uint16_t fg) +cell_drawstring(int w, int h, char *str, int x, int y) { while (*str) { - cell_drawchar_5x7(w, h, *str, x, y, fg, FALSE); - x += 5; + x += cell_drawchar(w, h, *str, x, y, FALSE); str++; } } void -cell_drawstring_invert_5x7(int w, int h, char *str, int x, int y, uint16_t fg, int invert) +cell_drawstring_invert(int w, int h, char *str, int x, int y, int invert) { while (*str) { - cell_drawchar_5x7(w, h, *str, x, y, fg, invert); - x += 5; + x += cell_drawchar(w, h, *str, x, y, invert); str++; } } @@ -1590,13 +1657,18 @@ cell_draw_marker_info(int m, int n, int w, int h) if (!markers[mk].enabled) continue; int xpos = 1 + (j%2)*146; - int ypos = 1 + (j/2)*7; + int ypos = 1 + (j/2)*8; xpos -= m * CELLWIDTH -CELLOFFSETX; ypos -= n * CELLHEIGHT; - strcpy(buf, "MK1"); - buf[2] += mk; - cell_drawstring_invert_5x7(w, h, buf, xpos, ypos, config.trace_color[t], mk == active_marker); - xpos += 20; + + setForegroundColor(config.trace_color[t]); + if (mk == active_marker) + cell_drawstring(w, h, S_SARROW, xpos, ypos); + xpos += 5; + chsnprintf(buf, sizeof buf, "MK%d", mk); + cell_drawstring(w, h, buf, xpos, ypos); + + xpos += 19; //trace_get_info(t, buf, sizeof buf); int32_t freq = frequencies[markers[mk].index]; if (uistat.marker_delta && mk != active_marker) { @@ -1605,13 +1677,14 @@ cell_draw_marker_info(int m, int n, int w, int h) } else { frequency_string_short(buf, sizeof buf, freq, 0); } - cell_drawstring_5x7(w, h, buf, xpos, ypos, config.trace_color[t]); + cell_drawstring(w, h, buf, xpos, ypos); xpos += 64; if (uistat.marker_delta && mk != active_marker) trace_get_value_string_delta(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index, markers[active_marker].index); else trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + setForegroundColor(DEFAULT_FG_COLOR); + cell_drawstring(w, h, buf, xpos, ypos); j++; } @@ -1619,15 +1692,16 @@ cell_draw_marker_info(int m, int n, int w, int h) if (!uistat.marker_delta && previous_marker >= 0 && active_marker != previous_marker && markers[previous_marker].enabled) { int idx0 = markers[previous_marker].index; int xpos = 192; - int ypos = 1 + (j/2)*7; + int ypos = 1 + (j/2)*8; xpos -= m * CELLWIDTH -CELLOFFSETX; ypos -= n * CELLHEIGHT; strcpy(buf, S_DELTA "1:"); buf[1] += previous_marker; - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + setForegroundColor(DEFAULT_FG_COLOR); + cell_drawstring(w, h, buf, xpos, ypos); xpos += 19; if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { - frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0]); + frequency_string(buf, sizeof buf, frequencies[idx] - frequencies[idx0], ""); } else { //chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9 - time_of_index(idx0) * 1e9), // distance_of_index(idx) - distance_of_index(idx0)); @@ -1635,70 +1709,87 @@ cell_draw_marker_info(int m, int n, int w, int h) buf[n++] = ' '; string_value_with_prefix(&buf[n], sizeof buf - n, distance_of_index(idx) - distance_of_index(idx0), 'm'); } - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + cell_drawstring(w, h, buf, xpos, ypos); } } else { for (t = 0; t < TRACES_MAX; t++) { if (!trace[t].enabled) continue; int xpos = 1 + (j%2)*146; - int ypos = 1 + (j/2)*7; + int ypos = 1 + (j/2)*8; xpos -= m * CELLWIDTH -CELLOFFSETX; ypos -= n * CELLHEIGHT; - strcpy(buf, "CH0"); - buf[2] += trace[t].channel; +// setForegroundColor(config.trace_color[t]); +// strcpy(buf, "CH0"); +// buf[2] += trace[t].channel; //chsnprintf(buf, sizeof buf, "CH%d", trace[t].channel); - cell_drawstring_invert_5x7(w, h, buf, xpos, ypos, config.trace_color[t], t == uistat.current_trace); - xpos += 20; +// cell_drawstring_invert(w, h, buf, xpos, ypos, t == uistat.current_trace); +// xpos += 20; + setForegroundColor(config.trace_color[t]); + if (t == uistat.current_trace) + cell_drawstring(w, h, S_SARROW, xpos, ypos); + xpos += 5; + chsnprintf(buf, sizeof buf, "CH%d", trace[t].channel); + cell_drawstring(w, h, buf, xpos, ypos); + xpos += 19; + trace_get_info(t, buf, sizeof buf); - cell_drawstring_5x7(w, h, buf, xpos, ypos, config.trace_color[t]); - xpos += 64; + cell_drawstring(w, h, buf, xpos, ypos); + xpos += 60; trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], idx); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + cell_drawstring(w, h, buf, xpos, ypos); j++; } // draw marker frequency int xpos = 192; - int ypos = 1 + (j/2)*7; + int ypos = 1 + (j/2)*8; xpos -= m * CELLWIDTH -CELLOFFSETX; ypos -= n * CELLHEIGHT; - strcpy(buf, "1:"); - buf[0] += active_marker; +// strcpy(buf, "1:"); +// buf[0] += active_marker; +// xpos += 5; +// setForegroundColor(0xffff); +// cell_drawstring_invert(w, h, buf, xpos, ypos, uistat.lever_mode == LM_MARKER); +// xpos += 14; + if (uistat.lever_mode == LM_MARKER) + cell_drawstring(w, h, S_SARROW, xpos, ypos); xpos += 5; - cell_drawstring_invert_5x7(w, h, buf, xpos, ypos, 0xffff, uistat.lever_mode == LM_MARKER); - xpos += 14; + chsnprintf(buf, sizeof buf, "1:%d", active_marker); + cell_drawstring(w, h, buf, xpos, ypos); + xpos += 19; + if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { - frequency_string(buf, sizeof buf, frequencies[idx]); + frequency_string(buf, sizeof buf, frequencies[idx], ""); } else { //chsnprintf(buf, sizeof buf, "%d ns %.1f m", (uint16_t)(time_of_index(idx) * 1e9), distance_of_index(idx)); int n = string_value_with_prefix(buf, sizeof buf, time_of_index(idx), 's'); buf[n++] = ' '; string_value_with_prefix(&buf[n], sizeof buf-n, distance_of_index(idx), 'm'); } - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + cell_drawstring(w, h, buf, xpos, ypos); } - + setForegroundColor(DEFAULT_FG_COLOR); if (electrical_delay != 0) { // draw electrical delay int xpos = 21; - int ypos = 1 + ((j+1)/2)*7; + int ypos = 1 + ((j+1)/2)*8; xpos -= m * CELLWIDTH -CELLOFFSETX; ypos -= n * CELLHEIGHT; chsnprintf(buf, sizeof buf, "Edelay"); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + cell_drawstring(w, h, buf, xpos, ypos); xpos += 7 * 5; int n = string_value_with_prefix(buf, sizeof buf, electrical_delay * 1e-12, 's'); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + cell_drawstring(w, h, buf, xpos, ypos); xpos += n * 5 + 5; float light_speed_ps = 299792458e-12; //(m/ps) string_value_with_prefix(buf, sizeof buf, electrical_delay * light_speed_ps * velocity_factor, 'm'); - cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff); + cell_drawstring(w, h, buf, xpos, ypos); } } void -frequency_string(char *buf, size_t len, uint32_t freq) +frequency_string(char *buf, size_t len, uint32_t freq, char *prefix) { /* if (freq < 0) { freq = -freq; @@ -1706,13 +1797,13 @@ frequency_string(char *buf, size_t len, uint32_t freq) len -= 1; }*/ if (freq < 1000) { - chsnprintf(buf, len, "%d Hz", (int)freq); + chsnprintf(buf, len, "%s%d Hz", prefix, (int)freq); } else if (freq < 1000000U) { - chsnprintf(buf, len, "%d.%03d kHz", + chsnprintf(buf, len, "%s%d.%03d kHz", prefix, (freq / 1000U), (freq % 1000U)); } else { - chsnprintf(buf, len, "%d.%03d %03d MHz", + chsnprintf(buf, len, "%s%d.%03d %03d MHz", prefix, (freq / 1000000U), ((freq / 1000U) % 1000U), (freq % 1000U)); @@ -1749,56 +1840,31 @@ frequency_string_short(char *b, size_t len, int32_t freq, char prefix) void draw_frequencies(void) { - char buf[24]; - if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { - if (frequency0 < frequency1) { - strcpy(buf, "START "); - frequency_string(buf+6, 24-6, frequency0); - strcat(buf, " "); - ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000); - strcpy(buf, "STOP "); - frequency_string(buf+5, 24-5, frequency1); - strcat(buf, " "); - ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000); - } else if (frequency0 > frequency1) { - uint32_t fcenter = frequency0/2 + frequency1/2; - uint32_t fspan = frequency0 - frequency1; - int x = OFFSETX; - strcpy(buf, "CENTER"); - ili9341_drawstring_5x7_inv(buf, x, 233, 0xffff, 0x0000, uistat.lever_mode == LM_CENTER); - x += 5 * 6; - strcpy(buf, " "); - frequency_string(buf+1, 24-1, fcenter); - strcat(buf, " "); - ili9341_drawstring_5x7(buf, x, 233, 0xffff, 0x0000); - x = 205; - strcpy(buf, "SPAN"); - ili9341_drawstring_5x7_inv(buf, x, 233, 0xffff, 0x0000, uistat.lever_mode == LM_SPAN); - x += 5 * 4; - strcpy(buf, " "); - frequency_string(buf+1, 24-1, fspan); - strcat(buf, " "); - ili9341_drawstring_5x7(buf, x, 233, 0xffff, 0x0000); - } else { - int x = OFFSETX; - strcpy(buf, "CW"); - ili9341_drawstring_5x7_inv(buf, x, 233, 0xffff, 0x0000, uistat.lever_mode == LM_CENTER); - x += 5 * 2; - strcpy(buf, " "); - frequency_string(buf+1, 24-1, frequency0); - ili9341_drawstring_5x7(buf, x, 233, 0xffff, 0x0000); - chsnprintf(buf, 24, " "); - ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000); - } - } else { - strcpy(buf, "START 0s "); - ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000); + char buf1[24];buf1[0]=' '; + char buf2[24]; + if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { + if (frequency0 < frequency1) { + frequency_string(buf1+1, sizeof(buf1)-1, frequency0, "START "); + frequency_string(buf2, sizeof buf2, frequency1, "STOP "); + } else if (frequency0 > frequency1) { + frequency_string(buf1+1, sizeof(buf1)-1, frequency0/2 + frequency1/2, "CENTER "); + frequency_string(buf2, sizeof buf2, frequency0 - frequency1, "SPAN "); + } else { + frequency_string(buf1+1, sizeof(buf1)-1, frequency0, "CW "); + } + + } else { + chsnprintf(buf1, sizeof buf1, "START 0s"); + chsnprintf(buf2, sizeof buf2, "%s%d ns", "STOP ", (uint16_t)(time_of_index(101) * 1e9)); + } + setForegroundColor(DEFAULT_FG_COLOR); + setBackgroundColor(DEFAULT_BG_COLOR); + ili9341_fill(0, 232, 320, 8, DEFAULT_BG_COLOR); + if (uistat.lever_mode == LM_SPAN || uistat.lever_mode == LM_CENTER) + buf1[0] = S_SARROW[0]; + ili9341_drawstring(buf1, OFFSETX, 232); + ili9341_drawstring(buf2, 205, 232); - strcpy(buf, "STOP "); - chsnprintf(buf+5, 24-5, "%d ns", (uint16_t)(time_of_index(101) * 1e9)); - strcat(buf, " "); - ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000); - } } void @@ -1806,8 +1872,10 @@ draw_cal_status(void) { int x = 0; int y = 100; -#define YSTEP 7 - ili9341_fill(0, y, 10, 6*YSTEP, 0x0000); +#define YSTEP 8 + setForegroundColor(DEFAULT_FG_COLOR); + setBackgroundColor(DEFAULT_BG_COLOR); + ili9341_fill(0, y, 10, 6*YSTEP, DEFAULT_BG_COLOR); if (cal_status & CALSTAT_APPLY) { char c[3] = "C0"; c[1] += lastsaveid; @@ -1815,100 +1883,62 @@ draw_cal_status(void) c[0] = 'c'; else if (active_props == ¤t_props) c[1] = '*'; - ili9341_drawstring_5x7(c, x, y, 0xffff, 0x0000); + ili9341_drawstring(c, x, y); y += YSTEP; } if (cal_status & CALSTAT_ED) { - ili9341_drawstring_5x7("D", x, y, 0xffff, 0x0000); + ili9341_drawstring("D", x, y); y += YSTEP; } if (cal_status & CALSTAT_ER) { - ili9341_drawstring_5x7("R", x, y, 0xffff, 0x0000); + ili9341_drawstring("R", x, y); y += YSTEP; } if (cal_status & CALSTAT_ES) { - ili9341_drawstring_5x7("S", x, y, 0xffff, 0x0000); + ili9341_drawstring("S", x, y); y += YSTEP; } if (cal_status & CALSTAT_ET) { - ili9341_drawstring_5x7("T", x, y, 0xffff, 0x0000); + ili9341_drawstring("T", x, y); y += YSTEP; } if (cal_status & CALSTAT_EX) { - ili9341_drawstring_5x7("X", x, y, 0xffff, 0x0000); + ili9341_drawstring("X", x, y); y += YSTEP; } } +// Draw battery level +#define BATTERY_TOP_LEVEL 4100 +#define BATTERY_BOTTOM_LEVEL 3100 +#define BATTERY_WARNING_LEVEL 3300 + void draw_battery_status(void) { - int w = 10, h = 14; - int x = 0, y = 0; - int i, c; - uint16_t *buf = spi_buffer; - uint8_t vbati = vbat2bati(vbat); - uint16_t col = vbati == 0 ? RGB565(0, 255, 0) : RGB565(0, 0, 240); - memset(spi_buffer, 0, w * h * 2); - - // battery head - x = 3; - buf[y * w + x++] = col; - buf[y * w + x++] = col; - buf[y * w + x++] = col; - buf[y * w + x++] = col; - - y++; - x = 3; - buf[y * w + x++] = col; - x++; x++; - buf[y * w + x++] = col; - - y++; - x = 1; - for (i = 0; i < 8; i++) - buf[y * w + x++] = col; - - for (c = 0; c < 3; c++) { - y++; - x = 1; - buf[y * w + x++] = col; - x++; x++; x++; x++; x++; x++; - buf[y * w + x++] = col; - - y++; - x = 1; - buf[y * w + x++] = col; - x++; - for (i = 0; i < 4; i++) - buf[y * w + x++] = ( ((c+1) * 25) >= (100 - vbati)) ? col : 0; - x++; - buf[y * w + x++] = col; - - y++; - x = 1; - buf[y * w + x++] = col; - x++; - for (i = 0; i < 4; i++) - buf[y * w + x++] = ( ((c+1) * 25) >= (100 - vbati)) ? col : 0; - x++; - buf[y * w + x++] = col; - } - - // battery foot - y++; - x = 1; - buf[y * w + x++] = col; - x++; x++; x++; x++; x++; x++; - buf[y * w + x++] = col; - - y++; - x = 1; - for (i = 0; i < 8; i++) - buf[y * w + x++] = col; - - ili9341_bulk(0, 1, w, h); + uint8_t string_buf[25]; + // Set battery color + setForegroundColor(vbat < BATTERY_WARNING_LEVEL ? RGBHEX(0xff0000) : RGBHEX(0x1fe300)); + setBackgroundColor(DEFAULT_BG_COLOR); +// chsnprintf(string_buf, sizeof string_buf, "V:%d", vbat); +// ili9341_drawstringV(string_buf, 1, 60); + // Prepare battery bitmap image + // Battery top + int x=0; + string_buf[x++] = 0b00111100; + string_buf[x++] = 0b00100100; + string_buf[x++] = 0b11111111; +// string_buf[x++] = 0b10000001; + // Fill battery status + for (int power=BATTERY_TOP_LEVEL; power > BATTERY_BOTTOM_LEVEL; power-=100) + string_buf[x++] = (power > vbat) ? 0b10000001 : // Empty line + 0b11111111; // Full line + // Battery bottom +// string_buf[x++] = 0b10000001; + string_buf[x++] = 0b11111111; + // Draw battery + blit8BitWidthBitmap(0, 1, 8, x, string_buf); } void @@ -1921,7 +1951,7 @@ request_to_redraw_grid(void) void redraw_frame(void) { - ili9341_fill(0, 0, 320, 240, 0); + ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR); draw_frequencies(); draw_cal_status(); } diff --git a/ui.c b/ui.c index ce5aeb5..651bd9d 100644 --- a/ui.c +++ b/ui.c @@ -76,11 +76,15 @@ uint8_t ui_mode = UI_NORMAL; uint8_t keypad_mode; int8_t selection = 0; +// Set structure align as WORD (save flash memory) +#pragma pack(push, 2) typedef struct { uint8_t type; + uint8_t data; char *label; const void *reference; } menuitem_t; +#pragma pack(pop) int8_t last_touch_status = FALSE; int16_t last_touch_x; @@ -117,8 +121,6 @@ static void ui_process_numeric(void); static void menu_push_submenu(const menuitem_t *submenu); - - static int btn_check(void) { int cur_button = READ_PORT() & BUTTON_MASK; @@ -312,11 +314,12 @@ touch_cal_exec(void) int x1, x2, y1, y2; adc_stop(ADC1); - - ili9341_fill(0, 0, 320, 240, 0); - ili9341_line(0, 0, 0, 32, 0xffff); - ili9341_line(0, 0, 32, 0, 0xffff); - ili9341_drawstring_5x7("TOUCH UPPER LEFT", 10, 10, 0xffff, 0x0000); + setForegroundColor(DEFAULT_FG_COLOR); + setBackgroundColor(DEFAULT_BG_COLOR); + ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR); + ili9341_line(0, 0, 0, 32); + ili9341_line(0, 0, 32, 0); + ili9341_drawstring("TOUCH UPPER LEFT", 10, 10); do { status = touch_check(); @@ -324,10 +327,10 @@ touch_cal_exec(void) x1 = last_touch_x; y1 = last_touch_y; - ili9341_fill(0, 0, 320, 240, 0); - ili9341_line(320-1, 240-1, 320-1, 240-32, 0xffff); - ili9341_line(320-1, 240-1, 320-32, 240-1, 0xffff); - ili9341_drawstring_5x7("TOUCH LOWER RIGHT", 230, 220, 0xffff, 0x0000); + ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR); + ili9341_line(320-1, 240-1, 320-1, 240-32); + ili9341_line(320-1, 240-1, 320-32, 240-1); + ili9341_drawstring("TOUCH LOWER RIGHT", 230, 220); do { status = touch_check(); @@ -353,8 +356,10 @@ touch_draw_test(void) adc_stop(ADC1); - ili9341_fill(0, 0, 320, 240, 0); - ili9341_drawstring_5x7("TOUCH TEST: DRAG PANEL", OFFSETX, 233, 0xffff, 0x0000); + ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR); + setForegroundColor(DEFAULT_FG_COLOR); + setBackgroundColor(DEFAULT_BG_COLOR); + ili9341_drawstring("TOUCH TEST: DRAG PANEL", OFFSETX, 233); do { status = touch_check(); @@ -364,7 +369,7 @@ touch_draw_test(void) do { status = touch_check(); touch_position(&x1, &y1); - ili9341_line(x0, y0, x1, y1, 0xffff); + ili9341_line(x0, y0, x1, y1); x0 = x1; y0 = y1; chThdSleepMilliseconds(50); @@ -388,21 +393,23 @@ show_version(void) int x = 5, y = 5; adc_stop(ADC1); - ili9341_fill(0, 0, 320, 240, 0); + ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR); - ili9341_drawstring_size(BOARD_NAME, x, y, 0xffff, 0x0000, 4); + setForegroundColor(DEFAULT_FG_COLOR); + setBackgroundColor(DEFAULT_BG_COLOR); + ili9341_drawstring_size(BOARD_NAME, x, y, 4); y += 25; - ili9341_drawstring_5x7("2016-2019 Copyright @edy555", x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Licensed under GPL. See: https://github.com/ttrftech/NanoVNA", x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Version: " VERSION, x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Build Time: " __DATE__ " - " __TIME__, x, y += 10, 0xffff, 0x0000); + ili9341_drawstring("2016-2019 Copyright @edy555", x, y += 10); + ili9341_drawstring("Licensed under GPL. See: https://github.com/ttrftech/NanoVNA", x, y += 10); + ili9341_drawstring("Version: " VERSION, x, y += 10); + ili9341_drawstring("Build Time: " __DATE__ " - " __TIME__, x, y += 10); y += 5; - ili9341_drawstring_5x7("Kernel: " CH_KERNEL_VERSION, x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Compiler: " PORT_COMPILER_NAME, x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: " PORT_CORE_VARIANT_NAME, x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Port Info: " PORT_INFO, x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("Platform: " PLATFORM_NAME, x, y += 10, 0xffff, 0x0000); + ili9341_drawstring("Kernel: " CH_KERNEL_VERSION, x, y += 10); + ili9341_drawstring("Compiler: " PORT_COMPILER_NAME, x, y += 10); + ili9341_drawstring("Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: " PORT_CORE_VARIANT_NAME, x, y += 10); + ili9341_drawstring("Port Info: " PORT_INFO, x, y += 10); + ili9341_drawstring("Platform: " PLATFORM_NAME, x, y += 10); while (true) { if (touch_check() == EVT_TOUCH_PRESSED) @@ -420,11 +427,12 @@ enter_dfu(void) adc_stop(ADC1); int x = 5, y = 5; - + setForegroundColor(DEFAULT_FG_COLOR); + setBackgroundColor(DEFAULT_BG_COLOR); // leave a last message - ili9341_fill(0, 0, 320, 240, 0); - ili9341_drawstring_5x7("DFU: Device Firmware Update Mode", x, y += 10, 0xffff, 0x0000); - ili9341_drawstring_5x7("To exit DFU mode, please reset device yourself.", x, y += 10, 0xffff, 0x0000); + ili9341_fill(0, 0, 320, 240, DEFAULT_BG_COLOR); + ili9341_drawstring("DFU: Device Firmware Update Mode", x, y += 10); + ili9341_drawstring("To exit DFU mode, please reset device yourself.", x, y += 10); // see __early_init in ./NANOVNA_STM32_F072/board.c *((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) = BOOT_FROM_SYTEM_MEMORY_MAGIC; @@ -442,43 +450,28 @@ enum { MT_CLOSE }; -typedef void (*menuaction_cb_t)(int item); +typedef void (*menuaction_cb_t)(int item, uint8_t data); static void menu_move_back(void); static void -menu_calop_cb(int item) +menu_calop_cb(int item, uint8_t data) { - switch (item) { - case 0: // OPEN - cal_collect(CAL_OPEN); - break; - case 1: // SHORT - cal_collect(CAL_SHORT); - break; - case 2: // LOAD - cal_collect(CAL_LOAD); - break; - case 3: // ISOLN - cal_collect(CAL_ISOLN); - break; - case 4: // THRU - cal_collect(CAL_THRU); - break; - } + cal_collect(data); selection = item+1; draw_cal_status(); draw_menu(); } static void -menu_caldone_cb(int item) +menu_caldone_cb(int item, uint8_t data) { extern const menuitem_t menu_save[]; //extern const menuitem_t menu_cal[]; (void)item; + (void)data; cal_done(); draw_cal_status(); menu_move_back(); @@ -486,16 +479,16 @@ menu_caldone_cb(int item) } static void -menu_cal2_cb(int item) +menu_cal2_cb(int item, uint8_t data) { + (void)data; switch (item) { case 2: // RESET cal_status = 0; break; case 3: // CORRECTION // toggle applying correction - if (cal_status) - cal_status ^= CALSTAT_APPLY; + cal_status ^= CALSTAT_APPLY; draw_menu(); break; } @@ -504,11 +497,10 @@ menu_cal2_cb(int item) } static void -menu_recall_cb(int item) +menu_recall_cb(int item, uint8_t data) { - if (item < 0 || item >= 5) - return; - if (caldata_recall(item) == 0) { + (void)item; + if (caldata_recall(data) == 0) { menu_move_back(); ui_mode_normal(); update_grid(); @@ -517,8 +509,9 @@ menu_recall_cb(int item) } static void -menu_config_cb(int item) +menu_config_cb(int item, uint8_t data) { + (void)data; switch (item) { case 0: touch_cal_exec(); @@ -546,20 +539,18 @@ menu_config_cb(int item) } static void -menu_dfu_cb(int item) +menu_dfu_cb(int item, uint8_t data) { - switch (item) { - case 0: - enter_dfu(); - } + (void)item; + (void)data; + enter_dfu(); } static void -menu_save_cb(int item) +menu_save_cb(int item, uint8_t data) { - if (item < 0 || item >= 5) - return; - if (caldata_save(item) == 0) { + (void)item; + if (caldata_save(data) == 0) { menu_move_back(); ui_mode_normal(); draw_cal_status(); @@ -581,21 +572,19 @@ choose_active_trace(void) } static void -menu_trace_cb(int item) +menu_trace_cb(int item, uint8_t data) { - if (item < 0 || item >= 4) - return; - if (trace[item].enabled) { - if (item == uistat.current_trace) { + if (trace[data].enabled) { + if (data == uistat.current_trace) { // disable if active trace is selected - trace[item].enabled = FALSE; + trace[data].enabled = FALSE; choose_active_trace(); } else { // make active selected trace uistat.current_trace = item; } } else { - trace[item].enabled = TRUE; + trace[data].enabled = TRUE; uistat.current_trace = item; } request_to_redraw_grid(); @@ -603,127 +592,64 @@ menu_trace_cb(int item) } static void -menu_format_cb(int item) +menu_format_cb(int item, uint8_t data) { - switch (item) { - case 0: - set_trace_type(uistat.current_trace, TRC_LOGMAG); - break; - case 1: - set_trace_type(uistat.current_trace, TRC_PHASE); - break; - case 2: - set_trace_type(uistat.current_trace, TRC_DELAY); - break; - case 3: - set_trace_type(uistat.current_trace, TRC_SMITH); - break; - case 4: - set_trace_type(uistat.current_trace, TRC_SWR); - break; - } - + (void)item; + set_trace_type(uistat.current_trace, data); request_to_redraw_grid(); ui_mode_normal(); //redraw_all(); } static void -menu_format2_cb(int item) +menu_channel_cb(int item, uint8_t data) { - switch (item) { - case 0: - set_trace_type(uistat.current_trace, TRC_POLAR); - break; - case 1: - set_trace_type(uistat.current_trace, TRC_LINEAR); - break; - case 2: - set_trace_type(uistat.current_trace, TRC_REAL); - break; - case 3: - set_trace_type(uistat.current_trace, TRC_IMAG); - break; - case 4: - set_trace_type(uistat.current_trace, TRC_R); - break; - case 5: - set_trace_type(uistat.current_trace, TRC_X); - break; - } - - request_to_redraw_grid(); - ui_mode_normal(); -} - -static void -menu_channel_cb(int item) -{ - if (item < 0 || item >= 2) - return; - set_trace_channel(uistat.current_trace, item); + (void)item; + set_trace_channel(uistat.current_trace, data); menu_move_back(); ui_mode_normal(); } static void -menu_transform_window_cb(int item) +menu_transform_window_cb(int item, uint8_t data) { + (void)item; // TODO - switch (item) { - case 0: - domain_mode = (domain_mode & ~TD_WINDOW) | TD_WINDOW_MINIMUM; - ui_mode_normal(); - break; - case 1: - domain_mode = (domain_mode & ~TD_WINDOW) | TD_WINDOW_NORMAL; - ui_mode_normal(); - break; - case 2: - domain_mode = (domain_mode & ~TD_WINDOW) | TD_WINDOW_MAXIMUM; - ui_mode_normal(); - break; + domain_mode = (domain_mode & ~TD_WINDOW) | data; + ui_mode_normal(); +} + +static void +menu_transform_cb(int item, uint8_t data) +{ + (void)item; + (void)data; + domain_mode ^= DOMAIN_TIME; + uistat.lever_mode = LM_MARKER; + draw_frequencies(); + ui_mode_normal(); +} + +static void +menu_velocity_cb(int item, uint8_t data){ + (void)item; + (void)data; + int status = btn_wait_release(); + if (status & EVT_BUTTON_DOWN_LONG) { + ui_mode_numeric(KM_VELOCITY_FACTOR); + ui_process_numeric(); + } else { + ui_mode_keypad(KM_VELOCITY_FACTOR); + ui_process_keypad(); } } static void -menu_transform_cb(int item) +menu_transform_filter_cb(int item, uint8_t data) { - int status; - switch (item) { - case 0: - if ((domain_mode & DOMAIN_MODE) == DOMAIN_TIME) { - domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_FREQ; - } else { - domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_TIME; - } - uistat.lever_mode = LM_MARKER; - draw_frequencies(); - ui_mode_normal(); - break; - case 1: - domain_mode = (domain_mode & ~TD_FUNC) | TD_FUNC_LOWPASS_IMPULSE; - ui_mode_normal(); - break; - case 2: - domain_mode = (domain_mode & ~TD_FUNC) | TD_FUNC_LOWPASS_STEP; - ui_mode_normal(); - break; - case 3: - domain_mode = (domain_mode & ~TD_FUNC) | TD_FUNC_BANDPASS; - ui_mode_normal(); - break; - case 5: - status = btn_wait_release(); - if (status & EVT_BUTTON_DOWN_LONG) { - ui_mode_numeric(KM_VELOCITY_FACTOR); - ui_process_numeric(); - } else { - ui_mode_keypad(KM_VELOCITY_FACTOR); - ui_process_keypad(); - } - break; - } + (void)item; + domain_mode = (domain_mode & ~TD_FUNC) | data; + ui_mode_normal(); } static void @@ -739,26 +665,26 @@ choose_active_marker(void) } static void -menu_scale_cb(int item) +menu_scale_cb(int item, uint8_t data) { - int status; - int km = KM_SCALE + item; - if (km == KM_SCALE && trace[uistat.current_trace].type == TRC_DELAY) { - km = KM_SCALEDELAY; + (void)item; + if (data == KM_SCALE && trace[uistat.current_trace].type == TRC_DELAY) { + data = KM_SCALEDELAY; } - status = btn_wait_release(); + int status = btn_wait_release(); if (status & EVT_BUTTON_DOWN_LONG) { - ui_mode_numeric(km); + ui_mode_numeric(data); ui_process_numeric(); } else { - ui_mode_keypad(km); + ui_mode_keypad(data); ui_process_keypad(); } } static void -menu_stimulus_cb(int item) +menu_stimulus_cb(int item, uint8_t data) { + (void)data; int status; switch (item) { case 0: /* START */ @@ -797,8 +723,9 @@ get_marker_frequency(int marker) } static void -menu_marker_op_cb(int item) +menu_marker_op_cb(int item, uint8_t data) { + (void)data; int32_t freq = get_marker_frequency(active_marker); if (freq < 0) return; // no active marker @@ -851,8 +778,9 @@ menu_marker_op_cb(int item) } static void -menu_marker_search_cb(int item) +menu_marker_search_cb(int item, uint8_t data) { + (void)data; int i; if (active_marker == -1) return; @@ -888,9 +816,10 @@ menu_marker_search_cb(int item) } static void -menu_marker_smith_cb(int item) +menu_marker_smith_cb(int item, uint8_t data) { - marker_smith_format = item; + (void)item; + marker_smith_format = data; redraw_marker(active_marker, TRUE); draw_menu(); } @@ -912,8 +841,9 @@ active_marker_select(int item) } static void -menu_marker_sel_cb(int item) +menu_marker_sel_cb(int item, uint8_t data) { + (void)data; if (item >= 0 && item < 4) { if (markers[item].enabled) { if (item == active_marker) { @@ -943,215 +873,215 @@ menu_marker_sel_cb(int item) } const menuitem_t menu_calop[] = { - { MT_CALLBACK, "OPEN", menu_calop_cb }, - { MT_CALLBACK, "SHORT", menu_calop_cb }, - { MT_CALLBACK, "LOAD", menu_calop_cb }, - { MT_CALLBACK, "ISOLN", menu_calop_cb }, - { MT_CALLBACK, "THRU", menu_calop_cb }, - { MT_CALLBACK, "DONE", menu_caldone_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, CAL_OPEN, "OPEN", menu_calop_cb }, + { MT_CALLBACK, CAL_SHORT, "SHORT", menu_calop_cb }, + { MT_CALLBACK, CAL_LOAD, "LOAD", menu_calop_cb }, + { MT_CALLBACK, CAL_ISOLN, "ISOLN", menu_calop_cb }, + { MT_CALLBACK, CAL_THRU, "THRU", menu_calop_cb }, + { MT_CALLBACK, 0, "DONE", menu_caldone_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_save[] = { - { MT_CALLBACK, "SAVE 0", menu_save_cb }, - { MT_CALLBACK, "SAVE 1", menu_save_cb }, - { MT_CALLBACK, "SAVE 2", menu_save_cb }, - { MT_CALLBACK, "SAVE 3", menu_save_cb }, - { MT_CALLBACK, "SAVE 4", menu_save_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "SAVE 0", menu_save_cb }, + { MT_CALLBACK, 1, "SAVE 1", menu_save_cb }, + { MT_CALLBACK, 2, "SAVE 2", menu_save_cb }, + { MT_CALLBACK, 3, "SAVE 3", menu_save_cb }, + { MT_CALLBACK, 4, "SAVE 4", menu_save_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_cal[] = { - { MT_SUBMENU, "CALIBRATE", menu_calop }, - { MT_SUBMENU, "SAVE", menu_save }, - { MT_CALLBACK, "RESET", menu_cal2_cb }, - { MT_CALLBACK, "CORRECTION", menu_cal2_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_SUBMENU, 0, "CALIBRATE", menu_calop }, + { MT_SUBMENU, 0, "SAVE", menu_save }, + { MT_CALLBACK, 0, "RESET", menu_cal2_cb }, + { MT_CALLBACK, 0, "CORRECTION", menu_cal2_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_trace[] = { - { MT_CALLBACK, "TRACE 0", menu_trace_cb }, - { MT_CALLBACK, "TRACE 1", menu_trace_cb }, - { MT_CALLBACK, "TRACE 2", menu_trace_cb }, - { MT_CALLBACK, "TRACE 3", menu_trace_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "TRACE 0", menu_trace_cb }, + { MT_CALLBACK, 1, "TRACE 1", menu_trace_cb }, + { MT_CALLBACK, 2, "TRACE 2", menu_trace_cb }, + { MT_CALLBACK, 3, "TRACE 3", menu_trace_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_format2[] = { - { MT_CALLBACK, "POLAR", menu_format2_cb }, - { MT_CALLBACK, "LINEAR", menu_format2_cb }, - { MT_CALLBACK, "REAL", menu_format2_cb }, - { MT_CALLBACK, "IMAG", menu_format2_cb }, - { MT_CALLBACK, "RESISTANCE", menu_format2_cb }, - { MT_CALLBACK, "REACTANCE", menu_format2_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, TRC_POLAR, "POLAR", menu_format_cb }, + { MT_CALLBACK, TRC_LINEAR, "LINEAR", menu_format_cb }, + { MT_CALLBACK, TRC_REAL, "REAL", menu_format_cb }, + { MT_CALLBACK, TRC_IMAG, "IMAG", menu_format_cb }, + { MT_CALLBACK, TRC_R, "RESISTANCE", menu_format_cb }, + { MT_CALLBACK, TRC_X, "REACTANCE", menu_format_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_format[] = { - { MT_CALLBACK, "LOGMAG", menu_format_cb }, - { MT_CALLBACK, "PHASE", menu_format_cb }, - { MT_CALLBACK, "DELAY", menu_format_cb }, - { MT_CALLBACK, "SMITH", menu_format_cb }, - { MT_CALLBACK, "SWR", menu_format_cb }, - { MT_SUBMENU, S_RARROW" MORE", menu_format2 }, - //{ MT_CALLBACK, "LINEAR", menu_format_cb }, - //{ MT_CALLBACK, "SWR", menu_format_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, TRC_LOGMAG, "LOGMAG", menu_format_cb }, + { MT_CALLBACK, TRC_PHASE, "PHASE", menu_format_cb }, + { MT_CALLBACK, TRC_DELAY, "DELAY", menu_format_cb }, + { MT_CALLBACK, TRC_SMITH, "SMITH", menu_format_cb }, + { MT_CALLBACK, TRC_SWR, "SWR", menu_format_cb }, + { MT_SUBMENU, 0, S_RARROW" MORE", menu_format2 }, + //{ MT_CALLBACK, TRC_LINEAR, "LINEAR", menu_format_cb }, + //{ MT_CALLBACK, TRC_SWR, "SWR", menu_format_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_scale[] = { - { MT_CALLBACK, "SCALE/DIV", menu_scale_cb }, - { MT_CALLBACK, "\2REFERENCE\0POSITION", menu_scale_cb }, - { MT_CALLBACK, "\2ELECTRICAL\0DELAY", menu_scale_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, KM_SCALE, "SCALE/DIV", menu_scale_cb }, + { MT_CALLBACK, KM_REFPOS, "\2REFERENCE\0POSITION", menu_scale_cb }, + { MT_CALLBACK, KM_EDELAY, "\2ELECTRICAL\0DELAY", menu_scale_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_channel[] = { - { MT_CALLBACK, "\2CH0\0REFLECT", menu_channel_cb }, - { MT_CALLBACK, "\2CH1\0THROUGH", menu_channel_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "\2CH0\0REFLECT", menu_channel_cb }, + { MT_CALLBACK, 1, "\2CH1\0THROUGH", menu_channel_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_transform_window[] = { - { MT_CALLBACK, "MINIMUM", menu_transform_window_cb }, - { MT_CALLBACK, "NORMAL", menu_transform_window_cb }, - { MT_CALLBACK, "MAXIMUM", menu_transform_window_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, TD_WINDOW_MINIMUM, "MINIMUM", menu_transform_window_cb }, + { MT_CALLBACK, TD_WINDOW_NORMAL, "NORMAL", menu_transform_window_cb }, + { MT_CALLBACK, TD_WINDOW_MAXIMUM, "MAXIMUM", menu_transform_window_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_transform[] = { - { MT_CALLBACK, "\2TRANSFORM\0ON", menu_transform_cb }, - { MT_CALLBACK, "\2LOW PASS\0IMPULSE", menu_transform_cb }, - { MT_CALLBACK, "\2LOW PASS\0STEP", menu_transform_cb }, - { MT_CALLBACK, "BANDPASS", menu_transform_cb }, - { MT_SUBMENU, "WINDOW", menu_transform_window }, - { MT_CALLBACK, "\2VELOCITY\0FACTOR", menu_transform_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "\2TRANSFORM\0ON", menu_transform_cb }, + { MT_CALLBACK, TD_FUNC_LOWPASS_IMPULSE, "\2LOW PASS\0IMPULSE", menu_transform_filter_cb }, + { MT_CALLBACK, TD_FUNC_LOWPASS_STEP, "\2LOW PASS\0STEP", menu_transform_filter_cb }, + { MT_CALLBACK, TD_FUNC_BANDPASS, "BANDPASS", menu_transform_filter_cb }, + { MT_SUBMENU, 0, "WINDOW", menu_transform_window }, + { MT_CALLBACK, 0, "\2VELOCITY\0FACTOR", menu_velocity_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_display[] = { - { MT_SUBMENU, "TRACE", menu_trace }, - { MT_SUBMENU, "FORMAT", menu_format }, - { MT_SUBMENU, "SCALE", menu_scale }, - { MT_SUBMENU, "CHANNEL", menu_channel }, - { MT_SUBMENU, "TRANSFORM", menu_transform }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_SUBMENU, 0, "TRACE", menu_trace }, + { MT_SUBMENU, 0, "FORMAT", menu_format }, + { MT_SUBMENU, 0, "SCALE", menu_scale }, + { MT_SUBMENU, 0, "CHANNEL", menu_channel }, + { MT_SUBMENU, 0, "TRANSFORM", menu_transform }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_stimulus[] = { - { MT_CALLBACK, "START", menu_stimulus_cb }, - { MT_CALLBACK, "STOP", menu_stimulus_cb }, - { MT_CALLBACK, "CENTER", menu_stimulus_cb }, - { MT_CALLBACK, "SPAN", menu_stimulus_cb }, - { MT_CALLBACK, "CW FREQ", menu_stimulus_cb }, - { MT_CALLBACK, "\2PAUSE\0SWEEP", menu_stimulus_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "START", menu_stimulus_cb }, + { MT_CALLBACK, 0, "STOP", menu_stimulus_cb }, + { MT_CALLBACK, 0, "CENTER", menu_stimulus_cb }, + { MT_CALLBACK, 0, "SPAN", menu_stimulus_cb }, + { MT_CALLBACK, 0, "CW FREQ", menu_stimulus_cb }, + { MT_CALLBACK, 0, "\2PAUSE\0SWEEP", menu_stimulus_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_marker_sel[] = { - { MT_CALLBACK, "MARKER 1", menu_marker_sel_cb }, - { MT_CALLBACK, "MARKER 2", menu_marker_sel_cb }, - { MT_CALLBACK, "MARKER 3", menu_marker_sel_cb }, - { MT_CALLBACK, "MARKER 4", menu_marker_sel_cb }, - { MT_CALLBACK, "ALL OFF", menu_marker_sel_cb }, - { MT_CALLBACK, "DELTA", menu_marker_sel_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 1, "MARKER 1", menu_marker_sel_cb }, + { MT_CALLBACK, 2, "MARKER 2", menu_marker_sel_cb }, + { MT_CALLBACK, 3, "MARKER 3", menu_marker_sel_cb }, + { MT_CALLBACK, 4, "MARKER 4", menu_marker_sel_cb }, + { MT_CALLBACK, 0, "ALL OFF", menu_marker_sel_cb }, + { MT_CALLBACK, 0, "DELTA", menu_marker_sel_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_marker_ops[] = { - { MT_CALLBACK, S_RARROW"START", menu_marker_op_cb }, - { MT_CALLBACK, S_RARROW"STOP", menu_marker_op_cb }, - { MT_CALLBACK, S_RARROW"CENTER", menu_marker_op_cb }, - { MT_CALLBACK, S_RARROW"SPAN", menu_marker_op_cb }, - { MT_CALLBACK, S_RARROW"EDELAY", menu_marker_op_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, S_RARROW"START", menu_marker_op_cb }, + { MT_CALLBACK, 0, S_RARROW"STOP", menu_marker_op_cb }, + { MT_CALLBACK, 0, S_RARROW"CENTER", menu_marker_op_cb }, + { MT_CALLBACK, 0, S_RARROW"SPAN", menu_marker_op_cb }, + { MT_CALLBACK, 0, S_RARROW"EDELAY", menu_marker_op_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_marker_search[] = { //{ MT_CALLBACK, "OFF", menu_marker_search_cb }, - { MT_CALLBACK, "MAXIMUM", menu_marker_search_cb }, - { MT_CALLBACK, "MINIMUM", menu_marker_search_cb }, - { MT_CALLBACK, "\2SEARCH\0" S_LARROW" LEFT", menu_marker_search_cb }, - { MT_CALLBACK, "\2SEARCH\0" S_RARROW" RIGHT", menu_marker_search_cb }, - { MT_CALLBACK, "TRACKING", menu_marker_search_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "MAXIMUM", menu_marker_search_cb }, + { MT_CALLBACK, 0, "MINIMUM", menu_marker_search_cb }, + { MT_CALLBACK, 0, "\2SEARCH\0" S_LARROW" LEFT", menu_marker_search_cb }, + { MT_CALLBACK, 0, "\2SEARCH\0" S_RARROW" RIGHT", menu_marker_search_cb }, + { MT_CALLBACK, 0, "TRACKING", menu_marker_search_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_marker_smith[] = { - { MT_CALLBACK, "LIN", menu_marker_smith_cb }, - { MT_CALLBACK, "LOG", menu_marker_smith_cb }, - { MT_CALLBACK, "Re+Im", menu_marker_smith_cb }, - { MT_CALLBACK, "R+Xj", menu_marker_smith_cb }, - { MT_CALLBACK, "R+L/C", menu_marker_smith_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, MS_LIN, "LIN", menu_marker_smith_cb }, + { MT_CALLBACK, MS_LOG, "LOG", menu_marker_smith_cb }, + { MT_CALLBACK, MS_REIM,"Re+Im", menu_marker_smith_cb }, + { MT_CALLBACK, MS_RX, "R+Xj", menu_marker_smith_cb }, + { MT_CALLBACK, MS_RLC, "R+L/C", menu_marker_smith_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_marker[] = { - { MT_SUBMENU, "\2SELECT\0MARKER", menu_marker_sel }, - { MT_SUBMENU, "SEARCH", menu_marker_search }, - { MT_SUBMENU, "OPERATIONS", menu_marker_ops }, - { MT_SUBMENU, "\2SMITH\0VALUE", menu_marker_smith }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_SUBMENU, 0, "\2SELECT\0MARKER", menu_marker_sel }, + { MT_SUBMENU, 0, "SEARCH", menu_marker_search }, + { MT_SUBMENU, 0, "OPERATIONS", menu_marker_ops }, + { MT_SUBMENU, 0, "\2SMITH\0VALUE", menu_marker_smith }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_recall[] = { - { MT_CALLBACK, "RECALL 0", menu_recall_cb }, - { MT_CALLBACK, "RECALL 1", menu_recall_cb }, - { MT_CALLBACK, "RECALL 2", menu_recall_cb }, - { MT_CALLBACK, "RECALL 3", menu_recall_cb }, - { MT_CALLBACK, "RECALL 4", menu_recall_cb }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "RECALL 0", menu_recall_cb }, + { MT_CALLBACK, 1, "RECALL 1", menu_recall_cb }, + { MT_CALLBACK, 2, "RECALL 2", menu_recall_cb }, + { MT_CALLBACK, 3, "RECALL 3", menu_recall_cb }, + { MT_CALLBACK, 4, "RECALL 4", menu_recall_cb }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_dfu[] = { - { MT_CALLBACK, "\2RESET AND\0ENTER DFU", menu_dfu_cb }, - { MT_CANCEL, S_LARROW"CANCEL", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "\2RESET AND\0ENTER DFU", menu_dfu_cb }, + { MT_CANCEL, 0, S_LARROW"CANCEL", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_config[] = { - { MT_CALLBACK, "TOUCH CAL", menu_config_cb }, - { MT_CALLBACK, "TOUCH TEST", menu_config_cb }, - { MT_CALLBACK, "SAVE", menu_config_cb }, - { MT_CALLBACK, "VERSION", menu_config_cb }, - { MT_SUBMENU, S_RARROW"DFU", menu_dfu }, - { MT_CANCEL, S_LARROW" BACK", NULL }, - { MT_NONE, NULL, NULL } // sentinel + { MT_CALLBACK, 0, "TOUCH CAL", menu_config_cb }, + { MT_CALLBACK, 0, "TOUCH TEST", menu_config_cb }, + { MT_CALLBACK, 0, "SAVE", menu_config_cb }, + { MT_CALLBACK, 0, "VERSION", menu_config_cb }, + { MT_SUBMENU, 0, S_RARROW"DFU", menu_dfu }, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_top[] = { - { MT_SUBMENU, "DISPLAY", menu_display }, - { MT_SUBMENU, "MARKER", menu_marker }, - { MT_SUBMENU, "STIMULUS", menu_stimulus }, - { MT_SUBMENU, "CAL", menu_cal }, - { MT_SUBMENU, "RECALL", menu_recall }, - { MT_SUBMENU, "CONFIG", menu_config }, - { MT_NONE, NULL, NULL } // sentinel + { MT_SUBMENU, 0, "DISPLAY", menu_display }, + { MT_SUBMENU, 0, "MARKER", menu_marker }, + { MT_SUBMENU, 0, "STIMULUS", menu_stimulus }, + { MT_SUBMENU, 0, "CAL", menu_cal }, + { MT_SUBMENU, 0, "RECALL", menu_recall }, + { MT_SUBMENU, 0, "CONFIG", menu_config }, + { MT_NONE, 0, NULL, NULL } // sentinel }; #define MENU_STACK_DEPTH_MAX 4 uint8_t menu_current_level = 0; const menuitem_t *menu_stack[4] = { - menu_top, NULL, NULL, NULL + menu_top, 0, NULL, NULL, NULL }; static void @@ -1217,7 +1147,7 @@ void menu_invoke(int item) menuaction_cb_t cb = (menuaction_cb_t)menu->reference; if (cb == NULL) return; - (*cb)(item); + (*cb)(item, menu->data); break; } @@ -1333,8 +1263,10 @@ draw_keypad(void) uint16_t bg = config.menu_normal_color; if (i == selection) bg = config.menu_active_color; + setForegroundColor(DEFAULT_MENU_TEXT_COLOR); + setBackgroundColor(bg); ili9341_fill(keypads[i].x, keypads[i].y, 44, 44, bg); - ili9341_drawfont(keypads[i].c, &NF20x22, keypads[i].x+12, keypads[i].y+10, 0x0000, bg); + ili9341_drawfont(keypads[i].c, keypads[i].x+14, keypads[i].y+10); i++; } } @@ -1342,9 +1274,11 @@ draw_keypad(void) void draw_numeric_area_frame(void) { - ili9341_fill(0, 208, 320, 32, 0xffff); - ili9341_drawstring_5x7(keypad_mode_label[keypad_mode], 10, 220, 0x0000, 0xffff); - //ili9341_drawfont(KP_KEYPAD, &NF20x22, 300, 216, 0x0000, 0xffff); + ili9341_fill(0, 208, 320, 32, DEFAULT_MENU_COLOR); + setForegroundColor(DEFAULT_MENU_TEXT_COLOR); + setBackgroundColor(DEFAULT_MENU_COLOR); + ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 220); + //ili9341_drawfont(KP_KEYPAD, 300, 216); } void @@ -1353,10 +1287,11 @@ draw_numeric_input(const char *buf) int i = 0; int x = 64; int focused = FALSE; - const uint16_t xsim[] = { 0, 0, 8, 0, 0, 8, 0, 0, 0, 0 }; - for (i = 0; i < 10 && buf[i]; i++) { - uint16_t fg = 0x0000; - uint16_t bg = 0xffff; + uint16_t xsim = 0b0010010000000000; + + for (i = 0; i < 10 && buf[i]; i++, xsim<<=1) { + uint16_t fg = DEFAULT_MENU_TEXT_COLOR; + uint16_t bg = DEFAULT_MENU_COLOR; int c = buf[i]; if (c == '.') c = KP_PERIOD; @@ -1371,24 +1306,21 @@ draw_numeric_input(const char *buf) fg = RGB565(128,255,128); focused = TRUE; if (uistat.digit_mode) - bg = 0x0000; + bg = DEFAULT_MENU_COLOR; } - + setForegroundColor(fg); + setBackgroundColor(bg); if (c >= 0) - ili9341_drawfont(c, &NF20x22, x, 208+4, fg, bg); + ili9341_drawfont(c, x, 208+4); else if (focused) - ili9341_drawfont(0, &NF20x22, x, 208+4, fg, bg); + ili9341_drawfont(0, x, 208+4); else ili9341_fill(x, 208+4, 20, 24, bg); - x += 20; - if (xsim[i] > 0) { - //ili9341_fill(x, 208+4, xsim[i], 20, bg); - x += xsim[i]; - } + x += xsim&0x8000 ? 18+8 : 18; } if (i < 10) { - ili9341_fill(x, 208+4, 20*(10-i), 24, 0xffff); + ili9341_fill(x, 208+4, 20*(10-i), 24, DEFAULT_MENU_COLOR); } } @@ -1413,24 +1345,25 @@ menu_item_modify_attribute(const menuitem_t *menu, int item, } else if (menu == menu_marker_sel) { if (item < 4) { if (markers[item].enabled) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (item == 5) { if (uistat.marker_delta) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } } else if (menu == menu_marker_search) { if (item == 4 && marker_tracking) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (menu == menu_marker_smith) { + if (marker_smith_format == item) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (menu == menu_calop) { if ((item == 0 && (cal_status & CALSTAT_OPEN)) @@ -1439,18 +1372,18 @@ menu_item_modify_attribute(const menuitem_t *menu, int item, || (item == 3 && (cal_status & CALSTAT_ISOLN)) || (item == 4 && (cal_status & CALSTAT_THRU))) { domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_FREQ; - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (menu == menu_stimulus) { if (item == 5 /* PAUSE */ && !sweep_enabled) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (menu == menu_cal) { if (item == 3 /* CORRECTION */ && (cal_status & CALSTAT_APPLY)) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (menu == menu_transform) { if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME) @@ -1458,16 +1391,16 @@ menu_item_modify_attribute(const menuitem_t *menu, int item, || (item == 2 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP) || (item == 3 && (domain_mode & TD_FUNC) == TD_FUNC_BANDPASS) ) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } else if (menu == menu_transform_window) { if ((item == 0 && (domain_mode & TD_WINDOW) == TD_WINDOW_MINIMUM) || (item == 1 && (domain_mode & TD_WINDOW) == TD_WINDOW_NORMAL) || (item == 2 && (domain_mode & TD_WINDOW) == TD_WINDOW_MAXIMUM) ) { - *bg = 0x0000; - *fg = 0xffff; + *bg = DEFAULT_MENU_TEXT_COLOR; + *fg = config.menu_normal_color; } } } @@ -1484,18 +1417,22 @@ draw_menu_buttons(const menuitem_t *menu) continue; int y = 32*i; uint16_t bg = config.menu_normal_color; - uint16_t fg = 0x0000; + uint16_t fg = DEFAULT_MENU_TEXT_COLOR; // focus only in MENU mode but not in KEYPAD mode if (ui_mode == UI_MENU && i == selection) bg = config.menu_active_color; ili9341_fill(320-60, y, 60, 30, bg); menu_item_modify_attribute(menu, i, &fg, &bg); + setForegroundColor(fg); + setBackgroundColor(bg); if (menu_is_multiline(menu[i].label, &l1, &l2)) { - ili9341_drawstring_5x7(l1, 320-54, y+8, fg, bg); - ili9341_drawstring_5x7(l2, 320-54, y+15, fg, bg); + ili9341_fill(320-57, y+6, 54, 19, bg); + ili9341_drawstring(l1, 320-55, y+8); + ili9341_drawstring(l2, 320-55, y+16); } else { - ili9341_drawstring_5x7(menu[i].label, 320-54, y+12, fg, bg); + ili9341_fill(320-57, y+10, 54, 11, bg); + ili9341_drawstring(menu[i].label, 320-55, y+12); } } } @@ -1544,8 +1481,7 @@ draw_menu(void) void erase_menu_buttons(void) { - uint16_t bg = 0; - ili9341_fill(320-60, 0, 60, 32*7, bg); + ili9341_fill(320-60, 0, 60, 32*7, DEFAULT_BG_COLOR); } void @@ -1665,7 +1601,7 @@ ui_mode_menu(void) ui_mode = UI_MENU; /* narrowen plotting area */ area_width = AREA_WIDTH_NORMAL - (64-8); - area_height = HEIGHT; + area_height = HEIGHT+1; ensure_selection(); draw_menu(); } @@ -1719,7 +1655,7 @@ ui_mode_normal(void) return; area_width = AREA_WIDTH_NORMAL; - area_height = HEIGHT; + area_height = HEIGHT+1; leave_ui_mode(); ui_mode = UI_NORMAL; }