All pastes #1927825 Raw Edit

lamp.patch

public text v1 · immutable
#1927825 ·published 2010-08-28 17:06 UTC
rendered paste body
Index: apps/plugins/lamp.c
===================================================================
--- apps/plugins/lamp.c	(revision 27916)
+++ apps/plugins/lamp.c	(working copy)
@@ -24,6 +24,7 @@
 
 #include "plugin.h"
 #include "lib/helper.h"
+#include "backlight.h"
 
 
 
@@ -122,9 +123,16 @@
 
 #ifdef HAVE_LCD_COLOR
 /* RGB color sets */
-#define NUM_COLORSETS   2
+#define NUM_COLORSETS    9
 static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } ,    /* white */
-                                          { 255,   0,   0 } };   /* red */
+					  { 255,   0,   0 } ,    /* red */
+					  { 255, 165,   0 } ,    /* orange */
+					  { 255, 255,   0 } ,    /* yellow */
+					  {   0, 255,   0 } ,    /* green */
+					  {   0,   0, 255 } ,    /* blue */
+					  {  75,   0, 130 } ,    /* indigo */
+					  { 238, 130, 238 } ,    /* violet */
+					  {   0,   0,   0 } };   /* black */
 #endif /* HAVE_LCD_COLOR */
 
 /* this is the plugin entry point */
@@ -140,6 +148,7 @@
 
 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
     short old_brightness = rb->global_settings->brightness;
+    static int current_brightness = MAX_BRIGHTNESS_SETTING; /*A known state to start*/
 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
     short old_buttonlight_brightness =
@@ -185,22 +194,25 @@
         rb->lcd_clear_display();
         rb->lcd_update();
 
-        switch((button = rb->button_get(true)))
+        switch((button = rb->button_get_w_tmo(HZ*50)))
         {
             case LAMP_RIGHT:
+            	cs++;
+                break;
 #ifdef LAMP_NEXT
             case LAMP_NEXT:
+            	if (current_brightness != MAX_BRIGHTNESS_SETTING) { rb->backlight_set_brightness(++current_brightness); }
+		break;
 #endif /* LAMP_NEXT */
-                cs++;
+            case LAMP_LEFT:
+            	cs--;
                 break;
-
-            case LAMP_LEFT:
 #ifdef LAMP_PREV
             case LAMP_PREV:
+            	if (current_brightness != MIN_BRIGHTNESS_SETTING) { rb->backlight_set_brightness(--current_brightness); } 
+		break;
 #endif /* LAMP_PREV */
-                cs--;
-                break;
-
+	    case BUTTON_NONE:
             case (LAMP_RIGHT|BUTTON_REPEAT):
             case (LAMP_RIGHT|BUTTON_REL):
             case (LAMP_LEFT|BUTTON_REPEAT):
@@ -208,16 +220,21 @@
 #ifdef LAMP_NEXT
             case (LAMP_NEXT|BUTTON_REPEAT):
             case (LAMP_NEXT|BUTTON_REL):
+            	if (current_brightness != MAX_BRIGHTNESS_SETTING) { rb->backlight_set_brightness(++current_brightness); } 
+		break;
 #endif /* LAMP_NEXT */
 #ifdef LAMP_PREV
             case (LAMP_PREV|BUTTON_REPEAT):
             case (LAMP_PREV|BUTTON_REL):
+            	if (current_brightness != MIN_BRIGHTNESS_SETTING) { rb->backlight_set_brightness(--current_brightness); } 
+		break;
 #endif /* LAMP_PREV */
                 /* eat these... */
                 break;    
             default:
                     quit = true;
         }
+	rb->reset_poweroff_timer();
     } while (!quit);
 
 #else /* HAVE_LCD_COLOR */
@@ -256,4 +273,3 @@
 #endif
     return PLUGIN_OK;
 }
-