Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
common.cpp@34:4493c9f6d707, 2019-01-13 (annotated)
- Committer:
- pathfindr
- Date:
- Sun Jan 13 23:40:56 2019 +0000
- Revision:
- 34:4493c9f6d707
- Parent:
- 33:760005331b4c
- Child:
- 48:64b1613941d5
init
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pathfindr | 7:e9a19750700d | 1 | #include "common.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 | 33:760005331b4c | 9 | GLOBAL_LEDSequenceinProgress = true; |
| pathfindr | 7:e9a19750700d | 10 | led1 = 0; |
| pathfindr | 7:e9a19750700d | 11 | if (milliseconds > 0) { |
| pathfindr | 9:b0a1535b8ef2 | 12 | //ThisThread::sleep_for(milliseconds); |
| pathfindr | 9:b0a1535b8ef2 | 13 | Thread::wait(milliseconds); |
| pathfindr | 7:e9a19750700d | 14 | led1 = 1; |
| pathfindr | 7:e9a19750700d | 15 | } |
| pathfindr | 33:760005331b4c | 16 | GLOBAL_LEDSequenceinProgress = false; |
| pathfindr | 7:e9a19750700d | 17 | } |
| pathfindr | 7:e9a19750700d | 18 | void LED1blink(int count = 2, long milliseconds = 100) { |
| pathfindr | 33:760005331b4c | 19 | GLOBAL_LEDSequenceinProgress = true; |
| pathfindr | 7:e9a19750700d | 20 | for (int i = 0; i < (count*2); i++) { |
| pathfindr | 7:e9a19750700d | 21 | led1 = !led1; |
| pathfindr | 7:e9a19750700d | 22 | if (milliseconds > 0) { |
| pathfindr | 9:b0a1535b8ef2 | 23 | Thread::wait(milliseconds); |
| pathfindr | 9:b0a1535b8ef2 | 24 | //ThisThread::sleep_for(milliseconds); |
| pathfindr | 7:e9a19750700d | 25 | } else { |
| pathfindr | 9:b0a1535b8ef2 | 26 | Thread::wait(100); |
| pathfindr | 9:b0a1535b8ef2 | 27 | //ThisThread::sleep_for(100); //default if 0 provided |
| pathfindr | 7:e9a19750700d | 28 | } |
| pathfindr | 7:e9a19750700d | 29 | } |
| pathfindr | 7:e9a19750700d | 30 | led1 = 1; |
| pathfindr | 33:760005331b4c | 31 | GLOBAL_LEDSequenceinProgress = false; |
| pathfindr | 33:760005331b4c | 32 | } |
| pathfindr | 33:760005331b4c | 33 | void LED1errorCode(int pattern, int count) { |
| pathfindr | 33:760005331b4c | 34 | GLOBAL_LEDSequenceinProgress = true; |
| pathfindr | 33:760005331b4c | 35 | for (int i = 0; i < count; i++) { |
| pathfindr | 33:760005331b4c | 36 | for (int p = 0; p < pattern; p++) { |
| pathfindr | 33:760005331b4c | 37 | led1 = 0; |
| pathfindr | 33:760005331b4c | 38 | Thread::wait(200); |
| pathfindr | 33:760005331b4c | 39 | led1 = 1; |
| pathfindr | 33:760005331b4c | 40 | Thread::wait(300); |
| pathfindr | 33:760005331b4c | 41 | } |
| pathfindr | 33:760005331b4c | 42 | Thread::wait(1000); |
| pathfindr | 33:760005331b4c | 43 | } |
| pathfindr | 33:760005331b4c | 44 | led1 = 1; |
| pathfindr | 34:4493c9f6d707 | 45 | GLOBAL_LEDSequenceinProgress = false; |
| pathfindr | 7:e9a19750700d | 46 | } |
| pathfindr | 7:e9a19750700d | 47 | void LED1off() { |
| pathfindr | 7:e9a19750700d | 48 | led1 = 1; |
| pathfindr | 33:760005331b4c | 49 | GLOBAL_LEDSequenceinProgress = false; |
| pathfindr | 7:e9a19750700d | 50 | } |