diff --git a/drivers/tdisp/HD44780/tdisp_lld.c b/drivers/tdisp/HD44780/tdisp_lld.c index 9644eaa8..2e152977 100644 --- a/drivers/tdisp/HD44780/tdisp_lld.c +++ b/drivers/tdisp/HD44780/tdisp_lld.c @@ -32,13 +32,6 @@ #if GFX_USE_TDISP /*|| defined(__DOXYGEN__)*/ -#ifndef TDISP_ROWS - #define TDISP_ROWS 16 -#endif -#ifndef TDISP_COLUMNS - #define TDISP_COLUMNS 2 -#endif - #include "tdisp_lld_board_example.h" static void _writeData(uint8_t data) { diff --git a/include/tdisp/tdisp.h b/include/tdisp/tdisp.h index aa577f88..619a6bab 100644 --- a/include/tdisp/tdisp.h +++ b/include/tdisp/tdisp.h @@ -41,6 +41,13 @@ /* Include the low level driver information */ #include "tdisp/lld/tdisp_lld.h" +#ifndef TDISP_ROWS + #define TDISP_ROWS 2 +#endif +#ifndef TDISP_COLUMNS + #define TDISP_COLUMNS 16 +#endif + #ifndef TDISP_NEED_4BIT_MODE #define TDISP_NEED_4BIT_MODE FALSE #endif diff --git a/src/tdisp/tdisp.c b/src/tdisp/tdisp.c index a6e5e2f5..edd5b423 100644 --- a/src/tdisp/tdisp.c +++ b/src/tdisp/tdisp.c @@ -50,6 +50,9 @@ void tdispHome(void) { void tdispGotoXY(coord_t col, coord_t row) { uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + if(row >= TDISP_ROWS) + row = TDISP_ROWS - 1; + TDISP_LLD(write_cmd)(0x80 | (col + row_offsets[row])); } @@ -60,7 +63,7 @@ void tdispDrawChar(char c) { void tdispDrawString(char *s) { char c; - while(c = s++) + while(c = *s++) tdispDrawChar(c); }