From 755680ca7246b232c45e3b519e9d8a95ea97375f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Mon, 27 May 2019 15:20:01 +0300 Subject: Device: partial implementation of line scrolling logic. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- src/device/screen.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 src/device/screen.h (limited to 'src/device/screen.h') diff --git a/src/device/screen.h b/src/device/screen.h new file mode 100755 index 0000000..ec30cd5 --- /dev/null +++ b/src/device/screen.h @@ -0,0 +1,22 @@ +#ifndef DEVICE_SCREEN_H +#define DEVICE_SCREEN_H + +#include + +/** + * Struct that keeps track of the lines on the screen. + */ +struct display_status { + 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. */ +}; + +void display_update_scroll(struct display_status *status); +void display_status_init(struct display_status *status, char *msg); + +#endif /* DEVICE_SCREEN_H */ \ No newline at end of file -- cgit v1.2.3 From e37b3eacefef04258a6dc6e8714da249d2ff9c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Mon, 27 May 2019 15:44:38 +0300 Subject: Screen: More implementation details. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only a single function is a stub now --- the actual drawing. Signed-off-by: Ramūnas Mažeikis --- src/device/screen.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/device/screen.h') diff --git a/src/device/screen.h b/src/device/screen.h index ec30cd5..7763bd2 100755 --- a/src/device/screen.h +++ b/src/device/screen.h @@ -3,6 +3,10 @@ #include +#define SCREEN_WIDTH (64) +#define FONT_WIDTH (8) +#define SCREEN_MAX_CHARS (SCREEN_WIDTH / FONT_WIDTH) + /** * Struct that keeps track of the lines on the screen. */ @@ -16,7 +20,11 @@ struct display_status { size_t line_cursor; /* Index of the first line being displayed. */ }; +/** + * Displays scrolling text on the screen. + */ void display_update_scroll(struct display_status *status); + void display_status_init(struct display_status *status, char *msg); #endif /* DEVICE_SCREEN_H */ \ No newline at end of file -- cgit v1.2.3 From bf8b16d036e60eec56a42cbfcf012390c143e699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Mon, 27 May 2019 23:12:42 +0300 Subject: Screen: implementation of drawing and trivial docs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- src/device/screen.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/device/screen.h (limited to 'src/device/screen.h') diff --git a/src/device/screen.h b/src/device/screen.h old mode 100755 new mode 100644 index 7763bd2..54734e5 --- a/src/device/screen.h +++ b/src/device/screen.h @@ -1,9 +1,17 @@ +/** + * 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 +#include +#include -#define SCREEN_WIDTH (64) +#define SCREEN_WIDTH (128) +#define SCREEN_HEIGHT (32) #define FONT_WIDTH (8) #define SCREEN_MAX_CHARS (SCREEN_WIDTH / FONT_WIDTH) @@ -11,6 +19,7 @@ * Struct that keeps track of the lines on the screen. */ struct display_status { + SSD1306Brzo *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 */ @@ -25,6 +34,16 @@ struct display_status { */ void display_update_scroll(struct display_status *status); -void display_status_init(struct display_status *status, char *msg); +/** + * 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(SSD1306Brzo *screen, struct display_status *status, char *msg); #endif /* DEVICE_SCREEN_H */ \ No newline at end of file -- cgit v1.2.3 From f267021479ab1f020c7956378d5bf23405ee3e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Tue, 28 May 2019 20:00:23 +0300 Subject: Screen: adjustments, bug fixes and abstraction. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Line drawing code no longer assumes a particular screen as long as it's interface includes OLEDDisplay. Signed-off-by: Ramūnas Mažeikis --- src/device/screen.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/device/screen.h') diff --git a/src/device/screen.h b/src/device/screen.h index 54734e5..5d0e3b3 100644 --- a/src/device/screen.h +++ b/src/device/screen.h @@ -7,7 +7,7 @@ #define DEVICE_SCREEN_H #include -#include +#include #include #define SCREEN_WIDTH (128) @@ -19,7 +19,7 @@ * Struct that keeps track of the lines on the screen. */ struct display_status { - SSD1306Brzo *screen; /* Screen to draw on. */ + 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 */ @@ -32,8 +32,9 @@ struct display_status { /** * Displays scrolling text on the screen. */ -void display_update_scroll(struct display_status *status); +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. @@ -44,6 +45,6 @@ void display_update_scroll(struct display_status *status); * * msg - message to scroll on the screen */ -void display_status_init(SSD1306Brzo *screen, struct display_status *status, char *msg); +void display_status_init(OLEDDisplay *screen, struct display_status *status, char *msg); #endif /* DEVICE_SCREEN_H */ \ No newline at end of file -- cgit v1.2.3