diff --git a/data_embed/index.html b/data_embed/index.html index 46833e0..2b36b5c 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -125,7 +125,7 @@
- +
@@ -139,6 +139,10 @@
+
+ + +
diff --git a/include/preference_storage.h b/include/preference_storage.h index 0ce5548..1d539da 100644 --- a/include/preference_storage.h +++ b/include/preference_storage.h @@ -44,6 +44,9 @@ static const char *const PREF_APRS_SB_MIN_SPEED_PRESET = "sb_min_speed"; static const char *const PREF_APRS_SB_MIN_SPEED_PRESET_INIT = "sb_min_speed_i"; static const char *const PREF_APRS_SB_MAX_SPEED_PRESET = "sb_max_speed"; static const char *const PREF_APRS_SB_MAX_SPEED_PRESET_INIT = "sb_max_speed_i"; +static const char *const PREF_APRS_SB_ANGLE_PRESET = "sb_angle"; +static const char *const PREF_APRS_SB_ANGLE_PRESET_INIT = "sb_angle_i"; + // static const char *const PREF_APRS_GPS_EN = "gps_enabled"; static const char *const PREF_APRS_GPS_EN_INIT = "gps_state_init"; diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index dff2100..35a9328 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -161,6 +161,7 @@ ulong sb_min_interval = 60000L; ulong sb_max_interval = 360000L; float sb_min_speed = 0; float sb_max_speed = 30; +float sb_angle = 30; // angle to send packet at smart beaconing float average_speed[5] = {0,0,0,0,0}, average_speed_final=0; float old_course = 0, new_course = 0; @@ -179,7 +180,7 @@ ulong shutdown_countdown_timer = 0; boolean shutdown_active =true; boolean shutdown_countdown_timer_enable = false; boolean shutdown_usb_status_bef = false; -#define ANGLE 60 // angle to send packet at smart beaconing + #define ANGLE_AVGS 3 // angle averaging - x times float average_course[ANGLE_AVGS]; float avg_c_y, avg_c_x; @@ -640,6 +641,11 @@ void setup(){ } sb_max_speed = preferences.getInt(PREF_APRS_SB_MAX_SPEED_PRESET); + if (!preferences.getBool(PREF_APRS_SB_ANGLE_PRESET_INIT)){ + preferences.putBool(PREF_APRS_SB_ANGLE_PRESET_INIT, true); + preferences.putDouble(PREF_APRS_SB_ANGLE_PRESET, sb_angle); + } + sb_angle = preferences.getDouble(PREF_APRS_SB_ANGLE_PRESET); // if (!preferences.getBool(PREF_DEV_SHOW_RX_TIME_INIT)){ @@ -971,19 +977,18 @@ void loop() { if (new_course < 0) { new_course=360+new_course; } - if ((old_course < ANGLE) && (new_course > (360-ANGLE))) { - if (abs(new_course-old_course-360)>=ANGLE) { - nextTX = 0; - // lastTX = sb_min_interval + if ((old_course < sb_angle) && (new_course > (360-sb_angle))) { + if (abs(new_course-old_course-360)>=sb_angle) { + nextTX = 1; // give one second for turn to finish and then TX } } else { - if ((old_course > (360-ANGLE)) && (new_course < ANGLE)) { - if (abs(new_course-old_course+360)>=ANGLE) { - nextTX = 0; + if ((old_course > (360-sb_angle)) && (new_course < sb_angle)) { + if (abs(new_course-old_course+360)>=sb_angle) { + nextTX = 1; } } else { - if (abs(new_course-old_course)>=ANGLE) { - nextTX = 0; + if (abs(new_course-old_course)>=sb_angle) { + nextTX = 1; } } } diff --git a/src/taskWebServer.cpp b/src/taskWebServer.cpp index 58c03f2..b45f268 100644 --- a/src/taskWebServer.cpp +++ b/src/taskWebServer.cpp @@ -147,6 +147,7 @@ void handle_Cfg() { jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MAX_INTERVAL_PRESET); jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MIN_SPEED_PRESET); jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MAX_SPEED_PRESET); + jsonData += jsonLineFromPreferenceDouble(PREF_APRS_SB_ANGLE_PRESET); jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_BATTERY); jsonData += jsonLineFromPreferenceBool(PREF_APRS_FIXED_BEACON_PRESET); jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_ALTITUDE); @@ -210,6 +211,10 @@ void handle_SaveAPRSCfg() { if (server.hasArg(PREF_APRS_LATITUDE_PRESET)){ preferences.putString(PREF_APRS_LATITUDE_PRESET, server.arg(PREF_APRS_LATITUDE_PRESET)); } + if (server.hasArg(PREF_APRS_LONGITUDE_PRESET)){ + preferences.putString(PREF_APRS_LONGITUDE_PRESET, server.arg(PREF_APRS_LONGITUDE_PRESET)); + } + // Smart Beaconing settings if (server.hasArg(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET)){ preferences.putInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET, server.arg(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET).toInt()); @@ -226,9 +231,8 @@ void handle_SaveAPRSCfg() { if (server.hasArg(PREF_APRS_SB_MAX_SPEED_PRESET)){ preferences.putInt(PREF_APRS_SB_MAX_SPEED_PRESET, server.arg(PREF_APRS_SB_MAX_SPEED_PRESET).toInt()); } - - if (server.hasArg(PREF_APRS_LONGITUDE_PRESET)){ - preferences.putString(PREF_APRS_LONGITUDE_PRESET, server.arg(PREF_APRS_LONGITUDE_PRESET)); + if (server.hasArg(PREF_APRS_SB_ANGLE_PRESET)){ + preferences.putDouble(PREF_APRS_SB_ANGLE_PRESET, server.arg(PREF_APRS_SB_ANGLE_PRESET).toDouble()); } preferences.putBool(PREF_APRS_SHOW_BATTERY, server.hasArg(PREF_APRS_SHOW_BATTERY));