From 7c5042af3c606081d3f4b917ef667f6ed05780a8 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Sun, 9 Jun 2019 23:08:36 +0300 Subject: hook various previously unused modules together. This now allows us to send messages to the device and such. Yay? Yay. Signed-off-by: Gediminas Jakutis --- src/device/screen.h | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/device/screen.h') diff --git a/src/device/screen.h b/src/device/screen.h index 5d0e3b3..3efff6d 100644 --- a/src/device/screen.h +++ b/src/device/screen.h @@ -13,20 +13,24 @@ #define SCREEN_WIDTH (128) #define SCREEN_HEIGHT (32) #define FONT_WIDTH (8) -#define SCREEN_MAX_CHARS (SCREEN_WIDTH / FONT_WIDTH) +#define FONT_HEIGHT (16) +#define SCREEN_LINE_COUNT (SCREEN_HEIGHT / FONT_HEIGHT) +#define SCREEN_LINE_CHARS (SCREEN_WIDTH / FONT_WIDTH) +#define SCREEN_TOTAL_CHARS (SCREEN_LINE_COUNT * SCREEN_LINE_CHARS) +#define MESSAGE_MAX (1023) /** * Struct that keeps track of the lines on the screen. */ struct display_status { - OLEDDisplay *screen; /* Screen to draw on. */ - time_t delta; /* Seconds/Line */ - time_t last_scroll_time; /* Last second the line was scrolled */ - char *message; /* Entire message to be shown */ - char *first_line; /* First line on display */ - char *second_line; /* Second line on display */ - size_t message_len; /* Length of the message */ - size_t line_cursor; /* Index of the first line being displayed. */ + OLEDDisplay *screen; + unsigned long period; /* milliseconds/Line */ + unsigned long last_scroll_time; + char message[MESSAGE_MAX + 1]; /* Entire message to be shown */ + char lines[SCREEN_LINE_COUNT][SCREEN_LINE_CHARS + 1]; + char *cursor; /* the begining of the *next* location in the message to be shown*/ + size_t msg_len; + size_t remaining; /* offset of the next part of text to be shown */ }; /** @@ -44,7 +48,11 @@ int display_update_scroll(struct display_status *status); * status - structure to Initialise * * msg - message to scroll on the screen + * + * size - length of the message + * + * period - time between [elder] scrolls */ -void display_status_init(OLEDDisplay *screen, struct display_status *status, char *msg); +void display_status_init(OLEDDisplay *screen, struct display_status *status, char *msg, size_t size, unsigned long int period); -#endif /* DEVICE_SCREEN_H */ \ No newline at end of file +#endif /* DEVICE_SCREEN_H */ -- cgit v1.2.3