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
MBEDLight.cpp@71:90bf61bc3727, 2014-03-03 (annotated)
- Committer:
- ansond
- Date:
- Mon Mar 03 22:39:48 2014 +0000
- Revision:
- 71:90bf61bc3727
- Parent:
- 47:fa96ddc36f04
- Child:
- 72:46c94966311b
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 9:90fadae5489a | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 9:90fadae5489a | 2 | * |
ansond | 9:90fadae5489a | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 9:90fadae5489a | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 9:90fadae5489a | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 9:90fadae5489a | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 9:90fadae5489a | 7 | * furnished to do so, subject to the following conditions: |
ansond | 9:90fadae5489a | 8 | * |
ansond | 9:90fadae5489a | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 9:90fadae5489a | 10 | * substantial portions of the Software. |
ansond | 9:90fadae5489a | 11 | * |
ansond | 9:90fadae5489a | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 9:90fadae5489a | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 9:90fadae5489a | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 9:90fadae5489a | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 9:90fadae5489a | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 9:90fadae5489a | 17 | */ |
ansond | 9:90fadae5489a | 18 | |
ansond | 9:90fadae5489a | 19 | #include "MBEDLight.h" |
ansond | 9:90fadae5489a | 20 | |
ansond | 9:90fadae5489a | 21 | #include "LightDimmerAction.h" |
ansond | 9:90fadae5489a | 22 | #include "LightSwitchAction.h" |
ansond | 9:90fadae5489a | 23 | |
ansond | 9:90fadae5489a | 24 | // MBED Light |
ansond | 71:90bf61bc3727 | 25 | extern DigitalOut led2; |
ansond | 71:90bf61bc3727 | 26 | extern DigitalOut led3; |
ansond | 71:90bf61bc3727 | 27 | PwmOut led_2(LED2); |
ansond | 71:90bf61bc3727 | 28 | PwmOut led_3(LED3); |
ansond | 9:90fadae5489a | 29 | |
ansond | 9:90fadae5489a | 30 | // default constructor |
ansond | 9:90fadae5489a | 31 | MBEDLight::MBEDLight(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) : Light(error_handler,transports,instance,endpoint) { |
ansond | 9:90fadae5489a | 32 | } |
ansond | 9:90fadae5489a | 33 | |
ansond | 9:90fadae5489a | 34 | // destructor |
ansond | 9:90fadae5489a | 35 | MBEDLight::~MBEDLight() { |
ansond | 9:90fadae5489a | 36 | } |
ansond | 9:90fadae5489a | 37 | |
ansond | 9:90fadae5489a | 38 | // turn ON |
ansond | 71:90bf61bc3727 | 39 | void MBEDLight::on() { led2 = 1; led3 = 1; Light::on(); } |
ansond | 9:90fadae5489a | 40 | |
ansond | 9:90fadae5489a | 41 | // turn OFF |
ansond | 71:90bf61bc3727 | 42 | void MBEDLight::off() { led2 = 0; led3 = 0; Light::off(); } |
ansond | 9:90fadae5489a | 43 | |
ansond | 9:90fadae5489a | 44 | // dim |
ansond | 9:90fadae5489a | 45 | void MBEDLight::dim(int value) { |
ansond | 9:90fadae5489a | 46 | float dim_val = (float)(value/100.0); |
ansond | 71:90bf61bc3727 | 47 | led_2.write(dim_val); |
ansond | 71:90bf61bc3727 | 48 | led_3.write(dim_val); |
ansond | 32:56a11a9a35a2 | 49 | Light::dim(value); |
ansond | 9:90fadae5489a | 50 | } |