Hauptprogramm

Dependencies:   ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini

Committer:
ackerden
Date:
Sat Apr 17 11:25:37 2021 +0000
Revision:
13:096e5dc3ac23
Parent:
12:dfa3591affef
Child:
14:153f377f4030
Zeitfunktion erstellt;

Who changed what in which revision?

UserRevisionLine numberNew 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
pmic 6:e1fa1a2d7483 27 user_button.fall(&button_fall);
pmic 6:e1fa1a2d7483 28 user_button.rise(&button_rise);
pmic 6:e1fa1a2d7483 29 loop_timer.start();
pmic 6:e1fa1a2d7483 30
pmic 1:93d997d6b232 31 while (true) {
pmic 6:e1fa1a2d7483 32
pmic 6:e1fa1a2d7483 33 loop_timer.reset();
ackerden 12:dfa3591affef 34
ackerden 12:dfa3591affef 35
pmic 6:e1fa1a2d7483 36
ackerden 12:dfa3591affef 37
pmic 6:e1fa1a2d7483 38
pmic 6:e1fa1a2d7483 39 if (executeMainTask) {
ackerden 13:096e5dc3ac23 40
ackerden 13:096e5dc3ac23 41 //Zeitfunktion
ackerden 13:096e5dc3ac23 42 uhrzeit(time(NULL));
ackerden 13:096e5dc3ac23 43 ThisThread::sleep_for(5s); //Wartet 5s.
pmic 6:e1fa1a2d7483 44
ackerden 13:096e5dc3ac23 45 led = !led;
pmic 9:f10b974d01e0 46
pmic 1:93d997d6b232 47 } else {
pmic 6:e1fa1a2d7483 48
ackerden 13:096e5dc3ac23 49
pmic 6:e1fa1a2d7483 50 led = 0;
pmic 1:93d997d6b232 51 }
pmic 6:e1fa1a2d7483 52
ackerden 13:096e5dc3ac23 53
pmic 1:93d997d6b232 54 }
pmic 1:93d997d6b232 55 }
pmic 6:e1fa1a2d7483 56
pmic 6:e1fa1a2d7483 57 void button_fall()
pmic 6:e1fa1a2d7483 58 {
pmic 6:e1fa1a2d7483 59 user_button_timer.reset();
pmic 6:e1fa1a2d7483 60 user_button_timer.start();
pmic 6:e1fa1a2d7483 61 }
pmic 6:e1fa1a2d7483 62
pmic 6:e1fa1a2d7483 63 void button_rise()
pmic 6:e1fa1a2d7483 64 {
pmic 6:e1fa1a2d7483 65 int t_button_ms = duration_cast<milliseconds>(user_button_timer.elapsed_time()).count();
pmic 6:e1fa1a2d7483 66 user_button_timer.stop();
pmic 8:9bb806a7f585 67 if (t_button_ms > 200) {
pmic 6:e1fa1a2d7483 68 executeMainTask = !executeMainTask;
pmic 8:9bb806a7f585 69 }
pmic 6:e1fa1a2d7483 70 }