diff --git a/src/lcd.c b/src/lcd.c index 46934a0..4578dbc 100644 --- a/src/lcd.c +++ b/src/lcd.c @@ -237,6 +237,8 @@ short TERMIO_PutChar(unsigned char letter) { to_row(0); } } else { + LCD_OutChar(letter); + col++; if (col > MAX_CHARS_PER_LINE) { if (row == 0) { to_row(1); @@ -244,13 +246,17 @@ short TERMIO_PutChar(unsigned char letter) { to_row(0); } } - col++; - LCD_OutChar(letter); } return 1; } +void LCD_ClearToEnd(void){ + while (col != 0){ + TERMIO_PutChar(' '); + } +} + void LCD_OutNibble(uint8_t x){ x &= 0xf; //ensure only bottom nibble if (x <= 9){ diff --git a/src/lcd.h b/src/lcd.h index ecc5d8e..1ce06a1 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -2,7 +2,7 @@ #define LCD_H -#define MAX_CHARS_PER_LINE 15 +#define MAX_CHARS_PER_LINE 16 #define MAX_ROWS 2 void LCD_Open(void); @@ -13,6 +13,7 @@ void LCD_SingleLineGoTo(unsigned int row_to); void LCD_OutString(const char* string); short TERMIO_PutChar(unsigned char letter); void LCD_OutNibble(uint8_t x); +void LCD_ClearToEnd(void); unsigned char LCD_Timeout_Error(void); diff --git a/src/utils.c b/src/utils.c index 9f3ae93..323c6aa 100644 --- a/src/utils.c +++ b/src/utils.c @@ -24,6 +24,7 @@ char* u32str(uint32_t x, char* buf, uint8_t base) //corner case if (x == 0){ buf[i] = '0'; + i++; } //get reversed string while(x > 0){