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

Committer:
ansond
Date:
Fri Sep 26 05:16:07 2014 +0000
Revision:
192:54b758a8eaaa
Parent:
169:5ba15f5f7f87
updates to new logger name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:4c9bfcb3e759 1 /* Copyright C2013 Doug Anson, MIT License
ansond 0:4c9bfcb3e759 2 *
ansond 0:4c9bfcb3e759 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 0:4c9bfcb3e759 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 0:4c9bfcb3e759 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 0:4c9bfcb3e759 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 0:4c9bfcb3e759 7 * furnished to do so, subject to the following conditions:
ansond 0:4c9bfcb3e759 8 *
ansond 0:4c9bfcb3e759 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 0:4c9bfcb3e759 10 * substantial portions of the Software.
ansond 0:4c9bfcb3e759 11 *
ansond 0:4c9bfcb3e759 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 0:4c9bfcb3e759 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 0:4c9bfcb3e759 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 0:4c9bfcb3e759 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 0:4c9bfcb3e759 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 0:4c9bfcb3e759 17 */
ansond 0:4c9bfcb3e759 18
ansond 0:4c9bfcb3e759 19 #ifndef _LIGHT_H_
ansond 0:4c9bfcb3e759 20 #define _LIGHT_H_
ansond 0:4c9bfcb3e759 21
ansond 134:58e7537a8c5f 22 // Base class support
ansond 134:58e7537a8c5f 23 #include "Personality.h"
ansond 1:5d332fa199ce 24
ansond 29:9a99f076129a 25 // Philips Light Support
ansond 29:9a99f076129a 26 #include "PhilipsLight.h"
ansond 29:9a99f076129a 27
ansond 105:759dee018363 28 // External LED Light Support
ansond 144:e4d24c2c8f18 29 #include "CopCarLEDFlasher.h"
ansond 105:759dee018363 30
ansond 167:2529c18d0eb1 31 // APMDemoLight Support
ansond 167:2529c18d0eb1 32 #include "APMDemoLight.h"
ansond 167:2529c18d0eb1 33
ansond 134:58e7537a8c5f 34 class Light : public Personality {
ansond 0:4c9bfcb3e759 35 private:
ansond 9:90fadae5489a 36 void *m_dimmer_action;
ansond 9:90fadae5489a 37 void *m_switch_action;
ansond 28:52b7ca6aacd6 38
ansond 29:9a99f076129a 39 PhilipsLight *m_pl;
ansond 105:759dee018363 40 ExternalLEDLight *m_ext_led;
ansond 169:5ba15f5f7f87 41 #ifdef APM_LIGHT_PERSONALITY
ansond 167:2529c18d0eb1 42 APMDemoLight *m_apm_light;
ansond 169:5ba15f5f7f87 43 #endif
ansond 160:24337c83dd1d 44
ansond 160:24337c83dd1d 45 #ifdef ENABLE_THREADS
ansond 91:8732d54328ae 46 Thread *m_blinking_thread;
ansond 160:24337c83dd1d 47 #endif
ansond 91:8732d54328ae 48 int m_last_state;
ansond 91:8732d54328ae 49 bool m_is_blinking;
ansond 101:8747b6612e32 50 bool m_forward;
ansond 92:330746c526b7 51
ansond 92:330746c526b7 52 protected:
ansond 92:330746c526b7 53 int m_current_state;
ansond 91:8732d54328ae 54
ansond 0:4c9bfcb3e759 55 public:
ansond 192:54b758a8eaaa 56 Light(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint);
ansond 0:4c9bfcb3e759 57 virtual ~Light();
ansond 134:58e7537a8c5f 58
ansond 9:90fadae5489a 59 void setDimmerAction(void *dimmer_action);
ansond 9:90fadae5489a 60 void setSwitchAction(void *switch_action);
ansond 9:90fadae5489a 61
ansond 9:90fadae5489a 62 virtual void on();
ansond 9:90fadae5489a 63 virtual void off();
ansond 91:8732d54328ae 64 void blink();
ansond 9:90fadae5489a 65 virtual void dim(int value);
ansond 134:58e7537a8c5f 66
ansond 101:8747b6612e32 67 void updateDirection();
ansond 91:8732d54328ae 68 void blinkLight();
ansond 91:8732d54328ae 69
ansond 92:330746c526b7 70 void initLight();
ansond 92:330746c526b7 71
ansond 9:90fadae5489a 72 protected:
ansond 9:90fadae5489a 73 void *getDimmerAction();
ansond 29:9a99f076129a 74 void *getSwitchAction();
ansond 29:9a99f076129a 75
ansond 29:9a99f076129a 76 private:
ansond 105:759dee018363 77 PhilipsLight *pl();
ansond 169:5ba15f5f7f87 78 ExternalLEDLight *extled();
ansond 169:5ba15f5f7f87 79 #ifdef APM_LIGHT_PERSONALITY
ansond 167:2529c18d0eb1 80 APMDemoLight *apmlight();
ansond 169:5ba15f5f7f87 81 #endif
ansond 105:759dee018363 82 void startBlinking();
ansond 105:759dee018363 83 void stopBlinking();
ansond 105:759dee018363 84 void manageBlinkingThread();
ansond 105:759dee018363 85 void startBlinkingThread();
ansond 105:759dee018363 86 void stopBlinkingThread();
ansond 0:4c9bfcb3e759 87 };
ansond 0:4c9bfcb3e759 88
ansond 0:4c9bfcb3e759 89 #endif // _LIGHT_H_