Hauptprogramm

Dependencies:   ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini

Revision:
16:f0480e9c5039
Parent:
15:babdd038715a
Child:
17:621c4212fd4e
--- a/main.cpp	Mon Apr 19 14:10:40 2021 +0000
+++ b/main.cpp	Wed Apr 21 13:48:47 2021 +0000
@@ -1,14 +1,26 @@
 #include "mbed.h"
+#include "Servo.h"
+//Eigene Header einbinden
 
-//Eigene Header einbinden
+//include Zeitfunktion
 #include "realtimer.h"
 
+//include Servosteuerung
+#include "servo_bewegung.h"
+
 
 //LED Anzeige
-#include "Adafruit_LEDBackpack.h"
-#include "Adafruit_GFX.h"
-#include "glcdfont.h"
+//#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;
 
@@ -16,6 +28,10 @@
 DigitalOut  led(LED1);
 
 
+
+//I2C i2c(I2C_SDA , I2C_SCL);
+
+
 bool  executeMainTask = false;
 Timer user_button_timer, loop_timer;
 
@@ -24,17 +40,27 @@
 void button_fall();
 void button_rise();
 
-
-I2C i2c(D14, D6);
-Adafruit_8x8matrix matrix = Adafruit_8x8matrix(&i2c);
+/*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()
 {
-    matrix.begin(0x70);
+    //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);
@@ -44,18 +70,40 @@
 
         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);
+  /*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) {
+            
+        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);
+        
         
         //Zeitfunktion
         uhrzeit(time(NULL));
@@ -96,4 +144,25 @@
     if (t_button_ms > 200) {
         executeMainTask = !executeMainTask;
     }
-}
\ No newline at end of file
+}
+
+/*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);
+  }*/
\ No newline at end of file