summaryrefslogtreecommitdiff
path: root/apps/plugins/grayscale.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-07-28 09:15:00 +0000
committerJens Arnold <amiconn@rockbox.org>2005-07-28 09:15:00 +0000
commitb65b52b1b9de11482b7e8cb5ef4260e8dcc2f0d6 (patch)
tree139334f92f5469ce81f7b8898157f4fe9f2125bb /apps/plugins/grayscale.c
parent05af28036ee5d1dce5aaacc6482d0822caa54ce3 (diff)
Adjusted grayscale demo plugin to H1x0: (1) Button assignment. (2) Variable screen resolution.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7248 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/grayscale.c')
-rw-r--r--apps/plugins/grayscale.c63
1 files changed, 44 insertions, 19 deletions
diff --git a/apps/plugins/grayscale.c b/apps/plugins/grayscale.c
index e543f15427..3b86304123 100644
--- a/apps/plugins/grayscale.c
+++ b/apps/plugins/grayscale.c
@@ -22,7 +22,7 @@
#ifndef SIMULATOR /* not for simulator by now */
#include "plugin.h"
-#if CONFIG_LCD == LCD_SSD1815 /* only for Recorder/Ondio displays */
+#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
#include "gray.h"
/* variable button definitions */
@@ -30,6 +30,17 @@
#define GRAYSCALE_SHIFT BUTTON_ON
#elif CONFIG_KEYPAD == ONDIO_PAD
#define GRAYSCALE_SHIFT BUTTON_MENU
+#elif CONFIG_KEYPAD == IRIVER_H100_PAD
+#define GRAYSCALE_SHIFT BUTTON_ON
+#endif
+
+#define GFX_HEIGHT (LCD_HEIGHT-8)
+#if LCD_WIDTH < 160
+#define GFX_GRAYTONE_WIDTH 86
+#define GFX_GRAYTONE_STEP 3
+#else
+#define GFX_GRAYTONE_WIDTH 128
+#define GFX_GRAYTONE_STEP 2
#endif
/******************************* Globals ***********************************/
@@ -139,12 +150,15 @@ int main(void)
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
/* initialize the greyscale buffer:
- * 112 pixels wide, 7 rows (56 pixels) high, (try to) reserve
- * 32 bitplanes for 33 shades of grey. */
- shades = gray_init(rb, gbuf, gbuf_size, true, 112, 7, 32, NULL) + 1;
+ Archos: 112 pixels wide, 7 rows (56 pixels) high, (try to) reserve
+ 32 bitplanes for 33 shades of grey.
+ H1x0: 160 pixels wide, 30 rows (120 pixels) high, (try to) reserve
+ 32 bitplanes for 33 shades of grey. */
+ shades = gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH,
+ (GFX_HEIGHT*LCD_DEPTH/8), 32, NULL) + 1;
/* place greyscale overlay 1 row down */
- gray_set_position(0, 1);
+ gray_set_position(0, LCD_DEPTH);
rb->snprintf(pbuf, sizeof(pbuf), "Shades: %d", shades);
rb->lcd_puts(0, 0, pbuf);
@@ -159,36 +173,47 @@ int main(void)
/* draw a dark grey line star background */
gray_set_foreground(80);
- for (y = 0; y < 56; y += 8) /* horizontal part */
+ for (y = 0; y < GFX_HEIGHT; y += 8) /* horizontal part */
{
- gray_drawline(0, y, 111, 55 - y); /* grey lines */
+ gray_drawline(0, y, (LCD_WIDTH-1), (GFX_HEIGHT-1) - y); /*grey lines */
}
- for (x = 10; x < 112; x += 10) /* vertical part */
+ for (x = 10; x <= LCD_WIDTH; x += 10) /* vertical part */
{
- gray_drawline(x, 0, 111 - x, 55); /* grey lines */
+ gray_drawline(x, 0, (LCD_WIDTH-1) - x, (GFX_HEIGHT-1)); /*grey lines */
}
gray_set_foreground(0);
- gray_drawrect(0, 0, 112, 56); /* black border */
+ gray_drawrect(0, 0, LCD_WIDTH, GFX_HEIGHT); /* black border */
/* draw grey tones */
- for (i = 0; i < 86; i++)
+ for (i = 0; i < GFX_GRAYTONE_WIDTH; i++)
{
- x = 13 + i;
- gray_set_foreground(3 * i);
- gray_vline(x, 6, 49); /* vertical lines */
+ x = ((LCD_WIDTH-GFX_GRAYTONE_WIDTH)/2) + i;
+ gray_set_foreground(GFX_GRAYTONE_STEP * i);
+ /* vertical lines */
+ gray_vline(x, (GFX_HEIGHT/8), (GFX_HEIGHT-GFX_HEIGHT/8-1));
}
gray_set_drawmode(DRMODE_COMPLEMENT);
- gray_fillrect(13, 29, 86, 21); /* invert rectangle (lower half) */
- gray_drawline(13, 27, 98, 27); /* invert a line */
+ /* invert rectangle (lower half) */
+ gray_fillrect((LCD_WIDTH-GFX_GRAYTONE_WIDTH)/2, (GFX_HEIGHT/2+1),
+ GFX_GRAYTONE_WIDTH, (GFX_HEIGHT/2-GFX_HEIGHT/8-1));
+ /* invert a line */
+ gray_hline((LCD_WIDTH-GFX_GRAYTONE_WIDTH)/2,
+ (LCD_WIDTH+GFX_GRAYTONE_WIDTH)/2, (GFX_HEIGHT/2-1));
/* show bitmaps (1 bit and 8 bit) */
+ /* opaque */
gray_set_drawinfo(DRMODE_SOLID, 255, 100);
- gray_mono_bitmap(rockbox, 14, 13, 43, 7); /* opaque */
+ gray_mono_bitmap(rockbox,
+ MAX((LCD_WIDTH/2-47), ((LCD_WIDTH-GFX_GRAYTONE_WIDTH)/2)),
+ (5*GFX_HEIGHT/16-4), 43, 7);
+ /* transparent */
gray_set_drawinfo(DRMODE_FG, 0, 100);
- gray_mono_bitmap(showing, 58, 13, 39, 7); /* transparent */
- gray_gray_bitmap(grayscale_gray, 28, 35, 55, 7);
+ gray_mono_bitmap(showing, (LCD_WIDTH/2+4) , (5*GFX_HEIGHT/16-4), 39, 7);
+ /* greyscale */
+ gray_gray_bitmap(grayscale_gray, ((LCD_WIDTH-55)/2), (11*GFX_HEIGHT/16-4),
+ 55, 7);
gray_update();