a.binder 5 лет назад
Родитель
Сommit
15e5c83cdf

+ 13 - 0
SE/stuff/P5_Automation_can-dev-res/_ROTTARY_SW_config.h

@@ -0,0 +1,13 @@
+// rottary switch ports 
+#define ROTTARY_SW_sw A8 // 62 // A8 //A8 //53 // 89 // = A8
+#define ROTTARY_SW_dt  A9 // 90 // = A9
+#define ROTTARY_SW_clk A10  // 91 // = A10
+
+/*
+ LOW to trigger the interrupt whenever the pin is low,
+CHANGE to trigger the interrupt whenever the pin changes value
+RISING to trigger when the pin goes from low to high,
+FALLING for when the pin goes from high to low.
+The Due, Zero and MKR1000 boards allow also:
+HIGH to trigger the interrupt whenever the pin is high.
+ */

+ 9 - 0
SE/stuff/P5_Automation_can-dev-res/_ROTTARY_SW_loop.h

@@ -0,0 +1,9 @@
+ if(oldEncPos != encoderPos) {
+    Serial.print(" ROT_SW[");  Serial.print(encoderPos);  Serial.print("] ");  
+    oldEncPos = encoderPos;
+    
+     Serial.print("#550 CLK_AAdafruit_PWMServoDriver: #[");  Serial.print(encoderPos);  Serial.println(" ] ");   
+     //Adafruit_PWMServoDriver_0X40.setPWM(1, 0, map(encoderPos, 0, 180, SERVOMIN, SERVOMAX));
+     Adafruit_PWMServoDriver_0X40.setPWM(2, encoderPos * 5, encoderPos * 5);
+
+  }

+ 6 - 0
SE/stuff/P5_Automation_can-dev-res/_ROTTARY_SW_struct.h

@@ -0,0 +1,6 @@
+volatile byte aFlag = 0; // let's us know when we're expecting a rising edge on pinA to signal that the encoder has arrived at a detent
+volatile byte bFlag = 0; // let's us know when we're expecting a rising edge on pinB to signal that the encoder has arrived at a detent (opposite direction to when aFlag is set)
+volatile byte encoderPos = 0; //this variable stores our current value of encoder position. Change to int or uin16_t instead of byte if you want to record a larger range than 0-255
+volatile byte oldEncPos = 0; //stores the last encoder position value so we can compare to the current reading and see if it has changed (so we know when to print to the serial monitor)
+volatile byte reading1 = 0; //somewhere to store the direct values we read from our interrupt pins before checking to see if we have moved a whole detent
+volatile byte reading2 = 0; //somewhere to store the direct values we read from our interrupt pins before checking to see if we have moved a whole detent

+ 35 - 14
SE/stuff/P5_Automation_can-dev-res/_Slave_Ports_broadcast_func.h

