Display: queue up display_set_cursor(), too.

This commit is contained in:
Markus Hitter 2016-05-28 14:56:04 +02:00
parent 8d7471d3a4
commit 1d4ebbd7fa
3 changed files with 37 additions and 43 deletions

View File

@ -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.

View File

@ -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.
*/

View File

@ -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;