a.binder 5 éve
szülő
commit
1857fb61b7

+ 21 - 3
SE/stuff/P5_Automation_can-dev-res/P5_Automation_can-dev-res.ino

@@ -76,6 +76,12 @@
  */
 
 
+//#define HAS_TFT_ILI9163C 
+//#define HAS_LCD1602 
+//#define HAS_ROTTARY_SW
+#define HAS__PCINT_setup //to allow interrupts
+
+
 #define DEBUG 5 //Debug level
 
 #include "__main_struct.h"
@@ -133,6 +139,9 @@
 #endif
 
 
+#if defined(HAS__PCINT_setup)
+    #include "_PCINT_struct.h"
+#endif
 
 
 //BEGIN CAN
@@ -166,6 +175,14 @@
 #endif
 
 
+
+
+
+#if defined(HAS_ROTTARY_SW)
+ #include "_ROTTARY_SW_func.h"
+#endif
+
+
 #include "_TASK_TYPES_func.h"
 #include "_Slave_Ports_Status_QUEUE_func.h"
 #include "_Slave_Ports_Protocol_CAN_func.h"
@@ -205,7 +222,7 @@
   
 
 #if defined(HAS_ROTTARY_SW)
- #include "_ROTTARY_SW.h"
+ #include "_ROTTARY_SW_init.h"
 #endif
 
 
@@ -213,8 +230,9 @@
  #include "_I2C_driver_Adafruit_PWMServoDriver_init.h"
 #endif
 
-
-#include "_PCINT.h"
+#if defined(HAS__PCINT_setup)
+    #include "_PCINT_init.h"
+#endif
 
 #include "config_Slave_Ports_LOCAL_init.h"
 

+ 19 - 0
SE/stuff/P5_Automation_can-dev-res/_PCINT_init.h

@@ -0,0 +1,19 @@
+#include <PinChangeInt.h>
+
+
+
+// Do not use any Serial.print() in this function. Serial.print() uses interrupts, and is not compatible
+// with an interrupt routine...!
+void quicfunc() {
+  latest_interrupted_pin=PCintPort::arduinoPin;
+  interrupt_count[latest_interrupted_pin]++;
+};
+
+// You can assign any number of functions to different pins. How cool is that?
+void pin3func() {
+  pin3Count++;
+   Serial.println("pin3func TRIG");
+}
+
+//uint8_t i;
+//uint8_t currentPIN3Count=0;

+ 6 - 22
SE/stuff/P5_Automation_can-dev-res/_PCINT.h → SE/stuff/P5_Automation_can-dev-res/_PCINT_struct.h

@@ -1,4 +1,8 @@
-#include <PinChangeInt.h>
+#if ! ( defined __AVR_ATmega2560__ || defined __AVR_ATmega1280__ || defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__ || defined __AVR_ATmega640__ )
+    #error "This sketch only works on chips in the ATmega2560 family."
+#endif
+
+
 
 // PIN NAMING
 // For the Analog Input pins used as digital input pins, you can call them 14, 15, 16, etc.
@@ -13,9 +17,6 @@
 // SCK  = 52
 
 // NOW CHOOSE PINS
-#if ! ( defined __AVR_ATmega2560__ || defined __AVR_ATmega1280__ || defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__ || defined __AVR_ATmega640__ )
-#error "This sketch only works on chips in the ATmega2560 family."
-#endif
 
 
 #define FIRST_ANALOG_PIN 54
@@ -30,21 +31,4 @@
 
 volatile uint8_t latest_interrupted_pin;
 volatile uint8_t interrupt_count[TOTAL_PINS]={0}; // possible arduino pins
-volatile uint8_t pin3Count=0;
-
-
-// Do not use any Serial.print() in this function. Serial.print() uses interrupts, and is not compatible
-// with an interrupt routine...!
-void quicfunc() {
-  latest_interrupted_pin=PCintPort::arduinoPin;
-  interrupt_count[latest_interrupted_pin]++;
-};
-
-// You can assign any number of functions to different pins. How cool is that?
-void pin3func() {
-  pin3Count++;
-   Serial.println("pin3func TRIG");
-}
-
-uint8_t i;
-uint8_t currentPIN3Count=0;
+volatile uint8_t pin3Count=0;

+ 12 - 0
SE/stuff/P5_Automation_can-dev-res/_ROTTARY_SW_func.h

@@ -0,0 +1,12 @@
+
+ // You can assign any number of functions to different pins. How cool is that?
+void ROTTARY_SW_sw_INT() {
+   Serial.println("ROTTARY_SW_sw_INT TRIG");
+}
+
+void ROTTARY_SW_dt_INT() {
+   Serial.println("ROTTARY_SW_dt_INT TRIG");
+}
+void ROTTARY_SW_clk_INT() {
+   Serial.println("ROTTARY_SW_clk_INT TRIG");
+}

+ 0 - 12
SE/stuff/P5_Automation_can-dev-res/_ROTTARY_SW.h → SE/stuff/P5_Automation_can-dev-res/_ROTTARY_SW_init.h

@@ -3,18 +3,6 @@
 #define ROTTARY_SW_dt A9 // 90 // = A9
 #define ROTTARY_SW_clk A10 // 91 // = A10
 
