init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
LED.cpp@57:066dfbe8b4b9, 2020-02-13 (annotated)
- Committer:
- pathfindr
- Date:
- Thu Feb 13 00:57:06 2020 +0000
- Revision:
- 57:066dfbe8b4b9
- Parent:
- common.cpp@51:9078e6928412
- Child:
- 58:8d4a354816b1
init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pathfindr | 57:066dfbe8b4b9 | 1 | #include "LED.h" |
pathfindr | 7:e9a19750700d | 2 | |
pathfindr | 7:e9a19750700d | 3 | //------------------------------------------------------------------------------ |
pathfindr | 7:e9a19750700d | 4 | // LED |
pathfindr | 7:e9a19750700d | 5 | //------------------------------------------------------------------------------ |
pathfindr | 7:e9a19750700d | 6 | DigitalOut led1(PN_LED); |
pathfindr | 7:e9a19750700d | 7 | |
pathfindr | 7:e9a19750700d | 8 | void LED1on(long milliseconds = 0) { |
pathfindr | 7:e9a19750700d | 9 | led1 = 0; |
pathfindr | 7:e9a19750700d | 10 | if (milliseconds > 0) { |
pathfindr | 57:066dfbe8b4b9 | 11 | ThisThread::sleep_for(milliseconds); |
pathfindr | 57:066dfbe8b4b9 | 12 | //Thread::wait(milliseconds); |
pathfindr | 7:e9a19750700d | 13 | led1 = 1; |
pathfindr | 7:e9a19750700d | 14 | } |
pathfindr | 7:e9a19750700d | 15 | } |
pathfindr | 7:e9a19750700d | 16 | void LED1blink(int count = 2, long milliseconds = 100) { |
pathfindr | 7:e9a19750700d | 17 | for (int i = 0; i < (count*2); i++) { |
pathfindr | 7:e9a19750700d | 18 | led1 = !led1; |
pathfindr | 7:e9a19750700d | 19 | if (milliseconds > 0) { |
pathfindr | 57:066dfbe8b4b9 | 20 | //Thread::wait(milliseconds); |
pathfindr | 57:066dfbe8b4b9 | 21 | ThisThread::sleep_for(milliseconds); |
pathfindr | 7:e9a19750700d | 22 | } else { |
pathfindr | 57:066dfbe8b4b9 | 23 | //Thread::wait(100); |
pathfindr | 57:066dfbe8b4b9 | 24 | ThisThread::sleep_for(100); //default if 0 provided |
pathfindr | 7:e9a19750700d | 25 | } |
pathfindr | 7:e9a19750700d | 26 | } |
pathfindr | 7:e9a19750700d | 27 | led1 = 1; |
pathfindr | 33:760005331b4c | 28 | } |
pathfindr | 33:760005331b4c | 29 | void LED1errorCode(int pattern, int count) { |
pathfindr | 33:760005331b4c | 30 | for (int i = 0; i < count; i++) { |
pathfindr | 33:760005331b4c | 31 | for (int p = 0; p < pattern; p++) { |
pathfindr | 33:760005331b4c | 32 | led1 = 0; |
pathfindr | 57:066dfbe8b4b9 | 33 | //Thread::wait(200); |
pathfindr | 57:066dfbe8b4b9 | 34 | ThisThread::sleep_for(200); |
pathfindr | 33:760005331b4c | 35 | led1 = 1; |
pathfindr | 57:066dfbe8b4b9 | 36 | //Thread::wait(300); |
pathfindr | 57:066dfbe8b4b9 | 37 | ThisThread::sleep_for(300); |
pathfindr | 33:760005331b4c | 38 | } |
pathfindr | 57:066dfbe8b4b9 | 39 | ThisThread::sleep_for(1000); |
pathfindr | 33:760005331b4c | 40 | } |
pathfindr | 33:760005331b4c | 41 | led1 = 1; |
pathfindr | 7:e9a19750700d | 42 | } |
pathfindr | 7:e9a19750700d | 43 | void LED1off() { |
pathfindr | 7:e9a19750700d | 44 | led1 = 1; |
pathfindr | 7:e9a19750700d | 45 | } |