a.binder il y a 5 ans
Parent
commit
79d18a7de6

+ 15 - 6
SE/stuff/P5_Automation_can-dev-res/P5_Automation_can-dev-res.ino

@@ -81,8 +81,16 @@
 //#define HAS_ROTTARY_SW
 #define HAS__PCINT_setup //to allow interrupts
 
+#define HAS__jm_Scheduler //to allow planned actions blink etc
+
+#if defined(HAS__jm_Scheduler)
+    #include "jm_Scheduler.h"
+#endif
+
 //Debug level
-#define DEBUG 5 
+//#define DEBUG 5 
+//#define DISABLE_LOOP //To debug and disable any output
+
 
 #include "__main_struct.h"
 #include "__main_struct_funct.h"
@@ -279,9 +287,6 @@
 #endif
 
 
-#if defined(HAS_I2C_driver_Adafruit_PWMServoDriver)
- #include "_I2C_driver_Adafruit_PWMServoDriver_init.h"
-#endif
 
 #if defined(HAS__PCINT_setup)
     #include "_PCINT_init.h"
@@ -300,6 +305,9 @@
 #endif
 
 
+#if defined(HAS_I2C_driver_Adafruit_PWMServoDriver)
+ #include "_I2C_driver_Adafruit_PWMServoDriver_init.h"
+#endif
 
 
 
@@ -403,8 +411,8 @@ void loop() {
     
     
     if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT ) {
-                  Serial.print("Time: " );   Serial.println(time);
-
+            #ifndef DISABLE_LOOP
+                Serial.print("Time: " );   Serial.println(time);
                 Serial.print("#331_L1 main loop top   ARDUINO_FUNCT_INIT_RESULT__Slave_Ports_LOCAL_init  ");
                 Serial.println(ARDUINO_FUNCT_INIT_RESULT__Slave_Ports_LOCAL_init);
               
@@ -432,6 +440,7 @@ void loop() {
                     TASK_TYPE_T__EMPTY__JUST_PASSED_ARG__,
                     TASK_PORT_ASSOC_EMPTY
                  );
+              #endif
 }
  // Serial.println(time);
       #include "_SlaveID_loop1.h" //todo PCINT

+ 1 - 1
SE/stuff/P5_Automation_can-dev-res/_DISPLAY_struct.h

@@ -79,5 +79,5 @@ typedef struct ARDUINO_ARRAY_INDEX_T_TO_DELETE_S   DISPLAY_ARDUINO_ARRAY_INDEX_T
  typedef ARDUINO_FUNCT_INIT_RESULT_T ARDUINO_FUNCT_INIT_RESULT_Slave_Ports_queue__add_DISPLAY_T ;
  
  
- const DISPLAY_CURSOR_Y_CHARS_T DISPLAY_CURSOR_Y_CHARS_DEBUG = 8 ; //todo 10 linia do debugu??
+ const DISPLAY_CURSOR_Y_CHARS_T DISPLAY_CURSOR_Y_CHARS_DEBUG = 10 ; //todo 10 linia do debugu??
  

+ 55 - 1
SE/stuff/P5_Automation_can-dev-res/_I2C_driver_Adafruit_PWMServoDriver_func.h

@@ -3,7 +3,61 @@
  
  
   Adafruit_PWMServoDriver  Adafruit_PWMServoDriver_0X40 = Adafruit_PWMServoDriver(0x40);
