From 1d4ebbd7faa2a06ad5fb624f5f4feab52c62a0a2 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sat, 28 May 2016 14:56:04 +0200 Subject: [PATCH] Display: queue up display_set_cursor(), too. --- display.c | 19 +++++++++++++++++++ display_hd44780.c | 17 ----------------- display_ssd1306.c | 44 ++++++++++++++++++-------------------------- 3 files changed, 37 insertions(+), 43 deletions(-) diff --git a/display.c b/display.c index 96564dc..454b703 100644 --- a/display.c +++ b/display.c @@ -37,6 +37,25 @@ void display_clear(void) { display_writechar((uint8_t)low_code_clear); } +/** + Sets the cursor to the given position. + + \param line The vertical cursor position to set, in lines. First line is + zero. + + \param column The horizontal cursor position to set. In characters on + character based displays, in pixels on pixel based displays. + First column is zero. + + Use this directly for debugging purposes, only. Regular display updates + happen in display_clock(). +*/ +void display_set_cursor(uint8_t line, uint8_t column) { + display_writechar((uint8_t)low_code_set_cursor); + display_writechar((uint8_t)line); + display_writechar((uint8_t)column); +} + /** Prints a character at the current cursor position. diff --git a/display_hd44780.c b/display_hd44780.c index 566259d..488407c 100644 --- a/display_hd44780.c +++ b/display_hd44780.c @@ -37,23 +37,6 @@ void display_init(void) { displaybus_write(0x0C, parallel_4bit_instruction); } -/** - Sets the cursor to the given position. - - \param line The vertical cursor position to set, in lines. First line is - zero. Line height is character height, which is currently - fixed to 8 pixels. - - \param column The horizontal cursor position to set, in pixels. First - column is zero. - - Use this for debugging purposes, only. Regular display updates happen in - display_clock(). -*/ -void display_set_cursor(uint8_t line, uint8_t column) { - // Currently unimplemented. -} - /** Show a nice greeting. Pure eye candy. */ diff --git a/display_ssd1306.c b/display_ssd1306.c index ffa7716..e6a4c5f 100644 --- a/display_ssd1306.c +++ b/display_ssd1306.c @@ -35,8 +35,6 @@ TODO list: - - Move code in display_set_cursor() would to display_tick(). - - Lot's of prettification. Like a nice background picture with the Teacup logo, like "Welcome to Teacup" as a greeting screen, like writing numbers to readable places and so on. @@ -114,30 +112,6 @@ void display_init(void) { } } -/** - Sets the cursor to the given position. - - \param line The vertical cursor position to set, in lines. First line is - zero. Line height is character height, which is currently - fixed to 8 pixels. - - \param column The horizontal cursor position to set, in pixels. First - column is zero. - - Use this for debugging purposes, only. Regular display updates happen in - display_clock(). -*/ -void display_set_cursor(uint8_t line, uint8_t column) { - - // Enter command mode. - displaybus_write(0x00, 0); - // Set line. - displaybus_write(0xB0 | (line & 0x03), 0); - // Set column. - displaybus_write(0x00 | (column & 0x0F), 0); - displaybus_write(0x10 | ((column >> 4) & 0x0F), 1); -} - /** Show a nice greeting. Pure eye candy. */ @@ -220,6 +194,24 @@ void display_tick() { displaybus_write(0x02, 1); break; + case low_code_set_cursor: + /** + Set the cursor to the given position. + + This is a three-byte control command, so we fetch additional bytes + from the queue and cross fingers they're actually there. + */ + // Enter command mode. + displaybus_write(0x00, 0); + // Set line. + buf_pop(display, data); + displaybus_write(0xB0 | (data & 0x03), 0); + // Set column. + buf_pop(display, data); + displaybus_write(0x00 | (data & 0x0F), 0); + displaybus_write(0x10 | ((data >> 4) & 0x0F), 1); + break; + default: // Should be a printable character. index = data - 0x20;