eLandon_Miix пре 4 година
родитељ
комит
08cf46ee36
2 измењених фајлова са 42 додато и 14 уклоњено
  1. 18 0
      README.md
  2. 24 14
      src/main.cpp

+ 18 - 0
README.md

@@ -0,0 +1,18 @@
+# OSC MESSAGES
+
+ESP-IMU receives messages on UDP **input port** (default 9000)  
+The last IP that sent a message will receive all messages from ESP-IMU on **target port**  
+Default **target IP** can be changed through webserver
+**input port** and **target port** can be changed through webserver
+
+## to ESP-IMU
+- **/calibration** :  
+triggers a gyro calibration process, useful if the sensor drifts. Turn the sensor all the way around during 15 seconds
+
+## from ESP-IMU
+
+- **/button/[A, B, C]** :  
+message is sent on A/B/C button state change  
+1 when pressed, 0 when released
+
+- **/**

+ 24 - 14
src/main.cpp

@@ -21,14 +21,14 @@ OSC configuration custom page
 #include <FS.h>
 #include <SPIFFS.h>
 #include <M5Stack.h>
+
+extern void lcd_sleep();
+extern void lcd_wakeup();
+
 #include "wifimgr.h"
 #include "oscmgr.h"
 #include "imu.h"
 
-
-
-
-
 ///////////////////////   SENSOR   ////////////////////////////////////
 
 int sensor_rate = 10;
@@ -36,6 +36,20 @@ long int last_sent;
 
 ///////////////////////      TFT   ////////////////////////////////////
 
+long int idle ;
+long int idle_offset;
+
+void lcd_sleep(){
+  M5.Lcd.sleep();
+  M5.Lcd.setBrightness(0);
+}
+
+void lcd_wakeup(){
+  M5.Lcd.wakeup();
+  M5.Lcd.setBrightness(200);
+  idle_offset=millis();
+}
+
 void drawNetworkInfo(int offsetX, int offsetY){
   
   String printString = "Connected to ";
@@ -83,7 +97,6 @@ void drawSensorInfo(int offsetX, int offsetY){
 
 
 
-
 ///////////////////////     SETUP     ////////////////////////////////////
 
 void setup() {
@@ -162,28 +175,25 @@ void setup() {
 
 ///////////////////////     LOOP     ////////////////////////////////////
 
-long int idle ;
-long int idle_offset;
+
 
 void loop() {
 
   idle = millis()-idle_offset;
   if(idle>60000){
-    M5.Lcd.sleep();
-    M5.Lcd.setBrightness(0);
+    lcd_sleep();
   }
 
   if(M5.BtnA.read()){
-    M5.Lcd.wakeup();
-    M5.Lcd.setBrightness(200);
-    idle_offset=millis();
+    lcd_wakeup();
     }
 
   
   if (calib_flag)
     {
-        calib_flag = false;
-        calibGyro();
+      lcd_wakeup();
+      calib_flag = false;
+      calibGyro();
     }
   handle_imu();