summaryrefslogtreecommitdiff
path: root/apps/plugins/lib
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2010-06-04 08:43:32 +0000
committerMichael Sevakis <jethead71@rockbox.org>2010-06-04 08:43:32 +0000
commitbc26fe7a96d6f5e443003cb871dcb4bfba525352 (patch)
treefa05f187ca308af7bbddbc74a0270cd46cb48b72 /apps/plugins/lib
parente174a8ad8dc531ff093894b7f930f0b9750c74eb (diff)
downloadrockbox-bc26fe7a96d6f5e443003cb871dcb4bfba525352.tar.gz
rockbox-bc26fe7a96d6f5e443003cb871dcb4bfba525352.zip
Add a wrapper header, mylcd.h, in the lib subdirectory, which lets plugins' code automatically call the proper functions depending if compilation is for greylib or color display, also forms proper call to grey_ and xlcd_. mylcd_ub_ call greylib unbuffered routines, regular lcd routines otherwise. Form is mylcd_<fnname>, <fnname> is the symbol name stripped of prefixes lcd_, grey_, or xlcd_. Convert a couple plugins I know well (easy job).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26542 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r--apps/plugins/lib/mylcd.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/apps/plugins/lib/mylcd.h b/apps/plugins/lib/mylcd.h
new file mode 100644
index 0000000000..8b6223c30b
--- /dev/null
+++ b/apps/plugins/lib/mylcd.h
@@ -0,0 +1,142 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2010 Michael Sevakis
11 *
12 * Helper defines for writing code for both grey and color targets.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23#ifndef MYLCD_H
24#define MYLCD_H
25
26/***
27 * Most functions are, other than color depth, equivalent between grey, lcd
28 * and xlcd and most of the time the caller need not be concerned with which
29 * is actually called, making code nicer to read and maintain.
30 *
31 * Unbuffered routines revert to standard rb->lcd_XXXX funtions on color
32 * targets. On color, mylcd_ub_update_XXXX refer to the proper update
33 * functions, otherwise they are no-ops.
34 */
35
36#ifdef HAVE_LCD_COLOR
37#define mylcd_(fn) rb->lcd_##fn
38#define myxlcd_(fn) xlcd_##fn
39#define mylcd_ub_(fn) rb->lcd_##fn
40#define myxlcd_ub_(fn) xlcd_##fn
41#else
42#define mylcd_(fn) grey_##fn
43#define myxlcd_(fn) grey_##fn
44#define mylcd_ub_(fn) grey_ub_##fn
45#define myxlcd_ub_(fn) grey_ub_##fn
46#endif
47
48/* Common colors */
49#ifdef HAVE_LCD_COLOR
50#define MYLCD_BLACK LCD_BLACK
51#define MYLCD_DARKGRAY LCD_DARKGRAY
52#define MYLCD_LIGHTGRAY LCD_LIGHTGRAY
53#define MYLCD_WHITE LCD_WHITE
54#define MYLCD_DEFAULT_FG LCD_DEFAULT_FG
55#define MYLCD_DEFAULT_BG LCD_DEFAULT_BG
56#else
57#define MYLCD_BLACK GREY_BLACK
58#define MYLCD_DARKGRAY GREY_DARKGRAY
59#define MYLCD_LIGHTGRAY GREY_LIGHTGRAY
60#define MYLCD_WHITE GREY_WHITE
61#define MYLCD_DEFAULT_FG GREY_BLACK
62#define MYLCD_DEFAULT_BG GREY_WHITE
63#endif /* HAVE_LCD_COLOR */
64
65/* Update functions */
66#define mylcd_update mylcd_(update)
67#define mylcd_update_rect mylcd_(update_rect)
68
69/* Update functions - unbuffered : special handling for these */
70#ifdef HAVE_LCD_COLOR
71#define mylcd_ub_update() rb->lcd_update()
72#define mylcd_ub_update_rect(...) rb->lcd_update_rect(__VA_ARGS__)
73#else
74/* Still evaluate args like functions */
75static inline void mylcd_ub_update(void)
76 {}
77static inline void mylcd_ub_update_rect(int x, int y, int w, int h)
78 { (void)x; (void)y; (void)w; (void)h; }
79#endif
80
81/* Parameter handling */
82#define mylcd_set_drawmode mylcd_(set_drawmode)
83#define mylcd_get_drawmode mylcd_(get_drawmode)
84#define mylcd_set_foreground mylcd_(set_foreground)
85#define mylcd_get_foreground mylcd_(get_foreground)
86#define mylcd_set_background mylcd_(set_background)
87#define mylcd_get_background mylcd_(get_background)
88#define mylcd_set_drawinfo mylcd_(set_drawinfo)
89#define mylcd_setfont mylcd_(setfont)
90#define mylcd_getstringsize mylcd_(getstringsize)
91
92/* Whole display */
93#define mylcd_clear_display mylcd_(clear_display)
94
95/* Whole display - unbuffered */
96#define mylcd_ub_clear_display mylcd_ub_(clear_display)
97
98/* Pixel */
99#define mylcd_drawpixel mylcd_(drawpixel)
100
101/* Lines */
102#define mylcd_drawline mylcd_(drawline)
103#define mylcd_hline mylcd_(hline)
104#define mylcd_vline mylcd_(vline)
105#define mylcd_drawrect mylcd_(drawrect)
106
107/* Filled Primitives */
108#define mylcd_fillrect mylcd_(fillrect)
109#define mylcd_filltriangle myxlcd_(filltriangle)
110
111/* Bitmaps */
112#define mylcd_mono_bitmap_part mylcd_(mono_bitmap_part)
113#define mylcd_mono_bitmap mylcd_(mono_bitmap)
114#define mylcd_gray_bitmap_part myxlcd_(gray_bitmap_part)
115#define mylcd_gray_bitmap myxlcd_(gray_bitmap)
116#if 0 /* possible, but not implemented in greylib */
117#define mylcd_color_bitmap_part myxlcd_(color_bitmap_part)
118#define mylcd_color_bitmap myxlcd_(color_bitmap)
119#endif
120
121/* Bitmaps - unbuffered */
122#define mylcd_ub_gray_bitmap_part myxlcd_ub_(gray_bitmap_part)
123#define mylcd_ub_gray_bitmap myxlcd_ub_(gray_bitmap)
124
125/* Text */
126/* lcd_putsxyofs is static'ed in the core for now on color */
127#define mylcd_putsxyofs mylcd_(putsxyofs)
128#define mylcd_putsxy mylcd_(putsxy)
129
130/* Scrolling */
131#define mylcd_scroll_left myxlcd_(scroll_left)
132#define mylcd_scroll_right myxlcd_(scroll_right)
133#define mylcd_scroll_up myxlcd_(scroll_up)
134#define mylcd_scroll_down myxlcd_(scroll_down)
135
136/* Scrolling - unbuffered */
137#define mylcd_ub_scroll_left myxlcd_ub_(scroll_left)
138#define mylcd_ub_scroll_right myxlcd_ub_(scroll_right)
139#define mylcd_ub_scroll_up myxlcd_ub_(scroll_up)
140#define mylcd_ub_scroll_down myxlcd_ub_(scroll_down)
141
142#endif /* MYLCD_H */