Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
main.cpp
- Committer:
- ackerden
- Date:
- 2021-04-24
- Revision:
- 24:02223fec319a
- Parent:
- 21:1aaf25fc8d53
- Child:
- 25:863e6ef1245f
File content as of revision 24:02223fec319a:
#include "mbed.h" //Eigene Header einbinden //include Zeitfunktion #include "realtimer.h" //include Servosteuerung #include "servo_bewegung.h" //LED Anzeige #include "Adafruit_LED_Backpack.h" using namespace std::chrono; InterruptIn user_button(USER_BUTTON); DigitalOut led(LED1); BufferedSerial pc(SERIAL_TX, SERIAL_RX); I2C i2c(PB_9, PB_8); // i2c1 pins bool executeMainTask = false; Timer user_button_timer, loop_timer; //Adafruit_7segment matrix = Adafruit_7segment(); /* declaration of custom button functions */ void button_fall(); void button_rise(); void setup() { #ifndef __AVR_ATtiny85__ pc.set_baud(15200); //pc.println("7 Segment Backpack Test"); #endif //matrix.begin(0x70); } int main() { set_time(1618332129); //Zeit setzen //Laufvariablen int i = 0; user_button.fall(&button_fall); user_button.rise(&button_rise); loop_timer.start(); while (true) { loop_timer.reset(); /*matrix.print(10000, DEC); matrix.writeDisplay(); delay(500); // print a hex number matrix.print(0xBEEF, HEX); matrix.writeDisplay(); delay(500); // print a floating point matrix.print(12.34); matrix.writeDisplay(); delay(500); // print with print/println for (uint16_t counter = 0; counter < 9999; counter++) { matrix.println(counter); matrix.writeDisplay(); delay(10);*/ if (executeMainTask) { //Zeitfunktion uhrzeit(time(NULL)); switch(i){ //2 Minuten case 120: i += 5; //Seesaw Programm ThisThread::sleep_for(5s); //Wartet 5s.. break; //5 Minuten case 20: case 10: { i += 5; bewegung(); ThisThread::sleep_for(5s); //Wartet 5s.. break; } //7 Minuten case 420: i += 5; //Audio Signal ThisThread::sleep_for(5s); //Wartet 5s.. break; //10 Minuten case 600: i = 0; ThisThread::sleep_for(5s); //Wartet 5s.. break; default : i += 5; ThisThread::sleep_for(5s); //Wartet 5s.. break; } led = !led; }} } 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; } }