Display: implement cursor positioning for the HD44780.
This commit is contained in:
parent
1d4ebbd7fa
commit
c2c9753f80
|
|
@ -4,12 +4,6 @@
|
||||||
\brief Code specific to the HD44780 display.
|
\brief Code specific to the HD44780 display.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
TODO list:
|
|
||||||
|
|
||||||
- Implement display_set_cursor().
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
#if defined TEACUP_C_INCLUDE && defined DISPLAY_TYPE_HD44780
|
#if defined TEACUP_C_INCLUDE && defined DISPLAY_TYPE_HD44780
|
||||||
|
|
@ -60,12 +54,24 @@ void display_greeting(void) {
|
||||||
Regular update of the display. Typically called once a second from clock.c.
|
Regular update of the display. Typically called once a second from clock.c.
|
||||||
*/
|
*/
|
||||||
void display_clock(void) {
|
void display_clock(void) {
|
||||||
|
static uint8_t pos = 0;
|
||||||
|
|
||||||
display_clear();
|
display_clear();
|
||||||
|
|
||||||
update_current_position();
|
update_current_position();
|
||||||
sendf_P(display_writechar, PSTR("X:%lq Y:%lq"),
|
sendf_P(display_writechar, PSTR("X:%lq Y:%lq"),
|
||||||
current_position.axis[X], current_position.axis[Y]);
|
current_position.axis[X], current_position.axis[Y]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is a tiny demo showing how cursor positioning works. The
|
||||||
|
four-character text should move along the second display line.
|
||||||
|
*/
|
||||||
|
display_set_cursor(1, pos);
|
||||||
|
display_writestr_P(PSTR("ick!"));
|
||||||
|
pos++;
|
||||||
|
if (pos >= DISPLAY_SYMBOLS_PER_LINE) {
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,7 +79,7 @@ void display_clock(void) {
|
||||||
bus. As this is a character based display it's easy.
|
bus. As this is a character based display it's easy.
|
||||||
*/
|
*/
|
||||||
void display_tick() {
|
void display_tick() {
|
||||||
uint8_t data;
|
uint8_t data, command;
|
||||||
|
|
||||||
if (displaybus_busy()) {
|
if (displaybus_busy()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -86,6 +92,33 @@ void display_tick() {
|
||||||
displaybus_write(0x01, parallel_4bit_instruction);
|
displaybus_write(0x01, parallel_4bit_instruction);
|
||||||
break;
|
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.
|
||||||
|
*/
|
||||||
|
command = 0x80; // "Set DDRAM Address" base command.
|
||||||
|
|
||||||
|
/**
|
||||||
|
Add address of line.
|
||||||
|
|
||||||
|
As we have two lines only, this can be "calculated" without
|
||||||
|
a multiplication.
|
||||||
|
*/
|
||||||
|
buf_pop(display, data);
|
||||||
|
if (data) {
|
||||||
|
command += 0x40;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add column address.
|
||||||
|
buf_pop(display, data);
|
||||||
|
command += data;
|
||||||
|
|
||||||
|
displaybus_write(command, parallel_4bit_instruction);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Should be a printable character.
|
// Should be a printable character.
|
||||||
displaybus_write(data, parallel_4bit_data);
|
displaybus_write(data, parallel_4bit_data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue