aboutsummaryrefslogtreecommitdiff
path: root/display_sim.c
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2021-02-27 22:09:06 +1300
committerDavid Phillips <david@yeah.nah.nz>2021-02-27 22:09:06 +1300
commit8f9cd223c74ce0b026ae3368701a443f62d7b3d5 (patch)
tree77d276b9904263d3c6833e213e677dbc0f16679a /display_sim.c
parent27d6d2fc5a1647395a7a9074faf8362d6d0c358a (diff)
downloadaltimeter-8f9cd223c74ce0b026ae3368701a443f62d7b3d5.tar.xz
Migrate display to new peripheral model
Diffstat (limited to 'display_sim.c')
-rw-r--r--display_sim.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/display_sim.c b/display_sim.c
index c87329e..93e62c4 100644
--- a/display_sim.c
+++ b/display_sim.c
@@ -63,7 +63,7 @@ static FILE uart_out = FDEV_SETUP_STREAM(uart_putc, NULL, _FDEV_SETUP_WRITE);
/* internal function to dump the display contents to stdout, since there
* is no background thread for doing this constantly */
-void display_display(void)
+static void full_display(void)
{
int y = 0;
printf("\033[6A"); // hack: raw ANSI escape sequence to move up 6
@@ -74,7 +74,9 @@ void display_display(void)
printf("`--------------------'\n");
}
-void display_clear(void)
+/**/
+
+static void display_clear(void)
{
int x = 0;
int y = 0;
@@ -85,10 +87,10 @@ void display_clear(void)
display[y][x] = '\0';
}
- display_display();
+ full_display();
}
-void display_init(void)
+static void display_init(void)
{
uart_init();
/* FIXME hack: stdout not guaranteed to be assignable */
@@ -98,7 +100,7 @@ void display_init(void)
cursor_x = cursor_y = 0;
}
-void display_write(const char *text)
+static void display_write(const char *text)
{
char c = '\0';
while (cursor_x < LCD_WIDTH && *text) {
@@ -108,11 +110,19 @@ void display_write(const char *text)
c = '_';
display[cursor_y][cursor_x++] = c;
}
- display_display();
+ full_display();
}
-void display_set_cursor(int x, int y)
+static void display_set_cursor(int x, int y)
{
cursor_x = x;
cursor_y = y;
}
+
+void get_system_display(struct display *display)
+{
+ display->init = display_init;
+ display->clear = display_clear;
+ display->write = display_write;
+ display->set_cursor = display_set_cursor;
+}