Demo to control 4 LEDs
Dependencies: BSP_DISCO_F469NI mbed
Diff: Widgets/Switch.cpp
- Revision:
- 0:e06404fdff2f
- Child:
- 1:a6d179a9ffbb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Widgets/Switch.cpp Wed Oct 11 22:26:45 2017 +0000 @@ -0,0 +1,51 @@ +/* + * Switch.cpp + * + * Copyright 2017 Faberge@TsarTeam + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + + +#include "Switch.h" + +void Switch :: draw(color_t clr) +{ + if (state == false) + { + b1.draw(clr & FADEMASK); + b2.draw(clr); + } + if (state == true) + { + b1.draw(clr); + b2.draw(clr & FADEMASK); + } +} + +uint16_t Switch :: update() +{ + if ((state == false) && b1.isTouched()) + { + state = true; + draw(backColor); + funcOne(); + } + if ((state == true) && b2.isTouched()) + { + state = false; + draw(backColor); + funcTwo(); + } + + return state; +} \ No newline at end of file