@@ -28,21 +28,42 @@
   ) {
         Serial.println("#251 _Slave_Ports_broadcast_POP");
           int i;
-          for(i=0;i<=100;i++) {
+          for(i=ARDUINO_ARRAY_INDEX_FIRST;i<=Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A.ARDUINO_ARRAY_INDEX_CURRENT_A;i++) {
             if(Slave_Ports_Status_A[i].Broadcast_state == Broadcast_state_TO_REFRESH and Slave_Ports_Status_A[i].IS_Local_A == IS_Local_TRUE) {
-              Serial.print(" ind:"); Serial.print(i);  Serial.print("] IS_Local_A:");
-              Serial.print(Slave_Ports_Status_A[i].IS_Local_A);
-              Serial.print(" , ID:"); 
-              Serial.print(Slave_Ports_Status_A[i].Port_ID, HEX); Serial.print(" , PortTypes:");
-             Serial.print(Slave_Ports_Status_A[i].PortTypes, HEX); Serial.print(" , Addr:"); Serial.print(Slave_Ports_Status_A[i].Address, HEX);
-              Serial.print(" , Local:"); Serial.print(Slave_Ports_Status_A[i].LocalPort);
-              Serial.print(" , Exp state:"); Serial.print(Slave_Ports_Status_A[i].Exp_state);
-                Serial.print(" , Exp_state_ttl"); Serial.println(Slave_Ports_Status_A[i].Exp_state_ttl);  
-
-
-                   Serial.print("#2111 *_TEST_GLOBAL"); Serial.print(*_TEST_GLOBAL); Serial.println("]");
-
-                        Serial.println(" Prepared data");
+            #ifdef DEBUG
+                if(DEBUG > 5) {
+                    Serial.print(" ind:"); Serial.print(i);  Serial.print("] IS_Local_A:");
+                    Serial.print(Slave_Ports_Status_A[i].IS_Local_A);
+                    Serial.print(" , ID:"); 
+                    Serial.print(Slave_Ports_Status_A[i].Port_ID, HEX); Serial.print(" , PortTypes:");
+                    Serial.print(Slave_Ports_Status_A[i].PortTypes, HEX); Serial.print(" , Addr:"); Serial.print(Slave_Ports_Status_A[i].Address, HEX);
+                    Serial.print(" , Local:"); Serial.print(Slave_Ports_Status_A[i].LocalPort);
+                    Serial.print(" , Exp state:"); Serial.print(Slave_Ports_Status_A[i].Exp_state);
+                    Serial.print(" , Exp_state_ttl"); Serial.println(Slave_Ports_Status_A[i].Exp_state_ttl);  
+                    Serial.print("#2111 *_TEST_GLOBAL"); Serial.print(*_TEST_GLOBAL); Serial.println("]");
+                   }
+            #endif
+                  
+                         //DISPLAY_array16_T message = "#53 BCAST  ";
+                         //message.concat(Slave_Ports_Status_A[i].Port_ID);
+                         //DISPLAY_array16_T  DISPLAY_array16_AAT ;
+                         //message.toCharArray(DISPLAY_array16_AAT, message.length());
+                  DISPLAY__print(
+                          DISPLAY_A ,
+                          DISPLAY_T_ARDUINO_ATTR_ARRAY_A , 
+                          DISPLAY_PHYSICAL_CHAR_A, 
+                           DISPLAY_pos_seq_A_NEXT,
+                            DISPLAY_array16_I( "#53 BCAST  " + char( Slave_Ports_Status_A[i].Port_ID  ) , 2), //message,
+                            DISPLAY_TARGET_DISPLAY128,
+                           millis() , // time_seq_id_T time_seq_id_A;
+                           millis(), //time_min_run_T time_min_run_A;
+                          //queue
+                         Slave_Ports_Status_QUEUE_A,
+                         TASK_TYPE_T_Slave_Ports_broadcast____  ,  //TASK_TYPE_A,
+                         { Slave_Ports_Status_A[i].Port_ID } //TASK_PORT_ASSOC_A
+                         
+                         ); 
+                     Serial.println(" Prepared data");
                         #if defined(HAS_LCD1602)                              
                              String LCDarray1 = "L[";
                              LCDarray1.concat(Slave_Ports_Status_A[i].IS_Local_A); LCDarray1.concat("] ID["); LCDarray1.concat(String(Slave_Ports_Status_A[i].Port_ID, HEX)); LCDarray1.concat("] T["); LCDarray1.concat(String(Slave_Ports_Status_A[i].PortTypes, HEX));

+ 21 - 0
SE/stuff/P5_Automation_can-dev-res/__main_struct_funct.h

@@ -77,3 +77,24 @@ ARDUINO_ARRAY_ASSOC_TABLE_S* ARDUINO_ARRAY_ASSOC_TABLE_A
 );
 
 */
+
+
+
+
+char DISPLAY_array16_I(char message[], int count){  //to provide messages concat 
+        int i ;
+        String DISPLAY_array16_S ;
+        char DISPLAY_array16_A ;//DISPLAY_array16_T
+        for(i=0;i<=count; i++) {
+            DISPLAY_array16_S = DISPLAY_array16_S + message[i] ; 
+        }
+        DISPLAY_array16_S.toCharArray(DISPLAY_array16_A, DISPLAY_array16_S.length());
+        #ifdef DEBUG 
+            if(DEBUG > 4) {
+                Serial.print("#189 DISPLAY_array16_I ") ; Serial.print(DISPLAY_array16_A); Serial.println(" ] ");
+             }
+        #endif
+        return DISPLAY_array16_A ;
+} 
+
+