a.binder 4 年之前
父節點
當前提交
d1707cd9fa

+ 43 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/LiquidCrystal_I2C_setup.h

@@ -8,4 +8,46 @@
   lcd.setCursor(0,2);
   lcd.print("I2C 1604 DEMO");
   lcd.setCursor(0,3);
-  lcd.print("UGR Edition");
+ // lcd.print("UGR Edition");
+  
+  
+        SPFT(title);  
+
+  //lcd.createChar
+  delay(3000);
+  
+  // Characters
+  byte whole[8] = {B00000, B00000, B00000, B00000, B00000, B01110, B10001, B01110};
+  byte half[8] = {B00001, B00001, B00001, B00001, B00001, B01111, B10001, B01110};
+  byte quarter[8] = {B00001, B00001, B00001, B00001, B00001, B01111, B11111, B01110};
+  byte eighth[8] = { B01110, B01001, B00101, B00010, B00001, B01111, B11111, B01110};
+  byte sixteenth[8] = {B00110, B00101, B00110, B00101, B00100, B01100, B11100, B01000};
+  byte sixteenthRest[8] = {B00000, B01001, B10101, B01010, B00100, B01000, B10000, B00000};
+
+  lcd.createChar(0, whole);
+  lcd.createChar(1, half);
+  lcd.createChar(2, quarter);
+  lcd.createChar(3, eighth);
+  lcd.createChar(4, sixteenth);
+  lcd.createChar(5, sixteenthRest);
+
+
+
+    lcd.setCursor(0,3);
+
+    lcd.write(byte(0));
+  delay(2000);
+  lcd.write(byte(1));
+  delay(2000);
+  lcd.write(byte(2));
+  delay(2000);
+  lcd.write(byte(3));
+  delay(2000);
+  lcd.write(byte(4));
+  delay(2000);
+  lcd.write(byte(5));
+  delay(2000);
+
+
+
+  

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

@@ -1,25 +1,17 @@
 //oled
 
+unsigned long t = 0;
 
-//#define HAS_18x4LCD
-
-#define HAS_u8x8log
-
+#define HAS_18x4LCD
 
+//#define HAS_u8x8log
 #if defined(HAS_u8x8log)
-    #include <Arduino.h>
-   // #include <U8g2lib.h>
-   #include <U8x8lib.h>
-
-   
-   //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display
-   U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(U8X8_PIN_NONE);
+    #include "u8g2.h"
+#endif
 
-  // 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
-            
-   
-      U8X8LOG u8x8log;
 
+#ifdef U8X8_HAVE_HW_SPI
+#include <SPI.h>
 #endif
 
 #include "progmem__const.h"
@@ -47,10 +39,10 @@ const byte address[6] = "00001";
     //#endif
 #endif 
 
-    #if defined(HAS_18x4LCD)
-        #include <LiquidCrystal_I2C.h>
-        LiquidCrystal_I2C lcd(0x27,16,4);  // set the LCD address to 0x27 or 0x20
-    #endif
+#if defined(HAS_18x4LCD)
+    #include <LiquidCrystal_I2C.h>
+    LiquidCrystal_I2C lcd(0x27,16,4);  // set the LCD address to 0x27 or 0x20
+#endif
 
 //  #include "struct.h"
 #define HAS_QMC5883LCompass
@@ -77,52 +69,53 @@ bool blinkState = false;
  
 void setup()
 {
-    #if defined(HAS_u8x8log)
-        #include "u8g2__setup.h"
-    #endif
-     //#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
-        Wire.begin();
-    //#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
-     //   Fastwire::setup(400, true);
-    //#endif
-  
-    
-    
     Serial.begin(115200);
      while (!Serial); // Waiting for Serial Monitor
     //Serial.println("\nCompass ang gyro  test  ");
-    SPFT(title);  
-   
-    #include "scan.h"
-    #if defined(HAS_QMC5883LCompass)
-        SPFT(compass);   SPFT(init);
-        compass.init();
-    #endif
-    #if defined(HAS_MPU6050)
-        SPFT(gyroscope);SPFT(init);
-        accelgyro.initialize();
-        if(accelgyro.testConnection()) {
-            SPFT(ok); 
-            } else {SPFT(failed);}
-         accelgyro.setMotionDetectionDuration(80);
-    #endif
+    //SPFT(title);  
+       Wire.begin();
+
+#if defined(HAS_u8x8log)
+    #include "u8g2__setup.h"
+#endif
+  
+      SPFT(title);  
+
+#include "scan.h"
+    
+#if defined(HAS_QMC5883LCompass)
+    SPFT(compass);   SPFT(init);
+  // Serial.print("Compass init;");
+    compass.init();SPFT(ok);
+#endif
+#if defined(HAS_MPU6050)
+    SPFT(gyroscope);SPFT(init);
+    //Serial.print("accelgyro init;");
+    accelgyro.initialize();
+    if(accelgyro.testConnection()) {
+        SPFT(ok); 
+      //Serial.println("[OK]");
+        } else {
+        SPFT(failed);
+      //Serial.println("[failed]");
+        }
+     accelgyro.setMotionDetectionDuration(80);
+#endif
     
     pinMode(LED_PIN, OUTPUT);
 
-//lcd.backlight();

-//lcd.setCursor(3,0);

-//lcd.print("Hello, world!");

-   #if defined(HAS_18x4LCD)
-        #include "LiquidCrystal_I2C_setup.h"
-    #endif
+#if defined(HAS_18x4LCD)
+    #include "LiquidCrystal_I2C_setup.h"
+#endif
 // setZeroMotionDetectionThreshold(154);
 
  
 #if defined(HAS_nRF24L01)
-    radio.begin();
-    radio.openWritingPipe(address);
-    radio.setPALevel(RF24_PA_MIN);
-    radio.stopListening();
+        Serial.print("radio init;");
+        radio.begin();
+        radio.openWritingPipe(address);
+        radio.setPALevel(RF24_PA_MIN);
+        radio.stopListening();  Serial.println("[OK]");
 #endif
 
 }
