Display: create and use display_set_cursor().

Having this in a seperate function will be helpful later.
This commit is contained in:
Markus Hitter 2016-04-25 00:28:51 +02:00
parent cec45a2fec
commit bb8d6e0ad2
3 changed files with 24 additions and 5 deletions

View File

@ -34,6 +34,8 @@
void display_init(void);
void display_clear(void);
void display_text_P(uint8_t line, uint8_t column, PGM_P message_P);
void display_set_cursor(uint8_t line, uint8_t column);
void display_text_P(PGM_P message_P);
#endif /* _DISPLAY_H */

View File

@ -78,10 +78,16 @@ void display_clear(void) {
}
/**
Prints the text at a given position.
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.
*/
void display_text_P(uint8_t line, uint8_t column, PGM_P message) {
uint8_t i, index;
void display_set_cursor(uint8_t line, uint8_t column) {
// Enter command mode.
displaybus_write(0x00, 0);
@ -90,6 +96,16 @@ void display_text_P(uint8_t line, uint8_t column, PGM_P message) {
// Set column.
displaybus_write(0x00 | (column & 0x0F), 0);
displaybus_write(0x10 | ((column >> 4) & 0x0F), 1);
}
/**
Prints the text at the current cursor position.
\param message Zero terminated string of the text to be displayed, stored
in program memory.
*/
void display_text_P(PGM_P message) {
uint8_t i, index;
// Render text to bitmap to display.
displaybus_write(0x40, 0);

View File

@ -24,7 +24,8 @@ static void i2c_test(void) {
"Welcome to Teacup" is 64 pixel columns wide, entire display is
128 columns, so we offset by 32 columns to get it to the center.
*/
display_text_P(1, 32, PSTR("Welcome to Teacup"));
display_set_cursor(1, 32);
display_text_P(PSTR("Welcome to Teacup"));
}
#endif /* I2C_TEST */