diff --git a/k3ng_rotator_controller/k3ng_rotator_controller.ino b/k3ng_rotator_controller/k3ng_rotator_controller.ino index 14fcc7c..a2c1c30 100644 --- a/k3ng_rotator_controller/k3ng_rotator_controller.ino +++ b/k3ng_rotator_controller/k3ng_rotator_controller.ino @@ -1048,6 +1048,9 @@ 2021.10.19.02 FEATURE_NEXTION_DISPLAY: testing new initialization code (OPTION_NEW_NEXTION_INIT_CODE) + 2021.10.19.03 + FEATURE_NEXTION_DISPLAY: optimization of OPTION_NEW_NEXTION_INIT_CODE + All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc. Anything rotator_*.* should be in the ino directory! @@ -1061,7 +1064,7 @@ */ -#define CODE_VERSION "2021.10.19.02" +#define CODE_VERSION "2021.10.19.03" #include @@ -4752,7 +4755,6 @@ void service_nextion_display(){ static byte nextion_port_buffer[32]; char return_string[32]; static byte received_backslash = 0; - byte nextion_i_am_alive_string[4]; static byte i_am_alive_bytes_received = 0; static byte consecutive_ff_bytes_received = 0; @@ -4888,28 +4890,22 @@ void service_nextion_display(){ } } } - #else // OPTION_NEW_NEXTION_INIT_CODE // NEW CODE - if ((initialization_stage == 0) /*&& (millis() > 100)*/){ + if (initialization_stage == 0){ #if defined(DEBUG_NEXTION_DISPLAY_INIT) debug.println(F("\r\nservice_nextion_display: init: 0")); #endif nexSerial.begin(NEXTION_SERIAL_BAUD); initialization_stage = 1; last_various_things_update = millis(); - i_am_alive_bytes_received = 0; #if defined(DEBUG_NEXTION_DISPLAY_INIT) debug.println(F("\r\nservice_nextion_display: init 0 -> 1")); #endif } if (initialization_stage == 1){ - nextion_i_am_alive_string[0] = 136; - nextion_i_am_alive_string[1] = 255; - nextion_i_am_alive_string[2] = 255; - nextion_i_am_alive_string[3] = 255; - nextion_i_am_alive_string[4] = 0; // Null - end of string + byte nextion_i_am_alive_string[] = {136,255,255,255}; if ((millis()-last_various_things_update) > 2000){ // we've been waiting too long, let's send a reset to Nextion #if defined(DEBUG_NEXTION_DISPLAY_INIT) @@ -4941,10 +4937,18 @@ void service_nextion_display(){ if (serial_byte == nextion_i_am_alive_string[i_am_alive_bytes_received]){ i_am_alive_bytes_received++; #if defined(DEBUG_NEXTION_DISPLAY_INIT) - debug.println(F(" match!")); + debug.print(F(" match! i_am_alive_bytes_received:")); + debug.print(i_am_alive_bytes_received); + debug.println(""); #endif - if (nextion_i_am_alive_string[i_am_alive_bytes_received] == 0){ // a null is the end of the nextion_i_am_alive_string char[] - i_am_alive_bytes_received = 254; + if (i_am_alive_bytes_received == 4){ // have we receive all the 'i am alive' bytes? + initialization_stage = 2; + output_nextion_gSC_variable(); // send gSC variable ASAP + #if defined(DEBUG_NEXTION_DISPLAY_INIT) + debug.print(F("\r\nservice_nextion_display: nextion_i_am_alive_string received, init 1 -> 2 mS elapsed since rest:")); + debug.println(int((unsigned long)millis()-(unsigned long)last_various_things_update)); + #endif + last_various_things_update = millis(); } } else { i_am_alive_bytes_received = 0; // we didn't get a byte match, reset the byte pointer @@ -4953,16 +4957,6 @@ void service_nextion_display(){ #endif } } - - if (i_am_alive_bytes_received == 254){ // we got all the 'i am alive' bytes from the Nextion - initialization_stage = 2; - output_nextion_gSC_variable(); // send gSC variable ASAP - #if defined(DEBUG_NEXTION_DISPLAY_INIT) - debug.print(F("\r\nservice_nextion_display: nextion_i_am_alive_string received, init 1 -> 2 mS elapsed since rest:")); - debug.println(int((unsigned long)millis()-(unsigned long)last_various_things_update)); - #endif - last_various_things_update = millis(); - } } } #endif // OPTION_NEW_NEXTION_INIT_CODE diff --git a/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h b/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h index 38c08fd..f603806 100755 --- a/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h +++ b/k3ng_rotator_controller/rotator_features_wb6kcn_k3ng.h @@ -22,7 +22,7 @@ // #define FEATURE_AUTOCORRECT // #define FEATURE_TEST_DISPLAY_AT_STARTUP -// #define FEATURE_SATELLITE_TRACKING // https://github.com/k3ng/k3ng_rotator_controller/wiki/707-Satellite-Tracking +#define FEATURE_SATELLITE_TRACKING // https://github.com/k3ng/k3ng_rotator_controller/wiki/707-Satellite-Tracking #define LANGUAGE_ENGLISH // all languages customized in rotator_language.h // #define LANGUAGE_SPANISH @@ -74,7 +74,7 @@ // #define FEATURE_EL_POSITION_A2_ABSOLUTE_ENCODER // And if you are using any display other than a 4 bit LCD, you must also change the feature setting in rotator_k3ngdisplay.h!!!! -#define FEATURE_4_BIT_LCD_DISPLAY // Uncomment for classic 4 bit LCD display (most common) +// #define FEATURE_4_BIT_LCD_DISPLAY // Uncomment for classic 4 bit LCD display (most common) // #define FEATURE_ADAFRUIT_I2C_LCD // #define FEATURE_ADAFRUIT_BUTTONS // Uncomment this to use Adafruit I2C LCD buttons for manual AZ/EL instead of normal buttons (also set this feature in rotator_k3ngdisplay.h) // #define FEATURE_YOURDUINO_I2C_LCD