@@ -130,8 +123,15 @@ void setup()
 
 void loop()
 {
-
- u8x8log.print("millis=");
+if ( t < millis() ) {
+    t = millis() + 15000;			// every 15 seconds
+   // u8g2.print("\f");			// \f = form feed: clear the screen
+  }
+ // u8g2.print("millis=");
+ // u8g2.print(millis());
+ // u8g2.print("\n");
+
+    Serial.println("[L]");
 //uint8_t tiles[8] = { B00001111,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0};
 //u8x8.drawTile(0, U8LOG_HEIGHT+1, 1, tiles);
 

+ 8 - 4
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/progmem__const.h

@@ -2,8 +2,10 @@
 
 #define FPr(x);   Serial.print(FP(x));              // FlashPrint(FT)
 #if defined(HAS_u8x8log)
-    #define SPFT(x);  u8x8log.print(FP(FT_##x));         // shorter version (ID)
-    #else
+    #define SPFT(x);  u8x8.print(FP(FT_##x));         // shorter version (ID)
+#elif defined(HAS_18x4LCD)
+    #define SPFT(x);  lcd.print(FP(FT_##x));         // shorter version (ID)
+#else
     #define SPFT(x);  Serial.print(FP(FT_##x));         // shorter version (ID)
 #endif
 #define SFP(x);   Serial.print(FP(x));
@@ -11,12 +13,14 @@
 #define FP(x)     (__FlashStringHelper*)(x)         // Helper
 
 #if defined(HAS_u8x8log)
-    #define SPFT2(x,y);  u8x8log.print(FP(FT_##x)); Serial.print("[");   Serial.print(y);   Serial.print("] ");         // shorter version (ID)
+    #define SPFT2(x,y);  u8x8.print(FP(FT_##x)); Serial.print("[");   Serial.print(y);   Serial.print("] ");         // shorter version (ID)
+#elif defined(HAS_18x4LCD)
+    #define SPFT2(x,y);  lcd.print(FP(FT_##x)); Serial.print("[");   Serial.print(y);   Serial.print("] ");         // shorter version (ID)
 #else
     #define SPFT2(x,y);  Serial.print(FP(FT_##x)); Serial.print("[");   Serial.print(y);   Serial.print("] ");         // shorter version (ID)
 #endif
 
-FT(title, "\nCompass ang gyro  test\n" );
+FT(title, "Compass ang gyro  test" );
 FT(compass, "Compass" );
 FT(gyroscope, "Gyro" );
 

+ 26 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/u8g2.h

@@ -0,0 +1,26 @@
+  #include <Arduino.h>
+  //  #include <U8g2lib.h>
+   #include <U8x8lib.h>   
+   U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display
+ //   U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); 	      
+   // 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;
+  
+ /* 
+  int16_t offset;				// current offset for the scrolling text
+u8g2_uint_t width;			// pixel width of the scrolling text (must be lesser than 128 unless U8G2_16BIT is defined
+const char *text = "U8g2";	// scroll this text from right to left
+
+const uint8_t tile_area_x_pos = 2;	// Update area left position (in tiles)
+const uint8_t tile_area_y_pos = 3;	// Update area upper position (distance from top in tiles)
+const uint8_t tile_area_width = 12;
+const uint8_t tile_area_height = 3;	// this will allow cour18 chars to fit into the area
+
+const u8g2_uint_t pixel_area_x_pos = tile_area_x_pos*8;
+const u8g2_uint_t pixel_area_y_pos = tile_area_y_pos*8;
+const u8g2_uint_t pixel_area_width = tile_area_width*8;
+const u8g2_uint_t pixel_area_height = tile_area_height*8;
+  */

+ 19 - 13
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/u8g2__setup.h

@@ -1,19 +1,25 @@
-    #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_5x7_f);
-  
-  u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer);
-  u8x8log.setRedrawMode(0);		// 0: Update screen with newline, 1: Update screen for every char  
-  
-  
-  
-  
-/*
+   u8x8.setFont(u8x8_font_chroma48medium8_r);// u8x8.setFont(u8x8_font_5x7_f);
+    u8x8.clear();
+
+ // u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer);
+ // u8x8log.setRedrawMode(0);		// 0: Update screen with newline, 1: Update screen for every char  
+  //  if ( t < millis() ) {
+  //      t = millis() + 15000;			// every 15 seconds
+        //u8x8log.print("\f");			// \f = form feed: clear the screen
+ //     }
+ // u8x8log.print("Setup oled");
+  //SPFT(title);
+//  u8x8log.print(millis());
+//  u8x8log.print("\n");
+  //void u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr);
+    
+  
+ /* 
+
  u8g2.begin();
           u8g2.setDisplayRotation(U8G2_R2);
 

+ 1 - 0
se.oxygen.xpr

@@ -5665,6 +5665,7 @@
             <file name="../../procesy5-dita-templates-druki/__ROOT_DITAMAP__SPECS__/__ROOT_DITAMAP__SPECS__.ditamap"/>
         </folder>
         <folder name="p5-automation">
+            <folder path="../Documents/Arduino/"/>
             <folder path="../Documents/Arduino/libraries/"/>
             <folder path="SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/"/>
         </folder>