From: Martin Mares Date: Fri, 18 Apr 2025 19:40:29 +0000 (+0200) Subject: Waiting room: More display X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e642daef0b0a3cfed24a217b8084993c13dac629;p=home-hw.git Waiting room: More display --- diff --git a/waiting/firmware/main.c b/waiting/firmware/main.c index c8b1b64..ac9b979 100644 --- a/waiting/firmware/main.c +++ b/waiting/firmware/main.c @@ -185,12 +185,23 @@ static void display_command(byte cmd) display_write_nibble((cmd << 4) & 0xf0); } +static void display_goto(uint row, uint col) +{ + display_command(LCD_CMD_SET_DDRAM_ADDR | (row * 0x40) | col); +} + static void display_char(byte ch) { display_write_nibble((ch & 0xf0) | LCD_BIT_RS); display_write_nibble(((ch << 4) & 0xf0) | LCD_BIT_RS); } +static void display_string(const char *str) +{ + while (*str) + display_char(*str++); +} + static void display_init(void) { debug_puts("Display init\n"); @@ -224,16 +235,13 @@ static void display_init(void) // Configure text direction display_command(LCD_CMD_ENTRY_MODE_SET | LCD_ENTRY_INCREMENT); - // Go home (this takes a long time) - display_command(LCD_CMD_RETURN_HOME); + // Clear the display (this takes a long time) + display_command(LCD_CMD_CLEAR_DISPLAY); delay_ms(2); - display_char('M'); - display_char('n'); - display_char('a'); - display_char('u'); - display_char('!'); - display_command(LCD_CMD_SET_DDRAM_ADDR | 1); + display_goto(0, 0); + display_string("Mnauky!"); + display_goto(1, 0); debug_puts("Display ready\n"); }