summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2008-04-24 00:06:45 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2008-04-24 00:06:45 +0000
commit8efd5d3fdf8833e8b8dfa87d10a5d97f8388c0b8 (patch)
tree225d9140ea72250052bc8b9c183c1caa27562d4a
parentbcb442d0a28dd0053ba62d88a31159d9c9b25b2c (diff)
downloadrockbox-8efd5d3fdf8833e8b8dfa87d10a5d97f8388c0b8.zip
rockbox-8efd5d3fdf8833e8b8dfa87d10a5d97f8388c0b8.tar.gz
rockbox-8efd5d3fdf8833e8b8dfa87d10a5d97f8388c0b8.tar.bz2
rockbox-8efd5d3fdf8833e8b8dfa87d10a5d97f8388c0b8.tar.xz
Flashlight plugin: support inverted LCD (somebody with a target please test), replace the ugly floats with a much simpler color set. For now white and red are defined.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17230 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/plugins/flashlight.c109
3 files changed, 47 insertions, 70 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index fa59fcf..b3710e4 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -581,7 +581,9 @@ static const struct plugin_api rockbox_api = {
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
backlight_set_brightness,
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
-
+#ifdef HAVE_LCD_INVERT
+ lcd_set_invert_display,
+#endif /* HAVE_LCD_INVERT */
};
int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 9ca1473..461966e 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -728,7 +728,9 @@ struct plugin_api {
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
void (*backlight_set_brightness)(int val);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
-
+#ifdef HAVE_LCD_INVERT
+ void (*lcd_set_invert_display)(bool yesno);
+#endif /* HAVE_LCD_INVERT */
};
/* plugin header */
diff --git a/apps/plugins/flashlight.c b/apps/plugins/flashlight.c
index 02449ca..5127c53 100644
--- a/apps/plugins/flashlight.c
+++ b/apps/plugins/flashlight.c
@@ -81,53 +81,11 @@ PLUGIN_HEADER
static struct plugin_api* rb; /* global api struct pointer */
#ifdef HAVE_LCD_COLOR
-void hsv_to_rgb(float hue, float sat, float v,
- float *red, float *green, float *blue)
-{
- float r, g, b;
-
- if (hue > 0.17 && hue <= 0.33) /* green/red */
- {
- g = 1.0;
- r = ((float)0.33 - hue) / (float)0.16;
- b = 0.0;
- }
- else if (hue > 0.33 && hue <= 0.5) /* green/blue */
- {
- g = 1.0;
- b = (hue - (float)0.33) / (float)0.17;
- r = 0.0;
- }
- else if (hue > 0.5 && hue <= 0.67) /* blue/green */
- {
- b = 1.0;
- g = ((float)0.67 - hue) / (float)0.17;
- r = 0.0;
- }
- else if (hue > 0.67 && hue <= 0.83) /* blue/red */
- {
- b = 1.0;
- r = (hue - (float)0.67) / (float)0.16;
- g = 0.0;
- }
- else if (hue > 0.83 && hue <= 1.0) /* red/blue */
- {
- r = 1.0;
- b = ((float)1.0 - hue) / (float)0.17;
- g = 0.0;
- }
- else /* red/green */
- {
- r = 1.0;
- g = hue / (float)0.17;
- b = 0.0;
- }
-
- *red = (sat * r + ((float)1.0 - sat)) * v;
- *green = (sat * g + ((float)1.0 - sat)) * v;
- *blue = (sat * b + ((float)1.0 - sat)) * v;
-}
-#endif
+/* RGB color sets */
+#define NUM_COLORSETS 2
+static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */
+ { 255, 0, 0 } }; /* red */
+#endif /* HAVE_LCD_COLOR */
/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@@ -136,8 +94,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb = api;
#ifdef HAVE_LCD_COLOR
- int h = 0;
- float var_r, var_g, var_b;
+ int cs = 0;
bool quit = false;
#endif /* HAVE_LCD_COLOR */
@@ -146,56 +103,68 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#if LCD_DEPTH > 1
- rb->lcd_set_backdrop(NULL);
unsigned bg_color=rb->lcd_get_background();
+ rb->lcd_set_backdrop(NULL);
rb->lcd_set_background(LCD_WHITE);
#endif
+
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
rb->backlight_set_brightness(MAX_BRIGHTNESS_SETTING);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
+#ifdef HAVE_LCD_INVERT
+#ifdef OLYMPUS_MROBE_100
+ /* mrobe-100 has inverted display so invert it for max brightness */
+ lcd_set_invert_display(true);
+#else
+ lcd_set_invert_display(false);
+#endif /* OLYMPUS_MROBE_100 */
+#endif /* HAVE_LCD_INVERT */
+
backlight_force_on(rb);
#ifdef HAVE_LCD_COLOR
do
{
- if (h != 0)
- {
- hsv_to_rgb( ((float)(h - 5) / 360.0), 1, 1, &var_r, &var_g, &var_b);
- rb->lcd_set_background( LCD_RGBPACK( ((int)(var_r * 255)),
- ((int)(var_g * 255)),
- ((int)(var_b * 255)) ) );
- }
- else
- { /* Whilte screen */
- rb->lcd_set_background(LCD_WHITE);
- }
+ if((cs < 0) || (cs >= NUM_COLORSETS))
+ cs = 0;
+ rb->lcd_set_background( LCD_RGBPACK( colorset[cs][0],
+ colorset[cs][1],
+ colorset[cs][2] ) );
rb->lcd_clear_display();
rb->lcd_update();
switch(rb->button_get(true))
{
case FLASHLIGHT_RIGHT:
- case (FLASHLIGHT_RIGHT|BUTTON_REPEAT):
- case (FLASHLIGHT_RIGHT|BUTTON_REL):
#ifdef FLASHLIGHT_NEXT
case FLASHLIGHT_NEXT:
- case (FLASHLIGHT_NEXT|BUTTON_REPEAT):
- case (FLASHLIGHT_NEXT|BUTTON_REL):
#endif /* FLASHLIGHT_NEXT */
- h = (h + 5) % 365;
+ cs++;
break;
+
case FLASHLIGHT_LEFT:
+#ifdef FLASHLIGHT_PREV
+ case FLASHLIGHT_PREV:
+#endif /* FLASHLIGHT_PREV */
+ cs--;
+ break;
+
+ case (FLASHLIGHT_RIGHT|BUTTON_REPEAT):
+ case (FLASHLIGHT_RIGHT|BUTTON_REL):
case (FLASHLIGHT_LEFT|BUTTON_REPEAT):
case (FLASHLIGHT_LEFT|BUTTON_REL):
+#ifdef FLASHLIGHT_NEXT
+ case (FLASHLIGHT_NEXT|BUTTON_REPEAT):
+ case (FLASHLIGHT_NEXT|BUTTON_REL):
+#endif /* FLASHLIGHT_NEXT */
#ifdef FLASHLIGHT_PREV
case FLASHLIGHT_PREV:
case (FLASHLIGHT_PREV|BUTTON_REPEAT):
case (FLASHLIGHT_PREV|BUTTON_REL):
#endif /* FLASHLIGHT_PREV */
- h = (h + 360) % 365;
+ /* eat these... */
break;
-
default:
quit = true;
}
@@ -215,6 +184,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* restore */
backlight_use_settings(rb);
+#ifdef HAVE_LCD_INVERT
+ lcd_set_invert_display(rb->global_settings->invert);
+#endif /* HAVE_LCD_INVERT */
+
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
rb->backlight_set_brightness(old_brightness);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */