fix lcd indexing, clear to end of line function

This commit is contained in:
Jeff Wang 2019-03-21 21:01:53 -04:00
parent b3f0f12c32
commit 33949440db
3 changed files with 11 additions and 3 deletions

View File

@ -237,6 +237,8 @@ short TERMIO_PutChar(unsigned char letter) {
to_row(0); to_row(0);
} }
} else { } else {
LCD_OutChar(letter);
col++;
if (col > MAX_CHARS_PER_LINE) { if (col > MAX_CHARS_PER_LINE) {
if (row == 0) { if (row == 0) {
to_row(1); to_row(1);
@ -244,13 +246,17 @@ short TERMIO_PutChar(unsigned char letter) {
to_row(0); to_row(0);
} }
} }
col++;
LCD_OutChar(letter);
} }
return 1; return 1;
} }
void LCD_ClearToEnd(void){
while (col != 0){
TERMIO_PutChar(' ');
}
}
void LCD_OutNibble(uint8_t x){ void LCD_OutNibble(uint8_t x){
x &= 0xf; //ensure only bottom nibble x &= 0xf; //ensure only bottom nibble
if (x <= 9){ if (x <= 9){

View File

@ -2,7 +2,7 @@
#define LCD_H #define LCD_H
#define MAX_CHARS_PER_LINE 15 #define MAX_CHARS_PER_LINE 16
#define MAX_ROWS 2 #define MAX_ROWS 2
void LCD_Open(void); void LCD_Open(void);
@ -13,6 +13,7 @@ void LCD_SingleLineGoTo(unsigned int row_to);
void LCD_OutString(const char* string); void LCD_OutString(const char* string);
short TERMIO_PutChar(unsigned char letter); short TERMIO_PutChar(unsigned char letter);
void LCD_OutNibble(uint8_t x); void LCD_OutNibble(uint8_t x);
void LCD_ClearToEnd(void);
unsigned char LCD_Timeout_Error(void); unsigned char LCD_Timeout_Error(void);

View File

@ -24,6 +24,7 @@ char* u32str(uint32_t x, char* buf, uint8_t base)
//corner case //corner case
if (x == 0){ if (x == 0){
buf[i] = '0'; buf[i] = '0';
i++;
} }
//get reversed string //get reversed string
while(x > 0){ while(x > 0){