- // You can assign any number of functions to different pins. How cool is that?
-void ROTTARY_SW_sw_INT() {
-   Serial.println("ROTTARY_SW_sw_INT TRIG");
-}
-
-void ROTTARY_SW_dt_INT() {
-   Serial.println("ROTTARY_SW_dt_INT TRIG");
-}
-void ROTTARY_SW_clk_INT() {
-   Serial.println("ROTTARY_SW_clk_INT TRIG");
-}
-
 /*
  LOW to trigger the interrupt whenever the pin is low,
 CHANGE to trigger the interrupt whenever the pin changes value

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

@@ -1,4 +1,12 @@
 
+
+
+
+
+#if defined(HAS__PCINT_setup)
+
+
+
   attachPinChangeInterrupt(ROTTARY_SW_sw, ROTTARY_SW_sw_INT, FALLING);  // add more attachInterrupt code as required
   pinMode(ROTTARY_SW_sw, INPUT_PULLUP);
   attachPinChangeInterrupt(ROTTARY_SW_dt, ROTTARY_SW_dt_INT, FALLING); //FALLING //RISING 
@@ -6,3 +14,4 @@
   attachPinChangeInterrupt(ROTTARY_SW_clk, ROTTARY_SW_clk_INT, FALLING); //CHANGE
   pinMode(ROTTARY_SW_clk, INPUT_PULLUP);
   
+#endif

+ 18 - 10
SE/stuff/P5_Automation_can-dev-res/_TFT_ILI9163C_func.h

@@ -80,12 +80,16 @@ void DISPLAY_DEV__CURSOR__NEWLINE(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR
          DISPLAY_DEV.setCursor(0,DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
     }
     
-     #if defined(DEBUG)
-                Serial.print("#83 Dspl Y:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
-                Serial.print("] #MaxY:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_Y_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
-                Serial.print("]  maxX:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
-                Serial.print("] #YxF:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
-                Serial.println("] "); 
+           #if defined(DEBUG)
+                if(DEBUG > 6) {     
+                     Serial.print("#83 Dspl Y:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
+                     Serial.print("] #MaxY:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_Y_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
+                     Serial.print("]  maxX:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
+                     Serial.print("]  x_A:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_x_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
+                     
+                     //Serial.print("] #YxF:["); Serial.print(&DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A *  DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
+                     Serial.println("] "); 
+                }
             #endif
 }
 
@@ -112,13 +116,15 @@ void  DISPLAY_DEV_CTRL__println(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A
                                 int i;
                                 
                                  #if defined(DEBUG)
+                                  if(DEBUG > 6) {  
                                      Serial.print("#34 arr16"); Serial.print(DISPLAY_array16_A);
                                      Serial.print("] #34 sizeof["); Serial.print(message.length());
                                      Serial.print("] #34 String["); Serial.print(message);
                                      Serial.print("] #34 frag"); Serial.print( message.substring(2, 5));
-                                    Serial.print("] parts["); Serial.print( parts);
-                                    Serial.print("] XC["); Serial.print( DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A);
+                                     Serial.print("] parts["); Serial.print( parts);
+                                     Serial.print("] XC["); Serial.print( DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A);
                                      Serial.println("] "); 
+                                     }
                                  #endif
                                  
                                 
@@ -128,11 +134,13 @@ void  DISPLAY_DEV_CTRL__println(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A
                                     substr_end = substr_begin + DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A ;
                                     DISPLAY_DEV.print(message.substring(substr_begin, substr_end));
                                        #if defined(DEBUG)
+                                        if(DEBUG > 4) {  
                                              Serial.print("#112 msg part["); Serial.print(i);
                                              Serial.print("]  beg["); Serial.print(substr_begin);
                                              Serial.print("]  end["); Serial.print(substr_end);
-                                             Serial.print("]  frag["); Serial.print(message.substring(substr_begin, substr_end));
-                                             Serial.println("] "); 
+                                            // Serial.print("]  frag["); Serial.print(message.substring(substr_begin, substr_end));
+                                             Serial.println("] ");
+                                             } 
                                          #endif
                                         substr_begin = substr_end + 1;
                                         if( parts >= 1 and not(i == parts))

+ 5 - 3
SE/stuff/P5_Automation_can-dev-res/_TFT_ILI9163C_struct.h

@@ -5,8 +5,10 @@
    DISPLAY_PHYSICAL_X_PX_T DISPLAY_PHYSICAL_X_PX_A = 128;
    DISPLAY_PHYSICAL_Y_PX_T DISPLAY_PHYSICAL_Y_PX_A = 128 ;
 
+DISPLAY_CURSOR_X_CHARS_T DISPLAY_CURSOR_X_CHARS_A = 0;
+DISPLAY_CURSOR_Y_CHARS_T DISPLAY_CURSOR_Y_CHARS_A = 0;
 
-    DISPLAY_textsize_x_T DISPLAY_textsize_x_A = 6.5; //5 nominal
+    DISPLAY_textsize_x_T DISPLAY_textsize_x_A = 7; //5 nominal
     DISPLAY_textsize_y_T DISPLAY_textsize_y_A = 10; //8 nominal
 
  DISPLAY_PHYSICAL_X_CHARS_T DISPLAY_PHYSICAL_X_CHARS_A = DISPLAY_PHYSICAL_X_PX_A /  DISPLAY_textsize_x_A ; //todo to test
@@ -55,8 +57,8 @@ struct DISPLAY_PHYSICAL_CHAR_S {
                  DISPLAY_PHYSICAL_Y_PX_A ,
                  DISPLAY_PHYSICAL_X_CHARS_A,
                  DISPLAY_PHYSICAL_Y_CHARS_A ,
-                 0, 
-                 0,
+                 DISPLAY_CURSOR_X_CHARS_A,
+                 DISPLAY_CURSOR_Y_CHARS_A,
                  DISPLAY_textsize_x_A,
                  DISPLAY_textsize_y_A }
           ;