Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Revision:
108:673b2f43dfe7
Parent:
107:db7af0f306fa
Child:
135:7f3f963cd159
--- a/ExternalLEDLight.cpp	Sun Mar 16 06:06:08 2014 +0000
+++ b/ExternalLEDLight.cpp	Sun Mar 16 06:13:42 2014 +0000
@@ -48,10 +48,18 @@
     }
     else {
         // turn the light on or off
-        if (this->m_state == 0) *(this->m_led) = 0;
+        if (this->m_state == 0) {
+            // just turn the LED off
+            *(this->m_led) = 0;
+        }
         else {
-            if (*(this->m_led) == 0)
+            // turn the LED on - but re-adjust for the current dim setting:
+            //  - if the dimming is set to 0, then lets go ahead and make the light full bright...
+            //  - otherwise we wont see the transition change. 
+            if (this->m_dim == 0.0)
                 *(this->m_led) = 1;
+            else
+                *(this->m_led) = this->m_dim;
         }
     }
  }