-                           
+
+
+Adafruit_PWMServoDriver Adafruit_PWMServoDriver_F(I2C_ADDRESS_T I2C_ADDRESS_A) {
+    return * new Adafruit_PWMServoDriver(I2C_ADDRESS_A);
+}
+
+struct Adafruit_PWMServoDriver_S {
+        Adafruit_PWMServoDriver *Adafruit_PWMServoDriver_V ;
+    };
+
+typedef struct Adafruit_PWMServoDriver_S Adafruit_PWMServoDriver_T;
+
+Adafruit_PWMServoDriver_T Adafruit_PWMServoDriver_A = {
+    &Adafruit_PWMServoDriver_F(0x41)
+} ; 
+
+/*
+Adafruit_PWMServoDriver *Adafruit_PWMServoDriver_T[10];
+
+ Adafruit_PWMServoDriver_T[0] = new Adafruit_PWMServoDriver(0x41);
+*/
+//Adafruit_PWMServoDriver Adafruit_PWMServoDriver_T[42] = new Adafruit_PWMServoDriver(0x42);
+
+
+//analog_reads[0]->member_function();       
+
+
+/*
+const size_t ANALOG_SIZE = 3;
+ResponsiveAnalogRead analog_reads[ANALOG_SIZE] = {
+    ResponsiveAnalogRead(A0, true),
+    ResponsiveAnalogRead(A1, true),
+    ResponsiveAnalogRead(A2, true)
+};
+
+
+Patching the library
+If you really want to initialize the array in setup(), then you can patch the file ResponsiveAnalogRead.h from the library:
+
+Add default values to all the parameters of the constructor. For example:
+ResponsiveAnalogRead(int pin=0, bool sleepEnable=0, float snapMultiplier=0.01);
+Add a method for setting the pin after initialization:
+void setPin(int newPin) { pin = newPin; pinMode(pin, INPUT); }
+The first change will enable you to compile your code as-is. The second change will allow you to update the objects in setup() rather than overwriting them (which I don't find very elegant):
+
+for (size_t i = 0; i < ANALOG_SIZE; i++) {
+    analog_reads[i].setPin(ANALOG_PINS[i]);
+    analog_reads[i].enableSleep();
+}
+Note that using the default constructor now has the side effect of setting pin 0 to input. This should not be a big deal, as the constructor is called before setup(), and all the IO pins are inputs at this point. If you want nevertheless to void that side effect, then set the default pin to -1, and patch the constructor to only configure the pin if it's not -1.
+
+Patching the library creates a maintenance burden though: you will have to reapply the patch each time the library is updated. This may not be that bad if you know how to git rebase or git merge, but ideally you would want to get a pull request accepted by the original maintainer.
+
+Edit: Before patching the library, consider weighting in this issue and using this fork.
+*/                    
                                           //          
                            //  ARDUINO_DRIVER_STATUS_T  Adafruit_PWMServoDriver_A =    ARDUINO_DRIVER_INITIALIZED_FREQ ;
                              

+ 11 - 1
SE/stuff/P5_Automation_can-dev-res/_I2C_driver_Adafruit_PWMServoDriver_init.h

@@ -4,4 +4,14 @@
 Adafruit_PWMServoDriver  Adafruit_PWMServoDriver_0X40 = Adafruit_PWMServoDriver(0x40);
 Adafruit_PWMServoDriver  Adafruit_PWMServoDriver_0X41 = Adafruit_PWMServoDriver(0x41);
  */
- 
+ 
+ 
+ //Adafruit_PWMServoDriver  Adafruit_PWMServoDriver_0X40 = Adafruit_PWMServoDriver(0x40);
+ 
+ /*
+ 
+ ARDUINO_METHOD_ARRAY_A = {
+        {    Adafruit_PWMServoDriver_A = Adafruit_PWMServoDriver(0x41) }
+    } ;
+    
+    */

+ 11 - 0
SE/stuff/P5_Automation_can-dev-res/_I2C_driver_Adafruit_PWMServoDriver_struct.h

@@ -13,3 +13,14 @@ Board 4:  Address = 0x44  Offset = binary 00100 (bridge A2)
 
 */
 
+/*
+struct ARDUINO_METHOD_ARRAY_S { //TODO TO ASSOCIATE CLASS METHODS BY INDEX
+    Adafruit_PWMServoDriver Adafruit_PWMServoDriver_A(I2C_ADDRESS_T I2C_ADDRESS_A ) ;
+};
+
+typedef struct ARDUINO_METHOD_ARRAY_S ARDUINO_METHOD_ARRAY_T ;
+*/
+
+
+
+//Adafruit_PWMServoDriver Adafruit_PWMServoDriver_T[0] = new Adafruit_PWMServoDriver(0x41);

+ 3 - 2
SE/stuff/P5_Automation_can-dev-res/_TFT_ILI9163C_func.h

@@ -78,9 +78,10 @@ void DISPLAY_DEV__CURSOR_Y_CHARS__SET(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_
 
          //DISPLAY_DEV.clearScreen();
                  DISPLAY_DEV.fillRect(0, 
-                    DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A,
+                  (  DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A + 1 ) * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A,
                     DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_PX_A , 
-                    DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A  , GREEN);
+                    DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A , GREEN);
+               
          
 }
 

+ 1 - 1
SE/stuff/P5_Automation_can-dev-res/__main_I2C_struc.h

