summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/grey.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/grey.h')
-rw-r--r--apps/plugins/lib/grey.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h
new file mode 100644
index 0000000000..136794bd26
--- /dev/null
+++ b/apps/plugins/lib/grey.h
@@ -0,0 +1,166 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* New greyscale framework
11*
12* This is a generic framework to display 129 shades of grey on low-depth
13* bitmap LCDs (Archos b&w, Iriver & Ipod 4-grey) within plugins.
14*
15* Copyright (C) 2008 Jens Arnold
16*
17* All files in this archive are subject to the GNU General Public License.
18* See the file COPYING in the source tree root for full license agreement.
19*
20* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21* KIND, either express or implied.
22*
23****************************************************************************/
24
25#ifndef __GREY_H__
26#define __GREY_H__
27
28#include "plugin.h"
29
30#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
31
32#define GREY_BRIGHTNESS(y) (y)
33
34#define GREY_BLACK GREY_BRIGHTNESS(0)
35#define GREY_DARKGRAY GREY_BRIGHTNESS(85)
36#define GREY_LIGHTGRAY GREY_BRIGHTNESS(170)
37#define GREY_WHITE GREY_BRIGHTNESS(255)
38
39/* Library initialisation and release */
40bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
41 bool buffered, int width, int height, long *buf_taken);
42void grey_release(void);
43
44/* Special functions */
45void grey_show(bool enable);
46void grey_deferred_lcd_update(void);
47
48/* Update functions */
49void grey_update(void);
50void grey_update_rect(int x, int y, int width, int height);
51
52/* Parameter handling */
53void grey_set_position(int x, int y);
54void grey_set_drawmode(int mode);
55int grey_get_drawmode(void);
56void grey_set_foreground(unsigned brightness);
57unsigned grey_get_foreground(void);
58void grey_set_background(unsigned brightness);
59unsigned grey_get_background(void);
60void grey_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness);
61void grey_setfont(int newfont);
62int grey_getstringsize(const unsigned char *str, int *w, int *h);
63
64/* Whole display */
65void grey_clear_display(void);
66void grey_ub_clear_display(void);
67
68/* Pixel */
69void grey_drawpixel(int x, int y);
70
71/* Lines */
72void grey_drawline(int x1, int y1, int x2, int y2);
73void grey_hline(int x1, int x2, int y);
74void grey_vline(int x, int y1, int y2);
75void grey_drawrect(int x, int y, int nx, int ny);
76
77/* Filled primitives */
78void grey_fillrect(int x, int y, int nx, int ny);
79void grey_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3);
80
81/* Bitmaps */
82void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
83 int stride, int x, int y, int width, int height);
84void grey_mono_bitmap(const unsigned char *src, int x, int y, int width,
85 int height);
86void grey_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
87 int stride, int x, int y, int width, int height);
88void grey_gray_bitmap(const unsigned char *src, int x, int y, int width,
89 int height);
90void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
91 int stride, int x, int y, int width, int height);
92void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width,
93 int height);
94
95/* Text */
96void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str);
97void grey_putsxy(int x, int y, const unsigned char *str);
98
99/* Scrolling */
100void grey_scroll_left(int count);
101void grey_scroll_right(int count);
102void grey_scroll_up(int count);
103void grey_scroll_down(int count);
104void grey_ub_scroll_left(int count);
105void grey_ub_scroll_right(int count);
106void grey_ub_scroll_up(int count);
107void grey_ub_scroll_down(int count);
108
109/*** Internal stuff ***/
110
111/* flag definitions */
112#define _GREY_RUNNING 0x0001 /* greyscale overlay is running */
113#define _GREY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */
114
115/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
116 * whichever is faster for the architecture) */
117#ifdef CPU_ARM
118#define _GREY_MULUQ(a, b) ((uint32_t) (((uint32_t) (a)) * ((uint32_t) (b))))
119#else
120#define _GREY_MULUQ(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b))))
121#endif
122
123#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
124#define _GREY_X_ADVANCE sizeof(struct grey_data)
125#else
126#if LCD_DEPTH == 1
127#define _GREY_X_ADVANCE (8*sizeof(struct grey_data))
128#elif LCD_DEPTH == 2
129#define _GREY_X_ADVANCE (4*sizeof(struct grey_data))
130#endif
131#endif /* LCD_PIXELFORMAT */
132
133/* The greyscale buffer management structure */
134struct _grey_info
135{
136 int x;
137 int y;
138 int width;
139 int height;
140#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
141 int bx; /* 8-pixel units */
142 int bwidth; /* 8-pixel units */
143#else /* vertical packing */
144 int by; /* 4-pixel or 8-pixel units */
145 int bheight; /* 4-pixel or 8-pixel units */
146#endif
147 unsigned long flags; /* various flags, see #defines */
148#ifndef SIMULATOR
149 struct grey_data *data; /* start of greyscale display data */
150#endif
151 unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */
152 unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */
153 int fg_val; /* current foreground value */
154 int bg_val; /* current background value */
155 int fg_brightness; /* current foreground brightness */
156 int bg_brightness; /* current background brightness */
157 int drawmode; /* current draw mode */
158 int curfont; /* current selected font */
159};
160
161/* Global variables */
162extern struct plugin_api *_grey_rb;
163extern struct _grey_info _grey_info;
164
165#endif /* HAVE_LCD_BITMAP && (LCD_DEPTH < 4) */
166#endif /* __GREY_H__ */