![](/media/cache/profiles/8158fa3e4de806e614f7ff02e7b22fde.jpg.50x50_q85.png)
New version of quadcopter software written to OO principles
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
Status/StatusLights/StatusLights.cpp@4:9ffbf9101992, 2015-05-08 (annotated)
- Committer:
- joe4465
- Date:
- Fri May 08 09:07:38 2015 +0000
- Revision:
- 4:9ffbf9101992
- Parent:
- 2:969dfa4f2436
End of FYP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joe4465 | 2:969dfa4f2436 | 1 | #include "StatusLights.h" |
joe4465 | 2:969dfa4f2436 | 2 | |
joe4465 | 2:969dfa4f2436 | 3 | StatusLights::StatusLights() |
joe4465 | 2:969dfa4f2436 | 4 | { |
joe4465 | 2:969dfa4f2436 | 5 | _ledState = 0; |
joe4465 | 2:969dfa4f2436 | 6 | _led1 = new DigitalOut(LED1); |
joe4465 | 2:969dfa4f2436 | 7 | _led2 = new DigitalOut(LED2); |
joe4465 | 2:969dfa4f2436 | 8 | _led3 = new DigitalOut(LED3); |
joe4465 | 2:969dfa4f2436 | 9 | _led4 = new DigitalOut(LED4); |
joe4465 | 2:969dfa4f2436 | 10 | |
joe4465 | 2:969dfa4f2436 | 11 | DEBUG("Status lights initialised\r\n"); |
joe4465 | 2:969dfa4f2436 | 12 | } |
joe4465 | 2:969dfa4f2436 | 13 | |
joe4465 | 2:969dfa4f2436 | 14 | StatusLights::~StatusLights(){} |
joe4465 | 2:969dfa4f2436 | 15 | |
joe4465 | 2:969dfa4f2436 | 16 | void StatusLights::preFlight() |
joe4465 | 2:969dfa4f2436 | 17 | { |
joe4465 | 2:969dfa4f2436 | 18 | _led1 -> write(!_led1 -> read()); |
joe4465 | 2:969dfa4f2436 | 19 | } |
joe4465 | 2:969dfa4f2436 | 20 | |
joe4465 | 2:969dfa4f2436 | 21 | void StatusLights::standby() |
joe4465 | 2:969dfa4f2436 | 22 | { |
joe4465 | 2:969dfa4f2436 | 23 | _led2 -> write(!_led2 -> read()); |
joe4465 | 2:969dfa4f2436 | 24 | } |
joe4465 | 2:969dfa4f2436 | 25 | |
joe4465 | 2:969dfa4f2436 | 26 | void StatusLights::groundReady() |
joe4465 | 2:969dfa4f2436 | 27 | { |
joe4465 | 2:969dfa4f2436 | 28 | _led3 -> write(!_led3 -> read()); |
joe4465 | 2:969dfa4f2436 | 29 | } |
joe4465 | 2:969dfa4f2436 | 30 | |
joe4465 | 2:969dfa4f2436 | 31 | void StatusLights::flying() |
joe4465 | 2:969dfa4f2436 | 32 | { |
joe4465 | 2:969dfa4f2436 | 33 | _ledState++; |
joe4465 | 2:969dfa4f2436 | 34 | if (_ledState > 5) { _ledState = 0; } |
joe4465 | 2:969dfa4f2436 | 35 | |
joe4465 | 2:969dfa4f2436 | 36 | _led1 -> write(_ledState == 0); |
joe4465 | 2:969dfa4f2436 | 37 | _led2 -> write(_ledState == 1 || _ledState == 5); |
joe4465 | 2:969dfa4f2436 | 38 | _led3 -> write(_ledState == 2 || _ledState == 4); |
joe4465 | 2:969dfa4f2436 | 39 | _led4 -> write(_ledState == 3); |
joe4465 | 2:969dfa4f2436 | 40 | } |
joe4465 | 2:969dfa4f2436 | 41 | |
joe4465 | 2:969dfa4f2436 | 42 | void StatusLights::error() |
joe4465 | 2:969dfa4f2436 | 43 | { |
joe4465 | 2:969dfa4f2436 | 44 | _led1 -> write(!_led1 -> read()); |
joe4465 | 2:969dfa4f2436 | 45 | _led2 -> write(!_led2 -> read()); |
joe4465 | 2:969dfa4f2436 | 46 | _led3 -> write(!_led3 -> read()); |
joe4465 | 2:969dfa4f2436 | 47 | _led4 -> write(!_led4 -> read()); |
joe4465 | 2:969dfa4f2436 | 48 | } |
joe4465 | 2:969dfa4f2436 | 49 | |
joe4465 | 2:969dfa4f2436 | 50 | void StatusLights::clear() |
joe4465 | 2:969dfa4f2436 | 51 | { |
joe4465 | 2:969dfa4f2436 | 52 | _led1->write(0); |
joe4465 | 2:969dfa4f2436 | 53 | _led2->write(0); |
joe4465 | 2:969dfa4f2436 | 54 | _led3->write(0); |
joe4465 | 2:969dfa4f2436 | 55 | _led4->write(0); |
joe4465 | 2:969dfa4f2436 | 56 | _ledState = 0; |
joe4465 | 2:969dfa4f2436 | 57 | } |