From 488a1b983e1c2fac14de25aa781caf12628e53c8 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 12 Jan 2014 01:30:26 +0100 Subject: put_line/scrolling: Make the scroll engine inform custom scrollers about start/stop of scrolling. With the new lcd_putsxy_scroll_func() code can register custom scroll functions (put_line() makes use of that). In order for the custom scroller to be able to properly manage its userdata pointer (set via struct scrollinfo::userdata) the scroll engine must inform the scroller about start and stop of scrolling. To inform about start the lcd_scroll_* functions now return true when the line will scroll. To inform about stop the scroll engine calls into the scroller one last time, with the text set to NULL. put_line() can use this to release the userdata registered per scrolling line so that it can be recycled. This fixes that some scrolling lines became glitchy after some time because the userdata was recycled too early. Change-Id: Iff0a6ce2a4f9ae2bada1b8e62f4f5950224942a9 --- firmware/drivers/lcd-scroll.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'firmware/drivers/lcd-scroll.c') diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c index a1bde9fe12..5162f9a100 100644 --- a/firmware/drivers/lcd-scroll.c +++ b/firmware/drivers/lcd-scroll.c @@ -30,7 +30,7 @@ #define MAIN_LCD #endif -static struct scrollinfo LCDFN(scroll)[LCD_SCROLLABLE_LINES]; +static struct scrollinfo LCDFN(scroll)[LCDM(SCROLLABLE_LINES)]; struct scroll_screen_info LCDFN(scroll_info) = { @@ -51,6 +51,13 @@ struct scroll_screen_info LCDFN(scroll_info) = void LCDFN(scroll_stop)(void) { + for (int i = 0; i < LCDFN(scroll_info).lines; i++) + { + /* inform scroller about end of scrolling */ + struct scrollinfo *s = &LCDFN(scroll_info).scroll[i]; + s->line = NULL; + s->scroll_func(s); + } LCDFN(scroll_info).lines = 0; } @@ -66,6 +73,9 @@ void LCDFN(scroll_stop_viewport_rect)(const struct viewport *vp, int x, int y, i && (x < (s->x+s->width) && (x+width) >= s->x) && (y < (s->y+s->height) && (y+height) >= s->y)) { + /* inform scroller about end of scrolling */ + s->line = NULL; + s->scroll_func(s); /* If i is not the last active line in the array, then move the last item to position i. This compacts the scroll array at the same time of removing the line */ -- cgit v1.2.3