diff options
author | 2019-06-01 15:27:19 +0300 | |
---|---|---|
committer | 2019-06-01 15:27:19 +0300 | |
commit | fb220a85890b1de874061cc6b1b2102ba33ad43f (patch) | |
tree | 6ec02e665d35d114c2212a5243dd1cb0f6afff37 /src/device/screen.h | |
parent | 96d7d31534921889c219a5c9e00a46c3e94d0124 (diff) | |
parent | 227a0e12ee262dbabdd8d988fec194273cf90029 (diff) | |
download | usurpation-fb220a85890b1de874061cc6b1b2102ba33ad43f.tar.gz usurpation-fb220a85890b1de874061cc6b1b2102ba33ad43f.tar.bz2 usurpation-fb220a85890b1de874061cc6b1b2102ba33ad43f.zip |
Merge branch '35-Message-Output'
Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
Diffstat (limited to 'src/device/screen.h')
-rw-r--r-- | src/device/screen.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/device/screen.h b/src/device/screen.h new file mode 100644 index 0000000..5d0e3b3 --- /dev/null +++ b/src/device/screen.h @@ -0,0 +1,50 @@ +/** + * Simple API for scrolling lines. Keeps things simple by not even assuming + * which screen is being drawn on. + */ + +#ifndef DEVICE_SCREEN_H +#define DEVICE_SCREEN_H + +#include <time.h> +#include <OLEDDisplay.h> +#include <Wire.h> + +#define SCREEN_WIDTH (128) +#define SCREEN_HEIGHT (32) +#define FONT_WIDTH (8) +#define SCREEN_MAX_CHARS (SCREEN_WIDTH / FONT_WIDTH) + +/** + * 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. */ +}; + +/** + * Displays scrolling text on the screen. + */ +int display_update_scroll(struct display_status *status); + +#define END_OF_MESSAGE (1 << 0) +/** + * Initialises display_status structure so it can be used for + * display_update_scroll. + * + * screen - screen to draw on + * + * status - structure to Initialise + * + * msg - message to scroll on the screen + */ +void display_status_init(OLEDDisplay *screen, struct display_status *status, char *msg); + +#endif /* DEVICE_SCREEN_H */
\ No newline at end of file |