diff --git a/k3ng_rotator_controller/k3ng_rotator_controller.ino b/k3ng_rotator_controller/k3ng_rotator_controller.ino index d86948f..4e5b095 100644 --- a/k3ng_rotator_controller/k3ng_rotator_controller.ino +++ b/k3ng_rotator_controller/k3ng_rotator_controller.ino @@ -840,13 +840,24 @@ \PA[x][x][x] - set the park azimuth \PE[x][x][x] - set the park elevation \PA or \PE (no parameter) - report current park azimuth and elevation + \P still initiates park FEATURE_NEXTION_DISPLAY & FEATURE_SATELLITE_TRACKING - Changing the current satellite on the Nextion display no longer echoes the command output on the control port + Changing the current satellite on the Nextion display no longer echoes the command output on the control port + + 2020.09.01.01 + FEATURE_NEXTION_DISPLAY & FEATURE_PARK + Added vPA and vPE API variables for park azimuth and elevation settings + Added vAT API variable for autopark time setting in minutes + FEATURE_NEXTION_DISPLAY + Added transient user messaging capability for vSS1 and vSS2 via request_transient_message() call + \PA or \PE command from Nextion pushes output to vSS1 in transient message + Now updating software version date based on UTC date, not Eastern US date. G'day, mates! :-) + All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc. Anything rotator_*.* should be in the ino directory! - qwerty + qwerty was here Documentation: https://github.com/k3ng/k3ng_rotator_controller/wiki @@ -856,7 +867,7 @@ */ -#define CODE_VERSION "2020.08.30.01" +#define CODE_VERSION "2020.09.01.01" #include #include @@ -1483,7 +1494,6 @@ struct config_t { int latitude; byte next_pass_max_el; byte order; - //byte last_calc_timed_out; byte status; // bitmapped: 1 = aos, 2 = last_calc_timed_out, 4 = AOS/LOS state change tm next_aos; tm next_los; @@ -1491,6 +1501,15 @@ struct config_t { #endif //FEATURE_SATELLITE_TRACKING +#if defined(FEATURE_NEXTION_DISPLAY) + char vSS1transient_message[32]; + unsigned long vSS1transient_message_time = 0; + byte vSS1transient_message_status = NEXTION_TRANSIENT_MESSAGE_IDLE; + char vSS2transient_message[32]; + unsigned long vSS2transient_message_time = 0; + byte vSS2transient_message_status = NEXTION_TRANSIENT_MESSAGE_IDLE; +#endif + /* ------------------ let's start doing some stuff now that we got the formalities out of the way --------------------*/ @@ -2911,8 +2930,7 @@ void check_overlap(){ #endif //OPTION_BLINK_OVERLAP_LED if ((overlap_led) && ((millis() - last_check_time) > 500)) { - // if ((analog_az > (500)) && (azimuth > (ANALOG_AZ_OVERLAP_DEGREES)) && (!overlap_led_status)) { - if ((raw_azimuth > (ANALOG_AZ_OVERLAP_DEGREES)) && (!overlap_led_status)) { + if ((raw_azimuth > ANALOG_AZ_OVERLAP_DEGREES) && (!overlap_led_status)) { digitalWriteEnhanced(overlap_led, OVERLAP_LED_ACTIVE_STATE); overlap_led_status = 1; #ifdef OPTION_BLINK_OVERLAP_LED @@ -2923,8 +2941,7 @@ void check_overlap(){ debug.println("check_overlap: in overlap"); #endif // DEBUG_OVERLAP } else { - // if (((analog_az < (500)) || (azimuth < (ANALOG_AZ_OVERLAP_DEGREES))) && (overlap_led_status)) { - if ((raw_azimuth < (ANALOG_AZ_OVERLAP_DEGREES)) && (overlap_led_status)) { + if ((raw_azimuth < ANALOG_AZ_OVERLAP_DEGREES) && (overlap_led_status)) { digitalWriteEnhanced(overlap_led, OVERLAP_LED_INACTIVE_STATE); overlap_led_status = 0; #ifdef DEBUG_OVERLAP @@ -4277,7 +4294,39 @@ void sendNextionCommand(const char* send_command){ nexSerial.write(0xFF); } #endif //FEATURE_NEXTION_DISPLAY +// -------------------------------------------------------------- +#if defined(FEATURE_NEXTION_DISPLAY) +void request_transient_message(char* message,byte vSS_number,unsigned int message_ms){ + if (vSS_number == 1){ + strcpy(vSS1transient_message,message); + vSS1transient_message_time = message_ms; + vSS1transient_message_status = NEXTION_TRANSIENT_MESSAGE_REQUESTED; + #if defined(DEBUG_NEXTION_TRANSIENT_MSG) + debug.print(F("request_transient_message: vSS1: NEXTION_TRANSIENT_MESSAGE_REQUESTED \"")); + debug.print(message); + debug.print(F("\" ")); + debug.print(message_ms); + debug.println(F("mS")); + #endif + } + + if (vSS_number == 2){ + strcpy(vSS2transient_message,message); + vSS2transient_message_time = message_ms; + vSS2transient_message_status = NEXTION_TRANSIENT_MESSAGE_REQUESTED; + #if defined(DEBUG_NEXTION_TRANSIENT_MSG) + debug.print(F("request_transient_message: vSS2: NEXTION_TRANSIENT_MESSAGE_REQUESTED \"")); + debug.print(message); + debug.print(F("\" ")); + debug.print(message_ms); + debug.println(F("mS")); + #endif + } + +} + +#endif // #if defined(FEATURE_NEXTION_DISPLAY) // -------------------------------------------------------------- #if defined(FEATURE_NEXTION_DISPLAY) void service_nextion_display(){ @@ -4350,21 +4399,22 @@ void service_nextion_display(){ #if defined(ANALOG_AZ_OVERLAP_DEGREES) static byte last_overlap_indicator = 0; - byte overlap_indicator = 0;; + static unsigned long last_status3_update = 0; + byte overlap_indicator = 0; #endif #if defined(FEATURE_PARK) static byte last_park_status = NOT_PARKED; #endif - #if defined(ANALOG_AZ_OVERLAP_DEGREES) - static unsigned long last_status3_update = 0; - #endif - #if defined(FEATURE_SATELLITE_TRACKING) unsigned int temp2 = 0; #endif + #if defined(DEBUG_NEXTION_COMMANDS_COMING_FROM_NEXTION) + char debug_workstring[32]; + #endif + if ((initialization_stage == 0) && (millis() > 500)){ @@ -4547,8 +4597,8 @@ void service_nextion_display(){ } #endif - // Rotator Controller API Implementation Version - strcpy_P(workstring1,(const char*) F("vRCAPIv.val=2020082401")); + // Rotator Controller API Implementation Version qwerty + strcpy_P(workstring1,(const char*) F("vRCAPIv.val=2020083101")); sendNextionCommand(workstring1); #if defined(DEBUG_NEXTION_DISPLAY_INIT) @@ -4590,6 +4640,27 @@ void service_nextion_display(){ } #endif + #if defined(FEATURE_PARK) + strcpy_P(workstring1,(const char*) F("vPA.val=")); + dtostrf(configuration.park_azimuth, 1, 0, workstring2); + strcat(workstring1,workstring2); + sendNextionCommand(workstring1); + + #if defined(FEATURE_ELEVATION_CONTROL) + strcpy_P(workstring1,(const char*) F("vPE.val=")); + dtostrf(configuration.park_elevation, 1, 0, workstring2); + strcat(workstring1,workstring2); + sendNextionCommand(workstring1); + #endif + + #if defined(FEATURE_AUTOPARK) + strcpy_P(workstring1,(const char*) F("vAT.val=")); + dtostrf(configuration.autopark_time_minutes, 1, 0, workstring2); + strcat(workstring1,workstring2); + sendNextionCommand(workstring1); + #endif + #endif //FEATURE_PARK + last_various_things_update = millis(); if (initialization_stage == 2){ @@ -4631,7 +4702,19 @@ void service_nextion_display(){ } if ((serial_byte == 13) || (nextion_port_buffer_index > 31)){ // do we have a carriage return or have we hit the end of the buffer? + #if defined(DEBUG_NEXTION_COMMANDS_COMING_FROM_NEXTION) + debug.print(F("service_nextion_display: process_backslash_command: \"")); + strcpy(debug_workstring,nextion_port_buffer); + debug.print(debug_workstring); + debug.print(F("\" nextion_port_buffer_index: ")); + debug.println(nextion_port_buffer_index); + #endif process_backslash_command(nextion_port_buffer, nextion_port_buffer_index, 0, DO_NOT_INCLUDE_RESPONSE_CODE, return_string, SOURCE_NEXTION); + #if defined(DEBUG_NEXTION_COMMANDS_COMING_FROM_NEXTION) + debug.print(F("service_nextion_display: process_backslash_command: return_string: \"")); + debug.print(return_string); + debug.println(F("\"")); + #endif nextion_port_buffer_index = 0; received_backslash = 0; last_serial_receive_time = 0; @@ -4888,6 +4971,30 @@ void service_nextion_display(){ } } #endif //!defined(FEATURE_ELEVATION_CONTROL) + + // if we have a transient message requested, initialize the timer and display the message + if (vSS1transient_message_status == NEXTION_TRANSIENT_MESSAGE_REQUESTED){ + strcpy(workstring1,vSS1transient_message); + vSS1transient_message_time = vSS1transient_message_time + millis(); + vSS1transient_message_status = NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS; + #if defined(DEBUG_NEXTION_TRANSIENT_MSG) + debug.print(F("service_nextion_display: vSS1: NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS: \"")); + debug.print(workstring1); + debug.println(F("\"")); + #endif + } else { // do we have a transient message in progress? + if (vSS1transient_message_status == NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS){ + if (millis() < vSS1transient_message_time){ // have we timed out + strcpy(workstring1,vSS1transient_message); // no + } else { + vSS1transient_message_status = NEXTION_TRANSIENT_MESSAGE_IDLE; // yes, clear the transient message condition + #if defined(DEBUG_NEXTION_TRANSIENT_MSG) + debug.println(F("service_nextion_display: vSS1: NEXTION_TRANSIENT_MESSAGE_IDLE")); + #endif + } + } + } + strcpy_P(workstring2,(const char*) F("vSS1.txt=\"")); strcat(workstring2,workstring1); strcat(workstring2,"\""); @@ -4929,12 +5036,38 @@ TODO: } break; } + #else if (raw_azimuth > ANALOG_AZ_OVERLAP_DEGREES){ strcat(workstring1,NEXTION_OVERLAP_STRING); strcat(workstring1,"\r\n"); } #endif + + // if we have a transient message requested, initialize the timer and display the message + if (vSS2transient_message_status == NEXTION_TRANSIENT_MESSAGE_REQUESTED){ + strcpy(workstring1,vSS2transient_message); + vSS2transient_message_time = vSS2transient_message_time + millis(); + vSS2transient_message_status = NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS; + #if defined(DEBUG_NEXTION_TRANSIENT_MSG) + debug.print(F("service_nextion_display: vSS2: NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS: \"")); + debug.print(workstring1); + debug.println(F("\"")); + #endif + + } else { // do we have a transient message in progress? + if (vSS2transient_message_status == NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS){ + if (millis() < vSS2transient_message_time){ // have we timed out + strcpy(workstring1,vSS2transient_message); // no + } else { + vSS2transient_message_status = NEXTION_TRANSIENT_MESSAGE_IDLE; // yes, clear the transient message condition + #if defined(DEBUG_NEXTION_TRANSIENT_MSG) + debug.println(F("service_nextion_display: vSS2: NEXTION_TRANSIENT_MESSAGE_IDLE")); + #endif + } + } + } + strcpy_P(workstring2,(const char*) F("vSS2.txt=\"")); strcat(workstring2,workstring1); strcat(workstring2,"\""); @@ -8007,7 +8140,12 @@ void output_debug(){ dtostrf((map(analogReadEnhanced(az_preset_pot), AZ_PRESET_POT_FULL_CW, AZ_PRESET_POT_FULL_CCW, AZ_PRESET_POT_FULL_CW_MAP, AZ_PRESET_POT_FULL_CCW_MAP)),0,0,tempstring); debug.print(tempstring); } - debug.print(" Offset:"); + #if defined(ANALOG_AZ_OVERLAP_DEGREES) + if (raw_azimuth > ANALOG_AZ_OVERLAP_DEGREES){ + debug.print(F(" OVERLAP")); + } + #endif + debug.print(F(" Offset:")); dtostrf(configuration.azimuth_offset,0,2,tempstring); debug.print(tempstring); #endif // ndef HARDWARE_EA4TX_ARS_USB @@ -13882,6 +14020,11 @@ byte process_backslash_command(byte input_buffer[], int input_buffer_index, byte float tempfloat = 0; byte hit_decimal = 0; + #if defined(FEATURE_PARK) && defined(FEATURE_NEXTION_DISPLAY) + char workstring1[32]; + char workstring2[32]; + #endif + #if !defined(OPTION_SAVE_MEMORY_EXCLUDE_REMOTE_CMDS) float heading = 0; #endif @@ -14447,10 +14590,40 @@ byte process_backslash_command(byte input_buffer[], int input_buffer_index, byte } else { if ((input_buffer[2] == 'A') || (input_buffer[2] == 'E')){ if (input_buffer_index == 3){ // PA or PE, no parameters, it's a query - control_port->print(F("Park Azimuth: ")); - control_port->print(configuration.park_azimuth); - control_port->print(F(" Elevation: ")); - control_port->print(configuration.park_elevation); + #if defined(FEATURE_NEXTION_DISPLAY) + if (input_source == SOURCE_NEXTION){ + strcpy_P(workstring1,(const char*) F("Park Az: ")); + dtostrf(configuration.park_azimuth, 1, 0, workstring2); + strcat(workstring1,workstring2); + #if defined(FEATURE_ELEVATION_CONTROL) + strcat_P(workstring1,(const char*) F(" El: ")); + dtostrf(configuration.park_elevation, 1, 0, workstring2); + strcat(workstring1,workstring2); + #endif + request_transient_message(workstring1,1,5000); + //zzzzzzz + } else { + #if defined(FEATURE_ELEVATION_CONTROL) + control_port->print(F("Park Azimuth: ")); + control_port->print(configuration.park_azimuth); + control_port->print(F(" Elevation: ")); + control_port->println(configuration.park_elevation); + #else + control_port->print(F("Park Azimuth: ")); + control_port->println(configuration.park_azimuth); + #endif + } + #else + #if defined(FEATURE_ELEVATION_CONTROL) + control_port->print(F("Park Azimuth: ")); + control_port->print(configuration.park_azimuth); + control_port->print(F(" Elevation: ")); + control_port->println(configuration.park_elevation); + #else + control_port->print(F("Park Azimuth: ")); + control_port->println(configuration.park_azimuth); + #endif + #endif } else { if (input_buffer_index == 4){ temp_int = (input_buffer[3] - 48); diff --git a/k3ng_rotator_controller/rotator.h b/k3ng_rotator_controller/rotator.h index 861b4f8..2966a63 100755 --- a/k3ng_rotator_controller/rotator.h +++ b/k3ng_rotator_controller/rotator.h @@ -311,6 +311,11 @@ #define SOURCE_CONTROL_PORT 0 #define SOURCE_NEXTION 1 +#define NEXTION_TRANSIENT_MESSAGE_IDLE 0 +#define NEXTION_TRANSIENT_MESSAGE_REQUESTED 1 +#define NEXTION_TRANSIENT_MESSAGE_IN_PROGRESS 2 + + /* ------end of macros ------- */ diff --git a/k3ng_rotator_controller/rotator_debug_log_activation.h b/k3ng_rotator_controller/rotator_debug_log_activation.h index 7002a1e..1e73baf 100644 --- a/k3ng_rotator_controller/rotator_debug_log_activation.h +++ b/k3ng_rotator_controller/rotator_debug_log_activation.h @@ -65,6 +65,8 @@ // #define DEBUG_NEXTION_DISPLAY_SERIAL_SEND // #define DEBUG_NEXTION_DISPLAY_SERIAL_RECV // #define DEBUG_NEXTION_DISPLAY_INIT // set DEFAULT_DEBUG_STATE to 1 above +// #define DEBUG_NEXTION_TRANSIENT_MSG +// #define DEBUG_NEXTION_COMMANDS_COMING_FROM_NEXTION // #define DEBUG_TEST_POLAR_TO_CARTESIAN // #define DEBUG_SATELLITE_TRACKING // #define DEBUG_SATELLITE_TRACKING_LOAD