1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (c) 2010 Michael Sevakis
12 * Helper defines for writing code for pgfx, grey and color targets.
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.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
27 * Most functions are, other than color depth, equivalent between pgfx, grey,
28 * lcd and xlcd and most of the time the caller need not be concerned with
29 * which is actually called, making code nicer to read and maintain.
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.
35 * lib/playergfx.h or lib/grey.h should be included before including this
36 * header. For bitmap LCD's, defaults to rb->lcd_XXXX otherwise.
38 #if defined (HAVE_LCD_CHARCELLS) && defined(__PGFX_H__)
39 #define MYLCD_CFG_PGFX /* using PGFX */
40 #define mylcd_(fn) pgfx_##fn
41 #define mylcd_ub_(fn) pgfx_##fn
43 #elif defined (HAVE_LCD_BITMAP) && (LCD_DEPTH < 8) && defined(__GREY_H__)
44 #define MYLCD_CFG_GREYLIB /* using greylib */
45 #define mylcd_(fn) grey_##fn
46 #define myxlcd_(fn) grey_##fn
47 #define mylcd_ub_(fn) grey_ub_##fn
48 #define myxlcd_ub_(fn) grey_ub_##fn
51 #define MYLCD_BLACK GREY_BLACK
52 #define MYLCD_DARKGRAY GREY_DARKGRAY
53 #define MYLCD_LIGHTGRAY GREY_LIGHTGRAY
54 #define MYLCD_WHITE GREY_WHITE
55 #define MYLCD_DEFAULT_FG GREY_BLACK
56 #define MYLCD_DEFAULT_BG GREY_WHITE
58 #elif defined (HAVE_LCD_BITMAP)
59 #define MYLCD_CFG_RB_XLCD /* using standard (X)LCD routines */
60 #define mylcd_(fn) rb->lcd_##fn
61 #define myxlcd_(fn) xlcd_##fn
62 #define mylcd_ub_(fn) rb->lcd_##fn
63 #define myxlcd_ub_(fn) xlcd_##fn
66 #define MYLCD_BLACK LCD_BLACK
67 #define MYLCD_DARKGRAY LCD_DARKGRAY
68 #define MYLCD_LIGHTGRAY LCD_LIGHTGRAY
69 #define MYLCD_WHITE LCD_WHITE
70 #define MYLCD_DEFAULT_FG LCD_DEFAULT_FG
71 #define MYLCD_DEFAULT_BG LCD_DEFAULT_BG
74 #error Configuration not supported! Did you forget to include the correct lib header?
75 #endif /* end LCD type selection */
77 /* Update functions */
78 #define mylcd_update mylcd_(update)
79 #ifdef HAVE_LCD_BITMAP
80 #define mylcd_update_rect mylcd_(update_rect)
82 static inline void mylcd_update_rect(int x
, int y
, int w
, int h
)
83 { (void)x
; (void)y
; (void)w
; (void)h
; pgfx_update(); }
84 #endif /* HAVE_LCD_BITMAP */
86 /* Update functions - unbuffered : special handling for these
87 * It is desirable to still evaluate arguments even if there will
88 * be no function call, just in case they have side-effects.
90 #if defined (MYLCD_CFG_PGFX)
91 #define mylcd_ub_update pgfx_update
92 static inline void mylcd_ub_update_rect(int x
, int y
, int w
, int h
)
93 { (void)x
; (void)y
; (void)w
; (void)h
; pgfx_update(); }
95 #elif defined (MYLCD_CFG_GREYLIB)
96 static inline void mylcd_ub_update(void)
98 static inline void mylcd_ub_update_rect(int x
, int y
, int w
, int h
)
99 { (void)x
; (void)y
; (void)w
; (void)h
; }
101 #else /* color or RB default */
102 #define mylcd_ub_update rb->lcd_update
103 #define mylcd_ub_update_rect rb->lcd_update_rect
106 /* Parameter handling */
107 #define mylcd_set_drawmode mylcd_(set_drawmode)
108 #define mylcd_get_drawmode mylcd_(get_drawmode)
110 #ifdef HAVE_LCD_BITMAP
111 #define mylcd_set_foreground mylcd_(set_foreground)
112 #define mylcd_get_foreground mylcd_(get_foreground)
113 #define mylcd_set_background mylcd_(set_background)
114 #define mylcd_get_background mylcd_(get_background)
115 #define mylcd_set_drawinfo mylcd_(set_drawinfo)
116 #define mylcd_setfont mylcd_(setfont)
117 #define mylcd_getstringsize mylcd_(getstringsize)
118 #endif /* HAVE_LCD_BITMAP */
121 #define mylcd_clear_display mylcd_(clear_display)
123 /* Whole display - unbuffered */
124 #define mylcd_ub_clear_display mylcd_ub_(clear_display)
127 #define mylcd_drawpixel mylcd_(drawpixel)
130 #define mylcd_drawline mylcd_(drawline)
131 #define mylcd_hline mylcd_(hline)
132 #define mylcd_vline mylcd_(vline)
133 #define mylcd_drawrect mylcd_(drawrect)
135 /* Filled Primitives */
136 #define mylcd_fillrect mylcd_(fillrect)
137 #ifdef HAVE_LCD_BITMAP
138 #define mylcd_filltriangle myxlcd_(filltriangle)
139 #endif /* HAVE_LCD_BITMAP */
142 #define mylcd_mono_bitmap_part mylcd_(mono_bitmap_part)
143 #define mylcd_mono_bitmap mylcd_(mono_bitmap)
145 #ifdef HAVE_LCD_BITMAP
146 #define mylcd_gray_bitmap_part myxlcd_(gray_bitmap_part)
147 #define mylcd_gray_bitmap myxlcd_(gray_bitmap)
148 #if 0 /* possible, but not implemented in greylib */
149 #define mylcd_color_bitmap_part myxlcd_(color_bitmap_part)
150 #define mylcd_color_bitmap myxlcd_(color_bitmap)
152 #endif /* HAVE_LCD_BITMAP */
154 /* Bitmaps - unbuffered */
155 #ifdef HAVE_LCD_BITMAP
156 #define mylcd_ub_gray_bitmap_part myxlcd_ub_(gray_bitmap_part)
157 #define mylcd_ub_gray_bitmap myxlcd_ub_(gray_bitmap)
158 #endif /* HAVE_LCD_BITMAP */
161 /* lcd_putsxyofs is static'ed in the core for now on color */
162 #ifdef HAVE_LCD_BITMAP
163 #define mylcd_putsxyofs mylcd_(putsxyofs)
164 #define mylcd_putsxy mylcd_(putsxy)
165 #endif /* HAVE_LCD_BITMAP */
168 #ifdef HAVE_LCD_BITMAP
169 #define mylcd_scroll_left myxlcd_(scroll_left)
170 #define mylcd_scroll_right myxlcd_(scroll_right)
171 #define mylcd_scroll_up myxlcd_(scroll_up)
172 #define mylcd_scroll_down myxlcd_(scroll_down)
173 #endif /* HAVE_LCD_BITMAP */
175 /* Scrolling - unbuffered */
176 #ifdef HAVE_LCD_BITMAP
177 #define mylcd_ub_scroll_left myxlcd_ub_(scroll_left)
178 #define mylcd_ub_scroll_right myxlcd_ub_(scroll_right)
179 #define mylcd_ub_scroll_up myxlcd_ub_(scroll_up)
180 #define mylcd_ub_scroll_down myxlcd_ub_(scroll_down)
181 #endif /* HAVE_LCD_BITMAP */