From de712f2f421b63e4d2b332b8d237333befa4ee7a Mon Sep 17 00:00:00 2001 From: Anthony Good Date: Fri, 2 Apr 2021 16:16:36 -0400 Subject: [PATCH] 2021.04.02.01 FEATURE_AUDIBLE_ALERT new commands: \- Query audible alert state \-0 Disable audible alerts \-1 Enable audible alerts \-X Silence current audible alert \-~ Manually trigger audible alert \-A0 Disable AZ target alert \-A1 Enable AZ target alert \-E0 Disable EL target alert \-E1 Enable EL target alert --- .../k3ng_rotator_controller.ino | 171 ++++++++++++++++-- k3ng_rotator_controller/rotator.h | 7 +- k3ng_rotator_controller/rotator_pins_test.h | 4 +- k3ng_rotator_controller/rotator_settings.h | 4 +- .../rotator_settings_test.h | 4 +- 5 files changed, 171 insertions(+), 19 deletions(-) diff --git a/k3ng_rotator_controller/k3ng_rotator_controller.ino b/k3ng_rotator_controller/k3ng_rotator_controller.ino index 76a5cfe..e403b32 100644 --- a/k3ng_rotator_controller/k3ng_rotator_controller.ino +++ b/k3ng_rotator_controller/k3ng_rotator_controller.ino @@ -961,6 +961,18 @@ Bit Values AUDIBLE_ALERT 8192 + 2021.04.02.01 + FEATURE_AUDIBLE_ALERT new commands: + \- Query audible alert state + \-0 Disable audible alerts + \-1 Enable audible alerts + \-X Silence current audible alert + \-~ Manually trigger audible alert + \-A0 Disable AZ target alert + \-A1 Enable AZ target alert + \-E0 Disable EL target alert + \-E1 Enable EL target alert + All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc. Anything rotator_*.* should be in the ino directory! @@ -975,7 +987,7 @@ */ -#define CODE_VERSION "2021.04.01.01" +#define CODE_VERSION "2021.04.02.01" #include @@ -1218,7 +1230,9 @@ struct config_t { float tracking_sun_degrees_difference_threshold; float tracking_moon_degrees_difference_threshold; float tracking_sat_degrees_difference_threshold; - byte audible_alert_enabled; + byte audible_alert_enabled; + byte audible_alert_enabled_az_target; + byte audible_alert_enabled_el_target; } configuration; @@ -1933,7 +1947,7 @@ void loop() { // -------------------------------------------------------------- #if defined(FEATURE_AUDIBLE_ALERT) - void audible_alert(byte how_called){ + byte audible_alert(byte how_called){ static unsigned long alert_start_time = 0; @@ -1951,22 +1965,69 @@ void loop() { break; case AUDIBLE_ALERT_ACTIVATE: if (configuration.audible_alert_enabled){ - if ((AUDIBLE_ALERT_TYPE == 1)){ + if (AUDIBLE_ALERT_TYPE == 1){ digitalWriteEnhanced(pin_audible_alert, AUDIBLE_PIN_ACTIVE_STATE); } if (AUDIBLE_ALERT_TYPE == 2){ tone(pin_audible_alert, AUDIBLE_PIN_TONE_FREQ); } - alert_start_time = millis(); + if (millis() == 0){ + alert_start_time = 1; + } else { + alert_start_time = millis(); + } } + break; + case AUDIBLE_ALERT_MANUAL_ACTIVATE: + if (!configuration.audible_alert_enabled){ + configuration.audible_alert_enabled = 1; + configuration_dirty = 1; + } + if ((AUDIBLE_ALERT_TYPE == 1)){ + digitalWriteEnhanced(pin_audible_alert, AUDIBLE_PIN_ACTIVE_STATE); + } + if (AUDIBLE_ALERT_TYPE == 2){ + tone(pin_audible_alert, AUDIBLE_PIN_TONE_FREQ); + } + alert_start_time = millis(); + break; + case AUDIBLE_ALERT_SILENCE: + if (AUDIBLE_ALERT_TYPE == 1){ + digitalWriteEnhanced(pin_audible_alert, AUDIBLE_PIN_INACTIVE_STATE); + } + if (AUDIBLE_ALERT_TYPE == 2){ + noTone(pin_audible_alert); + } + break; + case AUDIBLE_ALERT_DISABLE: + if (AUDIBLE_ALERT_TYPE == 1){ + digitalWriteEnhanced(pin_audible_alert, AUDIBLE_PIN_INACTIVE_STATE); + } + if (AUDIBLE_ALERT_TYPE == 2){ + noTone(pin_audible_alert); + } + alert_start_time = 0; + configuration.audible_alert_enabled = 0; + configuration_dirty = 1; break; - + case AUDIBLE_ALERT_ENABLE: + configuration.audible_alert_enabled = 1; + configuration_dirty = 1; + break; } + if (alert_start_time){ + return(1); + } else { + return(0); + } + } #endif //FEATURE_AUDIBLE_ALERT +/* "make something rare and of value" */ + // -------------------------------------------------------------- #if defined(FEATURE_AZ_POSITION_A2_ABSOLUTE_ENCODER) || defined(FEATURE_EL_POSITION_A2_ABSOLUTE_ENCODER) @@ -6954,6 +7015,8 @@ void initialize_eeprom_with_defaults(){ configuration.tracking_moon_degrees_difference_threshold = 0.1; configuration.tracking_sat_degrees_difference_threshold = 0.1; configuration.audible_alert_enabled = 1; + configuration.audible_alert_enabled_az_target = AUDIBLE_ALERT_AT_AZ_TARGET; + configuration.audible_alert_enabled_el_target = AUDIBLE_ALERT_AT_EL_TARGET; #ifdef FEATURE_ELEVATION_CONTROL @@ -10830,7 +10893,7 @@ void service_rotation(){ az_request_queue_state = NONE; #if defined(FEATURE_AUDIBLE_ALERT) - if (AUDIBLE_ALERT_AT_AZ_TARGET){ + if (configuration.audible_alert_enabled_az_target){ audible_alert(AUDIBLE_ALERT_ACTIVATE); } #endif @@ -10930,7 +10993,7 @@ void service_rotation(){ #endif // defined(FEATURE_PARK) && !defined(FEATURE_ELEVATION_CONTROL) #if defined(FEATURE_AUDIBLE_ALERT) - if (AUDIBLE_ALERT_AT_AZ_TARGET){ + if (configuration.audible_alert_enabled_az_target){ audible_alert(AUDIBLE_ALERT_ACTIVATE); } #endif @@ -10963,7 +11026,7 @@ void service_rotation(){ #endif // defined(FEATURE_PARK) && !defined(FEATURE_ELEVATION_CONTROL) #if defined(FEATURE_AUDIBLE_ALERT) - if (AUDIBLE_ALERT_AT_AZ_TARGET){ + if (configuration.audible_alert_enabled_az_target){ audible_alert(AUDIBLE_ALERT_ACTIVATE); } #endif @@ -11116,7 +11179,7 @@ void service_rotation(){ el_request_queue_state = NONE; #if defined(FEATURE_AUDIBLE_ALERT) - if (AUDIBLE_ALERT_AT_EL_TARGET){ + if (configuration.audible_alert_enabled_el_target){ audible_alert(AUDIBLE_ALERT_ACTIVATE); } #endif @@ -11206,7 +11269,7 @@ void service_rotation(){ #endif // DEBUG_SERVICE_ROTATION #if defined(FEATURE_AUDIBLE_ALERT) - if (AUDIBLE_ALERT_AT_EL_TARGET){ + if (configuration.audible_alert_enabled_el_target){ audible_alert(AUDIBLE_ALERT_ACTIVATE); } #endif @@ -11236,7 +11299,7 @@ void service_rotation(){ #endif // DEBUG_SERVICE_ROTATION #if defined(FEATURE_AUDIBLE_ALERT) - if (AUDIBLE_ALERT_AT_EL_TARGET){ + if (configuration.audible_alert_enabled_el_target){ audible_alert(AUDIBLE_ALERT_ACTIVATE); } #endif @@ -15263,6 +15326,89 @@ byte process_backslash_command(byte input_buffer[], int input_buffer_index, byte #endif //FEATURE_SATELLITE_TRACKING + #if defined(FEATURE_AUDIBLE_ALERT) + case '-': // audible alert query and control + if (input_buffer_index == 2){ + control_port->print(F("Audible alerts are ")); + if (configuration.audible_alert_enabled){ + control_port->print(F("en")); + } else { + control_port->print(F("dis")); + } + control_port->println(F("abled.")); + control_port->print(F("AZ target alert: o")); + if (configuration.audible_alert_enabled_az_target){ + control_port->println(F("n.")); + } else { + control_port->println(F("ff.")); + } + control_port->print(F("EL target alert: o")); + if (configuration.audible_alert_enabled_el_target){ + control_port->println(F("n.")); + } else { + control_port->println(F("ff.")); + } + if (configuration.audible_alert_enabled){ + control_port->print(F("Audible alert is o")); + if (audible_alert(AUDIBLE_ALERT_SERVICE)){ + control_port->println(F("n.")); + } else { + control_port->println(F("ff.")); + } + } + } else { + if (input_buffer_index == 3){ + if (input_buffer[2] == '0'){ + configuration.audible_alert_enabled = 0; + configuration_dirty = 1; + control_port->println(F("Audible alerts disabled.")); + } + if (input_buffer[2] == '1'){ + configuration.audible_alert_enabled = 1; + configuration_dirty = 1; + control_port->println(F("Audible alerts enabled.")); + } + if (input_buffer[2] == 'X'){ + audible_alert(AUDIBLE_ALERT_SILENCE); + control_port->println(F("Audible alert silenced.")); + } + if (input_buffer[2] == '~'){ + audible_alert(AUDIBLE_ALERT_MANUAL_ACTIVATE); + control_port->println(F("Audible alert activated.")); + } + } else { + if (input_buffer_index == 4){ + if (input_buffer[2] == 'A'){ + if (input_buffer[3] == '0'){ + configuration.audible_alert_enabled_az_target = 0; + configuration_dirty = 1; + control_port->println(F("AZ target audible alert disabled.")); + } + if (input_buffer[3] == '1'){ + configuration.audible_alert_enabled_az_target = 1; + configuration_dirty = 1; + control_port->println(F("AZ target audible alert enabled.")); + } + } + if (input_buffer[2] == 'E'){ + if (input_buffer[3] == '0'){ + configuration.audible_alert_enabled_el_target = 0; + configuration_dirty = 1; + control_port->println(F("EL target audible alert disabled.")); + } + if (input_buffer[3] == '1'){ + configuration.audible_alert_enabled_el_target = 1; + configuration_dirty = 1; + control_port->println(F("EL target audible alert enabled.")); + } + } + } + + } + } + break; + #endif + // TODO : one big status query command #if !defined(OPTION_SAVE_MEMORY_EXCLUDE_EXTENDED_COMMANDS) @@ -16018,6 +16164,7 @@ Not implemented yet: + // \?CCxxxx xxxx - Convert coordinates to grid if ((input_buffer[2] == 'C') && (input_buffer[3] == 'C')){ diff --git a/k3ng_rotator_controller/rotator.h b/k3ng_rotator_controller/rotator.h index e788f84..d012a9d 100755 --- a/k3ng_rotator_controller/rotator.h +++ b/k3ng_rotator_controller/rotator.h @@ -1,5 +1,5 @@ /*---------------------- macros - don't touch these unless you know what you are doing ---------------------*/ -#define EEPROM_MAGIC_NUMBER 116 +#define EEPROM_MAGIC_NUMBER 117 #define AZ 1 #define EL 2 @@ -172,6 +172,11 @@ #define AUDIBLE_ALERT_SERVICE 0 #define AUDIBLE_ALERT_ACTIVATE 1 +#define AUDIBLE_ALERT_SILENCE 2 +#define AUDIBLE_ALERT_DISABLE 3 +#define AUDIBLE_ALERT_ENABLE 4 +#define AUDIBLE_ALERT_MANUAL_ACTIVATE 5 + // for debugging diff --git a/k3ng_rotator_controller/rotator_pins_test.h b/k3ng_rotator_controller/rotator_pins_test.h index da4bef5..0c898a0 100644 --- a/k3ng_rotator_controller/rotator_pins_test.h +++ b/k3ng_rotator_controller/rotator_pins_test.h @@ -238,10 +238,10 @@ #ifdef FEATURE_AUDIBLE_ALERT - #define pin_audible_alert 0 + #define pin_audible_alert A8 #endif -#define pin_status_led A8 // Status LED - blinks when there is rotation in progress +#define pin_status_led 0 // Status LED - blinks when there is rotation in progress // Added 2020.07.24.01 #define satellite_tracking_active_pin 0 diff --git a/k3ng_rotator_controller/rotator_settings.h b/k3ng_rotator_controller/rotator_settings.h index df7e392..fde1df9 100755 --- a/k3ng_rotator_controller/rotator_settings.h +++ b/k3ng_rotator_controller/rotator_settings.h @@ -307,8 +307,8 @@ You can tweak these, but read the online documentation! #define AUDIBLE_PIN_INACTIVE_STATE LOW #define AUDIBLE_PIN_TONE_FREQ 1000 #define AUDIBLE_ALERT_AT_STARTUP 1 -#define AUDIBLE_ALERT_AT_AZ_TARGET 1 -#define AUDIBLE_ALERT_AT_EL_TARGET 1 +#define AUDIBLE_ALERT_AT_AZ_TARGET 1 // factory default setting +#define AUDIBLE_ALERT_AT_EL_TARGET 1 // factory default setting #define OVERLAP_LED_ACTIVE_STATE HIGH #define OVERLAP_LED_INACTIVE_STATE LOW diff --git a/k3ng_rotator_controller/rotator_settings_test.h b/k3ng_rotator_controller/rotator_settings_test.h index 90c26f6..5d7f6ec 100755 --- a/k3ng_rotator_controller/rotator_settings_test.h +++ b/k3ng_rotator_controller/rotator_settings_test.h @@ -317,8 +317,8 @@ You can tweak these, but read the online documentation! #define AUDIBLE_PIN_INACTIVE_STATE LOW #define AUDIBLE_PIN_TONE_FREQ 1000 #define AUDIBLE_ALERT_AT_STARTUP 1 -#define AUDIBLE_ALERT_AT_AZ_TARGET 1 -#define AUDIBLE_ALERT_AT_EL_TARGET 0 +#define AUDIBLE_ALERT_AT_AZ_TARGET 1 // factory default setting +#define AUDIBLE_ALERT_AT_EL_TARGET 1 // factory default setting #define OVERLAP_LED_ACTIVE_STATE HIGH #define OVERLAP_LED_INACTIVE_STATE LOW