From d79a1bf55f80295ba863d4ed36cf4dd2fb7154f6 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Mon, 20 Jan 2020 23:34:14 -0800 Subject: [PATCH] right scrolling --- components/squeezelite/display.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/components/squeezelite/display.c b/components/squeezelite/display.c index 50ccafbf..58f377b5 100644 --- a/components/squeezelite/display.c +++ b/components/squeezelite/display.c @@ -364,23 +364,30 @@ static void scroll_task(void *args) { u8_t *scroll_ptr, *frame; bool active = false; int len = display->width * display->height / 8; - int scroll_len; + int scroll_len, scroll_step; while (1) { if (!active) vTaskSuspend(NULL); - + // restart at the beginning - I don't know what right scrolling means ... - scroll_ptr = scroller.scroll_frame; scroll_len = len - (display->width - scroller.scroll_width) * display->height / 8; + if (scroller.direction == 1) { + scroll_ptr = scroller.scroll_frame; + scroll_step = scroller.by * display->height / 8; + } else { + scroll_ptr = scroller.scroll_frame + scroller.size - scroll_len; + scroll_step = -scroller.by * display->height / 8; + } + frame = malloc(display->width * display->height / 8); // scroll required amount of columns (within the window) - while (scroll_ptr <= scroller.scroll_frame + scroller.size - scroller.by * display->height / 8 - len) { - scroll_ptr += scroller.by * display->height / 8; - + while (scroller.direction == 1 ? (scroll_ptr <= scroller.scroll_frame + scroller.size - scroll_step - len) : + (scroll_ptr + scroll_step >= scroller.scroll_frame) ) { // build a combined frame memcpy(frame, scroller.back_frame, len); for (int i = 0; i < scroll_len; i++) frame[i] |= scroll_ptr[i]; + scroll_ptr += scroll_step; xSemaphoreTake(display_sem, portMAX_DELAY); active = scroller.active;