Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
main.cpp
- Committer:
- ackerden
- Date:
- 2021-04-19
- Revision:
- 15:babdd038715a
- Parent:
- 14:153f377f4030
- Child:
- 16:f0480e9c5039
File content as of revision 15:babdd038715a:
#include "mbed.h" //Eigene Header einbinden #include "realtimer.h" //LED Anzeige #include "Adafruit_LEDBackpack.h" #include "Adafruit_GFX.h" #include "glcdfont.h" using namespace std::chrono; InterruptIn user_button(USER_BUTTON); DigitalOut led(LED1); bool executeMainTask = false; Timer user_button_timer, loop_timer; /* declaration of custom button functions */ void button_fall(); void button_rise(); I2C i2c(D14, D6); Adafruit_8x8matrix matrix = Adafruit_8x8matrix(&i2c); int main() { matrix.begin(0x70); set_time(1618332129); //Zeit setzen int i = 0; user_button.fall(&button_fall); user_button.rise(&button_rise); loop_timer.start(); while (true) { loop_timer.reset(); matrix.clear(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { matrix.drawPixel(i, j, LED_ON); } } matrix.writeDisplay(); // write the changes we just made to the display wait(60); if (executeMainTask) { //Zeitfunktion uhrzeit(time(NULL)); //Zeitfunktionen if (i != 360){ ThisThread::sleep_for(5s); //Wartet 5s.. printf("%d\n", i); } else{ i=0; } i += 5; led = !led; } else { led = 0; } } } void button_fall() { user_button_timer.reset(); user_button_timer.start(); } void button_rise() { int t_button_ms = duration_cast<milliseconds>(user_button_timer.elapsed_time()).count(); user_button_timer.stop(); if (t_button_ms > 200) { executeMainTask = !executeMainTask; } }