diff --git a/Makefile b/Makefile index 341524d..e16ea2e 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ # Compiler options here. ifeq ($(USE_OPT),) - USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage -# USE_OPT = -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage +# USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage + USE_OPT = -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage endif # C specific options here (added to USE_OPT). diff --git a/nanovna.h b/nanovna.h index 8dbdef0..fd0eefc 100644 --- a/nanovna.h +++ b/nanovna.h @@ -121,7 +121,7 @@ void load_default_properties(void); extern float perform(bool b, int i, int32_t f, int e); enum { - AV_OFF, AV_MIN, AV_MAX, AV_2, AV_4, AV_8 + AV_OFF, AV_MIN, AV_MAX_HOLD, AV_MAX_DECAY, AV_4, AV_16 }; enum { M_LOW, M_HIGH, M_GENLOW, M_GENHIGH, diff --git a/sa_core.c b/sa_core.c index a4720aa..646bf2e 100644 --- a/sa_core.c +++ b/sa_core.c @@ -511,6 +511,8 @@ int avoid_spur(int f) static int modulation_counter = 0; +char age[POINTS_COUNT]; + float perform(bool break_on_operation, int i, int32_t f, int tracking) { // long local_IF = (MODE_LOW(setting_mode)?frequency_IF + (int)(actual_rbw < 300.0?setting_spur * 1000 * actual_rbw :0):0); @@ -594,15 +596,26 @@ static bool sweep(bool break_on_operation) RSSI = RSSI - stored_t[i] ; } // stored_t[i] = (SI4432_Read_Byte(0x69) & 0x0f) * 3.0 - 90.0; // Display the AGC value in thestored trace - if (scandirty || setting_average == AV_OFF) + if (scandirty || setting_average == AV_OFF) { actual_t[i] = RSSI; - else { + age[i] = 0; + } else { switch(setting_average) { - case AV_MIN: if (actual_t[i] > RSSI) actual_t[i] = RSSI; break; - case AV_MAX: if (actual_t[i] < RSSI) actual_t[i] = RSSI; break; - case AV_2: actual_t[i] = (actual_t[i] + RSSI) / 2.0; break; - case AV_4: actual_t[i] = (actual_t[i]*3 + RSSI) / 4.0; break; - case AV_8: actual_t[i] = (actual_t[i]*7 + RSSI) / 8.0; break; + case AV_MIN: if (actual_t[i] > RSSI) actual_t[i] = RSSI; break; + case AV_MAX_HOLD: if (actual_t[i] < RSSI) actual_t[i] = RSSI; break; + case AV_MAX_DECAY: + if (actual_t[i] < RSSI) { + actual_t[i] = RSSI; + age[i] = 0; + } else { + if (age[i] > 20) + actual_t[i] -= 0.5; + else + age[i] += 1; + } + break; + case AV_4: actual_t[i] = (actual_t[i] + RSSI) / 4.0; break; + case AV_16: actual_t[i] = (actual_t[i]*3 + RSSI) / 16.0; break; } } if (frequencies[i] > 1000000) { diff --git a/ui_sa.c b/ui_sa.c index d9d5eb6..d997f30 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -593,12 +593,12 @@ const menuitem_t menu_highoutputmode[] = { }; static const menuitem_t menu_average[] = { - { MT_CALLBACK, 0, "OFF", menu_average_cb}, - { MT_CALLBACK, 0, "MIN", menu_average_cb}, - { MT_CALLBACK, 0, "MAX", menu_average_cb}, - { MT_CALLBACK, 0, " 2 ", menu_average_cb}, + { MT_CALLBACK, 0, " OFF", menu_average_cb}, + { MT_CALLBACK, 0, "\2 MIN\0 HOLD", menu_average_cb}, + { MT_CALLBACK, 0, "\2 MAX\0 HOLD", menu_average_cb}, + { MT_CALLBACK, 0, "\2 MAX\0 DECAY", menu_average_cb}, { MT_CALLBACK, 0, " 4 ", menu_average_cb}, - { MT_CALLBACK, 0, " 8 ", menu_average_cb}, + { MT_CALLBACK, 0, " 16 ", menu_average_cb}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel };