![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Handheld_Node
Dependencies: XBeeLib buzzer mbed
functions/breathLed.cpp@0:2ab14db2fd40, 2018-07-25 (annotated)
- Committer:
- basvuyk
- Date:
- Wed Jul 25 09:11:48 2018 +0000
- Revision:
- 0:2ab14db2fd40
Handheld_Node
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
basvuyk | 0:2ab14db2fd40 | 1 | #include "mbed.h" |
basvuyk | 0:2ab14db2fd40 | 2 | |
basvuyk | 0:2ab14db2fd40 | 3 | namespace mbed { |
basvuyk | 0:2ab14db2fd40 | 4 | void breathLed(int systemState){ |
basvuyk | 0:2ab14db2fd40 | 5 | static double ledVal = 0; |
basvuyk | 0:2ab14db2fd40 | 6 | static int direction = 1; |
basvuyk | 0:2ab14db2fd40 | 7 | PwmOut statusLED(PA_11); |
basvuyk | 0:2ab14db2fd40 | 8 | statusLED.period(0.001f); // Set pwm frequency 1000Hz |
basvuyk | 0:2ab14db2fd40 | 9 | |
basvuyk | 0:2ab14db2fd40 | 10 | if (systemState == 1){ |
basvuyk | 0:2ab14db2fd40 | 11 | if (ledVal > 0.6){ |
basvuyk | 0:2ab14db2fd40 | 12 | direction = 0; |
basvuyk | 0:2ab14db2fd40 | 13 | } |
basvuyk | 0:2ab14db2fd40 | 14 | if (ledVal < 0.03){ |
basvuyk | 0:2ab14db2fd40 | 15 | direction = 1; |
basvuyk | 0:2ab14db2fd40 | 16 | } |
basvuyk | 0:2ab14db2fd40 | 17 | |
basvuyk | 0:2ab14db2fd40 | 18 | if (direction == 1){ |
basvuyk | 0:2ab14db2fd40 | 19 | ledVal = ledVal + 0.01; |
basvuyk | 0:2ab14db2fd40 | 20 | statusLED = ledVal; |
basvuyk | 0:2ab14db2fd40 | 21 | } |
basvuyk | 0:2ab14db2fd40 | 22 | else{ |
basvuyk | 0:2ab14db2fd40 | 23 | ledVal = ledVal - 0.01; |
basvuyk | 0:2ab14db2fd40 | 24 | statusLED = ledVal; |
basvuyk | 0:2ab14db2fd40 | 25 | } |
basvuyk | 0:2ab14db2fd40 | 26 | } |
basvuyk | 0:2ab14db2fd40 | 27 | else{ |
basvuyk | 0:2ab14db2fd40 | 28 | statusLED = 0; |
basvuyk | 0:2ab14db2fd40 | 29 | ledVal = 0; |
basvuyk | 0:2ab14db2fd40 | 30 | } |
basvuyk | 0:2ab14db2fd40 | 31 | } |
basvuyk | 0:2ab14db2fd40 | 32 | } |