initial refactor of led
authorJim Morris <morris@wolfman.com>
Wed, 26 Jun 2013 22:04:44 +0000 (15:04 -0700)
committerJim Morris <morris@wolfman.com>
Wed, 26 Jun 2013 22:04:44 +0000 (15:04 -0700)
src/modules/utils/panel/panels/LcdBase.h
src/modules/utils/panel/panels/VikiLCD.cpp

index 8aa4025..ceef3e3 100644 (file)
@@ -57,15 +57,23 @@ using namespace std;
 #define LCD_BACKLIGHT 0x08
 #define LCD_NOBACKLIGHT 0x00
 
-// for setBacklight(), sets specific leds on some panels
-#define LED_OFF 0x0
-#define LED_RED 0x1
-#define LED_YELLOW 0x3
-#define LED_GREEN 0x2
-#define LED_TEAL 0x6
-#define LED_BLUE 0x4
-#define LED_VIOLET 0x5
-#define LED_WHITE 0x7 
+// convenience LED defintions
+#define LED_1  0x0001
+#define LED_2  0x0002
+#define LED_3  0x0004
+#define LED_4  0x0008
+#define LED_5  0x0010
+#define LED_6  0x0020
+#define LED_7  0x0040
+#define LED_8  0x0080
+#define LED_9  0x0100
+#define LED_10 0x0200
+#define LED_11 0x0400
+#define LED_12 0x0800
+#define LED_13 0x1000
+#define LED_14 0x2000
+#define LED_15 0x4000
+#define LED_16 0x8000
 
 // Standard directional button bits
 #define BUTTON_SELECT 0x01
@@ -107,7 +115,8 @@ class LcdBase {
         virtual int getEncoderResolution()= 0;
                                             
         // optional
-        virtual void setBacklight(uint8_t status){};
+        virtual void setLed(uint16_t led, bool onoff){};
+        virtual void setLedBrightness(uint16_t led, int val){};
         virtual void buzz(long,uint16_t){};
 
         // only used on certain panels
index 3de0399..d830c01 100644 (file)
@@ -94,7 +94,9 @@ void VikiLCD::init(){
        i2c->write(this->i2c_address, data, 2);
 
        // turn leds off
-       setBacklight(0);
+       setLed(0, false);
+       setLed(1, false);
+       setLed(2, false);
        
        //put the LCD into 4 bit mode
        // start with a non-standard command to make it realize we're speaking 4-bit here
@@ -295,13 +297,13 @@ void VikiLCD::write(char value) {
        send(value, 1);
 }
 
-// Allows to set the backlight, if the LCD backpack is used
-void VikiLCD::setBacklight(uint8_t status) {
+// Sets the indicator leds
+void VikiLCD::setLed(uint16_t led, bool onoff) {
        // LED turns on when bit is cleared
        _backlightBits = M17_BIT_LB|M17_BIT_LG|M17_BIT_LR; // all off
-       if (status & LED_RED) _backlightBits &= ~M17_BIT_LR; // red on
-       if (status & LED_GREEN) _backlightBits &= ~M17_BIT_LG; // green on
-       if (status & LED_BLUE) _backlightBits &= ~M17_BIT_LB; // blue on
+       if (status & LED_1) _backlightBits &= ~M17_BIT_LR; // on
+       if (status & LED_2) _backlightBits &= ~M17_BIT_LG; // green on
+       if (status & LED_3) _backlightBits &= ~M17_BIT_LB; // blue on
 
        burstBits16(_backlightBits);
 }