a.binder 5 jaren geleden
bovenliggende
commit
6335b3de4c

+ 26 - 25
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/gyro_and_compass_test.ino

@@ -17,9 +17,7 @@
 
   // U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display
             
-      #define U8LOG_WIDTH 16
-      #define U8LOG_HEIGHT 8
-      uint8_t u8log_buffer[U8LOG_WIDTH*U8LOG_HEIGHT];
+   
       U8X8LOG u8x8log;
 
 #endif
@@ -56,7 +54,7 @@ const byte address[6] = "00001";
 
 //  #include "struct.h"
 #define HAS_QMC5883LCompass
-#if defined(QMC5883LCompass)
+#if defined(HAS_QMC5883LCompass)
     #include <QMC5883LCompass.h>
     QMC5883LCompass compass;
 #endif
@@ -83,7 +81,7 @@ void setup()
         #include "u8g2__setup.h"
     #endif
      //#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
-     //   Wire.begin();
+        Wire.begin();
     //#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
      //   Fastwire::setup(400, true);
     //#endif
@@ -96,14 +94,16 @@ void setup()
     SPFT(title);  
    
     #include "scan.h"
-    #if defined(QMC5883LCompass)
-        Serial.println("compass.init()");
+    #if defined(HAS_QMC5883LCompass)
+        SPFT(compass);   SPFT(init);
         compass.init();
     #endif
     #if defined(HAS_MPU6050)
-        Serial.println("accelgyro.initialize()");
+        SPFT(gyroscope);SPFT(init);
         accelgyro.initialize();
-        Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
+        if(accelgyro.testConnection()) {
+            SPFT(ok); 
+            } else {SPFT(failed);}
          accelgyro.setMotionDetectionDuration(80);
     #endif
     
@@ -131,10 +131,11 @@ void setup()
 void loop()
 {
 
- // u8x8log.print("millis=");
-
+ u8x8log.print("millis=");
+//uint8_t tiles[8] = { B00001111,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0};
+//u8x8.drawTile(0, U8LOG_HEIGHT+1, 1, tiles);
 
-#if defined(QMC5883LCompass)
+#if defined(HAS_QMC5883LCompass)
       int x, y, z;
    Serial.println();
      // Read compass values
@@ -143,12 +144,12 @@ void loop()
      x = compass.getX();
      y = compass.getY();
      z = compass.getZ();
-    SPFT(compass);
-    SPFT2(x,x);
-     Serial.print("   Y: ");
-     Serial.print(y);
-     Serial.print("   Z: ");
-     Serial.print(z);
+  //  SPFT(compass);
+  //  SPFT2(X,x);
+  //   SPFT(Y);
+  //   SP(y);
+  //   SPFT(Z);
+  //   SP(z);
 #endif
 #if defined(HAS_MPU6050)
             accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
@@ -157,13 +158,13 @@ void loop()
             //accelgyro.getRotation(&gx, &gy, &gz);
         #ifdef OUTPUT_READABLE_ACCELGYRO
                 // display tab-separated accel/gyro x/y/z values
-                Serial.print("  a/g:\t");
-                Serial.print(ax); Serial.print("\t");
-                Serial.print(ay); Serial.print("\t");
-                Serial.print(az); Serial.print("\t");
-                Serial.print(gx); Serial.print("\t");
-                Serial.print(gy); Serial.print("\t");
-                Serial.print(gz);
+         //       SPFT(gyroscope);
+           //     SPFT2(ax,ax); SP("\t");
+             //   SPFT2(ay,ay); SP("\t");
+               // SPFT2(az,az); SP("\t");
+               // SPFT2(gx,gx); SP("\t");
+               // SPFT2(gy,gy); SP("\t");
+               // SPFT2(gz,gz);
             #endif
         
             #ifdef OUTPUT_BINARY_ACCELGYRO

+ 5 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/progmem__const.h

@@ -18,6 +18,11 @@
 
 FT(title, "\nCompass ang gyro  test\n" );
 FT(compass, "Compass" );
+FT(gyroscope, "Gyro" );
+
+FT(init, "init" );
+FT(failed, "failed" );
+FT(ok, "OK" );
 FT(x, "[X]" );
 FT(y, "[Y]" );
 FT(z, "[Z]" );

+ 9 - 2
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/u8g2__setup.h

@@ -1,10 +1,17 @@
+    #define U8LOG_WIDTH 14 //16
+      #define U8LOG_HEIGHT 5 //U8LOG_HEIGHT 8
+      uint8_t u8log_buffer[U8LOG_WIDTH*U8LOG_HEIGHT];
+ 
  
   u8x8.begin();
     u8x8.setFlipMode(1);
-  u8x8.setFont(u8x8_font_chroma48medium8_r);
+  u8x8.setFont(u8x8_font_5x7_f);
   
   u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer);
-  u8x8log.setRedrawMode(1);		// 0: Update screen with newline, 1: Update screen for every char  
+  u8x8log.setRedrawMode(0);		// 0: Update screen with newline, 1: Update screen for every char  
+  
+  
+  
   
 /*
  u8g2.begin();