Przeglądaj źródła

testing bin displ

a.binder 5 lat temu
rodzic
commit
f823ff3f61

+ 129 - 13
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/compass__loop.h

@@ -15,7 +15,7 @@
       }
        
        
-         lcd.setCursor(0,2);
+         lcd.setCursor(9,0);
 
 
          lcd.print(round(angle));
@@ -27,19 +27,135 @@
   //   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};
   
+  //draw bargraf
+  //i * x = 360 ==22
+  //0--8 >180 <0 ..
+  for(int i = 0 ; i <=16 ; i++ ) {
+    if(angle > 180) {
+      
+    } else {
+    }
   
-  lcd.createChar(0, compass__empty);
-  lcd.createChar(1, compass__left_marker);
-  lcd.createChar(2, compass__marker);
-  lcd.createChar(3, compass__right_marker);
+  }
 
+   
+  
+  lcd.createChar(0, compass__N);
+  lcd.createChar(1, compass__E);
+  lcd.createChar(2, compass__S);
+  lcd.createChar(3, compass__W);
+  lcd.createChar(4, compass__N);
+ //WRITE PART OF compass__bearing
+ 
+
+ 
+     byte compass__bearing__part[8]; 
+     for(int p = 0; p<8; p++) {
+                        compass__bearing__part[p] = B00000;
+                     }
+            int context_digit = 0 ; //4
+            int context_row = 0 ; //5
+            int context_digit_real = 0 ; //5
+            int context_digit_row_real = 0 ; //5
+
+            bool context_is_printing = false;
+     for(int degree = 0; context_digit_real < 4; degree ++ ) {
+            if(context_row == 5) {
+                context_row = 0 ;
+                context_digit ++ ;
+            }
+            if(context_digit == 4) {
+                context_digit = 0;
+            }
+            
+            if(degree == 360) {
+                degree = 0;
+            }
+            
+          if(context_digit_row_real == 5) {
+                    lcd.createChar(context_digit_real, compass__bearing__part);
+                     for(int p = 0; p<8; p++) {
+                        compass__bearing__part[p] = B00000;
+                     }
+                    context_digit_row_real = 0;
+                    context_digit_real ++;
+                }
+            
+            if(angle == degree) {
+                context_is_printing = true ; 
+              // lcd.createChar(0, display__char_A[2].character);
+              // lcd.write(byte(0));
+               Serial.print("Cd[");Serial.print(context_digit);Serial.print("] r[");Serial.print(context_row) ; Serial.print("]");
+            }
+            if(context_is_printing == true) { 
+                  for(int p = 0; p<8; p++) {
+                        byte row ; 
+                        int shift = B00001;
+                        shift = shift << ( 4 - context_row ) ;
+                        //bitWrite(row,1,1);
+                        byte input = display__char_A[context_digit].character[p] & shift;
+                        compass__bearing__part[p] = compass__bearing__part[p] | input ; // B11111 ; //compass__bearing[p] & B00001 ;
+                        /*if(context_row == 0 ) {
+                            compass__bearing__part[p] = compass__bearing__part[p] | ( display__char_A[context_digit].character[p] & B10000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+                        } else if(context_row == 1 ) {
+                            compass__bearing__part[p] = compass__bearing__part[p] | ( display__char_A[context_digit].character[p] & B01000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+                        } else if(context_row == 2 ) {
+                            compass__bearing__part[p] = compass__bearing__part[p] | ( display__char_A[context_digit].character[p] & B00100 ); // B11111 ; //compass__bearing[p] & B00001 ;
+                        } else if(context_row == 3 ) {
+                            compass__bearing__part[p] = compass__bearing__part[p] | ( display__char_A[context_digit].character[p] & B00010 ); // B11111 ; //compass__bearing[p] & B00001 ;
+                        } else if(context_row == 4 ) {
+                            compass__bearing__part[p] = compass__bearing__part[p] | ( display__char_A[context_digit].character[p] & B00001 );// B11111 ; //compass__bearing[p] & B00001 ;
+                        } */
+                     }
+                context_digit_row_real ++;
+                
+            }
+              context_row ++;
+          //  context_digit ++ ;
+     }
+     
+     
+     for(int p = 0; p<8; p++) {
+        compass__bearing__part[p] = B00000;
+     }
+     compass__bearing__part[0] = compass__bearing__part[0] | ( display__char_A[2].character[0] & B00001 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[0] = compass__bearing__part[0] | ( display__char_A[2].character[0] & B00010 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[0] = compass__bearing__part[0] | ( display__char_A[2].character[0] & B00100 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[0] = compass__bearing__part[0] | ( display__char_A[2].character[0] & B01000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[0] = compass__bearing__part[0] | ( display__char_A[2].character[0] & B10000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+
+     compass__bearing__part[1] = compass__bearing__part[1] | ( display__char_A[2].character[1] & B00001 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[1] = compass__bearing__part[1] | ( display__char_A[2].character[1] & B00010 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[1] = compass__bearing__part[1] | ( display__char_A[2].character[1] & B00100 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[1] = compass__bearing__part[1] | ( display__char_A[2].character[1] & B01000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[1] = compass__bearing__part[1] | ( display__char_A[2].character[1] & B10000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+
+     compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B00001 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B00010 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B00100 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B01000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B10000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+
+     compass__bearing__part[3] = compass__bearing__part[3] | ( display__char_A[2].character[3] & B00001 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[3] = compass__bearing__part[3] | ( display__char_A[2].character[3] & B00010 ); // B11111 ; //compass__bearing[p] & B00001 ;
+     compass__bearing__part[3] = compass__bearing__part[3] | ( display__char_A[2].character[3] & B00100 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B01000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+    // compass__bearing__part[2] = compass__bearing__part[2] | ( display__char_A[2].character[2] & B10000 ); // B11111 ; //compass__bearing[p] & B00001 ;
+
+   
+    lcd.createChar(4, compass__bearing__part);
+  //  lcd.createChar(4, compass__N);
+          lcd.setCursor(13,0);
+
+      lcd.write(byte(0));
+     lcd.write(byte(1));
+     lcd.write(byte(2));
+      lcd.write(byte(3));
+
+      lcd.write(byte(4));
+
+     
+    
 
-     lcd.write(byte(0));
-     lcd.write(byte(0));
-delay(1000);
+delay(110);

+ 145 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/display.h

@@ -0,0 +1,145 @@
+// Characters
+
+struct display__char_S {
+    byte character[8];
+}  ;
+
+typedef display__char_S display__char_T;
+
+display__char_T display__char_A[5] ;
+
+bool display__char_A__init(display__char_T* display__char_A) {
+     //display__char_A[0].character = {B10001, B10001, B11001, B10101, B10011, B10001, B10001, B10001};
+     display__char_A[0].character[0] =  B10001 ;//{, , , , , , , };
+     display__char_A[0].character[1] =  B10001 ;
+     display__char_A[0].character[2] =  B11001 ;
+     display__char_A[0].character[3] =  B10101 ;
+     display__char_A[0].character[4] =  B10011 ;
+     display__char_A[0].character[5] =  B10001 ;
+     display__char_A[0].character[6] =  B10001 ;
+     display__char_A[0].character[7] =  B10001 ;
+
+     display__char_A[1].character[0] =  B11111  ;
+     display__char_A[1].character[1] =  B10000  ;
+     display__char_A[1].character[2] =  B10000  ;
+     display__char_A[1].character[3] =  B11111  ;
+     display__char_A[1].character[4] =  B10000  ;
+     display__char_A[1].character[5] =  B10000  ;
+     display__char_A[1].character[6] =  B10000  ;
+     display__char_A[1].character[7] =  B11111  ;
+
+// byte compass__S[8] = {, , , , , , , };
+
+     display__char_A[2].character[0] =   B01110 ;
+     display__char_A[2].character[1] =   B10001 ;
+     display__char_A[2].character[2] =   B01000 ;
+     display__char_A[2].character[3] =   B00100 ;
+     display__char_A[2].character[4] =   B00010 ;
+     display__char_A[2].character[5] =   B00001 ;
+     display__char_A[2].character[6] =   B10001 ;
+     display__char_A[2].character[7] =   B01110 ;
+     
+ //          byte compass__W[8] = {, , , , , , , };
+    
+     display__char_A[3].character[0] = B10001   ;
+     display__char_A[3].character[1] = B10001   ;
+     display__char_A[3].character[2] = B10101   ;
+     display__char_A[3].character[3] = B11011   ;
+     display__char_A[3].character[4] = B11011   ;
+     display__char_A[3].character[5] = B11011   ;
+     display__char_A[3].character[6] = B10001   ;
+     display__char_A[3].character[7] = B10001   ;
+     
+    /* 
+     display__char_A[0].character[0] =    ;
+     display__char_A[0].character[1] =    ;
+     display__char_A[0].character[2] =    ;
+     display__char_A[0].character[3] =    ;
+     display__char_A[0].character[4] =    ;
+     display__char_A[0].character[5] =    ;
+     display__char_A[0].character[6] =    ;
+     display__char_A[0].character[7] =    ;
+     */
+}
+bool res = display__char_A__init(display__char_A);
+
+  byte   compass__bearing[8] = {B00100, B01110, B11111, B11111, B11111, B11111, B11111, B11011};
+          byte compass__N[8] = {B10001, B10001, B11001, B10101, B10011, B10001, B10001, B10001};
+          byte compass__E[8] = {B11111, B10000, B10000, B11111, B10000, B10000, B10000, B11111};
+          byte compass__S[8] = {B01110, B10001, B01000, B00100, B00010, B00001, B10001, B01110};
+          byte compass__W[8] = {B10001, B10001, B10101, B11011, B11011, B11011, B10001, B10001};
+          
+  /*
+  const int display_x_A__MAX = 40 ;
+  const int display_y_A__MAX = 2 ;
+  
+  
+  typedef int x_T;
+  typedef int y_T;
+  
+  struct display_y_S {
+       byte value;
+       byte used; //if empty
+  };
+  typedef display_y_S display_y_T;
+  
+  struct display_S {
+       //x_T x;
+       display_y_T display_y_A[display_y_A__MAX];
+       //byte value;
+       //byte used; //if empty
+
+  };
+  
+  typedef display_S display_T;
+  
+
+  display_T display_A[display_x_A__MAX];
+  
+  
+  void display__allocate(display_T* display_A, x_T x_A, y_T y_A) {
+       // int pixel = 0;
+       
+        for(int x = 0 ; x<=x_A ; x++) {
+            for(int y = 0 ; y<=y_A ; y++) {
+                   bitSet(display_A[x].display_y_A[y].used, y );
+            }
+        }
+  }
+  */
+ // void display__allocated__print(display_T* display_A) {
+ //       int segment  = 0 ;
+ //       int segment_bit = 1 ;
+ //       byte character[8] ; 
+ //       byte character_bit ; 
+        
+    /*    for(int x = 0 ; x<= display_x_A__MAX ; x++ ) {
+     //       character_bit = character_bit + display_A[x]
+            if(segment_bit == 8) {
+                segment_bit = 0 ;
+                character_bit = 0 ;
+                segment ++ ; 
+            }
+            segment_bit ++ ;
+        }
+        */
+  //}
+  
+  /*
+  {181}  {270}  {0}   {90}       {180}
+  [0,0]                         [40,0]
+   |
+   |
+   |
+   +----[5,8]                   [40,8]                   
+        
+  0 0 1 0 0 
+  0 1 0 0 0
+  0 0 1 0 0 
+  0 0 0 1 0 
+  0 1 0 0 0 
+  0 0 1 0 0
+  0 1 0 0 0
+   */  
+  
+  

+ 1 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/display__setup.h

@@ -0,0 +1 @@
+ //    display__allocate(display_A, 40, 8);

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

@@ -5,7 +5,7 @@ unsigned long t = 0;
 
 #define HAS_18x4LCD
 
-//#define HAS_u8x8log
+#define HAS_u8x8log
 #if defined(HAS_u8x8log)
     #include "u8g2.h"
 #endif
@@ -17,6 +17,9 @@ unsigned long t = 0;
 
 #include "progmem__const.h"
 
+#include "display.h"
+
+
 #define HAS_nRF24L01
 
 //radio
@@ -74,13 +77,14 @@ void setup()
      while (!Serial); // Waiting for Serial Monitor
     //Serial.println("\nCompass ang gyro  test  ");
     //SPFT(title);  
-       Wire.begin();
+   //    Wire.begin();
 
 #if defined(HAS_u8x8log)
     #include "u8g2__setup.h"
 #endif
   
       SPFT(title);  
+#include "display__setup.h"
 
 #include "scan.h"
     
@@ -165,12 +169,13 @@ if ( t < millis() ) {
                 Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));
             #endif
 #endif
+  delay(150);
     #if defined(HAS_18x4LCD)
         #include "LiquidCrystal_I2C_loop.h"
     #endif
     #if defined(HAS_nRF24L01)
         #include "radio__loop.h"
     #endif
-  delay(1500);
+
 
 }

+ 3 - 1
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/u8g2.h

@@ -1,7 +1,9 @@
   #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_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);
+
  //   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

+ 7 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/gyro_and_compass_test/u8g2__setup.h

@@ -1,9 +1,16 @@
   
  
   u8x8.begin();
+    u8x8.setPowerSave(0);
+
     u8x8.setFlipMode(1);
    u8x8.setFont(u8x8_font_chroma48medium8_r);// u8x8.setFont(u8x8_font_5x7_f);
     u8x8.clear();
+u8x8.setCursor(0, 0);
+      u8x8.print("Setup oled");
+
+   SPFT(title);
+        u8x8.refreshDisplay();		// only required for SSD1606/7  
 
  // u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer);
  // u8x8log.setRedrawMode(0);		// 0: Update screen with newline, 1: Update screen for every char