|
|
@@ -0,0 +1,338 @@
|
|
|
+/*
|
|
|
+ 2021-01 abinder - moving to libs, and cleanup
|
|
|
+
|
|
|
+*/
|
|
|
+#define DISPLAY_CURSOR_Y_CHARS_DEBUG_DEF 5 //todo proportional
|
|
|
+
|
|
|
+
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_I2C_ARRAY_DRIVER_DEF 1
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_DISPLAY_DEF 2// 3 //todo debug
|
|
|
+
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_DISPLAY_MENU_DEF 1 //todo test
|
|
|
+
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_DISPLAY_MENU_ITEM_A_DEF 2 //todo debug
|
|
|
+#define ARDUINO_ARRAY_INDEX_LIMIT_PORTS_DEF 1//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_I2C_driver_Adafruit_PWMServoDriver)
|
|
|
+ #include "_I2C_driver_Adafruit_PWMServoDriver_struct.h" //lite - too much ram 4% //reorganize
|
|
|
+#endif
|
|
|
+
|
|
|
+#include "_CAN_config.h" //lite _CAN/
|
|
|
+
|
|
|
+#if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_config.h" //lite _ROTTARY_SW/
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_I2C_driver_Adafruit_PWMServoDriver)
|
|
|
+ #include "_I2C_driver_Adafruit_PWMServoDriver_config.h" //lite _I2C_driver_Adafruit_PWMServoDriver/
|
|
|
+#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
|
|
|
+
|
|
|
+
|
|
|
+//BEGIN CAN
|
|
|
+
|
|
|
+
|
|
|
+#include "_CAN_init.h" //lite #include "_CAN/_CAN_init.h"
|
|
|
+//EOF CAN
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //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/
|
|
|
+
|
|
|
+
|
|
|
+ #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"
|
|
|
+#endif
|
|
|
+
|
|
|
+ #include "_DISPLAY_DEV.h"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_I2C_driver_Adafruit_PWMServoDriver)
|
|
|
+ #include "_I2C_driver_Adafruit_PWMServoDriver_func.h" //lite _I2C_driver_Adafruit_PWMServoDriver/
|
|
|
+#endif
|
|
|
+
|
|
|
+ #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
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#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_ttl_decrement_func.h"
|
|
|
+#include "_Slave_Ports_broadcast_func.h"
|
|
|
+#include "TASK_TYPE_T_Set_Port_Smooth_forward__.h"
|
|
|
+#include "_Slave_Ports_I2C_func.h"
|
|
|
+#include "_Slave_Ports_action_func.h"
|
|
|
+
|
|
|
+#include "_DISPLAY_queue_pop_func.h"
|
|
|
+#include "_Slave_Ports_Status_QUEUE_func.h"
|
|
|
+
|
|
|
+#include "_Slave_Ports_Protocol_CAN_func.h"
|
|
|
+#include "TASK_TYPE_T_Get_Ports_Status_INPUT_A___.h"
|
|
|
+#include "_Slave_Ports_Status_func.h"
|
|
|
+#include "Slave_Ports_Status__DISPLAY_TARGET.h"
|
|
|
+
|
|
|
+
|
|
|
+#include "TASK_TYPE_T_Set_Ports_Status_LIMITS_A__.h"
|
|
|
+
|
|
|
+//L #include "_CAN_func.h" //lite _CAN/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//L #include "_Slave_Ports.h"
|
|
|
+ // #include "_Slave_Ports_ttl_decrement_POP.h"
|
|
|
+ // #define _CAN_P_0x102_PWM0x00_0 { _Slave1_ID , "PWM", 0x00, 0 }
|
|
|
+ //#define _CAN_P_0x102_PWMServoDriver0x40
|
|
|
+
|
|
|
+ // #define Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver();
|
|
|
+ // Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);
|
|
|
+
|
|
|
+
|
|
|
+// #define __CSpin 53 // 10 // chip select
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_TFT_ILI9163C)
|
|
|
+ #include "_TFT_ILI9163C_init.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "_DISPLAY_init.h"
|
|
|
+
|
|
|
+#include "config_Slave_Ports_LOCAL_init.h" //lite
|
|
|
+
|
|
|
+
|
|
|
+#if defined(HAS_I2C_driver_Adafruit_PWMServoDriver)
|
|
|
+ //L #include "_I2C_driver_Adafruit_PWMServoDriver_init.h" //lite _I2C_driver_Adafruit_PWMServoDriver/
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include "__main_init.h"
|
|
|
+
|
|
|
+ #ifdef DISABLE_LOOP
|
|
|
+ //L #include "___DEBUG/___DEBUG_DISABLE_INIT.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+ //#include "scan.h"
|
|
|
+
|
|
|
+void setup() { //REMEMBER NOT INITIALIZE ANY VARIABLES OR ARRAYS
|
|
|
+ Serial.begin(115200);
|
|
|
+ //Wire.begin();
|
|
|
+ // scan_h();
|
|
|
+
|
|
|
+
|
|
|
+ #if defined(HAS_u8g2)
|
|
|
+ //L #include "u8g2__setup.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #if defined(HAS_u8x8)
|
|
|
+ #include "u8x8__setup.h"
|
|
|
+ #endif
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ unsigned long time;
|
|
|
+
|
|
|
+ #include "_LOOP_LATENCY_COUNTER.h" //lite ___loop/
|
|
|
+
|
|
|
+
|
|
|
+void loop() {
|
|
|
+ register long time;
|
|
|
+ time = millis();
|
|
|
+ #include "___loop_init.h" //lite ___loop/
|
|
|
+
|
|
|
+ #if defined(HAS_ROTTARY_SW)
|
|
|
+ #include "_ROTTARY_SW_loop.h" //lite _ROTTARY_SW/
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #include "__main_loop_top.h" //lite ___loop/
|
|
|
+ #include "__main_loop_end.h" //lite ___loop/
|
|
|
+
|
|
|
+}
|
|
|
+
|