Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
main.cpp@14:153f377f4030, 2021-04-17 (annotated)
- Committer:
- ackerden
- Date:
- Sat Apr 17 13:20:05 2021 +0000
- Revision:
- 14:153f377f4030
- Parent:
- 13:096e5dc3ac23
- Child:
- 15:babdd038715a
Zeitfunktion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pmic | 1:93d997d6b232 | 1 | #include "mbed.h" |
ackerden | 13:096e5dc3ac23 | 2 | //#include "mbed_rtc_time.h" |
pmic | 6:e1fa1a2d7483 | 3 | |
ackerden | 13:096e5dc3ac23 | 4 | //Eigene Header einbinden |
ackerden | 13:096e5dc3ac23 | 5 | #include "realtimer.h" |
haefeman | 11:be62f37f3a98 | 6 | |
ackerden | 13:096e5dc3ac23 | 7 | |
pmic | 6:e1fa1a2d7483 | 8 | |
pmic | 6:e1fa1a2d7483 | 9 | using namespace std::chrono; |
pmic | 6:e1fa1a2d7483 | 10 | |
pmic | 8:9bb806a7f585 | 11 | InterruptIn user_button(USER_BUTTON); |
pmic | 8:9bb806a7f585 | 12 | DigitalOut led(LED1); |
pmic | 6:e1fa1a2d7483 | 13 | |
ackerden | 12:dfa3591affef | 14 | |
pmic | 6:e1fa1a2d7483 | 15 | bool executeMainTask = false; |
pmic | 6:e1fa1a2d7483 | 16 | Timer user_button_timer, loop_timer; |
ackerden | 13:096e5dc3ac23 | 17 | |
pmic | 6:e1fa1a2d7483 | 18 | |
pmic | 6:e1fa1a2d7483 | 19 | /* declaration of custom button functions */ |
pmic | 6:e1fa1a2d7483 | 20 | void button_fall(); |
pmic | 6:e1fa1a2d7483 | 21 | void button_rise(); |
pmic | 6:e1fa1a2d7483 | 22 | |
ackerden | 12:dfa3591affef | 23 | |
pmic | 1:93d997d6b232 | 24 | int main() |
pmic | 9:f10b974d01e0 | 25 | { |
ackerden | 13:096e5dc3ac23 | 26 | set_time(1618332129); //Zeit setzen |
ackerden | 14:153f377f4030 | 27 | int i = 0; |
ackerden | 14:153f377f4030 | 28 | |
ackerden | 14:153f377f4030 | 29 | |
pmic | 6:e1fa1a2d7483 | 30 | user_button.fall(&button_fall); |
pmic | 6:e1fa1a2d7483 | 31 | user_button.rise(&button_rise); |
pmic | 6:e1fa1a2d7483 | 32 | loop_timer.start(); |
pmic | 6:e1fa1a2d7483 | 33 | |
pmic | 1:93d997d6b232 | 34 | while (true) { |
pmic | 6:e1fa1a2d7483 | 35 | |
pmic | 6:e1fa1a2d7483 | 36 | loop_timer.reset(); |
ackerden | 12:dfa3591affef | 37 | |
ackerden | 12:dfa3591affef | 38 | |
pmic | 6:e1fa1a2d7483 | 39 | |
ackerden | 12:dfa3591affef | 40 | |
pmic | 6:e1fa1a2d7483 | 41 | |
pmic | 6:e1fa1a2d7483 | 42 | if (executeMainTask) { |
ackerden | 13:096e5dc3ac23 | 43 | |
ackerden | 13:096e5dc3ac23 | 44 | //Zeitfunktion |
ackerden | 13:096e5dc3ac23 | 45 | uhrzeit(time(NULL)); |
ackerden | 14:153f377f4030 | 46 | |
ackerden | 14:153f377f4030 | 47 | |
ackerden | 14:153f377f4030 | 48 | //Zeitfunktionen |
ackerden | 14:153f377f4030 | 49 | if (i != 360){ |
ackerden | 14:153f377f4030 | 50 | ThisThread::sleep_for(5s); //Wartet 5s.. |
ackerden | 14:153f377f4030 | 51 | printf("%d\n", i); |
ackerden | 14:153f377f4030 | 52 | } |
ackerden | 14:153f377f4030 | 53 | else{ |
ackerden | 14:153f377f4030 | 54 | i=0; |
ackerden | 14:153f377f4030 | 55 | } |
ackerden | 14:153f377f4030 | 56 | |
ackerden | 14:153f377f4030 | 57 | |
ackerden | 14:153f377f4030 | 58 | i += 5; |
pmic | 6:e1fa1a2d7483 | 59 | |
ackerden | 13:096e5dc3ac23 | 60 | led = !led; |
pmic | 9:f10b974d01e0 | 61 | |
pmic | 1:93d997d6b232 | 62 | } else { |
pmic | 6:e1fa1a2d7483 | 63 | |
ackerden | 13:096e5dc3ac23 | 64 | |
pmic | 6:e1fa1a2d7483 | 65 | led = 0; |
pmic | 1:93d997d6b232 | 66 | } |
pmic | 6:e1fa1a2d7483 | 67 | |
ackerden | 13:096e5dc3ac23 | 68 | |
pmic | 1:93d997d6b232 | 69 | } |
pmic | 1:93d997d6b232 | 70 | } |
pmic | 6:e1fa1a2d7483 | 71 | |
pmic | 6:e1fa1a2d7483 | 72 | void button_fall() |
pmic | 6:e1fa1a2d7483 | 73 | { |
pmic | 6:e1fa1a2d7483 | 74 | user_button_timer.reset(); |
pmic | 6:e1fa1a2d7483 | 75 | user_button_timer.start(); |
pmic | 6:e1fa1a2d7483 | 76 | } |
pmic | 6:e1fa1a2d7483 | 77 | |
pmic | 6:e1fa1a2d7483 | 78 | void button_rise() |
pmic | 6:e1fa1a2d7483 | 79 | { |
pmic | 6:e1fa1a2d7483 | 80 | int t_button_ms = duration_cast<milliseconds>(user_button_timer.elapsed_time()).count(); |
pmic | 6:e1fa1a2d7483 | 81 | user_button_timer.stop(); |
pmic | 8:9bb806a7f585 | 82 | if (t_button_ms > 200) { |
pmic | 6:e1fa1a2d7483 | 83 | executeMainTask = !executeMainTask; |
pmic | 8:9bb806a7f585 | 84 | } |
pmic | 6:e1fa1a2d7483 | 85 | } |