2020.08.20.01

FEATURE_SATELLITE_TRACKING
          Removed FEATURE_SATELLITE_TRACKING_MULTI_SAT_AOS_LOS.  It's all within FEATURE_SATELLITE_TRACKING now.  We're not going to get satellite tracking to fit on a Nano, so no need to break out sub-features for memory saving.
          Significant updates to the \| (list satellites command).  It now displays current az, el, lat, long, next aos, next los, next aos max el, time to next aos, and aos status.  Updating is done in the background.  This is some cool $41t.
        FEATURE_NEXTION_DISPLAY
          Fixed bug with vSS2 API variable and Parked and Parking messages
        Added OPTION_CLI_VT100 for sending VT100 escape codes.  More on this later.
This commit is contained in:
Anthony Good 2020-08-20 20:39:38 -04:00
parent 1a8e2be355
commit 2e3dd204ed
7 changed files with 377 additions and 170 deletions

View File

@ -769,6 +769,14 @@
FEATURE_NEXTION_DISPLAY
Fixed bugs with gSC and gL API variables. I picked the wrong week to quit sniffing glue.
2020.08.20.01
FEATURE_SATELLITE_TRACKING
Removed FEATURE_SATELLITE_TRACKING_MULTI_SAT_AOS_LOS. It's all within FEATURE_SATELLITE_TRACKING now. We're not going to get satellite tracking to fit on a Nano, so no need to break out sub-features for memory saving.
Significant updates to the \| (list satellites command). It now displays current az, el, lat, long, next aos, next los, next aos max el, time to next aos, and aos status. Updating is done in the background. This is some cool $41t.
FEATURE_NEXTION_DISPLAY
Fixed bug with vSS2 API variable and Parked and Parking messages
Added OPTION_CLI_VT100 for sending VT100 escape codes. More on this later.
All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc.
Anything rotator_*.* should be in the ino directory!
@ -780,7 +788,7 @@
*/
#define CODE_VERSION "2020.08.19.01"
#define CODE_VERSION "2020.08.20.01"
#include <avr/pgmspace.h>
#include <EEPROM.h>
@ -1385,7 +1393,8 @@ struct config_t {
float current_satellite_next_los_el = 0;
byte current_satellite_next_aos_max_el = 0;
tm current_satellite_next_aos, current_satellite_next_los;
byte periodic_satellite_status = 0;
byte periodic_current_satellite_status = 0;
byte periodic_aos_los_satellite_status = 0;
Satellite sat;
Observer obs("", DEFAULT_LATITUDE, DEFAULT_LONGITUDE, DEFAULT_ALTITUDE_M);
@ -1393,17 +1402,15 @@ struct config_t {
//zzzzzz
struct satellite_list{
char name[SATELLITE_NAME_LENGTH];
#if defined FEATURE_SATELLITE_TRACKING_MULTI_SAT_AOS_LOS
int azimuth;
float elevation;
int next_aos_az;
int next_los_az;
double longitude;
double latitude;
byte next_pass_max_el;
tm next_aos;
tm next_los;
#endif
int azimuth;
int elevation;
int next_aos_az;
int next_los_az;
int longitude;
int latitude;
byte next_pass_max_el;
tm next_aos;
tm next_los;
} satellite[SATELLITE_LIST_LENGTH];
#endif //FEATURE_SATELLITE_TRACKING
@ -1634,9 +1641,7 @@ void loop() {
#if defined(FEATURE_SATELLITE_TRACKING)
service_satellite_tracking(0);
service_calc_satellite_data(0,0,0,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_SERVICE,SERVICE_CALC_DO_NOT_PRINT_DONE);
#if defined(FEATURE_SATELLITE_TRACKING_MULTI_SAT_AOS_LOS)
service_calculate_multi_satellite_upcoming_aos_and_los(SERVICE_CALC_SERVICE);
#endif
//service_calculate_multi_satellite_upcoming_aos_and_los(SERVICE_CALC_SERVICE);
#endif
check_for_reset_flag();
@ -4749,7 +4754,8 @@ TODO:
#if defined(FEATURE_PARK)
switch(park_status){
case PARK_INITIATED:
strcat(workstring1,NEXTION_PARKING_STRING);
strcat(workstring1,NEXTION_PARKING_STRING);
break;
case PARKED:
strcat(workstring1,NEXTION_PARKED_STRING);
break;
@ -4762,7 +4768,7 @@ TODO:
}
#else
if (raw_azimuth > ANALOG_AZ_OVERLAP_DEGREES){
strcat(workstring1,"OVERLAP");
strcat(workstring1,NEXTION_OVERLAP_STRING);
strcat(workstring1,"\r\n");
}
#endif
@ -5124,7 +5130,7 @@ TODO:
sendNextionCommand(workstring1);
strcpy(workstring1,"vALI.txt=\"");
strcat(workstring1,satellite_aos_los_string());
strcat(workstring1,satellite_aos_los_string(255));
strcat(workstring1,"\"");
sendNextionCommand(workstring1);
@ -5913,7 +5919,7 @@ void update_lcd_display(){
// strcat(workstring,tm_time_string_short(&current_satellite_next_los));
// }
//k3ngdisplay.print_center_fixed_field_size(workstring,LCD_SATELLITE_TRACKING_ROW-1,LCD_COLUMNS);
k3ngdisplay.print_center_fixed_field_size(satellite_aos_los_string(),LCD_SATELLITE_TRACKING_ROW-1,LCD_COLUMNS);
k3ngdisplay.print_center_fixed_field_size(satellite_aos_los_string(255),LCD_SATELLITE_TRACKING_ROW-1,LCD_COLUMNS);
} // if (current_display_state_sat == 1)
@ -6641,7 +6647,7 @@ void write_settings_to_eeprom(){
//zzzzzz
load_satellite_tle_into_P13(satellite_to_find,tle_line1,tle_line2,DO_NOT_LOAD_HARDCODED_TLE,LOAD_INTO_CURRENT_SATELLITE);
strcpy(configuration.current_satellite,current_satellite_name);
service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
configuration_dirty = 1;
} else {
load_satellite_tle_into_P13(satellite_to_find,tle_line1,tle_line2,DO_NOT_LOAD_HARDCODED_TLE,LOAD_INTO_CALC_SATELLITE);
@ -14316,34 +14322,25 @@ byte process_backslash_command(byte input_buffer[], int input_buffer_index, byte
#if defined(FEATURE_SATELLITE_TRACKING)
case '|':
for (int z = 0;z < SATELLITE_LIST_LENGTH;z++){
if (strlen(satellite[z].name) > 2){
if (z < 9){control_port->print(" ");}
control_port->print(z+1);
control_port->print(": ");
control_port->print(satellite[z].name);
control_port->print("\t");
if (strlen(satellite[z].name)<8){control_port->print("\t");}
if (strlen(satellite[z].name)<4){control_port->print("\t");}
control_port->print(satellite[z].azimuth,1);
control_port->print(" ");
control_port->print(satellite[z].elevation,1);
control_port->print("\t");
control_port->print(satellite[z].latitude,4);
control_port->print(" ");
control_port->print(satellite[z].longitude,4);
control_port->print("\t");
control_port->print(tm_date_string(&satellite[z].next_aos));
control_port->print(" ");
control_port->print(tm_time_string_short(&satellite[z].next_aos));
control_port->print("\t");
control_port->print(tm_date_string(&satellite[z].next_los));
control_port->print(" ");
control_port->print(tm_time_string_short(&satellite[z].next_los));
control_port->print(" ");
control_port->println(satellite[z].next_pass_max_el);
if (input_buffer_index == 3){
x = (input_buffer[2] - 48);
} else {
if (input_buffer_index == 4){
x = ((input_buffer[2] - 48) * 10) + (input_buffer[3] - 48);
} else {
if (input_buffer_index == 5){
x = ((input_buffer[2] - 48) * 100) + ((input_buffer[3] - 48) * 10) + (input_buffer[4] - 48);
} else {
x = 0;
}
}
}
periodic_aos_los_satellite_status = x;
if (periodic_aos_los_satellite_status == 0){
print_aos_los_satellite_status();
}
break;
case '~':
@ -14360,8 +14357,8 @@ byte process_backslash_command(byte input_buffer[], int input_buffer_index, byte
}
}
}
periodic_satellite_status = x;
if (periodic_satellite_status == 0){
periodic_current_satellite_status = x;
if (periodic_current_satellite_status == 0){
print_current_satellite_status();
}
break;
@ -14503,9 +14500,7 @@ byte process_backslash_command(byte input_buffer[], int input_buffer_index, byte
break;
// case '&':
// service_calculate_multi_satellite_upcoming_aos_and_los(SERVICE_CALC_INITIALIZE);
// break;
#endif //FEATURE_SATELLITE_TRACKING
@ -15361,7 +15356,7 @@ Not implemented yet:
control_port->print(" Max El:");
control_port->println(current_satellite_next_aos_max_el);
temp_datetime.seconds = 0;
control_port->print(satellite_aos_los_string());
control_port->print(satellite_aos_los_string(255));
control_port->println();
control_port->println();
@ -15376,22 +15371,92 @@ Not implemented yet:
#endif //FEATURE_SATELLITE_TRACKING
//-----------------------------------------------------------------------
#if defined(FEATURE_SATELLITE_TRACKING)
char* satellite_aos_los_string(){
void print_aos_los_satellite_status(){
if (periodic_aos_los_satellite_status){
send_vt100_code(VT100_CLEAR_SCREEN);
send_vt100_code(VT100_CURSOR_UPPER_LEFT_CORNER);
}
control_port->println(F(" # Sat Az El Lat Long Next AOS Next LOS Max El"));
control_port->println(F("-- -------------- --- --- --- ---- ---------------- ---------------- ------"));
// 1: AO-07 150 -37 -37 -36 2020-08-20 18:56 2020-08-20 19:16 48
for (int z = 0;z < SATELLITE_LIST_LENGTH;z++){
if (strlen(satellite[z].name) > 2){
if (strcmp(satellite[z].name,current_satellite_name) == 0){
send_vt100_code(VT100_BOLD);
}
if (z < 9){control_port->print(" ");}
control_port->print(z+1);
control_port->print(": ");
control_port->print(satellite[z].name);
control_port->print("\t");
if (strlen(satellite[z].name)<8){control_port->print("\t");}
if (strlen(satellite[z].name)<4){control_port->print("\t");}
if (satellite[z].azimuth >= 0){control_port->print(" ");}
if (abs(satellite[z].azimuth) < 10){control_port->print(" ");}
if (abs(satellite[z].azimuth) < 100){control_port->print(" ");}
control_port->print(satellite[z].azimuth);
control_port->print(" ");
if (satellite[z].elevation >= 0){control_port->print(" ");}
if (abs(satellite[z].elevation) < 10){control_port->print(" ");}
if (abs(satellite[z].elevation) < 100){control_port->print(" ");}
control_port->print(satellite[z].elevation);
control_port->print("\t");
if (satellite[z].latitude >= 0){control_port->print(" ");}
if (abs(satellite[z].latitude) < 10){control_port->print(" ");}
if (abs(satellite[z].latitude) < 100){control_port->print(" ");}
control_port->print(satellite[z].latitude);
control_port->print(" ");
if (satellite[z].longitude >= 0){control_port->print(" ");}
if (abs(satellite[z].longitude) < 10){control_port->print(" ");}
if (abs(satellite[z].longitude) < 100){control_port->print(" ");}
control_port->print(satellite[z].longitude);
control_port->print("\t");
control_port->print(tm_date_string(&satellite[z].next_aos));
control_port->print(" ");
control_port->print(tm_time_string_short(&satellite[z].next_aos));
control_port->print("\t");
control_port->print(tm_date_string(&satellite[z].next_los));
control_port->print(" ");
control_port->print(tm_time_string_short(&satellite[z].next_los));
control_port->print("\t");
if (abs(satellite[z].next_pass_max_el) < 10){control_port->print(" ");}
if (abs(satellite[z].next_pass_max_el) < 100){control_port->print(" ");}
control_port->print(satellite[z].next_pass_max_el);
control_port->print(" ");
if (satellite[z].next_los.year > 0){
control_port->print(satellite_aos_los_string(z));
}
if (satellite[z].elevation >= SATELLITE_AOS_ELEVATION_MIN){
send_vt100_code(VT100_CODE_BLINK);
control_port->print(F(" * AOS *")); //zzzzzz
send_vt100_code(VT100_CODE_CHAR_ATTR_OFF);
}
if (strcmp(satellite[z].name,current_satellite_name) == 0){
send_vt100_code(VT100_CODE_CHAR_ATTR_OFF);
}
control_port->println();
}
}
control_port->println();
}
#endif //FEATURE_SATELLITE_TRACKING
//-----------------------------------------------------------------------
#if defined(FEATURE_SATELLITE_TRACKING)
char* time_duration_string(int days, int hours, int minutes, int seconds){
static char tempstring[8];
char tempstring2[3];
int days, hours, minutes, seconds;
strcpy(tempstring,"");
if (satellite_visible) {
temp_datetime = current_satellite_next_los;
strcpy(tempstring,"LOS in ");
} else {
temp_datetime = current_satellite_next_aos;
strcpy(tempstring,"AOS in ");
}
difftime(&temp_datetime,&current_clock,&days,&hours,&minutes,&seconds);
if (days > 0){
dtostrf(days,0,0,tempstring2);
strcat(tempstring,tempstring2);
@ -15429,7 +15494,44 @@ Not implemented yet:
}
}
return tempstring;
}
#endif //FEATURE_SATELLITE_TRACKING
//-----------------------------------------------------------------------
#if defined(FEATURE_SATELLITE_TRACKING)
char* satellite_aos_los_string(byte which_satellite){
// which_satellite = 255: use current satellite
// which_satellite < 255: use satellite from array
static char tempstring[15];
int days, hours, minutes, seconds;
strcpy(tempstring,"");
if (which_satellite == 255){
if (satellite_visible) {
temp_datetime = current_satellite_next_los;
strcpy_P(tempstring,(const char*) F("LOS in ")); //zzzzzz
} else {
temp_datetime = current_satellite_next_aos;
strcpy_P(tempstring,(const char*) F("AOS in "));
}
} else {
if (satellite[which_satellite].elevation > SATELLITE_AOS_ELEVATION_MIN) {
temp_datetime = satellite[which_satellite].next_los;
strcpy_P(tempstring,(const char*) F("LOS in "));
} else {
temp_datetime = satellite[which_satellite].next_aos;
strcpy_P(tempstring,(const char*) F("AOS in "));
}
}
difftime(&temp_datetime,&current_clock,&days,&hours,&minutes,&seconds);
strcat(tempstring,time_duration_string(days, hours, minutes, seconds));
return(tempstring);
}
@ -17709,7 +17811,7 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
if (where_to_load_it == LOAD_INTO_CURRENT_SATELLITE){
strcpy(current_satellite_name,sat.name);
// service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
// service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
}
@ -17725,9 +17827,13 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
static byte satellite_tracking_activated_by_activate_line = 0;
static byte satellite_tracking_pin_state = 0;
static byte satellite_initialized = 0;
static unsigned long last_periodic_satellite_status_print = 0;
static unsigned long last_periodic_current_satellite_status_print = 0;
static unsigned long last_periodic_aos_los_satellite_status_print = 0;
static byte aos_los_update_needed = 0;
// I am so sick and tired of people trying to get shit working on an effing Nano. My time is worth something... more than
// the $10 to go buy a Chinese Mega clone.
if ((!satellite_initialized) && (millis() > 4000)){ // wait until 4 seconds of update to load first TLE and initialize
@ -17750,14 +17856,21 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
if (!satellite_initialized){return;}
if ((periodic_satellite_status > 0) && ((millis()-last_periodic_satellite_status_print) >= (periodic_satellite_status * 1000))){
if ((periodic_current_satellite_status > 0) && ((millis()-last_periodic_current_satellite_status_print) >= (periodic_current_satellite_status * 1000))){
print_current_satellite_status();
last_periodic_satellite_status_print = millis();
last_periodic_current_satellite_status_print = millis();
}
if (periodic_satellite_status == 0){last_periodic_satellite_status_print = 0;}
if (periodic_current_satellite_status == 0){last_periodic_current_satellite_status_print = 0;}
if ((periodic_aos_los_satellite_status > 0) && ((millis()-last_periodic_aos_los_satellite_status_print) >= (periodic_aos_los_satellite_status * 1000))){
print_aos_los_satellite_status();
last_periodic_aos_los_satellite_status_print = millis();
}
if (periodic_aos_los_satellite_status == 0){last_periodic_aos_los_satellite_status_print = 0;}
if (satellite_tracking_active_pin) {
if ((satellite_tracking_active) && (!satellite_tracking_pin_state)) {
digitalWriteEnhanced(satellite_tracking_active_pin, HIGH);
@ -17792,10 +17905,11 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
// sat.LL(current_satellite_latitude,current_satellite_longitude);
// sat.altaz(obs, current_satellite_elevation, current_satellite_azimuth);
service_calc_satellite_data(255,1,UPDATE_JUST_CURRENT_SAT_AZ_EL,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_JUST_AZ_EL,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
last_update_satellite_position = millis();
}
}
if ((current_satellite_azimuth >= SATELLITE_AOS_AZIMUTH_MIN) && (current_satellite_azimuth <= SATELLITE_AOS_AZIMUTH_MAX) && (current_satellite_elevation >= SATELLITE_AOS_ELEVATION_MIN) && (current_satellite_elevation <= SATELLITE_AOS_ELEVATION_MAX)) {
if (!satellite_visible) {
@ -17815,10 +17929,24 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
}
if ((aos_los_update_needed) && (service_calc_satellite_data(0,0,0,0,SERVICE_CALC_REPORT_STATE,0) == SERVICE_IDLE)){
service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
service_calc_satellite_data(255,1,UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
aos_los_update_needed = 0;
}
static byte satellite_array_refresh_position = 0;
// let's update data for other satellites in the array
if ((service_calc_satellite_data(0,0,0,0,SERVICE_CALC_REPORT_STATE,0) == SERVICE_IDLE) && (!aos_los_update_needed)){
if (strlen(satellite[satellite_array_refresh_position].name) > 2){
service_calc_satellite_data(satellite_array_refresh_position,1,UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
}
satellite_array_refresh_position++;
if (satellite_array_refresh_position >= SATELLITE_LIST_LENGTH){
satellite_array_refresh_position = 0;
}
}
if ((satellite_tracking_active) && ((millis() - last_tracking_check) > SATELLITE_TRACKING_UPDATE_INTERVAL)) {
#ifdef DEBUG_SATELLITE_TRACKING
@ -17909,52 +18037,52 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
#endif //FEATURE_SATELLITE_TRACKING
//------------------------------------------------------
#if defined(FEATURE_SATELLITE_TRACKING) && defined(FEATURE_SATELLITE_TRACKING_MULTI_SAT_AOS_LOS)
void service_calculate_multi_satellite_upcoming_aos_and_los(byte action){
// #if defined(FEATURE_SATELLITE_TRACKING)
// void service_calculate_multi_satellite_upcoming_aos_and_los(byte action){
static int z;
static byte service_state = SERVICE_IDLE;
// static int z;
// static byte service_state = SERVICE_IDLE;
if (action == SERVICE_CALC_INITIALIZE){
if (service_calc_satellite_data(0,0,0,0,SERVICE_CALC_REPORT_STATE,0) == SERVICE_IDLE){
z = 0;
service_state = SERVICE_CALC_IN_PROGRESS;
return;
} else {
control_port->println(F("System is busy with a calculation. Try again later."));
}
}
// if (action == SERVICE_CALC_INITIALIZE){
// if (service_calc_satellite_data(0,0,0,0,SERVICE_CALC_REPORT_STATE,0) == SERVICE_IDLE){
// z = 0;
// service_state = SERVICE_CALC_IN_PROGRESS;
// return;
// } else {
// control_port->println(F("System is busy with a calculation. Try again later."));
// }
// }
if ((action == SERVICE_CALC_SERVICE) && (service_state == SERVICE_CALC_IN_PROGRESS)){
if (service_calc_satellite_data(0,0,0,0,SERVICE_CALC_REPORT_STATE,0) == SERVICE_IDLE){
if (strlen(satellite[z].name) > 2){
//pull_satellite_tle_and_activate(satellite[z].name,NOT_VERBOSE,LOAD_INTO_CALC_SATELLITE);
if (z == 0){
service_calc_satellite_data(z,1,PRINT_AOS_LOS_TABULAR_REPORT,SERVICE_CALC_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
} else {
service_calc_satellite_data(z,1,PRINT_AOS_LOS_TABULAR_REPORT,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
}
// control_port->print(z+1);
// control_port->print(": ");
// control_port->println(satellite[z].name);
}
if (z < SATELLITE_LIST_LENGTH){
z++;
} else {
service_state = SERVICE_IDLE;
control_port->println(F("Done."));
}
}
} //if (service_state = SERVICE_CALC_IN_PROGRESS)
// if ((action == SERVICE_CALC_SERVICE) && (service_state == SERVICE_CALC_IN_PROGRESS)){
// if (service_calc_satellite_data(0,0,0,0,SERVICE_CALC_REPORT_STATE,0) == SERVICE_IDLE){
// if (strlen(satellite[z].name) > 2){
// //pull_satellite_tle_and_activate(satellite[z].name,NOT_VERBOSE,LOAD_INTO_CALC_SATELLITE);
// if (z == 0){
// service_calc_satellite_data(z,1,PRINT_AOS_LOS_TABULAR_REPORT,SERVICE_CALC_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
// } else {
// service_calc_satellite_data(z,1,PRINT_AOS_LOS_TABULAR_REPORT,SERVICE_CALC_DO_NOT_PRINT_HEADER,SERVICE_CALC_INITIALIZE,SERVICE_CALC_DO_NOT_PRINT_DONE);
// }
// // control_port->print(z+1);
// // control_port->print(": ");
// // control_port->println(satellite[z].name);
// }
// if (z < SATELLITE_LIST_LENGTH){
// z++;
// } else {
// service_state = SERVICE_IDLE;
// control_port->println(F("Done."));
// }
// }
// } //if (service_state = SERVICE_CALC_IN_PROGRESS)
}
#endif //FEATURE_SATELLITE_TRACKING
// }
// #endif //FEATURE_SATELLITE_TRACKING
//------------------------------------------------------
#if defined(FEATURE_SATELLITE_TRACKING)
byte service_calc_satellite_data(byte do_this_satellite,byte run_this_many_passes,byte do_this_format,byte do_this_print_header,byte service_action,byte do_print_done){
// the # of the sat
// in the satellite[] array
// 255 = current sat
// the # of the sat
// in the satellite[] array
// 255 = current sat
static double calc_satellite_latitude;
static double calc_satellite_longitude;
@ -17981,31 +18109,56 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
static byte this_satellite;
static byte current_satellite_position_in_array;
#define JUST_GETTING_STARTED 0
#define GET_AOS_THEN_LOS 1
#define GET_LOS_THEN_AOS 2
#define GOT_AOS_NEED_LOS 3
#define GOT_LOS_NEED_AOS 4
#define WE_ARE_DONE 5
static unsigned long calculation_start_time;
static byte aos_and_los_collection_state;
static byte service_state = SERVICE_IDLE;
static byte aos_and_los_collection_state;
#define JUST_GETTING_STARTED 0
#define GET_AOS_THEN_LOS 1
#define GET_LOS_THEN_AOS 2
#define GOT_AOS_NEED_LOS 3
#define GOT_LOS_NEED_AOS 4
#define WE_ARE_DONE 5
byte pull_result = 0;
if (service_action == SERVICE_CALC_REPORT_STATE){
return service_state;
}
if (service_action == SERVICE_CALC_INITIALIZE){ // initialize calculation
if (service_state == SERVICE_CALC_IN_PROGRESS){
if (do_this_format == UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS){
control_port->println(F("Calculation terminated by system request."));
} else {
control_port->println(F("Calculation terminated by user request."));
#if defined(DEBUG_SATELLITE_TRACKING_CALC)
debug.print("service_calc_satellite_data: ");
switch(do_this_format){
case UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS:
debug.print("UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS");
break;
case UPDATE_CURRENT_SAT_JUST_AZ_EL:
debug.print("UPDATE_CURRENT_SAT_JUST_AZ_EL");
break;
case UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS:
debug.print("UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS");
break;
}
}
debug.print(" sat:");
debug.print(do_this_satellite);
if (service_state == SERVICE_CALC_IN_PROGRESS){
debug.print(" calc terminated by ");
if (do_this_format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS){
debug.print("system");
} else {
debug.print("user");
}
}
debug.println("");
#endif
AOS = 0;
@ -18037,8 +18190,8 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
}
if ((format == UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS) || (format == UPDATE_JUST_CURRENT_SAT_AZ_EL)){
// calculate az and el for current satellite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ((format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS) || (format == UPDATE_CURRENT_SAT_JUST_AZ_EL)){
for (int z = 0;z < SATELLITE_LIST_LENGTH;z++){
if (strlen(satellite[z].name) > 2){
if (strcmp(satellite[z].name,current_satellite_name) == 0){
@ -18047,7 +18200,6 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
}
}
}
sat_datetime.settime(current_clock.year, current_clock.month, current_clock.day, current_clock.hours, current_clock.minutes, current_clock.seconds);
obs.LA = latitude;
obs.LO = longitude;
@ -18056,15 +18208,37 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
sat.predict(sat_datetime);
sat.LL(current_satellite_latitude,current_satellite_longitude);
sat.altaz(obs, current_satellite_elevation, current_satellite_azimuth);
if (current_satellite_position_in_array != 255){
satellite[current_satellite_position_in_array].azimuth = int(current_satellite_azimuth);
satellite[current_satellite_position_in_array].elevation = int(current_satellite_elevation);
if (current_satellite_position_in_array != 255){
satellite[current_satellite_position_in_array].elevation = current_satellite_elevation;
satellite[current_satellite_position_in_array].azimuth = current_satellite_azimuth;
satellite[current_satellite_position_in_array].latitude = current_satellite_latitude;
satellite[current_satellite_position_in_array].longitude = current_satellite_longitude;
}
}
// END - calculate az and el for current satellite - - - - - - - - - - - - - - - -
if (format == UPDATE_JUST_CURRENT_SAT_AZ_EL){
// calculate az and el for satellite in the array - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (format == UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS){
sat_datetime.settime(current_clock.year, current_clock.month, current_clock.day, current_clock.hours, current_clock.minutes, current_clock.seconds);
obs.LA = latitude;
obs.LO = longitude;
obs.HT = altitude_m;
pull_result = pull_satellite_tle_and_activate(satellite[this_satellite].name,NOT_VERBOSE,LOAD_INTO_CALC_SATELLITE);
if (pull_result == 1){
sat.predict(sat_datetime);
sat.LL(calc_satellite_latitude,calc_satellite_longitude);
sat.altaz(obs, calc_satellite_elevation, calc_satellite_azimuth);
satellite[this_satellite].azimuth = calc_satellite_azimuth;
satellite[this_satellite].elevation = calc_satellite_elevation;
satellite[this_satellite].latitude = calc_satellite_latitude;
satellite[this_satellite].longitude = calc_satellite_longitude;
}
//service_state = SERVICE_IDLE; // temp - exit
}
// END - calculate az and el for satellite in the array - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (format == UPDATE_CURRENT_SAT_JUST_AZ_EL){ // No need to calculate next AOS/LOS for current satellite, we end this session
service_state = SERVICE_IDLE;
}
@ -18074,22 +18248,25 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
return 0;
}
} //if (service_action == SERVICE_CALC_INITIALIZE){ // initialize calculation
// - - - - - - - - - - - - - - - - - - -
if ((service_action == SERVICE_CALC_SERVICE) && (service_state == SERVICE_CALC_IN_PROGRESS)){
if ((millis() - calculation_start_time) > 15000){
control_port->print(sat.name);
control_port->println(F(": No visible pass found."));
if ((format != UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS) && (format != UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS)){
control_port->print(sat.name);
control_port->println(F(": No visible pass found."));
}
service_state = SERVICE_IDLE;
return 0;
}
// - - - - - - - - -
if (format == UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS){
if ((format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS) || (format == UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS)){
if (aos_and_los_collection_state != WE_ARE_DONE){
add_time(calc_years,calc_months,calc_days,calc_hours,calc_minutes,1,0);
sat_datetime.settime(calc_years, calc_months, calc_days, calc_hours, calc_minutes, 0);
@ -18108,13 +18285,22 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
}
if (!AOS){
if ((aos_and_los_collection_state == GET_AOS_THEN_LOS) || (aos_and_los_collection_state == GOT_LOS_NEED_AOS)){
current_satellite_next_aos.year = calc_years;
current_satellite_next_aos.month = calc_months;
current_satellite_next_aos.day = calc_days;
current_satellite_next_aos.hours = calc_hours;
current_satellite_next_aos.minutes = calc_minutes;
current_satellite_next_aos_az = calc_satellite_azimuth;
current_satellite_next_aos_el = calc_satellite_elevation;
if (format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS){
current_satellite_next_aos.year = calc_years;
current_satellite_next_aos.month = calc_months;
current_satellite_next_aos.day = calc_days;
current_satellite_next_aos.hours = calc_hours;
current_satellite_next_aos.minutes = calc_minutes;
current_satellite_next_aos_az = calc_satellite_azimuth;
current_satellite_next_aos_el = calc_satellite_elevation;
} else {
satellite[this_satellite].next_aos.year = calc_years;
satellite[this_satellite].next_aos.month = calc_months;
satellite[this_satellite].next_aos.day = calc_days;
satellite[this_satellite].next_aos.hours = calc_hours;
satellite[this_satellite].next_aos.minutes = calc_minutes;
satellite[this_satellite].next_aos_az = calc_satellite_azimuth;
}
if (aos_and_los_collection_state == GET_AOS_THEN_LOS){
aos_and_los_collection_state = GOT_AOS_NEED_LOS;
} else {
@ -18135,17 +18321,30 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
}
if (!LOS){
if ((aos_and_los_collection_state == GOT_AOS_NEED_LOS) || (aos_and_los_collection_state == GET_LOS_THEN_AOS)){
current_satellite_next_los.year = calc_years;
current_satellite_next_los.month = calc_months;
current_satellite_next_los.day = calc_days;
current_satellite_next_los.hours = calc_hours;
current_satellite_next_los.minutes = calc_minutes;
current_satellite_next_los_az = calc_satellite_azimuth;
current_satellite_next_los_el = calc_satellite_elevation;
if (format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS){
current_satellite_next_los.year = calc_years;
current_satellite_next_los.month = calc_months;
current_satellite_next_los.day = calc_days;
current_satellite_next_los.hours = calc_hours;
current_satellite_next_los.minutes = calc_minutes;
current_satellite_next_los_az = calc_satellite_azimuth;
current_satellite_next_los_el = calc_satellite_elevation;
} else {
satellite[this_satellite].next_los.year = calc_years;
satellite[this_satellite].next_los.month = calc_months;
satellite[this_satellite].next_los.day = calc_days;
satellite[this_satellite].next_los.hours = calc_hours;
satellite[this_satellite].next_los.minutes = calc_minutes;
satellite[this_satellite].next_los_az = calc_satellite_azimuth;
}
if (aos_and_los_collection_state == GOT_AOS_NEED_LOS){
aos_and_los_collection_state = WE_ARE_DONE;
service_state = SERVICE_IDLE;
current_satellite_next_aos_max_el = (byte)pass_max_elevation;
if (format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS){
current_satellite_next_aos_max_el = (byte)pass_max_elevation;
} else {
satellite[this_satellite].next_pass_max_el = (byte)pass_max_elevation;
}
} else {
aos_and_los_collection_state = GOT_LOS_NEED_AOS; // got LOS first, will get AOS second next
}
@ -18156,7 +18355,7 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
}
}
} // while (aos_and_los_collection_state != WE_ARE_DONE)
} // if (format == UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS)
} // if (format == UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS)
@ -18414,6 +18613,7 @@ void convert_polar_to_cartesian(byte coordinate_conversion,double azimuth_in,dou
char tempstring2[5];
strcpy(tempstring,"");
if (time1->year == 0){strcat(tempstring,"000");}
dtostrf(time1->year,0,0,tempstring2);
strcat(tempstring,tempstring2);
strcat(tempstring,"-");
@ -18475,5 +18675,19 @@ void run_this_once(){
}
//------------------------------------------------------
void send_vt100_code(char* code_to_send){
#if defined(OPTION_CLI_VT100)
control_port->write(0x1B); //ESCape
control_port->print(code_to_send);
#endif //OPTION_CLI_VT100
}
// that's all, folks !

View File

@ -263,10 +263,11 @@
#define ACTIVATE_SUN_TRACKING 5
#define ACTIVATE_SATELLITE_TRACKING 6
#define UPDATE_CURRENT_SAT_AOS_AND_LOS_GLOBAL_VARS 0
#define UPDATE_CURRENT_SAT_AZ_EL_NEXT_AOS_AND_LOS 0
#define PRINT_AOS_LOS_MULTILINE_REPORT 1
#define PRINT_AOS_LOS_TABULAR_REPORT 2
#define UPDATE_JUST_CURRENT_SAT_AZ_EL 3
#define UPDATE_CURRENT_SAT_JUST_AZ_EL 3
#define UPDATE_SAT_ARRAY_SLOT_AZ_EL_NEXT_AOS_LOS 4
#define DO_NOT_INCLUDE_RESPONSE_CODE 0
#define INCLUDE_RESPONSE_CODE 1
@ -300,5 +301,12 @@
#define SERVICE_IDLE 0
#define SERVICE_CALC_IN_PROGRESS 1
#define VT100_CODE_CHAR_ATTR_OFF "[0m"
#define VT100_CODE_BLINK "[5m"
#define VT100_CLEAR_SCREEN "[2J"
#define VT100_CURSOR_UPPER_LEFT_CORNER "[f"
#define VT100_BOLD "[1m"
/* ------end of macros ------- */

View File

@ -23,7 +23,6 @@
// #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_MULTI_SAT_AOS_LOS
#define LANGUAGE_ENGLISH // all languages customized in rotator_language.h
// #define LANGUAGE_SPANISH

View File

@ -23,8 +23,6 @@
//#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_MULTI_SAT_AOS_LOS
#define LANGUAGE_ENGLISH // all languages customized in rotator_language.h
//#define LANGUAGE_SPANISH

View File

@ -29,7 +29,6 @@
// #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_MULTI_SAT_AOS_LOS
#define LANGUAGE_ENGLISH // all languages customized in rotator_language.h
// #define LANGUAGE_SPANISH
@ -186,6 +185,7 @@
#define OPTION_STEPPER_MOTOR_USE_TIMER_ONE_INSTEAD_OF_FIVE
// #define OPTION_ALLOW_ROTATIONAL_AND_CONFIGURATION_CMDS_AT_BOOT_UP // if disabled, rotational and configuration commands will be ignored on the serial port for the first 10 second after boot up
#define OPTION_CLI_VT100
// ######## ######## ###### ########
// ## ## ## ## ##

View File

@ -22,7 +22,6 @@
//#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_MULTI_SAT_AOS_LOS
#define LANGUAGE_ENGLISH // all languages customized in rotator_language.h
//#define LANGUAGE_SPANISH

View File

@ -35,17 +35,6 @@
#define ESE_STRING "ESE"
#define ENE_STRING "ENE"
#define NNE_STRING "NNE"
// #define TOUCH_DISPLAY_TITLE "K3NG Rotator Controller"
// #define TOUCH_DISPLAY_STOP_STRING "Stop"
// #define TOUCH_DISPLAY_OVERLAP_STRING "overlap"
// #define TOUCH_DISPLAY_DATA_ENTRY_CANCEL "cancel"
// #define TOUCH_DISPLAY_DATA_ENTRY_ENTER "enter"
// #define TOUCH_DISPLAY_DATA_ENTRY_SEPERATOR "."
// #define TOUCH_DISPLAY_DATA_ENTRY_DELETE "del"
// #define TOUCH_DISPLAY_PARKED_STRING "parked"
// #define TOUCH_DISPLAY_PARKING_STRING "Parking"
// #define TOUCH_DISPLAY_ENTER_AZ "Enter Azimuth"
// #define TOUCH_DISPLAY_ENTER_EL "Enter Elevation"
#define NEXTION_GPS_STRING "Sats"
#define NEXTION_PARKING_STRING "PARKING"
#define NEXTION_PARKED_STRING "PARKED"