Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Diff: Light.cpp
- Revision:
- 167:2529c18d0eb1
- Parent:
- 160:24337c83dd1d
- Child:
- 169:5ba15f5f7f87
diff -r 8e63cd2c003a -r 2529c18d0eb1 Light.cpp --- a/Light.cpp Thu Jul 03 18:35:47 2014 +0000 +++ b/Light.cpp Wed Jul 16 17:29:00 2014 +0000 @@ -53,11 +53,18 @@ if (EXT_LED_ENABLE) this->m_ext_led = new CopCarLEDFlasher(new PwmOut(EXT_LED_PIN),new PwmOut(EXT_LED_PIN_COPCAR),this->logger()); else this->m_ext_led = NULL; #endif + #ifdef LIGHT_PERSONALITY // Setup External LED Light if enabled if (EXT_LED_ENABLE) this->m_ext_led = new ExternalLEDLight(new PwmOut(EXT_LED_PIN),this->logger()); else this->m_ext_led = NULL; #endif + + #ifdef APM_LIGHT_PERSONALITY + // Setup APM Light if enabled + if (APM_LIGHT_ENABLE) this->m_apm_light = new APMDemoLight(this->logger()); + else this->m_apm_light = NULL; + #endif // DEBUG if (PL_ENABLE) this->logger()->log("Light name: %s (Philips Light %d)",this->getName(),PL_LIGHT_ID); @@ -73,6 +80,7 @@ if (this->m_switch_action != NULL) delete this->m_switch_action; if (this->m_pl != NULL) delete this->m_pl; if (this->m_ext_led != NULL) delete this->m_ext_led; + if (this->m_apm_light != NULL) delete this->m_apm_light; this->stopBlinkingThread(); } @@ -88,6 +96,9 @@ // get the External LED light ExternalLEDLight *Light::extled() { return this->m_ext_led; } + // get the APM light + APMDemoLight *Light::apmlight() { return this->m_apm_light; } + // set the dimmer action void Light::setDimmerAction(void *dimmer_action) { this->m_dimmer_action = dimmer_action; } @@ -106,6 +117,7 @@ this->manageBlinkingThread(); if (PL_ENABLE && this->pl() != NULL) this->pl()->on(); if (EXT_LED_ENABLE && this->extled() != NULL) this->extled()->on(); + if (APM_LIGHT_ENABLE && this->apmlight() != NULL) this->apmlight()->on(); } // turn OFF @@ -114,6 +126,7 @@ this->manageBlinkingThread(); if (PL_ENABLE && this->pl() != NULL) this->pl()->off(); if (EXT_LED_ENABLE && this->extled() != NULL) this->extled()->off(); + if (APM_LIGHT_ENABLE && this->apmlight() != NULL) this->apmlight()->off(); } // initiate blinking @@ -171,13 +184,27 @@ this->m_current_state = 0; this->manageBlinkingThread(); #endif + +#ifdef APM_LIGHT_PERSONALITY + if (this->m_forward) this->on(); else this->off(); +#else + #ifdef LIGHT_PERSONALITY + if (this->m_forward) this->on(); else this->off(); + #endif +#endif + #ifdef LIGHT_PERSONALITY - if (this->m_forward) this->on(); else this->off(); if (PL_ENABLE && this->pl() != NULL) { if (this->m_forward) this->pl()->on(); else this->pl()->off(); } if (EXT_LED_ENABLE && this->extled() != NULL) { if (this->m_forward) this->extled()->on(); else this->extled()->off(); } #endif +#ifdef APM_LIGHT_PERSONALITY + if (APM_LIGHT_ENABLE && this->apmlight() != NULL) { if (this->m_forward) this->apmlight()->on(); else this->apmlight()->off(); } +#endif + + // wait a bit... wait_ms(LIGHT_BLINK_WAIT_MS); this->m_is_blinking = true; + #ifdef COPCAR_PERSONALITY if (EXT_LED_ENABLE && this->extled() != NULL) { ((CopCarLEDFlasher *)this->extled())->on(); } wait_ms(125); @@ -185,11 +212,23 @@ this->m_current_state = 0; this->manageBlinkingThread(); #endif + +#ifdef APM_LIGHT_PERSONALITY + if (this->m_forward) this->on(); else this->off(); +#else + #ifdef LIGHT_PERSONALITY + if (this->m_forward) this->on(); else this->off(); + #endif +#endif + #ifdef LIGHT_PERSONALITY - if (this->m_forward) this->off(); else this->on(); if (PL_ENABLE && this->pl() != NULL) { if (this->m_forward) this->pl()->off(); else this->pl()->on(); } if (EXT_LED_ENABLE && this->extled() != NULL) { if (this->m_forward) this->extled()->off(); else this->extled()->on(); } #endif +#ifdef APM_LIGHT_PERSONALITY + if (APM_LIGHT_ENABLE && this->apmlight() != NULL) { if (this->m_forward) this->apmlight()->off(); else this->apmlight()->on(); } +#endif + wait_ms(LIGHT_BLINK_WAIT_MS); } @@ -197,6 +236,7 @@ void Light::dim(int value) { if (PL_ENABLE && this->pl() != NULL) this->pl()->dim(value); if (EXT_LED_ENABLE && this->extled() != NULL) this->extled()->dim(value); + if (APM_LIGHT_ENABLE && this->apmlight() != NULL) this->apmlight()->dim(value); }