a.binder 5 年之前
父节点
当前提交
283b8cc3de

+ 45 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/compass__loop.h

@@ -0,0 +1,45 @@
+     int x, y, z, angle;
+   Serial.println();
+     // Read compass values
+     compass.read();
+   
+     x = compass.getX();
+     y = compass.getY();
+     z = compass.getZ();
+     
+      if (Math.atan2(y, x) >= 0) {
+        angle = Math.atan2(y, x) * (180 / Math.PI);
+      }
+      else {
+        angle = (Math.atan2(y, x) + 2 * Math.PI) * (180 / Math.PI);
+      }
+       
+       
+         lcd.setCursor(0,2);
+
+
+         lcd.print(round(angle));
+
+  //  SPFT(compass);
+  //  SPFT2(X,x);
+  //   SPFT(Y);
+  //   SP(y);
+  //   SPFT(Z);
+  //   SP(z);
+  
+   // Characters
+  byte compass__empty[8] = {B00100, B01000, B00100, B00010, B00100, B01000, B00100, B01000};
+  byte compass__left_marker[8] = {B00001, B00001, B00001, B00001, B00001, B01111, B10001, B01110};
+  byte compass__marker[8] = {B00001, B00001, B00001, B00001, B00001, B01111, B11111, B01110};
+  byte compass__right_marker[8] = { B01110, B01001, B00101, B00010, B00001, B01111, B11111, B01110};
+  
+  
+  lcd.createChar(0, compass__empty);
+  lcd.createChar(1, compass__left_marker);
+  lcd.createChar(2, compass__marker);
+  lcd.createChar(3, compass__right_marker);
+
+
+     lcd.write(byte(0));
+     lcd.write(byte(0));
+delay(1000);

+ 2 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/gyro_and_compass_test.ino

@@ -1,4 +1,5 @@
 //oled
+#include <math.h>
 
 unsigned long t = 0;
 
@@ -180,7 +181,7 @@ if ( t < millis() ) {
         #include "LiquidCrystal_I2C_loop.h"
     #endif
     #if defined(HAS_nRF24L01)
-        #include "radio_loop.h"
+        #include "radio__loop.h"
     #endif
   delay(1500);
 

+ 0 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/radio_loop.h → SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/radio__loop.h