summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/grey_parm.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/grey_parm.c')
-rw-r--r--apps/plugins/lib/grey_parm.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/apps/plugins/lib/grey_parm.c b/apps/plugins/lib/grey_parm.c
new file mode 100644
index 0000000000..6d605059f8
--- /dev/null
+++ b/apps/plugins/lib/grey_parm.c
@@ -0,0 +1,116 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* New greyscale framework
11* Parameter handling
12*
13* This is a generic framework to display 129 shades of grey on low-depth
14* bitmap LCDs (Archos b&w, Iriver & Ipod 4-grey) within plugins.
15*
16* Copyright (C) 2008 Jens Arnold
17*
18* All files in this archive are subject to the GNU General Public License.
19* See the file COPYING in the source tree root for full license agreement.
20*
21* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22* KIND, either express or implied.
23*
24****************************************************************************/
25
26#include "plugin.h"
27#include "grey.h"
28
29/* Set position of the top left corner of the greyscale overlay
30 Note that depending on the target LCD, either x or y gets rounded
31 to the nearest multiple of 4 or 8 */
32void grey_set_position(int x, int y)
33{
34#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
35 _grey_info.bx = (x + 4) >> 3;
36 x = 8 * _grey_info.bx;
37#else
38#if LCD_DEPTH == 1
39 _grey_info.by = (y + 4) >> 3;
40 y = 8 * _grey_info.by;
41#elif LCD_DEPTH == 2
42 _grey_info.by = (y + 2) >> 2;
43 y = 4 * _grey_info.by;
44#endif
45#endif /* LCD_PIXELFORMAT */
46 _grey_info.x = x;
47 _grey_info.y = y;
48
49 if (_grey_info.flags & _GREY_RUNNING)
50 {
51#ifdef SIMULATOR
52 grey_deferred_lcd_update();
53 grey_update();
54#else
55 _grey_info.flags |= _GREY_DEFERRED_UPDATE;
56#endif
57 }
58}
59
60/* Set the draw mode for subsequent drawing operations */
61void grey_set_drawmode(int mode)
62{
63 _grey_info.drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
64}
65
66/* Return the current draw mode */
67int grey_get_drawmode(void)
68{
69 return _grey_info.drawmode;
70}
71
72/* Set the foreground shade for subsequent drawing operations */
73void grey_set_foreground(unsigned brightness)
74{
75 _grey_info.fg_val = _grey_info.gvalue[brightness];
76 _grey_info.fg_brightness = brightness;
77}
78
79/* Return the current foreground shade */
80unsigned grey_get_foreground(void)
81{
82 return _grey_info.fg_brightness;
83}
84
85/* Set the background shade for subsequent drawing operations */
86void grey_set_background(unsigned brightness)
87{
88 _grey_info.bg_val = _grey_info.gvalue[brightness];
89 _grey_info.bg_brightness = brightness;
90}
91
92/* Return the current background shade */
93unsigned grey_get_background(void)
94{
95 return _grey_info.bg_brightness;
96}
97
98/* Set draw mode, foreground and background shades at once */
99void grey_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
100{
101 grey_set_drawmode(mode);
102 grey_set_foreground(fg_brightness);
103 grey_set_background(bg_brightness);
104}
105
106/* Set font for the text output routines */
107void grey_setfont(int newfont)
108{
109 _grey_info.curfont = newfont;
110}
111
112/* Get width and height of a text when printed with the current font */
113int grey_getstringsize(const unsigned char *str, int *w, int *h)
114{
115 return _grey_rb->font_getstringsize(str, w, h, _grey_info.curfont);
116}