
simple project to control mirrorless camera
Dependencies: mbed BLE_API nRF51822
Diff: PowerSwitch/PowerSwitch.cpp
- Revision:
- 0:81f1818af032
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PowerSwitch/PowerSwitch.cpp Wed Oct 21 11:32:45 2015 +0000 @@ -0,0 +1,27 @@ +#include "PowerSwitch.h" +#include "mbed.h" + +PowerSwitch::PowerSwitch(PinName pin) : _pin(pin) { + powerState = false; +} + +void PowerSwitch::doSwitch(bool state, float duration){ + if (state) { + _pin = 1.0; + } else{ + _pin = 0.0; + } + + powerState = state; + switchPeriod.attach(this, &PowerSwitch::doSwitchEnd, duration); + +} + +bool PowerSwitch::powerStateOn(void){ + return powerState; +} + +void PowerSwitch::doSwitchEnd(void){ + switchPeriod.detach(); + _pin = 0.0; +} \ No newline at end of file