diff --git a/software/sys_controller/Makefile b/software/sys_controller/Makefile index 29f3a79..456014b 100644 --- a/software/sys_controller/Makefile +++ b/software/sys_controller/Makefile @@ -172,6 +172,7 @@ C_SRCS += ic_drivers/tvp7002/tvp7002.c C_SRCS += ic_drivers/ths7353/ths7353.c C_SRCS += ic_drivers/pcm1862/pcm1862.c C_SRCS += ic_drivers/st7032/st7032.c +C_SRCS += ic_drivers/sh1107/sh1107.c C_SRCS += ulibSD/sd_io.c C_SRCS += ulibSD/spi_io.c CXX_SRCS := @@ -198,6 +199,9 @@ endif ifeq ($(OSDLANG),JP) APP_CFLAGS_DEFINED_SYMBOLS += -DOSDLANG_JP endif +ifeq ($(HAS_SH1107),y) +APP_CFLAGS_DEFINED_SYMBOLS += -DHAS_SH1107 +endif APP_CFLAGS_UNDEFINED_SYMBOLS := APP_CFLAGS_OPTIMIZATION := -Os APP_CFLAGS_DEBUG_LEVEL := @@ -225,6 +229,7 @@ APP_INCLUDE_DIRS += ic_drivers/tvp7002 APP_INCLUDE_DIRS += ic_drivers/ths7353 APP_INCLUDE_DIRS += ic_drivers/pcm1862 APP_INCLUDE_DIRS += ic_drivers/st7032 +APP_INCLUDE_DIRS += ic_drivers/sh1107 APP_INCLUDE_DIRS += memory APP_INCLUDE_DIRS += ulibSD APP_LIBRARY_DIRS := diff --git a/software/sys_controller/ic_drivers/sh1107/font12.h b/software/sys_controller/ic_drivers/sh1107/font12.h new file mode 100644 index 0000000..836e427 --- /dev/null +++ b/software/sys_controller/ic_drivers/sh1107/font12.h @@ -0,0 +1,1337 @@ +#ifndef _FONT12_H +#define _FONT12_H + +static const uint8_t Font12_Table[] = +{ + // @0 ' ' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @12 '!' (7 pixels wide) + 0x00, // + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + + // @24 '"' (7 pixels wide) + 0x00, // + 0x36, // ## ## + 0x12, // # # + 0x12, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @36 '#' (7 pixels wide) + 0x00, // + 0x28, // # # + 0x28, // # # + 0x14, // # # + 0x3e, // ##### + 0x14, // # # + 0x3e, // ##### + 0x14, // # # + 0x0a, // # # + 0x0a, // # # + 0x00, // + 0x00, // + + // @48 '$' (7 pixels wide) + 0x00, // + 0x08, // # + 0x1c, // ### + 0x02, // # + 0x02, // # + 0x1c, // ### + 0x12, // # # + 0x0e, // ### + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + + // @60 '%' (7 pixels wide) + 0x00, // + 0x04, // # + 0x0a, // # # + 0x04, // # + 0x30, // ## + 0x0e, // ### + 0x10, // # + 0x28, // # # + 0x10, // # + 0x00, // + 0x00, // + 0x00, // + + // @72 '&' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x18, // ## + 0x04, // # + 0x04, // # + 0x2a, // # # # + 0x12, // # # + 0x2c, // ## # + 0x00, // + 0x00, // + 0x00, // + + // @84 ''' (7 pixels wide) + 0x00, // + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @96 '(' (7 pixels wide) + 0x00, // + 0x10, // # + 0x10, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x10, // # + 0x10, // # + 0x00, // + + // @108 ')' (7 pixels wide) + 0x00, // + 0x04, // # + 0x04, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x04, // # + 0x04, // # + 0x00, // + + // @120 '*' (7 pixels wide) + 0x00, // + 0x08, // # + 0x3e, // ##### + 0x08, // # + 0x14, // # # + 0x14, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @132 '+' (7 pixels wide) + 0x00, // + 0x00, // + 0x08, // # + 0x08, // # + 0x08, // # + 0x7f, // ####### + 0x08, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + + // @144 ',' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x18, // ## + 0x08, // # + 0x0c, // ## + 0x04, // # + 0x00, // + + // @156 '-' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @168 '.' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x0c, // ## + 0x0c, // ## + 0x00, // + 0x00, // + 0x00, // + + // @180 '/' (7 pixels wide) + 0x00, // + 0x20, // # + 0x20, // # + 0x10, // # + 0x10, // # + 0x08, // # + 0x08, // # + 0x04, // # + 0x04, // # + 0x02, // # + 0x00, // + 0x00, // + + // @192 '0' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @204 '1' (7 pixels wide) + 0x00, // + 0x0c, // ## + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @216 '2' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x20, // # + 0x10, // # + 0x08, // # + 0x04, // # + 0x22, // # # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @228 '3' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x20, // # + 0x18, // ## + 0x20, // # + 0x20, // # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @240 '4' (7 pixels wide) + 0x00, // + 0x30, // ## + 0x28, // # # + 0x28, // # # + 0x24, // # # + 0x22, // # # + 0x7e, // ###### + 0x20, // # + 0x70, // ### + 0x00, // + 0x00, // + 0x00, // + + // @252 '5' (7 pixels wide) + 0x00, // + 0x3c, // #### + 0x04, // # + 0x04, // # + 0x1c, // ### + 0x20, // # + 0x20, // # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @264 '6' (7 pixels wide) + 0x00, // + 0x38, // ### + 0x04, // # + 0x02, // # + 0x1e, // #### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @276 '7' (7 pixels wide) + 0x00, // + 0x3e, // ##### + 0x22, // # # + 0x20, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + + // @288 '8' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @300 '9' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x3c, // #### + 0x20, // # + 0x10, // # + 0x0e, // ### + 0x00, // + 0x00, // + 0x00, // + + // @312 ':' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x0c, // ## + 0x0c, // ## + 0x00, // + 0x00, // + 0x0c, // ## + 0x0c, // ## + 0x00, // + 0x00, // + 0x00, // + + // @324 ';' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x18, // ## + 0x18, // ## + 0x00, // + 0x00, // + 0x18, // ## + 0x0c, // ## + 0x04, // # + 0x00, // + 0x00, // + + // @336 '<' (7 pixels wide) + 0x00, // + 0x00, // + 0x30, // ## + 0x08, // # + 0x06, // ## + 0x01, // # + 0x06, // ## + 0x08, // # + 0x30, // ## + 0x00, // + 0x00, // + 0x00, // + + // @348 '=' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x3e, // ##### + 0x00, // + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @360 '>' (7 pixels wide) + 0x00, // + 0x00, // + 0x03, // ## + 0x04, // # + 0x18, // ## + 0x20, // # + 0x18, // ## + 0x04, // # + 0x03, // ## + 0x00, // + 0x00, // + 0x00, // + + // @372 '?' (7 pixels wide) + 0x00, // + 0x00, // + 0x18, // ## + 0x24, // # # + 0x20, // # + 0x10, // # + 0x08, // # + 0x00, // + 0x0c, // ## + 0x00, // + 0x00, // + 0x00, // + + // @384 '@' (7 pixels wide) + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x32, // # ## + 0x2a, // # # # + 0x2a, // # # # + 0x32, // # ## + 0x02, // # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + + // @396 'A' (7 pixels wide) + 0x00, // + 0x0c, // ## + 0x08, // # + 0x14, // # # + 0x14, // # # + 0x14, // # # + 0x3e, // ##### + 0x22, // # # + 0x77, // ### ### + 0x00, // + 0x00, // + 0x00, // + + // @408 'B' (7 pixels wide) + 0x00, // + 0x1f, // ##### + 0x22, // # # + 0x22, // # # + 0x1e, // #### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1f, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @420 'C' (7 pixels wide) + 0x00, // + 0x3c, // #### + 0x22, // # # + 0x02, // # + 0x02, // # + 0x02, // # + 0x02, // # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @432 'D' (7 pixels wide) + 0x00, // + 0x0f, // #### + 0x12, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x12, // # # + 0x0f, // #### + 0x00, // + 0x00, // + 0x00, // + + // @444 'E' (7 pixels wide) + 0x00, // + 0x3f, // ###### + 0x22, // # # + 0x0a, // # # + 0x0e, // ### + 0x0a, // # # + 0x02, // # + 0x22, // # # + 0x3f, // ###### + 0x00, // + 0x00, // + 0x00, // + + // @456 'F' (7 pixels wide) + 0x00, // + 0x7e, // ###### + 0x44, // # # + 0x14, // # # + 0x1c, // ### + 0x14, // # # + 0x04, // # + 0x04, // # + 0x0e, // ### + 0x00, // + 0x00, // + 0x00, // + + // @468 'G' (7 pixels wide) + 0x00, // + 0x3c, // #### + 0x22, // # # + 0x02, // # + 0x02, // # + 0x72, // # ### + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @480 'H' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x22, // # # + 0x3e, // ##### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x77, // ### ### + 0x00, // + 0x00, // + 0x00, // + + // @492 'I' (7 pixels wide) + 0x00, // + 0x3e, // ##### + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @504 'J' (7 pixels wide) + 0x00, // + 0x3c, // #### + 0x10, // # + 0x10, // # + 0x10, // # + 0x12, // # # + 0x12, // # # + 0x12, // # # + 0x0c, // ## + 0x00, // + 0x00, // + 0x00, // + + // @516 'K' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x12, // # # + 0x0a, // # # + 0x0e, // ### + 0x12, // # # + 0x22, // # # + 0x67, // ### ## + 0x00, // + 0x00, // + 0x00, // + + // @528 'L' (7 pixels wide) + 0x00, // + 0x0e, // ### + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x24, // # # + 0x24, // # # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @540 'M' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x36, // ## ## + 0x36, // ## ## + 0x2a, // # # # + 0x2a, // # # # + 0x22, // # # + 0x22, // # # + 0x77, // ### ### + 0x00, // + 0x00, // + 0x00, // + + // @552 'N' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x26, // ## # + 0x26, // ## # + 0x2a, // # # # + 0x2a, // # # # + 0x2a, // # # # + 0x32, // # ## + 0x37, // ### ## + 0x00, // + 0x00, // + 0x00, // + + // @564 'O' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @576 'P' (7 pixels wide) + 0x00, // + 0x1e, // #### + 0x24, // # # + 0x24, // # # + 0x24, // # # + 0x1c, // ### + 0x04, // # + 0x04, // # + 0x0e, // ### + 0x00, // + 0x00, // + 0x00, // + + // @588 'Q' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x38, // ### + 0x00, // + 0x00, // + + // @600 'R' (7 pixels wide) + 0x00, // + 0x1f, // ##### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1e, // #### + 0x12, // # # + 0x22, // # # + 0x47, // ### # + 0x00, // + 0x00, // + 0x00, // + + // @612 'S' (7 pixels wide) + 0x00, // + 0x2c, // ## # + 0x32, // # ## + 0x02, // # + 0x1c, // ### + 0x20, // # + 0x20, // # + 0x26, // ## # + 0x1a, // # ## + 0x00, // + 0x00, // + 0x00, // + + // @624 'T' (7 pixels wide) + 0x00, // + 0x7f, // ####### + 0x49, // # # # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @636 'U' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @648 'V' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x22, // # # + 0x14, // # # + 0x14, // # # + 0x14, // # # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + + // @660 'W' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x22, // # # + 0x2a, // # # # + 0x2a, // # # # + 0x2a, // # # # + 0x2a, // # # # + 0x14, // # # + 0x00, // + 0x00, // + 0x00, // + + // @672 'X' (7 pixels wide) + 0x00, // + 0x63, // ## ## + 0x22, // # # + 0x14, // # # + 0x08, // # + 0x08, // # + 0x14, // # # + 0x22, // # # + 0x63, // ## ## + 0x00, // + 0x00, // + 0x00, // + + // @684 'Y' (7 pixels wide) + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x14, // # # + 0x14, // # # + 0x08, // # + 0x08, // # + 0x08, // # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @696 'Z' (7 pixels wide) + 0x00, // + 0x3e, // ##### + 0x22, // # # + 0x10, // # + 0x08, // # + 0x08, // # + 0x04, // # + 0x22, // # # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @708 '[' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x1c, // ### + 0x00, // + + // @720 '\' (7 pixels wide) + 0x00, // + 0x02, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x08, // # + 0x08, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x00, // + 0x00, // + + // @732 ']' (7 pixels wide) + 0x00, // + 0x1c, // ### + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x1c, // ### + 0x00, // + + // @744 '^' (7 pixels wide) + 0x00, // + 0x08, // # + 0x08, // # + 0x14, // # # + 0x22, // # # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @756 '_' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x7f, // ####### + + // @768 '`' (7 pixels wide) + 0x00, // + 0x08, // # + 0x10, // # + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + + // @780 'a' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x3c, // #### + 0x22, // # # + 0x22, // # # + 0x7c, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @792 'b' (7 pixels wide) + 0x00, // + 0x03, // ## + 0x02, // # + 0x1a, // # ## + 0x26, // ## # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1f, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @804 'c' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x3c, // #### + 0x22, // # # + 0x02, // # + 0x02, // # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @816 'd' (7 pixels wide) + 0x00, // + 0x30, // ## + 0x20, // # + 0x2c, // ## # + 0x32, // # ## + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x7c, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @828 'e' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x3e, // ##### + 0x02, // # + 0x02, // # + 0x3c, // #### + 0x00, // + 0x00, // + 0x00, // + + // @840 'f' (7 pixels wide) + 0x00, // + 0x38, // ### + 0x04, // # + 0x3e, // ##### + 0x04, // # + 0x04, // # + 0x04, // # + 0x04, // # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @852 'g' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x6c, // ## ## + 0x32, // # ## + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x3c, // #### + 0x20, // # + 0x1c, // ### + 0x00, // + + // @864 'h' (7 pixels wide) + 0x00, // + 0x03, // ## + 0x02, // # + 0x1a, // # ## + 0x26, // ## # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x77, // ### ### + 0x00, // + 0x00, // + 0x00, // + + // @876 'i' (7 pixels wide) + 0x00, // + 0x08, // # + 0x00, // + 0x0e, // ### + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @888 'j' (7 pixels wide) + 0x00, // + 0x08, // # + 0x00, // + 0x1e, // #### + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x10, // # + 0x0e, // ### + 0x00, // + + // @900 'k' (7 pixels wide) + 0x00, // + 0x03, // ## + 0x02, // # + 0x3a, // # ### + 0x12, // # # + 0x0e, // ### + 0x0a, // # # + 0x12, // # # + 0x3b, // ## ### + 0x00, // + 0x00, // + 0x00, // + + // @912 'l' (7 pixels wide) + 0x00, // + 0x0c, // ## + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @924 'm' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x17, // ### # + 0x2a, // # # # + 0x2a, // # # # + 0x2a, // # # # + 0x2a, // # # # + 0x7f, // ####### + 0x00, // + 0x00, // + 0x00, // + + // @936 'n' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x1b, // ## ## + 0x26, // ## # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x77, // ### ### + 0x00, // + 0x00, // + 0x00, // + + // @948 'o' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x1c, // ### + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1c, // ### + 0x00, // + 0x00, // + 0x00, // + + // @960 'p' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x1b, // ## ## + 0x26, // ## # + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x1e, // #### + 0x02, // # + 0x07, // ### + 0x00, // + + // @972 'q' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x6c, // ## ## + 0x32, // # ## + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x3c, // #### + 0x20, // # + 0x70, // ### + 0x00, // + + // @984 'r' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x36, // ## ## + 0x0c, // ## + 0x04, // # + 0x04, // # + 0x04, // # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @996 's' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x3c, // #### + 0x22, // # # + 0x1c, // ### + 0x20, // # + 0x22, // # # + 0x1e, // #### + 0x00, // + 0x00, // + 0x00, // + + // @1008 't' (7 pixels wide) + 0x00, // + 0x00, // + 0x04, // # + 0x3e, // ##### + 0x04, // # + 0x04, // # + 0x04, // # + 0x44, // # # + 0x38, // ### + 0x00, // + 0x00, // + 0x00, // + + // @1020 'u' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x33, // ## ## + 0x22, // # # + 0x22, // # # + 0x22, // # # + 0x32, // # ## + 0x6c, // ## ## + 0x00, // + 0x00, // + 0x00, // + + // @1032 'v' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x22, // # # + 0x14, // # # + 0x14, // # # + 0x08, // # + 0x00, // + 0x00, // + 0x00, // + + // @1044 'w' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x2a, // # # # + 0x2a, // # # # + 0x2a, // # # # + 0x14, // # # + 0x00, // + 0x00, // + 0x00, // + + // @1056 'x' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x33, // ## ## + 0x12, // # # + 0x0c, // ## + 0x0c, // ## + 0x12, // # # + 0x33, // ## ## + 0x00, // + 0x00, // + 0x00, // + + // @1068 'y' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x77, // ### ### + 0x22, // # # + 0x24, // # # + 0x14, // # # + 0x18, // ## + 0x08, // # + 0x08, // # + 0x1e, // #### + 0x00, // + + // @1080 'z' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x3e, // ##### + 0x12, // # # + 0x08, // # + 0x04, // # + 0x22, // # # + 0x3e, // ##### + 0x00, // + 0x00, // + 0x00, // + + // @1092 '{' (7 pixels wide) + 0x00, // + 0x10, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x04, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x10, // # + 0x00, // + + // @1104 '|' (7 pixels wide) + 0x00, // + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x00, // + 0x00, // + + // @1116 '}' (7 pixels wide) + 0x00, // + 0x04, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x10, // # + 0x08, // # + 0x08, // # + 0x08, // # + 0x04, // # + 0x00, // + + // @1128 '~' (7 pixels wide) + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x24, // # # + 0x1a, // # ## + 0x00, // + 0x00, // + 0x00, // + 0x00, // + 0x00, // +}; + +#endif \ No newline at end of file diff --git a/software/sys_controller/ic_drivers/sh1107/sh1107.c b/software/sys_controller/ic_drivers/sh1107/sh1107.c new file mode 100644 index 0000000..47ef303 --- /dev/null +++ b/software/sys_controller/ic_drivers/sh1107/sh1107.c @@ -0,0 +1,139 @@ +// +// Copyright (C) 2025 Balázs Triszka +// +// This file is part of Open Source Scan Converter project. +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include "lcd.h" +#include "sh1107.h" +#include "alt_types.h" +#include "altera_avalon_pio_regs.h" +#include "i2c_opencores.h" +#include "av_controller.h" +#include "font12.h" + +#define OLED_WIDTH 128 +#define OLED_HEIGHT 64 + +extern alt_u32 sys_ctrl; + +static void OLED_Write(uint8_t value) +{ + SPI_write(I2CA_BASE, &value, 1); +} + +void sh1107_init() +{ + sys_ctrl &= ~(LCD_CS_N | LCD_RS); + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + + alt_u8 init[] = { + 0xae, /*turn off OLED display*/ + 0x00, /*set lower column address*/ + 0x10, /*set higher column address*/ + 0xb0, /*set page address*/ + 0xdc, 0x00, /*set display start line*/ + 0x81, /*contract control*/ + 0x6f, /*128*/ + 0x21, /* Set Memory addressing mode (0x20/0x21) */ + 0xa1, /*set segment remap*/ + 0xc0, /*Com scan direction*/ + 0xa4, /*Disable Entire Display On (0xA4/0xA5)*/ + 0xa6, /*normal / reverse*/ + 0xa8, /*multiplex ratio*/ + 0x3f, /*duty = 1/64*/ + 0xd3, 0x60, /*set display offset*/ + 0xd5, 0x41, /*set osc division*/ + 0xd9, 0x22, /*set pre-charge period*/ + 0xdb, 0x35, /*set vcomh*/ + 0xad, /*set charge pump enable*/ + 0x8a /*Set DC-DC enable (a=0:disable; a=1:enable) */ + }; + SPI_write(I2CA_BASE, init, sizeof(init)); + + // Clear the screen + OLED_Write(0xb0); + for (alt_u8 i = 0; i < OLED_HEIGHT; i++) + { + sys_ctrl &= ~LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + OLED_Write(0x00 + (i & 0x0f)); + OLED_Write(0x10 + (i >> 4)); + + sys_ctrl |= LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + for (alt_u8 i = 0; i < OLED_WIDTH / 8; i++) + OLED_Write(0); + } + + sys_ctrl &= ~LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + + // Turn on + OLED_Write(0xaf); + + sys_ctrl |= LCD_CS_N; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); +} + +void sh1107_write(char *row1, char *row2) +{ + sys_ctrl &= ~(LCD_CS_N | LCD_RS); + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + + alt_u8 row1len = strnlen(row1, LCD_ROW_LEN); + + for (alt_u8 i = 0; i < 12; i++) + { + sys_ctrl &= ~LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + OLED_Write(0xb0); + OLED_Write(0x00 + ((i + 13) & 0x0f)); + OLED_Write(0x10 + ((i + 13) >> 4)); + + sys_ctrl |= LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + for (alt_u8 j = 0; j < row1len; j++) + OLED_Write(Font12_Table[(row1[j] - 0x20) * 12 + i]); + + for (alt_u8 j = row1len; j < LCD_ROW_LEN; j++) + OLED_Write(Font12_Table[i]); + } + + alt_u8 row2len = strnlen(row2, LCD_ROW_LEN); + + for (alt_u8 i = 0; i < 12; i++) + { + sys_ctrl &= ~LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + OLED_Write(0xb0); + OLED_Write(0x00 + ((i + 39) & 0x0f)); + OLED_Write(0x10 + ((i + 39) >> 4)); + + sys_ctrl |= LCD_RS; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); + for (alt_u8 j = 0; j < row2len; j++) + OLED_Write(Font12_Table[(row2[j] - 0x20) * 12 + i]); + + for (alt_u8 j = row2len; j < LCD_ROW_LEN; j++) + OLED_Write(Font12_Table[i]); + } + + sys_ctrl |= LCD_CS_N; + IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, sys_ctrl); +} diff --git a/software/sys_controller/ic_drivers/sh1107/sh1107.h b/software/sys_controller/ic_drivers/sh1107/sh1107.h new file mode 100644 index 0000000..1d102a8 --- /dev/null +++ b/software/sys_controller/ic_drivers/sh1107/sh1107.h @@ -0,0 +1,31 @@ +// +// Copyright (C) 2025 Balázs Triszka +// +// This file is part of Open Source Scan Converter project. +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef SH1107_H_ +#define SH1107_H_ + +#include "system.h" +#include +#include "sysconfig.h" + +void sh1107_init(); + +void sh1107_write(char *row1, char *row2); + +#endif /* sh1107_H_ */ diff --git a/software/sys_controller/src/lcd.c b/software/sys_controller/src/lcd.c index fdbd8f1..7529009 100644 --- a/software/sys_controller/src/lcd.c +++ b/software/sys_controller/src/lcd.c @@ -19,13 +19,22 @@ #include "lcd.h" #include "st7032.h" +#include "sh1107.h" void lcd_init() { +#ifndef HAS_SH1107 st7032_init(); +#else + sh1107_init(); +#endif } void lcd_write(char *row1, char *row2) { +#ifndef HAS_SH1107 st7032_write(row1, row2); +#else + sh1107_write(row1, row2); +#endif } \ No newline at end of file