Biblioteka LEDController.
Diff: LEDController.cpp
- Revision:
- 0:4001e6959177
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LEDController.cpp Thu Dec 02 21:07:04 2021 +0000 @@ -0,0 +1,34 @@ +#include "LEDController.h" +#include "mbed.h" + +LEDController::LEDController(PinName pin, float flashPeriodCon, bool blinkingModeCon, bool shouldBeOnCon):Dout(pin){ + flashPeriod = flashPeriodCon; + blinkingMode = blinkingModeCon; + shouldBeOn = shouldBeOnCon; + flipper.attach(callback(this, &LEDController::flipperFunction), flashPeriod); +} + +void LEDController::toggleBlinkingMode(){ + blinkingMode = !blinkingMode; +} + +void LEDController::toggleShouldBeOn(){ + shouldBeOn = !shouldBeOn; +} + +bool LEDController::getBlinkingMode(){ + return blinkingMode; +} + +void LEDController::checkOnOffState(){ + if (shouldBeOn && !blinkingMode) { + Dout = 1; + } + if (!shouldBeOn) { + Dout = 0; + } +} + +void LEDController::flipperFunction(){ + if (shouldBeOn && blinkingMode) Dout = !Dout; +} \ No newline at end of file