Hauptprogramm

Dependencies:   ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini

Revision:
13:096e5dc3ac23
Parent:
12:dfa3591affef
Child:
14:153f377f4030
--- a/main.cpp	Wed Apr 14 14:23:47 2021 +0000
+++ b/main.cpp	Sat Apr 17 11:25:37 2021 +0000
@@ -1,16 +1,10 @@
-/*Zeitinput am Anfang: Startzeit 8:00*/
-
-#include <I2C.h>
 #include "mbed.h"
-#include "platform/mbed_thread.h"
+//#include "mbed_rtc_time.h"
 
-#include "mbed_rtc_time.h"
+//Eigene Header einbinden
+#include "realtimer.h"
 
-/* PM2_Libary */
-#include "EncoderCounter.h"
-#include "Servo.h"
-#include "SpeedController.h"
-#include "FastPWM.h"
+
 
 using namespace std::chrono;
 
@@ -20,39 +14,20 @@
 
 bool  executeMainTask = false;
 Timer user_button_timer, loop_timer;
-int   Ts_ms = 50;
+
 
 /* declaration of custom button functions */
 void button_fall();
 void button_rise();
 
 
-/* create analog input object */
-/*AnalogIn analogIn(PC_2);
-float    dist = 0.0f;
-*/
-/* create servo objects */
-/*Servo servo_S1(PB_2);
-Servo servo_S2(PC_8);
-// Servo servo_S3(PC_6); // not needed in this example
-int servoPeriod_mus = 20000;
-int servoOutput_mus_S1 = 0;
-int servoOutput_mus_S2 = 0;
-int servo_counter = 0;*/
-int loops_per_second = static_cast<int>(ceilf(1.0f/(0.001f*(float)Ts_ms)));
-
 int main()
 {
-    set_time(1618332129);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
+    set_time(1618332129);  //Zeit setzen
     user_button.fall(&button_fall);
     user_button.rise(&button_rise);
     loop_timer.start();
 
-
-    /* enable servos, you can also disable them */
-    //servo_S1.Enable(servoOutput_mus_S1, servoPeriod_mus);
-    //servo_S2.Enable(servoOutput_mus_S2, servoPeriod_mus);
-
     while (true) {
 
         loop_timer.reset();
@@ -62,58 +37,20 @@
  
 
         if (executeMainTask) {
-            time_t seconds = time(NULL);
-
-        printf("Time as seconds since January 1, 1970 = %u\n", (unsigned int)seconds);
-
-        printf("Time as a basic string = %s", ctime(&seconds));
-
-        char buffer[32];
-        strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
-        printf("Time as a custom formatted string = %s", buffer);
-
-        ThisThread::sleep_for(50);
+        
+        //Zeitfunktion
+        uhrzeit(time(NULL));
+        ThisThread::sleep_for(5s); //Wartet 5s.
 
-            /* read analog input */
-            //dist = analogIn.read() * 3.3f;
-
-            /* command servo position via output time, this needs to be calibrated */
-            /*servo_S1.SetPosition(servoOutput_mus_S1);
-            servo_S2.SetPosition(servoOutput_mus_S2);
-            if (servoOutput_mus_S1 <= servoPeriod_mus & servo_counter%loops_per_second == 0 & servo_counter != 0) {
-                servoOutput_mus_S1 += 100;
-            }
-            if (servoOutput_mus_S2 <= servoPeriod_mus & servo_counter%loops_per_second == 0 & servo_counter != 0) {
-                servoOutput_mus_S2 += 100;
-            }
-            servo_counter++;*/
-
-            /* visual feedback that the main task is executed */
-            led = !led;
+        led = !led;
 
         } else {
 
-            //dist = 0.0f;
-
-            //servoOutput_mus_S1 = 0;
-            //servoOutput_mus_S2 = 0;
-            //servo_S1.SetPosition(servoOutput_mus_S1);
-            //servo_S2.SetPosition(servoOutput_mus_S2);
-
+            
             led = 0;
         }
 
-        /* do only output via serial what's really necessary (this makes your code slow)*/
-        //printf("%3.3f, %3d;\r\n",
-               //dist,
-               //servoOutput_mus_S1,
-               //servoOutput_mus_S2);
-            
-
-
-        int T_loop_ms = duration_cast<milliseconds>(loop_timer.elapsed_time()).count();
-        int dT_loop_ms = Ts_ms - T_loop_ms;
-        thread_sleep_for(dT_loop_ms);
+    
     }
 }