a.binder 5 роки тому
батько
коміт
443a079ec2

+ 4 - 2
SE/stuff/P5_Automation_can-dev-res/P5_Automation_can-dev-res.ino

@@ -175,6 +175,7 @@
 
 #include "_I2C_driver_Adafruit_PWMServoDriver/_I2C_driver_Adafruit_PWMServoDriver_struct.h"
 
+#include "_CAN/_CAN_config.h"
 
 #if defined(HAS_ROTTARY_SW)
  #include "_ROTTARY_SW/_ROTTARY_SW_config.h"
@@ -229,7 +230,7 @@
 //BEGIN CAN
 
 
-#include "_CAN_init.h"
+#include "_CAN/_CAN_init.h"
 //EOF CAN
 
 
@@ -264,6 +265,7 @@
   //#include "_LCD1602_init.h"
 #endif
 
+#include "_CAN/_CAN_func.h"
 
 
 
@@ -421,7 +423,7 @@ void setup() {  //REMEMBER NOT INITIALIZE ANY VARIABLES OR ARRAYS
   #endif 
  
   //BEGIN CAN
-  #include "_CAN_setup.h"
+  #include "_CAN/_CAN_setup.h"
  
    #if defined(HAS_LCD1602) 
    /* todo 

+ 2 - 0
SE/stuff/P5_Automation_can-dev-res/_CAN/_CAN_config.h

@@ -0,0 +1,2 @@
+#define CAN_CSpin 53 
+#define CAN_INTpin 10

+ 26 - 0
SE/stuff/P5_Automation_can-dev-res/_CAN/_CAN_func.h

@@ -0,0 +1,26 @@
+void CAN_READ() {
+    if(!digitalRead(CAN_INTpin))                    // If pin 2 is low, read receive buffer
+          {
+            CAN0.readMsgBuf(&CANrxId, &CANlen, CANrxBuf); // Read data: len = data length, buf = data byte(s)
+            Serial.print("#5555CAN_READ read ID: ");
+            Serial.print(CANrxId, HEX);
+            Serial.print(" Data: ");
+          
+            for(int i = 0; i<CANlen; i++)           // Print each byte of the data
+            {
+              if(CANrxBuf[i] < 0x10)                // If data byte is less than 0x10, add a leading zero
+              {
+                Serial.print("0");
+         
+              }
+              Serial.print(CANrxBuf[i], HEX);
+              Serial.print(" ");
+          
+               
+            }
+            Serial.println();
+
+            
+          } else Serial.println(" [CAN] [NOT][digitalRead(CAN_INTpin)] ");
+
+    }

+ 1 - 1
SE/stuff/P5_Automation_can-dev-res/_CAN_init.h → SE/stuff/P5_Automation_can-dev-res/_CAN/_CAN_init.h

@@ -5,5 +5,5 @@
 long unsigned int CANrxId;
 unsigned char CANlen = 0;
 unsigned char CANrxBuf[8];
-const int CAN_CSpin = 53 , CAN_INTpin = 10 ;
+//const int CAN_CSpin = 53 , CAN_INTpin = 10 ;
 MCP_CAN CAN0(CAN_CSpin);                          // Set CS to pin 10

+ 17 - 1
SE/stuff/P5_Automation_can-dev-res/_CAN_setup.h → SE/stuff/P5_Automation_can-dev-res/_CAN/_CAN_setup.h

@@ -59,7 +59,7 @@
 
 
 //       #if Active_ControllerID == _Slave1_ID 
-        #include "_SlaveID_setup.h"
+        //#include "_SlaveID_setup.h" TODO FILTERS
 //       #elif Active_ControllerID == _ControllerID
   /*       TODO  LCDarray1 = "Master Module       ";
           LCDarray2 = "enabling remotes        ";
@@ -90,9 +90,25 @@
         CAN0.setMode(MCP_NORMAL);                // Change to normal mode to allow messages to be transmitted
         pinMode(CAN_INTpin, INPUT);                       // Setting pin 2 for /INT input
 
+
+#if defined(HAS__PCINT_setup)
+        #if defined(DISABLE_LOOP) ||  defined(DEBUG)
+                     Serial.println("will  attachPinChangeInterrupt(CAN_INTpin, CAN_READ, RISING)");
+            #endif
+      attachPinChangeInterrupt(CAN_INTpin, CAN_READ, RISING); //FALLING //RISING 
+
+#endif
+
+
          #if defined(DEBUG_CAN) || defined(DEBUG)
              Serial.println("  #94 EOF   MCP can setup.  ");
          #endif
 
 
+
+
+
+
+
+
   //EOF CAN

+ 2 - 0
SE/stuff/P5_Automation_can-dev-res/_PCINT/_PCINT_struct.h

@@ -27,6 +27,8 @@
 #define MYPIN1 ROTTARY_SW_clk // ROTTARY_SW_sw // ROTTARY_SW_sw // SS
 #define MYPIN2 ROTTARY_SW_dt // SCK
 #define MYPIN3 ROTTARY_SW_sw  // A8 //ROTTARY_SW_sw // MOSI
+//#define MYPIN4 ROTTARY_SW_sw  // A8 //ROTTARY_SW_sw // MOSI
+
 #define PIN3TEXT "ROTTARY_SW_sw " // This will say what MYPIN3 is, on the serial monitor
 
 volatile uint8_t latest_interrupted_pin;

+ 4 - 67
SE/stuff/P5_Automation_can-dev-res/___loop/_SlaveID_loop1.h

@@ -4,84 +4,21 @@ if(!digitalRead(CAN_INTpin))                    // If pin 2 is low, read receive
             Serial.print("#4444 read ID: ");
             Serial.print(CANrxId, HEX);
             Serial.print(" Data: ");
-           /*  #if defined(HAS_LCD1602)
-              lcd.setCursor(0,0); 
-              lcd.print("ID: ");
-              lcd.print(CANrxId, HEX);
-              lcd.setCursor(0,1); 
-              lcd.print(" Data: ");
-             #endif
-             */
-         /*     #if defined(HAS_TFT_ILI9163C)
-             DISPLAY_DEV.setCursor(0,40); 
-              DISPLAY_DEV.print("ID: ");
-              DISPLAY_DEV.print(CANrxId, HEX);
-              DISPLAY_DEV.setCursor(0,50); 
-              DISPLAY_DEV.print(" Data: ");
-             #endif
-             */
+          
             for(int i = 0; i<CANlen; i++)           // Print each byte of the data
             {
               if(CANrxBuf[i] < 0x10)                // If data byte is less than 0x10, add a leading zero
               {
                 Serial.print("0");
-             //    #if defined(HAS_LCD1602)
-             //       lcd.print("0");
-             //    #endif
-            //     #if defined(HAS_TFT_ILI9163C)
-            //        DISPLAY_DEV.print("0");
-            //     #endif
+         
               }
               Serial.print(CANrxBuf[i], HEX);
               Serial.print(" ");
-              /* #if defined(HAS_LCD1602)
-                  lcd.print(CANrxBuf[i], HEX);
-                  lcd.print(" ");
-               #endif
-               */
-        //       #if defined(HAS_TFT_ILI9163C)
-        //          DISPLAY_DEV.print(CANrxBuf[i], HEX);
-        //          DISPLAY_DEV.print(" ");
-        //       #endif
-
-             //  if(_Slave_Ports_queue_task_type_LIST[i]) {
-             //      Serial.print(" [");  Serial.print(_Slave_Ports_queue_task_type_LIST[i]);   Serial.print("] "); 
-             //  }
+          
                
             }
             Serial.println();
 
-
-
-         
-
-
-
-
-
-
             
           }
-        //EOF CAN
-        /*TODO
-          #if defined(HAS_LCD1602)
-          //  delay(LCDtim);  
-            //lcd.setCursor(0,1); 
-            lcd.print(lcdPattern);
-            //lcd.print(lcdPos % 10);
-            if(lcdPos == 16) { 
-              //lcd.print("N");
-              lcd.setCursor(0,1); 
-              lcdPos = 0;
-              if(lcdPattern==".") lcdPattern = "-" ;
-              else lcdPattern = "." ;
-            }
-            lcdPos ++;
-          #endif
-          */
-       //   #if defined(HAS_TFT_ILI9163C)
-       //     delay(LCDtim);  
-        //    display.setCursor(0,60); 
-       //     display.print("loop....");
-       //   #endif
-          
+