summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-04-04 07:12:10 +0200
committerThomas Martitz <kugel@rockbox.org>2013-12-14 23:11:30 +0100
commitb094d80dab4f7ac501172d0412e9e53289ede27b (patch)
tree797ed5c9103e292bf9c9912281d4e124dd6c7421
parent1c5d0b41eebdb4f8c627b1a0e5f7b699f0b08fb8 (diff)
downloadrockbox-b094d80dab4f7ac501172d0412e9e53289ede27b.tar.gz
rockbox-b094d80dab4f7ac501172d0412e9e53289ede27b.zip
scroll_engine: Split out common main and remote lcd functions.
Uses a similar technique as lcd_*.c files of #including a common .c file, so that a unified implementation can be reused for both displays. Change-Id: I21f6de76df757b093e1a1dff0a4caf96a44fe77e
-rw-r--r--firmware/drivers/lcd-scroll.c127
-rw-r--r--firmware/scroll_engine.c181
2 files changed, 137 insertions, 171 deletions
diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c
new file mode 100644
index 0000000000..ffd4663c79
--- /dev/null
+++ b/firmware/drivers/lcd-scroll.c
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Michael Sevakis
+ *
+ * LCD scroll control functions (API to apps).
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* This file is meant to be #included by scroll_engine.c (twice if a remote
+ * is present) */
+
+#ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */
+#define LCDFN(fn) lcd_ ## fn
+#define LCDM(ma) LCD_ ## ma
+#define MAIN_LCD
+#endif
+
+static struct scrollinfo LCDFN(scroll)[LCD_SCROLLABLE_LINES];
+
+struct scroll_screen_info LCDFN(scroll_info) =
+{
+ .scroll = LCDFN(scroll),
+ .lines = 0,
+ .ticks = 12,
+ .delay = HZ/2,
+ .bidir_limit = 50,
+#ifdef HAVE_LCD_BITMAP
+ .step = 6,
+#endif
+#ifdef HAVE_LCD_CHARCELLS
+ .jump_scroll_delay = HZ/4,
+ .jump_scroll = 0,
+#endif
+};
+
+
+void LCDFN(scroll_stop)(void)
+{
+ LCDFN(scroll_info).lines = 0;
+}
+
+/* Stop scrolling line y in the specified viewport, or all lines if y < 0 */
+void LCDFN(scroll_stop_viewport_line)(const struct viewport *current_vp, int line)
+{
+ int i = 0;
+
+ while (i < LCDFN(scroll_info).lines)
+ {
+ struct viewport *vp = LCDFN(scroll_info).scroll[i].vp;
+ if (((vp == current_vp)) &&
+ ((line < 0) || (LCDFN(scroll_info).scroll[i].y == line)))
+ {
+ /* If i is not the last active line in the array, then move
+ the last item to position i */
+ if ((i + 1) != LCDFN(scroll_info).lines)
+ {
+ LCDFN(scroll_info).scroll[i] =
+ LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines-1];
+ }
+ LCDFN(scroll_info).lines--;
+
+ /* A line can only appear once, so we're done,
+ * unless we are clearing the whole viewport */
+ if (line >= 0)
+ return ;
+ }
+ else
+ {
+ i++;
+ }
+ }
+}
+
+/* Stop all scrolling lines in the specified viewport */
+void LCDFN(scroll_stop_viewport)(const struct viewport *current_vp)
+{
+ LCDFN(scroll_stop_viewport_line)(current_vp, -1);
+}
+
+void LCDFN(scroll_speed)(int speed)
+{
+ LCDFN(scroll_info).ticks = scroll_tick_table[speed];
+}
+
+#if defined(HAVE_LCD_BITMAP)
+void LCDFN(scroll_step)(int step)
+{
+ LCDFN(scroll_info).step = step;
+}
+#endif
+
+void LCDFN(scroll_delay)(int ms)
+{
+ LCDFN(scroll_info).delay = ms / (HZ / 10);
+}
+
+void LCDFN(bidir_scroll)(int percent)
+{
+ LCDFN(scroll_info).bidir_limit = percent;
+}
+
+#ifdef HAVE_LCD_CHARCELLS
+void LCDFN(jump_scroll)(int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */
+{
+ LCDFN(scroll_info).jump_scroll = mode;
+}
+
+void LCDFN(jump_scroll_delay)(int ms)
+{
+ LCDFN(scroll_info).jump_scroll_delay = ms / (HZ / 10);
+}
+#endif
diff --git a/firmware/scroll_engine.c b/firmware/scroll_engine.c
index 82af26afa8..d134f7b2ce 100644
--- a/firmware/scroll_engine.c
+++ b/firmware/scroll_engine.c
@@ -9,7 +9,7 @@
*
* Copyright (C) 2007 by Michael Sevakis
*
- * LCD scrolling driver and scheduler
+ * LCD scrolling thread and scheduler
*
* Much collected and combined from the various Rockbox LCD drivers.
*
@@ -22,6 +22,7 @@
* KIND, either express or implied.
*
****************************************************************************/
+
#include "config.h"
#include "gcc_extensions.h"
#include "cpu.h"
@@ -49,181 +50,19 @@ static void scroll_thread(void);
static char scroll_stack[DEFAULT_STACK_SIZE*3];
static const char scroll_name[] = "scroll";
-static struct scrollinfo lcd_scroll[LCD_SCROLLABLE_LINES];
+#include "drivers/lcd-scroll.c"
#ifdef HAVE_REMOTE_LCD
-static struct scrollinfo lcd_remote_scroll[LCD_REMOTE_SCROLLABLE_LINES];
static struct event_queue scroll_queue SHAREDBSS_ATTR;
-#endif
-
-struct scroll_screen_info lcd_scroll_info =
-{
- .scroll = lcd_scroll,
- .lines = 0,
- .ticks = 12,
- .delay = HZ/2,
- .bidir_limit = 50,
-#ifdef HAVE_LCD_BITMAP
- .step = 6,
-#endif
-#ifdef HAVE_LCD_CHARCELLS
- .jump_scroll_delay = HZ/4,
- .jump_scroll = 0,
-#endif
-};
-
-#ifdef HAVE_REMOTE_LCD
-struct scroll_screen_info lcd_remote_scroll_info =
-{
- .scroll = lcd_remote_scroll,
- .lines = 0,
- .ticks = 12,
- .delay = HZ/2,
- .bidir_limit = 50,
- .step = 6,
-};
-#endif /* HAVE_REMOTE_LCD */
-
-void lcd_scroll_stop(void)
-{
- lcd_scroll_info.lines = 0;
-}
-
-/* Stop scrolling line y in the specified viewport, or all lines if y < 0 */
-void lcd_scroll_stop_viewport_line(const struct viewport *current_vp, int line)
-{
- int i = 0;
-
- while (i < lcd_scroll_info.lines)
- {
- struct viewport *vp = lcd_scroll_info.scroll[i].vp;
- if (((vp == current_vp)) &&
- ((line < 0) || (lcd_scroll_info.scroll[i].y == line)))
- {
- /* If i is not the last active line in the array, then move
- the last item to position i */
- if ((i + 1) != lcd_scroll_info.lines)
- {
- lcd_scroll_info.scroll[i] =
- lcd_scroll_info.scroll[lcd_scroll_info.lines-1];
- }
- lcd_scroll_info.lines--;
- /* A line can only appear once, so we're done,
- * unless we are clearing the whole viewport */
- if (line >= 0)
- return ;
- }
- else
- {
- i++;
- }
- }
-}
-
-/* Stop all scrolling lines in the specified viewport */
-void lcd_scroll_stop_viewport(const struct viewport *current_vp)
-{
- lcd_scroll_stop_viewport_line(current_vp, -1);
-}
-
-void lcd_scroll_speed(int speed)
-{
- lcd_scroll_info.ticks = scroll_tick_table[speed];
-}
-
-#if defined(HAVE_LCD_BITMAP)
-void lcd_scroll_step(int step)
-{
- lcd_scroll_info.step = step;
-}
-#endif
+/* copied from lcd-remote-1bit.c */
+/* Compile 1 bit vertical packing LCD driver for remote LCD */
+#undef LCDFN
+#define LCDFN(fn) lcd_remote_ ## fn
+#undef LCDM
+#define LCDM(ma) LCD_REMOTE_ ## ma
-void lcd_scroll_delay(int ms)
-{
- lcd_scroll_info.delay = ms / (HZ / 10);
-}
-
-void lcd_bidir_scroll(int percent)
-{
- lcd_scroll_info.bidir_limit = percent;
-}
-
-#ifdef HAVE_LCD_CHARCELLS
-void lcd_jump_scroll(int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */
-{
- lcd_scroll_info.jump_scroll = mode;
-}
-
-void lcd_jump_scroll_delay(int ms)
-{
- lcd_scroll_info.jump_scroll_delay = ms / (HZ / 10);
-}
-#endif
-
-#ifdef HAVE_REMOTE_LCD
-void lcd_remote_scroll_stop(void)
-{
- lcd_remote_scroll_info.lines = 0;
-}
-
-/* Stop scrolling line y in the specified viewport, or all lines if y < 0 */
-void lcd_remote_scroll_stop_viewport_line(const struct viewport *current_vp, int line)
-{
- int i = 0;
-
- while (i < lcd_scroll_info.lines)
- {
- struct viewport *vp = lcd_remote_scroll_info.scroll[i].vp;
- if (((vp == current_vp)) &&
- ((line < 0) || (lcd_remote_scroll_info.scroll[i].y == line)))
- {
- /* If i is not the last active line in the array, then move
- the last item to position i */
- if ((i + 1) != lcd_remote_scroll_info.lines)
- {
- lcd_remote_scroll_info.scroll[i] =
- lcd_remote_scroll_info.scroll[lcd_remote_scroll_info.lines-1];
- }
- lcd_remote_scroll_info.lines--;
-
- /* A line can only appear once, so we're done,
- * unless we are clearing the whole viewport */
- if (line >= 0)
- return ;
- }
- else
- {
- i++;
- }
- }
-}
-
-/* Stop all scrolling lines in the specified viewport */
-void lcd_remote_scroll_stop_viewport(const struct viewport *current_vp)
-{
- lcd_remote_scroll_stop_viewport_line(current_vp, -1);
-}
-
-void lcd_remote_scroll_speed(int speed)
-{
- lcd_remote_scroll_info.ticks = scroll_tick_table[speed];
-}
-
-void lcd_remote_scroll_step(int step)
-{
- lcd_remote_scroll_info.step = step;
-}
-
-void lcd_remote_scroll_delay(int ms)
-{
- lcd_remote_scroll_info.delay = ms / (HZ / 10);
-}
-
-void lcd_remote_bidir_scroll(int percent)
-{
- lcd_remote_scroll_info.bidir_limit = percent;
-}
+#include "drivers/lcd-scroll.c"
static void sync_display_ticks(void)
{