@@ -1,6 +1,6 @@
 
 typedef int I2C_ADDRESS ;
-
+typedef int I2C_ADDRESS_T ;
 
 
 

+ 4 - 1
SE/stuff/P5_Automation_can-dev-res/__main_loop_end.h

@@ -1,6 +1,7 @@
 
 if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_END_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT )  {
             
+            #ifndef DISABLE_LOOP
              _Slave_Ports_queue__list(Slave_Ports_Status_QUEUE_A) ;
               int _Slave_Ports_queue_count = _Slave_Ports_queue.count();
               int _Slave_Ports_queue_front = _Slave_Ports_queue.front();
@@ -28,14 +29,16 @@ if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_END_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT
                               DISPLAY_PHYSICAL_CHAR_A
              );
              
-             
+            #endif 
  
  
  }
  
  
 if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_END_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT )  {
+    #ifndef DISABLE_LOOP
     Serial.print("#39  ARDUINO_LOOP_LATENCY_COUNTER__MAIN_END_A");   Serial.print(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_END_A); Serial.println("] ");
+    #endif
     ARDUINO_LOOP_LATENCY_COUNTER__MAIN_END_A = ARDUINO_LOOP_LATENCY__MAIN_END_A ;
      
 } else {

+ 8 - 3
SE/stuff/P5_Automation_can-dev-res/__main_loop_top.h

@@ -7,13 +7,14 @@ if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT ) {
 
             
             if(ARDUINO_FUNCT_INIT_RESULT__Slave_Ports_LOCAL_init == true ){
+                        #ifndef DISABLE_LOOP
                             #ifdef DEBUG
                                      Serial.println(" ");
                                     Serial.print("#331__BBB main loop top bypassed  ARDUINO_FUNCT_INIT_RESULT__Slave_Ports_LOCAL_init  ");
                                     Serial.print(ARDUINO_FUNCT_INIT_RESULT__Slave_Ports_LOCAL_init);
                                     Serial.println("]");
                              #endif
-            
+                         #endif
                     }  else { 
                              #ifdef DEBUG
                                  Serial.print("#331___ccc main loop top ARDUINO_FUNCT_INIT_RESULT__Slave_Ports_LOCAL_init=[");
@@ -41,14 +42,16 @@ if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT ) {
             
             
             if(ARDUINO_FUNCT_INIT_RESULT_Slave_Ports_queue__add == true) {
+               #ifndef DISABLE_LOOP
                 #if defined(DEBUG)
                      Serial.println(" ");
                     Serial.print("#75 main loop top bypassed  ARDUINO_FUNCT_INIT_RESULT_Slave_Ports_queue__add=[");
                     Serial.print(ARDUINO_FUNCT_INIT_RESULT_Slave_Ports_queue__add);
                     Serial.println("]");
-             #endif
+               #endif
+              #endif
             } else {
-                #if defined(DEBUG)
+                 #if defined(DEBUG)
                     Serial.println(" ");
                     Serial.print("#777 main loop top ARDUINO_FUNCT_INIT_RESULT_Slave_Ports_queue__add=[");
                     Serial.print(ARDUINO_FUNCT_INIT_RESULT_Slave_Ports_queue__add);
@@ -63,7 +66,9 @@ if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT ) {
 }
 
 if(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A <= ARDUINO_LOOP_LATENCY_COUNTER_INIT )  {
+    #ifndef DISABLE_LOOP
     Serial.print("#66  ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A");   Serial.print(ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A); Serial.println("] ");
+    #endif
     ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A = ARDUINO_LOOP_LATENCY__MAIN_A ; 
 } else {
     ARDUINO_LOOP_LATENCY_COUNTER__MAIN_A -- ;

+ 0 - 1
SE/stuff/P5_Automation_can-dev-res/__main_struct.h

@@ -56,7 +56,6 @@ struct ARDUINO_ARRAY_ASSOC_TABLE_S {  //to associate and cache
 
 
 
-
 const ARDUINO_ARRAY_INDEX_T  ARDUINO_ARRAY_INDEX_NOT_SET = 0  ; //for controll arrays behaviour
 const ARDUINO_ARRAY_INDEX_T  ARDUINO_ARRAY_INDEX_CORRUPT = 0  ; //for controll arrays behaviour
 const ARDUINO_ARRAY_INDEX_T  ARDUINO_ARRAY_INDEX_FIRST = 1  ; //for controll arrays behaviour