|
|
@@ -0,0 +1,407 @@
|
|
|
+/*
|
|
|
+ 2021-01 abinder - moving to libs, and cleanup
|
|
|
+
|
|
|
+*/
|
|
|
+#define DISPLAY_CURSOR_Y_CHARS_DEBUG_DEF 5 //todo proportional
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_QUEUE_DEF 4
|
|
|
+
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_I2C_ARRAY_DRIVER_DEF 0//1
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_DISPLAY_DEF 0 // 3 //todo debug
|
|
|
+
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_DISPLAY_MENU_DEF 2 //todo test
|
|
|
+
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_DISPLAY_MENU_ITEM_A_DEF 10 //todo debug
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_PORTS_DEF 0//4//3 //todo debug lite
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_PORTS_I2C_DEF 0//2 //todo debug lite
|
|
|
+//#define HAS_DEBUG_ACTION_TRIG
|
|
|
+//#define DEBUG_I2C //to debug _Slave_Ports_I2C_POP etc
|
|
|
+//#define HAS_TFT_ILI9163C
|
|
|
+//#define HAS_TFT_ILI9163C__ROTATED
|
|
|
+//#define HAS_LCD1602
|
|
|
+//#define HAS_LCD1602_I2C
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//#define LCD1602_DISPLAY_PHYSICAL_X_CHARS_A
|
|
|
+//#define LCD1602_DISPLAY_PHYSICAL_Y_CHARS_A
|
|
|
+//#define HAS_ROTTARY_SW
|
|
|
+#define ROTTARY_ENCODER_ACTION_MILLIS_MIN 250
|
|
|
+//#define HAS_CAN
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//#define DEBUG_I2C_driver_Adafruit_PWMServoDriver
|
|
|
+//#define DEBUG_CAN
|
|
|
+//#define DEBUG_QUEUE
|
|
|
+//#define DEBUG_QUEUE_ASSERT
|
|
|
+//#define DEBUG_QUEUE_WAIT 500
|
|
|
+//#define DEBUG_STRUCT_INIT
|
|
|
+//#define DEBUG_STORAGE_QUEUE_TEST
|
|
|
+//#define DEBUG_ARDUINO_ATTR_ARRAY_S__commit_added_element_QUEUE
|
|
|
+//#define DEBUG_ARDUINO_ARRAY_INDEX_NEXT_LOCK
|
|
|
+//#define HAS__PCINT_setup //to allow interrupts
|
|
|
+//#define DEBUG_TASK_TYPE_T_Slave_Ports_broadcast____
|
|
|
+//#define DEBUG_TASK_TYPE_T_DISPLAY_queue_pop________
|
|
|
+//#define DEBUG_TASK_TYPE_T_Slave_Ports_set_I2C______
|
|
|
+//#define DEBUG_QUEUE_ASSERT todo not working
|
|
|
+//#define DEBUG_LAST_ACTION_TRIG_ENABLE
|
|
|
+#define DISABLE_DISPLAY__add_record
|
|
|
+#define DISPLAY_array16_T_is_DISPLAY_string_T
|
|
|
+#define ENABLE_DISPLAY_MENU
|
|
|
+#define USE_DISPLAY_string_T
|
|
|
+//#define USE_DISPLAY_char_PA //dev testing pointer to display
|
|
|
+//#define DISABLE_ANY_PRINT //when uno ?
|
|
|
+//#define DEBUG 3
|
|
|
+//#define DISABLE_LOOP
|
|
|
+#define DISABLE_QUEUE_REASSIGN
|
|
|
+//#define DEBUG_LATENCY_MARKER
|
|
|
+
|
|
|
+//ports assign config
|
|
|
+#define PortA0 A0 //for rottary pro mini SW
|
|
|
+#define PortA1 A1 //for rottary pro mini SW DT
|
|
|
+#define PortA2 A2 //for rottary pro mini SW CLK
|
|
|
+#define PortA3 A3
|
|
|
+
|
|
|
+
|
|
|
+#define PortA7 A7 //
|
|
|
+#define PortA8 A8 //for rottary sw
|
|
|
+#define PortA9 A9 //for rottary sw dt
|
|
|
+#define PortA10 A10 //for rottary sw clk
|
|
|
+#define Port7 7 //for TFT_ILI9163C_CSpin 7
|
|
|
+#define Port8 8 //for TFT_ILI9163C_DCpin 8
|
|
|
+#define Port9 9 //for TFT_ILI9163C__RSTpin 9
|
|
|
+#define Port10 10 // CAN_INTpin 10
|
|
|
+#define Port11 11 // todo PIR LOCAL
|
|
|
+#define Port12 12 // todo change CAN to 12 from 53
|
|
|
+#define Port53 53 // #define CAN_CSpin 53 //todo change can be 12?
|
|
|
+
|
|
|
+
|
|
|
+#include "Wire.h"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "progmem.h"
|
|
|
+
|
|
|
+
|
|
|
+#include "___CONFIG/config_Active_ControllerID.h" //there kleep id of device
|
|
|
+ //config active should once update id
|
|
|
+//EEPROM_Active_ControllerID_read_T EEPROM_Active_ControllerID_read_A = EEPROM_Active_ControllerID_read();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//#define DEBUG 5
|
|
|
+//#define DISABLE_LOOP //To debug and disable any output
|
|
|
+
|
|
|
+
|
|
|
+#include "__main_struct.h" //lite #include "___main/__main_struct.h"
|
|
|
+#include "__main_trigger_struct.h" //lite #include "___main/__main_trigger_struct.h"
|
|
|
+#include "__main_struct_funct.h" //lite #include "___main/__main_struct_funct.h"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "__main_struct_limits.h" /lite ___main/
|
|
|
+#include "_time_struct.h"
|
|
|
+
|
|
|
+//lite wyglada na niepotrzebne
|
|
|
+#include "_DRIVER_STATUS_struct.h" //lite
|
|
|
+
|
|
|
+ #include "__main_I2C_struc.h" //lite ___main/
|
|
|
+
|
|
|
+#include "__main_static.h" //lite ___main/
|
|
|
+#include "__main_auto.h" //lite ___main/
|
|
|
+#include "__main_register.h" //lite ___main/
|
|
|
+#include "__main_extern.h" //lite ___main/
|
|
|
+
|
|
|
+#include "config_Slave_Ports_LOCAL_config.h" //lite
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "_DISPLAY_struct__lite.h" //lite
|
|
|
+#include "_Port_ID_sruct.h"
|
|
|
+
|
|
|
+#include "_TASK_TYPES_struct.h"
|
|
|
+#include "_Slave_Ports_Status_QUEUE_struct.h"
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_config.h" //lite _ROTTARY_SW/
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_struct.h" //lite _ROTTARY_SW/
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_TFT_ILI9163C)
|
|
|
+ //L#include "_TFT_ILI9163C_struct.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+ #if defined(HAS_u8g2)
|
|
|
+ //L #include "u8g2_struct.h" //too much ram
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+ #if defined(HAS_u8x8)
|
|
|
+ #include "u8x8_struct.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS__PCINT_setup)
|
|
|
+ #include "_PCINT/_PCINT_struct.h" //pins MYPIN1 MYPIN2 MYPIN3
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //REMOTE PORTS DEFINITIONS
|
|
|
+ #include "_PortTypes_struct.h"
|
|
|
+ #include "_PortStates_struct.h"
|
|
|
+ #include "_Port_Exp_state_ttl_struct.h"
|
|
|
+ #include "_Port_Broadcast_state_struct.h"
|
|
|
+ #include "_Port_I2C_driver_struct.h"
|
|
|
+ //#include "_Slave_Ports_Status_struct_lite.h" // lite
|
|
|
+ #include "_Slave_Ports_Status_struct.h"
|
|
|
+ #include "_Slave_Ports_Protocol_CAN_struct.h" //lite _CAN/
|
|
|
+ //#include "_Slave_Ports_Protocol_CAN_2020_struct.h"
|
|
|
+
|
|
|
+
|
|
|
+ #include "automation_driven.submodule.struct.write.h"
|
|
|
+
|
|
|
+ #if defined(HAS_TFT_ILI9163C)
|
|
|
+ #include "_TFT_ILI9163C_func.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+#if defined(HAS_u8g2) //lite too much ram
|
|
|
+ //L #include <math.h>
|
|
|
+ //L #include "u8g2.h"
|
|
|
+ //L U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(HAS_u8x8)
|
|
|
+ #include "u8x8_func.h"
|
|
|
+ #include "u8x8_init.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+ #include "_DISPLAY_DEV.h"
|
|
|
+
|
|
|
+
|
|
|
+ #include "_TASK_TYPES_func.h"
|
|
|
+ #include "_Slave_Ports_Status_QUEUE_add_func.h"
|
|
|
+ #include "_DISPLAY_add_record_func.h"
|
|
|
+ //#include "_DISPLAY_func.h"
|
|
|
+ #include "_DISPLAY_func_lite.h"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_LCD1602)
|
|
|
+ //L#include "_LCD1602_init.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(HAS_LCD1602)
|
|
|
+ //L#include "_LCD1602_func.h"
|
|
|
+ //#include "_LCD1602_init.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void DISPLAY_MENU_SELECTOR( DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A,
|
|
|
+
|
|
|
+ Slave_Ports_Status_T* Slave_Ports_Status_A ,
|
|
|
+ Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_T &Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A,
|
|
|
+
|
|
|
+
|
|
|
+ // DISPLAY_MENU_ITEM_INDEX_T DISPLAY_MENU_ITEM_INDEX_A ,
|
|
|
+ time_seq_id_T time_seq_id_A ,
|
|
|
+ time_min_run_T time_min_run_A ,
|
|
|
+ //DISPLAY_MENU_SELECTOR_STATUS_T DISPLAY_MENU_SELECTOR_STATUS_A , //; //which mode
|
|
|
+ DISPLAY_MENU_SELECTOR_SWITCH_T DISPLAY_MENU_SELECTOR_SWITCH_A,
|
|
|
+ DISPLAY_MENU_SELECTOR_oldEncPos_T DISPLAY_MENU_SELECTOR_oldEncPos_A , //; //values
|
|
|
+ DISPLAY_MENU_SELECTOR_encoderPos_T DISPLAY_MENU_SELECTOR_encoderPos_A,
|
|
|
+
|
|
|
+ DISPLAY_MENU_SELECTOR_triggerCountOld_T DISPLAY_MENU_SELECTOR_triggerCountOld_A,
|
|
|
+ DISPLAY_MENU_SELECTOR_triggerCount_T DISPLAY_MENU_SELECTOR_triggerCount_A) {
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_func.h" //_ROTTARY_SW/
|
|
|
+#endif
|
|
|
+
|
|
|
+#include "_time_func.h"
|
|
|
+
|
|
|
+
|
|
|
+#include "DISPLAY_ELEMENT_TO_REFRESH.h"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "Slave_Ports_Status__DISPLAY_TARGET.h"
|
|
|
+
|
|
|
+
|
|
|
+#include "TASK_TYPE_T_Set_Ports_Status_LIMITS_A__.h"
|
|
|
+#include "TASK_TYPE_T_Set_Ports_Status_ASSOC.h"
|
|
|
+
|
|
|
+
|
|
|
+//L #include "_CAN_func.h" //lite _CAN/
|
|
|
+
|
|
|
+
|
|
|
+//EOF SERIAL ##############//EOF SERIAL ##############//EOF SERIAL ##############
|
|
|
+#include "SERIAL__init.h"
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY_SoftwareSerial)
|
|
|
+ #include <SoftwareSerial.h>
|
|
|
+ //SoftwareSerial SERIAL_PROXY_DEVICE(SERIAL_PROXY_SoftwareSerial_rx_pin, SERIAL_PROXY_SoftwareSerial_tx_pin); // RX, TX
|
|
|
+ #include "SERIAL_PROXY__init.h"
|
|
|
+
|
|
|
+ #if defined(SERIAL_PROXY_DEVICE)
|
|
|
+ #errior when set HAS_SERIAL_PROXY_SoftwareSerial - cannot be set both hardware SERIAL_PROXY_DEVICE
|
|
|
+ #endif
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY)
|
|
|
+ #include "SERIAL__struct.h"
|
|
|
+ // #include "SERIAL__func.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY_DISPLAY_SLAVE)
|
|
|
+ #define SoftwareSerial_SLAVE SoftwareSerial
|
|
|
+ #include "SERIAL_PROXY_DISPLAY_SLAVE__init.h"
|
|
|
+ #include "SERIAL_PROXY_DISPLAY_SLAVE__func.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY_DISPLAY_MASTER)
|
|
|
+ #define SoftwareSerial_MASTER SoftwareSerial
|
|
|
+ #include "SERIAL_PROXY_DISPLAY_MASTER__init.h"
|
|
|
+ #include "SERIAL_PROXY_DISPLAY_MASTER__func.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY)
|
|
|
+ // #define SoftwareSerial_PROXY SoftwareSerial
|
|
|
+ // #include "SERIAL__struct.h"
|
|
|
+ #include "SERIAL_PROXY__func.h"
|
|
|
+
|
|
|
+ #include "SERIAL__func.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+//EOF SERIAL ##############//EOF SERIAL ##############//EOF SERIAL ##############
|
|
|
+
|
|
|
+#if defined(HAS_TFT_ILI9163C)
|
|
|
+ #include "_TFT_ILI9163C_init.h"
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "_DISPLAY_init.h"
|
|
|
+#if defined(HAS_SERIAL_PROXY)
|
|
|
+ #include "automation_driven.submodule.struct.read__communication_generated.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+void setup() { //REMEMBER NOT INITIALIZE ANY VARIABLES OR ARRAYS
|
|
|
+ Serial.begin(115200);
|
|
|
+ //Wire.begin();
|
|
|
+ // scan_h();
|
|
|
+ SPFTFT(setup,init);
|
|
|
+
|
|
|
+ #if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_setup.h" //Attach interrupts //lite _ROTTARY_SW/
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+ #if defined(HAS_u8g2)
|
|
|
+ #include "u8g2__setup.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #if defined(HAS_u8x8)
|
|
|
+ #include "u8x8__setup.h"
|
|
|
+ #if defined(HAS_SERIAL_PROXY_DISPLAY_SLAVE)
|
|
|
+ u8x8.setCursor(0,1); //DISPLAY_DEV_setCursor(0,1);
|
|
|
+ u8x8.print(" connect rx to"); u8x8.print(SERIAL_PROXY_SoftwareSerial_rx_pin); //DISPLAY_DEV_print(" connect rx to"); u8x8.print(SERIAL_PROXY_SoftwareSerial_rx_pin);
|
|
|
+ u8x8.setCursor(0,2); //DISPLAY_DEV_setCursor(0,2);
|
|
|
+ u8x8.print(" connect tx to");u8x8.print(SERIAL_PROXY_SoftwareSerial_tx_pin);
|
|
|
+ u8x8.setCursor(0,3);
|
|
|
+ u8x8.print(" . ");
|
|
|
+ u8x8.setCursor(0,4);
|
|
|
+
|
|
|
+ #endif
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY_SoftwareSerial)
|
|
|
+ pinMode(SERIAL_PROXY_SoftwareSerial_rx_pin, INPUT);
|
|
|
+ pinMode(SERIAL_PROXY_SoftwareSerial_rx_pin, OUTPUT);
|
|
|
+ SERIAL_PROXY_DEVICE.begin(SERIAL_PROXY_SPEED);
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY)
|
|
|
+ #include "SERIAL_PROXY__setup.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+unsigned long time = 0;
|
|
|
+#include "_LOOP_LATENCY_COUNTER.h" //lite ___loop/
|
|
|
+unsigned long t_timestamp = 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void loop() {
|
|
|
+ register long time;
|
|
|
+ time = millis();
|
|
|
+
|
|
|
+
|
|
|
+ #if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_loop.h" //lite _ROTTARY_SW/
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+ #ifdef DISABLE_LOOP
|
|
|
+ #include "___DEBUG/___DEBUG_DISABLE_LOOP.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+ if( t_timestamp < millis() ) {
|
|
|
+ t_timestamp = millis() + 4000 ;
|
|
|
+ //u8x8.print("S"); //DISPLAY_DEV_print("S");
|
|
|
+ //Serial.print(F("D"));
|
|
|
+
|
|
|
+ Slave_Ports_Protocol_CAN_message_prototype_T__SERIAL_PROXY_DEVICE__send_ack() ;
|
|
|
+
|
|
|
+ Slave_Ports_Status__DISPLAY_TARGET(
|
|
|
+ Slave_Ports_Status_A ,
|
|
|
+ Slave_Ports_Status_T_ARDUINO_ATTR_ARRAY_A,
|
|
|
+ 0 ,
|
|
|
+ // DISPLAY_PHYSICAL_CHAR_A,
|
|
|
+ time,
|
|
|
+ time + ARDUINO_time_seq_id_A_INCREMENT //ARDUINO_LOOP_LATENCY_DISPLAY_MENU
|
|
|
+ //queue
|
|
|
+ ,Slave_Ports_Status_QUEUE_A, Slave_Ports_Status_QUEUE_T_ARDUINO_ATTR_ARRAY_A ,
|
|
|
+ TASK_TYPE_T__EMPTY__JUST_PASSED_ARG__,
|
|
|
+ TASK_PORT_ASSOC_EMPTY
|
|
|
+ //,DISPLAY_PHYSICAL_CHAR_A
|
|
|
+ );
|
|
|
+ DISPLAY__print_menu(
|
|
|
+ //lite removed DISPLAY_A ,
|
|
|
+ //lite removed DISPLAY_T_ARDUINO_ATTR_ARRAY_A ,
|
|
|
+ // DISPLAY_PHYSICAL_CHAR_A,
|
|
|
+ DISPLAY_MENU_INDEX_DEFAULT_A, //DISPLAY_MENU_ITEM_INDEX_T DISPLAY_MENU_ITEM_INDEX_A
|
|
|
+ time,time + ARDUINO_LOOP_LATENCY_DISPLAY_MENU//time_seq_id_A, (time_seq_id_A + 5000)
|
|
|
+ ,Slave_Ports_Status_A
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_SERIAL_PROXY)
|
|
|
+ #include "SERIAL_PROXY__loop.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|