diff options
Diffstat (limited to 'src/device/screen.c')
-rwxr-xr-x | src/device/screen.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/device/screen.c b/src/device/screen.c new file mode 100755 index 0000000..6ad9a87 --- /dev/null +++ b/src/device/screen.c @@ -0,0 +1,52 @@ +#include <time.h> +#include <stdlib.h> +#include "screen.h" + +void draw_lines(struct display_status *status); +void update_lines(struct display_status *status); +char * get_line(struct display_status *status, size_t rline); + +void display_update_scroll(struct display_status *status) +{ + time_t crr_time = time(NULL); + if (status->last_scroll_time - crr_time > status->delta) { + status->last_scroll_time += status->delta; + status->line_cursor++; + update_lines(status); + } + draw_lines(status); +} + +void draw_lines(struct display_status *status) +{ + +} + +void update_lines(struct display_status *status) +{ + status->first_line = get_line(status, status->line_cursor); + status->second_line = get_line(status, status->line_cursor + 1); +} + +/** + * Returns a pointer to the first charachter of requested line. If line does not + * exist --- a null is returned. + */ +char * get_line(struct display_status *status, size_t rline) +{ + size_t i; + size_t line_idx = 0; + + for (i = 0; i < status->message_len; i++) { + if (rline == line_idx) { + return status->message + i; + } + if (status->message[i] == '\0') { + line_idx++; + } + } + /* The fact that we are here means that end of the message was reached. + * In that case --- return null; + */ + return NULL; +}
\ No newline at end of file |