From: Robin Krens Date: Thu, 19 Sep 2019 16:17:49 +0000 (+0700) Subject: st7735s: font bitmaps and scrolling update (needs review) X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=1c7f68919de4c9b41241486a76d58246995dc4f6;p=cortex-from-scratch st7735s: font bitmaps and scrolling update (needs review) --- diff --git a/drivers/st7735s.c b/drivers/st7735s.c index 9676738..c99156f 100644 --- a/drivers/st7735s.c +++ b/drivers/st7735s.c @@ -23,6 +23,7 @@ #include #include +#include #include #define TIMEOUT 500 @@ -210,20 +211,34 @@ int tft_scroll() { /* Scroll the buffer */ memcpy(tftscreen.textmemptr, tftscreen.textmemptr + 21, BUFFER - 21); - for (int i = 21; i >= 0; i--) - tftscreen.buf[BUFFER - 21] = '\0'; + //for (int i = 21; i >= 0; i--) + tftscreen.buf[BUFFER - 21] = '\0'; tftscreen.x = 0; tftscreen.y = 0; tftscreen.cpos = 0; - + + //for (int i = 0; i < 320; i++) { + // uart_putc(tftscreen.buf[i]); + //} + tft_puts(tftscreen.buf); // CHECK: ending - tft_clrln(); + //tftscreen.y = 14; + //tft_puts(" "); + tftscreen.y = 14; + tftscreen.x = 0; + tftscreen.cpos = BUFFER - 21; + // DINOSAUR tft_clrln(); } -void tft_linefill() { +void tft_nl() { - // TODO + uint8_t blanks = 21 - tftscreen.x; + + // filler with blank spaces + for (int i = 0; i < blanks; i++) { + tft_putc(0xFFFF, 0x0000, ' '); + } } @@ -237,8 +252,38 @@ int tft_putc(uint16_t fg, uint16_t bg, int c) { int row = 0; uint8_t current; + + //if ((c == '\n') && (tftscreen.y == 14)) { + // tft_nl(); + // tft_scroll2(); + // return 1; + //} + + if (c == '\n') { + if (tftscreen.y == 14) { + tft_nl(); + return 1; + } + else { + tft_nl(); + //if (tftscreen.y < 15) + return 1; + } + } + //// else { + //// tft_putc(0xFFFF, 0x0000, 'o'); + //// } + // //else { + // // ENDFLAG = true; + // //} + //} + if (tftscreen.y >= 15) { tft_scroll(); + //if (ENDFLAG) { + // ENDFLAG = false; + // return 1; + //} } tft_command(TFT_CASET, 4, 0x00, STARTX + XPOS(tftscreen.x), 0x00, (STARTX + 4) + XPOS(tftscreen.x)); diff --git a/include/lib/fonts/wogfont.h b/include/lib/fonts/wogfont.h new file mode 100644 index 0000000..28cb942 --- /dev/null +++ b/include/lib/fonts/wogfont.h @@ -0,0 +1,143 @@ +/* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL + * + * $LOG$ + * 2019/9/18 - ROBIN KRENS + * Initial version + * + * $DESCRIPTION$ + * The classic wogfont is back! + * Designed by Robin Krens + * 5 by 7 bit font (lower case) + * */ + +const uint8_t ASCII5x7[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, // NULL + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, // SPACE + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // ! + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x28, 0x7C, 0x28, 0x7C, 0x28, // # definitely needed for terminal :D + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x02, 0x00, 0x00, 0x00, // . + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // / + 0xFE, 0x82, 0x92, 0x82, 0xFE, // 0 + 0x00, 0x00, 0x82, 0xFE, 0x02, // 1 + 0xDE, 0x92, 0x92, 0x92, 0xF2, // 2 + 0xC6, 0x92, 0x92, 0x92, 0xFE, // 3 + 0xF8, 0x08, 0x08, 0x08, 0xFE, // 4 + 0xF6, 0x92, 0x92, 0x92, 0x9E, // 5 + 0xFE, 0x92, 0x92, 0x92, 0xDE, // 6 + 0xC0, 0x80, 0x80, 0x80, 0xFE, // 7 + 0xFE, 0x92, 0x92, 0x92, 0xFE, // 8 + 0xF6, 0x92, 0x92, 0x92, 0xFE, // 9 + 0x00, 0x44, 0x00, 0x00, 0x00, //: + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x7E, 0x88, 0x88, 0x88, 0x7E, // upper case A + 0xFE, 0x92, 0x92, 0x92, 0x7C, // B + 0xFE, 0x82, 0x82, 0x82, 0xC6, // C + 0xFE, 0x82, 0x82, 0x82, 0x7C, // D + 0xFE, 0x92, 0x92, 0x92, 0xC6, // E + 0xFE, 0x90, 0x90, 0x90, 0xC0, // F + 0xFE, 0x82, 0x9A, 0x92, 0xDE, // G + 0xFE, 0x10, 0x10, 0x10, 0xFE, // H + 0x00, 0x82, 0xFE, 0x82, 0x00, // I + 0x00, 0x06, 0x02, 0x82, 0xFE, // J + 0xFE, 0x10, 0x10, 0x28, 0xC6, // K + 0xFE, 0x02, 0x02, 0x02, 0x06, // L + 0xFE, 0x60, 0x18, 0x60, 0xFE, // M + 0xFE, 0x60, 0x30, 0x18, 0xFE, // N + 0x7C, 0x82, 0x82, 0x82, 0x7C, // O + 0xFE, 0x90, 0x90, 0x90, 0x70, // P + 0x7C, 0x82, 0x8A, 0x84, 0x7A, // Q + 0xFE, 0x90, 0x90, 0x98, 0x6E, // R + 0xF6, 0x92, 0x92, 0x92, 0xDE, // S + 0xC0, 0x80, 0xFE, 0x80, 0xC0, // T + 0xFE, 0x02, 0x02, 0x02, 0xFE, // U + 0xF8, 0x0C, 0x02, 0x0C, 0xF8, // V + 0xFE, 0x0C, 0x30, 0x0C, 0xFE, // W + 0xC6, 0x6C, 0x10, 0x6C, 0xC6, // X + 0xE0, 0x30, 0x1E, 0x30, 0xE0, // Y + 0xC6, 0x8A, 0x92, 0xA2, 0xC6, // Z + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x7E, 0x88, 0x88, 0x88, 0x7E, // lower case A + 0xFE, 0x92, 0x92, 0x92, 0x7C, // b + 0xFE, 0x82, 0x82, 0x82, 0xC6, // c + 0xFE, 0x82, 0x82, 0x82, 0x7C, // d + 0xFE, 0x92, 0x92, 0x92, 0xC6, // e + 0xFE, 0x90, 0x90, 0x90, 0xC0, // f + 0xFE, 0x82, 0x9A, 0x92, 0xDE, // g + 0xFE, 0x10, 0x10, 0x10, 0xFE, // h + 0x00, 0x82, 0xFE, 0x82, 0x00, // i + 0x00, 0x06, 0x02, 0x82, 0xFE, // j + 0xFE, 0x10, 0x10, 0x28, 0xC6, // k + 0xFE, 0x02, 0x02, 0x02, 0x06, // l + 0xFE, 0x60, 0x18, 0x60, 0xFE, // m + 0xFE, 0x60, 0x30, 0x18, 0xFE, // n + 0x7C, 0x82, 0x82, 0x82, 0x7C, // o + 0xFE, 0x90, 0x90, 0x90, 0x70, // p + 0x7C, 0x82, 0x8A, 0x84, 0x7A, // q + 0xFE, 0x90, 0x90, 0x98, 0x6E, // r + 0xF6, 0x92, 0x92, 0x92, 0xDE, // s + 0xC0, 0x80, 0xFE, 0x80, 0xC0, // t + 0xFE, 0x02, 0x02, 0x02, 0xFE, // u + 0xF8, 0x0C, 0x02, 0x0C, 0xF8, // v + 0xFE, 0x0C, 0x30, 0x0C, 0xFE, // w + 0xC6, 0x6C, 0x10, 0x6C, 0xC6, // x + 0xE0, 0x30, 0x1E, 0x30, 0xE0, // y + 0xC6, 0x8A, 0x92, 0xA2, 0xC6, // z + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // DEL + +}; diff --git a/main.c b/main.c index b4ed64a..4712f7a 100644 --- a/main.c +++ b/main.c @@ -60,7 +60,7 @@ void main() led_init(); /* Real time clock */ - //rtc_init(); + rtc_init(); /* Eeprom Driver eeprom_at24c_init(); diff --git a/sysinfo.c b/sysinfo.c index 84d5097..d66aaf0 100644 --- a/sysinfo.c +++ b/sysinfo.c @@ -24,16 +24,17 @@ uint32_t get_msp(void); void sysinfo() { uint32_t tmp = *MCU_ID; - printf("# DEV ID: "); + printf("SYSTEM LOADING...\n\n"); + printf("DEV ID: "); if (tmp & 0x414) - printf("HIGH DENSITY\n"); + printf("H. DENSITY\n"); else { printf("UNKNOWN\n"); } tmp = (tmp >> 16); - printf("# REV: "); + printf("REV: "); switch (tmp) { case 0x1000: printf("REVISION A\n"); @@ -55,9 +56,9 @@ void sysinfo() { uint32_t data_bss = (uint32_t) &_endofbss - SRAM_OFFSET; uint32_t mem_free = SRAM_SIZE - stack_usage - data_bss; - printf("# TOTAL MEM: %#x\n", SRAM_SIZE); - printf("# FREE MEM: %#x\n", mem_free); - printf("# STACK USE: %#x\n", stack_usage); + printf("TOTAL MEM: %#x\n", SRAM_SIZE); + printf("FREE MEM: %#x\n", mem_free); + printf("STACK USE: %#x\n\n", stack_usage); }