Add multi-line support

This commit is contained in:
Savanni D'Gerinel 2022-06-26 13:28:23 -04:00
parent 9536b2c2b9
commit 0d9ef55b44
3 changed files with 13 additions and 4 deletions

View File

@ -38,7 +38,7 @@ void display_init(display_t *disp) {
sr_initialize(&disp->reg); sr_initialize(&disp->reg);
set_line_direction(&disp->register_select, LINE_OUT); set_line_direction(&disp->register_select, LINE_OUT);
set_line_direction(&disp->enable, LINE_OUT); set_line_direction(&disp->enable, LINE_OUT);
write_instruction(disp, 0b00111100); write_instruction(disp, 0b00111000);
} }
void display_clear(display_t *disp) { void display_clear(display_t *disp) {
@ -47,7 +47,13 @@ void display_clear(display_t *disp) {
} }
void display_enable(display_t *disp) { void display_enable(display_t *disp) {
write_instruction(disp, 0x0e); // write_instruction(disp, 0x0e);
write_instruction(disp, 0b00001100);
}
void display_set_location(display_t *disp, size_t column, size_t row) {
size_t addr = row * 40 + column;
write_instruction(disp, 0b10000000 | addr);
} }
void display_write_message(display_t *disp, const char *msg) { void display_write_message(display_t *disp, const char *msg) {

View File

@ -56,6 +56,8 @@ void display_clear(display_t *);
void display_enable(display_t *); void display_enable(display_t *);
void display_set_location(display_t *, size_t, size_t);
void display_write_message(display_t *, const char *); void display_write_message(display_t *, const char *);
#endif #endif

View File

@ -37,8 +37,9 @@ int main(void) {
display_clear(&display); display_clear(&display);
_delay_ms(500); _delay_ms(500);
const char msg[] = "Hello, my bat"; display_write_message(&display, "Hello, my bat");
display_write_message(&display, msg); display_set_location(&display, 0, 1);
display_write_message(&display, " -- Savanni");
display_enable(&display); display_enable(&display);
set_line(&light); set_line(&light);