2021.10.19.03

FEATURE_NEXTION_DISPLAY: optimization of OPTION_NEW_NEXTION_INIT_CODE
This commit is contained in:
Anthony Good 2021-10-18 22:20:21 -04:00
parent 54d8d51dd1
commit 87b9bb20d4
2 changed files with 19 additions and 25 deletions

View File

@ -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 <avr/pgmspace.h>
@ -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,20 +4937,11 @@ 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;
}
} else {
i_am_alive_bytes_received = 0; // we didn't get a byte match, reset the byte pointer
#if defined(DEBUG_NEXTION_DISPLAY_INIT)
debug.println(F(" no match"));
#endif
}
}
if (i_am_alive_bytes_received == 254){ // we got all the 'i am alive' bytes from the Nextion
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)
@ -4963,6 +4950,13 @@ void service_nextion_display(){
#endif
last_various_things_update = millis();
}
} else {
i_am_alive_bytes_received = 0; // we didn't get a byte match, reset the byte pointer
#if defined(DEBUG_NEXTION_DISPLAY_INIT)
debug.println(F(" no match"));
#endif
}
}
}
}
#endif // OPTION_NEW_NEXTION_INIT_CODE

View File

@ -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