Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
main.cpp
- Committer:
- ackerden
- Date:
- 2021-04-21
- Revision:
- 18:39be9e19768f
- Parent:
- 17:621c4212fd4e
- Child:
- 19:9ccd591cb637
File content as of revision 18:39be9e19768f:
#include "mbed.h" #include "Servo.h" //Eigene Header einbinden //include Zeitfunktion #include "realtimer.h" //include Servosteuerung #include "servo_bewegung.h" //LED Anzeige //#include "Adafruit_LED_Backpack.h" #define MID 1500 #define MIN 1000 #define MAX 2000 #define STEP 50 //Time delay between steps in milliseconds #define TIME 100 using namespace std::chrono; InterruptIn user_button(USER_BUTTON); DigitalOut led(LED1); //I2C i2c(I2C_SDA , I2C_SCL); bool executeMainTask = false; Timer user_button_timer, loop_timer; /* declaration of custom button functions */ void button_fall(); void button_rise(); /*void setup() { #ifndef __AVR_ATtiny85__ Serial.begin(9600); Serial.println("7 Segment Backpack Test"); #endif matrix.begin(0x70); }*/ //Adafruit_7segment matrix = Adafruit_7segment(); int main() { //myservo.period_ms(20); //myservo.pulsewidth_us(MID); //NB in microseconds set_time(1618332129); //Zeit setzen //Laufvariablen int i = 0; int zeit = 30; Servo Servo1(PA_0); Servo1.Enable(1500,20000); 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 300: i += 5; //Servo 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; break; ThisThread::sleep_for(5s); //Wartet 5s.. default : i += 5; ThisThread::sleep_for(5s); //Wartet 5s.. break; } /* for (int pos = 1000; pos < 2000; pos += 25) { Servo1.SetPosition(pos); wait_ns(50); } for (int pos = 2000; pos > 1000; pos -= 25) { Servo1.SetPosition(pos); wait_ns(50); }*/ //bewegung(zeit); 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; } } /*uint16_t blinkcounter = 0; boolean drawDots = false; for (uint16_t counter = 0; counter < 9999; counter ++) { matrix.writeDigitNum(0, (counter / 1000), drawDots); matrix.writeDigitNum(1, (counter / 100) % 10, drawDots); matrix.drawColon(drawDots); matrix.writeDigitNum(3, (counter / 10) % 10, drawDots); matrix.writeDigitNum(4, counter % 10, drawDots); blinkcounter+=50; if (blinkcounter < 500) { drawDots = false; } else if (blinkcounter < 1000) { drawDots = true; } else { blinkcounter = 0; } matrix.writeDisplay(); delay(10); }*/