From 0d9ef55b449f003ca6aa0ec4adec1781c9c80aa7 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 26 Jun 2022 13:28:23 -0400 Subject: [PATCH] Add multi-line support --- display/display.c | 10 ++++++++-- display/display.h | 2 ++ lcd/main.c | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/display/display.c b/display/display.c index 77bec1d..26c09b3 100644 --- a/display/display.c +++ b/display/display.c @@ -38,7 +38,7 @@ void display_init(display_t *disp) { sr_initialize(&disp->reg); set_line_direction(&disp->register_select, LINE_OUT); set_line_direction(&disp->enable, LINE_OUT); - write_instruction(disp, 0b00111100); + write_instruction(disp, 0b00111000); } void display_clear(display_t *disp) { @@ -47,7 +47,13 @@ void display_clear(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) { diff --git a/display/display.h b/display/display.h index 4c373f5..dc60a0a 100644 --- a/display/display.h +++ b/display/display.h @@ -56,6 +56,8 @@ void display_clear(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 *); #endif diff --git a/lcd/main.c b/lcd/main.c index ff01164..037cff6 100644 --- a/lcd/main.c +++ b/lcd/main.c @@ -37,8 +37,9 @@ int main(void) { display_clear(&display); _delay_ms(500); - const char msg[] = "Hello, my bat"; - display_write_message(&display, msg); + display_write_message(&display, "Hello, my bat"); + display_set_location(&display, 0, 1); + display_write_message(&display, " -- Savanni"); display_enable(&display); set_line(&light);