Apply SetNav in overlay apps and FoxHunt

This commit is contained in:
Armel FAUVEAU committed 2026-08-28 23:43:42 +02:00
1 parent f4811cbe1e
commit 9d6b560a54
6 files changed
+49 -17

No files matched your search

+14 -7
View File
@@ -608,6 +608,16 @@ static void FOXHUNT_AttCycle(int8_t dir)
FOXHUNT_RebaseMeasurements();
}
// Convert the two navigation keys into the same semantic value direction used
// by the resident menus and by the overlay FoxHunt app:
// UV-K5 UP/DOWN -> +1/-1
// UV-K1 LEFT/RIGHT -> -1/+1
static int8_t FOXHUNT_NavDirection(KEY_Code_t key)
{
int8_t direction = (key == KEY_UP) ? 1 : -1;
return gEeprom.SET_NAV ? direction : -direction;
}
// Fox identifier: MOE -> MOI -> MOS -> MOH -> MO5 -> MO -> CALL (F reverses).
static void FOXHUNT_FoxCycle(int8_t dir)
{
@@ -734,8 +744,8 @@ static void FOXHUNT_HandleKeys(void)
// released only by the long-press F handled above. Keeping ATT reachable is the whole
// point: on the final approach the sensitivity still has to be pulled down by hand.
if (foxLocked) {
if (kbd.current == KEY_UP) FOXHUNT_AttCycle(+1); // more attenuation
if (kbd.current == KEY_DOWN) FOXHUNT_AttCycle(-1); // less attenuation
if (kbd.current == KEY_UP || kbd.current == KEY_DOWN)
FOXHUNT_AttCycle(FOXHUNT_NavDirection(kbd.current));
return;
}
@@ -765,12 +775,9 @@ static void FOXHUNT_HandleKeys(void)
FOXHUNT_AttCycle(dir);
break;
case KEY_UP:
// Attenuation up one step (also the locked-mode control).
FOXHUNT_AttCycle(+1);
break;
case KEY_DOWN:
// Attenuation down one step.
FOXHUNT_AttCycle(-1);
// Follow SetNav: UP/DOWN on K5, LEFT/RIGHT on K1.
FOXHUNT_AttCycle(FOXHUNT_NavDirection(kbd.current));
break;
case KEY_MENU:
// Reset the peak / min hold and the trend reference (before each body scan).
+9 -2
View File
@@ -36,11 +36,11 @@
#include <stdint.h>
#include <stdbool.h>
/* ABI 2: the table below (v1 core + the fields once labelled "v2 additions") is a
/* ABI 3: the table below (v1 core + the fields once labelled "v2 additions") is a
* single versioned layout. Any change to app_api_t - a reorder, a removal, or an
* append - MUST bump this. Keep in sync with ABI_VERSION in pack_app.py, which
* stamps the blob the loader checks against. */
#define APP_ABI_VERSION 2u
#define APP_ABI_VERSION 3u
/* KEY codes mirrored from driver/keyboard.h (enum KEY_Code_e). Kept in sync by
* value so the app stays independent of the firmware headers. */
@@ -167,6 +167,13 @@ typedef struct app_api {
uint16_t *fm_channels; /* -> gFM_Channels[APP_FM_CH_MAX], shared RAM r/w */
void (*fm_state)(app_fm_state_t *s, bool write);/* read/write the resident gEeprom.FM_* */
void (*fm_commit)(void); /* deferred SETTINGS_SaveFM (config + channels) */
/* ---- navigation (ABI 3) ----
* Convert a raw APP_KEY_UP/DOWN into a semantic value direction:
* UV-K5 UP/DOWN -> +1/-1
* UV-K1 LEFT/RIGHT -> -1/+1
* Returns 0 for any other key. Keep get_key() raw for spatial controls. */
int8_t (*nav_dir)(uint8_t key);
} app_api_t;
/* BK4819 AF modes for set_af (mirror driver/bk4819.h values). */
+14
View File
@@ -60,6 +60,19 @@ static uint32_t app_crc32(const uint8_t *p, uint32_t len)
static void app_display_clear(void) { UI_DisplayClear(); }
static void app_status_clear(void) { UI_StatusClear(); }
static uint8_t app_get_key(void) { return (uint8_t)KEYBOARD_GetKey(); }
static int8_t app_nav_dir(uint8_t key)
{
int8_t direction;
if (key == KEY_UP)
direction = 1;
else if (key == KEY_DOWN)
direction = -1;
else
return 0;
return gEeprom.SET_NAV ? direction : -direction;
}
static void app_led(bool on) { BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, on); }
static void app_play_tone(uint16_t tone, uint16_t ms)
@@ -320,6 +333,7 @@ uint8_t APP_LaunchOverlay(uint8_t slot)
.fm_state = app_fm_state,
.fm_commit = app_fm_commit,
#endif
.nav_dir = app_nav_dir,
};
app_run_slot = slot; /* for cfg_load / cfg_save */
+2 -2
View File
@@ -281,8 +281,8 @@ static void onShort(uint8_t key)
if(fArm){ fArm=false; func(key); return; } /* F + key */
if(key<=APP_KEY_9){ digit(key); return; }
switch(key){
case APP_KEY_UP: upDown(+1); break;
case APP_KEY_DOWN: upDown(-1); break;
case APP_KEY_UP:
case APP_KEY_DOWN: upDown(A->nav_dir(key)); break;
case APP_KEY_STAR: startManual(+1); break;
case APP_KEY_MENU: menu(); break;
case APP_KEY_EXIT:
+3 -4
View File
@@ -285,8 +285,7 @@ static void handleKeys(void){
A->backlight_on();
if(foxLocked){
if(key==APP_KEY_UP) attCycle(+1);
if(key==APP_KEY_DOWN) attCycle(-1);
if(key==APP_KEY_UP||key==APP_KEY_DOWN) attCycle(A->nav_dir(key));
return;
}
if(key==APP_KEY_F){ fArm=!fArm; return; }
@@ -300,8 +299,8 @@ static void handleKeys(void){
if(foxAudioMode==AUDIO_BEEP){ audioTick=RATE_SLOW; }
break;
case APP_KEY_3: attCycle(dir); break;
case APP_KEY_UP: attCycle(+1); break;
case APP_KEY_DOWN: attCycle(-1); break;
case APP_KEY_UP:
case APP_KEY_DOWN: attCycle(A->nav_dir(key)); break;
case APP_KEY_MENU: peakDbm=minDbm=trendRef=curDbm; break;
default: break;
}
+7 -2
View File
@@ -147,8 +147,13 @@ void app_main(const app_api_t *api)
A->backlight_on();
switch (key) {
case APP_KEY_EXIT: running = false; break;
case APP_KEY_UP: if (speed < 8u) speed++; break;
case APP_KEY_DOWN: if (speed > 1u) speed--; break;
case APP_KEY_UP:
case APP_KEY_DOWN: {
const int8_t direction = A->nav_dir(key);
if (direction > 0 && speed < 8u) speed++;
if (direction < 0 && speed > 1u) speed--;
break;
}
case APP_KEY_MENU: paused = !paused; break;
case APP_KEY_STAR: bands = !bands; break;
case APP_KEY_F: autoc = !autoc; break;