mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Refresh app slots during UV Studio updates
This commit is contained in:
1 parent
7d0f2646f4
commit
fd437ec015
4 files changed
+49
-7
No files matched your search
@@ -1304,6 +1304,8 @@ void UART_HandleCommand(uint32_t Port)
|
|||||||
gSerialConfigCountDown_500ms = 12; // keep serial mode alive (6 s)
|
gSerialConfigCountDown_500ms = 12; // keep serial mode alive (6 s)
|
||||||
uint8_t slot = pUART_Command->Data[0];
|
uint8_t slot = pUART_Command->Data[0];
|
||||||
uint8_t status = APP_ValidateSlot(slot, NULL);
|
uint8_t status = APP_ValidateSlot(slot, NULL);
|
||||||
|
if (status == APP_OK)
|
||||||
|
APP_NotifySlotChanged();
|
||||||
struct __attribute__((packed)) {
|
struct __attribute__((packed)) {
|
||||||
Header_t Header;
|
Header_t Header;
|
||||||
uint8_t Slot;
|
uint8_t Slot;
|
||||||
|
|||||||
+29
-6
@@ -21,6 +21,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "apps/app_menu.h"
|
#include "apps/app_menu.h"
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/uart.h"
|
||||||
#include "driver/backlight.h"
|
#include "driver/backlight.h"
|
||||||
#include "driver/st7565.h"
|
#include "driver/st7565.h"
|
||||||
#include "driver/keyboard.h"
|
#include "driver/keyboard.h"
|
||||||
@@ -80,12 +81,21 @@ static void app_invert_name(uint8_t line)
|
|||||||
/* Debounced blocking key read, then wait for release (mirrors mb_get_key). */
|
/* Debounced blocking key read, then wait for release (mirrors mb_get_key). */
|
||||||
static KEY_Code_t app_get_key(void)
|
static KEY_Code_t app_get_key(void)
|
||||||
{
|
{
|
||||||
|
#if defined(ENABLE_UART) || defined(ENABLE_USB)
|
||||||
|
const uint8_t slot_revision = APP_SlotRevision();
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_FEAT_F4HWN_K5VIEWER
|
#ifdef ENABLE_FEAT_F4HWN_K5VIEWER
|
||||||
/* APP_MenuOpen() is modal and does not return to APP_Update(). Keep
|
/* APP_MenuOpen() is modal and does not return to APP_Update(). Keep
|
||||||
* serial key injection and the viewer connection alive while waiting. */
|
* serial key injection and the viewer connection alive while waiting. */
|
||||||
K5VIEWER_ParseInput();
|
K5VIEWER_ParseInput();
|
||||||
|
#endif
|
||||||
|
#if defined(ENABLE_UART) || defined(ENABLE_USB)
|
||||||
|
UART_ServiceCommands();
|
||||||
|
if (APP_SlotRevision() != slot_revision)
|
||||||
|
return KEY_INVALID;
|
||||||
#endif
|
#endif
|
||||||
APP_ModalBacklightTick(true);
|
APP_ModalBacklightTick(true);
|
||||||
|
|
||||||
@@ -219,6 +229,16 @@ static void app_show_error(const app_header_t *header, uint8_t rc)
|
|||||||
_Static_assert(APP_MENU_SLOT_COUNT <= APP_SLOT_COUNT,
|
_Static_assert(APP_MENU_SLOT_COUNT <= APP_SLOT_COUNT,
|
||||||
"APP_MENU_SLOT_COUNT exceeds the physical app slot count");
|
"APP_MENU_SLOT_COUNT exceeds the physical app slot count");
|
||||||
|
|
||||||
|
static void app_scan_slots(app_header_t hdr[APP_MENU_SLOT_COUNT],
|
||||||
|
bool installed[APP_MENU_SLOT_COUNT])
|
||||||
|
{
|
||||||
|
for (uint8_t slot = 0; slot < APP_MENU_SLOT_COUNT; slot++)
|
||||||
|
{
|
||||||
|
installed[slot] = APP_SlotInfo(slot, &hdr[slot]) == APP_OK &&
|
||||||
|
(hdr[slot].flags & APP_FLAG_COMMITTED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void APP_MenuOpen(void)
|
void APP_MenuOpen(void)
|
||||||
{
|
{
|
||||||
APP_ModalScreenSaverExit();
|
APP_ModalScreenSaverExit();
|
||||||
@@ -238,12 +258,8 @@ void APP_MenuOpen(void)
|
|||||||
* visible and selectable while scrolling. */
|
* visible and selectable while scrolling. */
|
||||||
app_header_t hdr[APP_MENU_SLOT_COUNT];
|
app_header_t hdr[APP_MENU_SLOT_COUNT];
|
||||||
bool installed[APP_MENU_SLOT_COUNT];
|
bool installed[APP_MENU_SLOT_COUNT];
|
||||||
|
uint8_t slot_revision = APP_SlotRevision();
|
||||||
for (uint8_t slot = 0; slot < APP_MENU_SLOT_COUNT; slot++)
|
app_scan_slots(hdr, installed);
|
||||||
{
|
|
||||||
installed[slot] = APP_SlotInfo(slot, &hdr[slot]) == APP_OK &&
|
|
||||||
(hdr[slot].flags & APP_FLAG_COMMITTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remember the physical slot and scrolling window across menu openings. */
|
/* Remember the physical slot and scrolling window across menu openings. */
|
||||||
static uint8_t sel = 0;
|
static uint8_t sel = 0;
|
||||||
@@ -254,6 +270,13 @@ void APP_MenuOpen(void)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
const uint8_t current_revision = APP_SlotRevision();
|
||||||
|
if (current_revision != slot_revision)
|
||||||
|
{
|
||||||
|
app_scan_slots(hdr, installed);
|
||||||
|
slot_revision = current_revision;
|
||||||
|
}
|
||||||
|
|
||||||
UI_DisplayClear();
|
UI_DisplayClear();
|
||||||
app_status_bar(); /* also wipes the VFO status line (DW, battery, ...) */
|
app_status_bar(); /* also wipes the VFO status line (DW, battery, ...) */
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -937,6 +937,18 @@ uint8_t APP_ValidateSlot(uint8_t slot, app_header_t *out_header)
|
|||||||
static bool app_shortcuts_cached;
|
static bool app_shortcuts_cached;
|
||||||
static uint8_t app_shortcut_mask;
|
static uint8_t app_shortcut_mask;
|
||||||
static uint8_t app_shortcut_slots[4];
|
static uint8_t app_shortcut_slots[4];
|
||||||
|
static uint8_t app_slot_revision;
|
||||||
|
|
||||||
|
uint8_t APP_SlotRevision(void)
|
||||||
|
{
|
||||||
|
return app_slot_revision;
|
||||||
|
}
|
||||||
|
|
||||||
|
void APP_NotifySlotChanged(void)
|
||||||
|
{
|
||||||
|
app_shortcuts_cached = false;
|
||||||
|
app_slot_revision++;
|
||||||
|
}
|
||||||
|
|
||||||
static int8_t app_shortcut_index(uint8_t shortcut)
|
static int8_t app_shortcut_index(uint8_t shortcut)
|
||||||
{
|
{
|
||||||
@@ -1238,7 +1250,7 @@ uint8_t APP_SlotErase(uint8_t slot)
|
|||||||
for (uint32_t off = 0; off < APP_SLOT_STRIDE; off += APP_SECTOR_SIZE)
|
for (uint32_t off = 0; off < APP_SLOT_STRIDE; off += APP_SECTOR_SIZE)
|
||||||
PY25Q16_SectorErase(base + off);
|
PY25Q16_SectorErase(base + off);
|
||||||
PY25Q16_InvalidateCache();
|
PY25Q16_InvalidateCache();
|
||||||
app_shortcuts_cached = false;
|
APP_NotifySlotChanged();
|
||||||
return APP_OK;
|
return APP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,5 +131,10 @@ uint8_t APP_SlotInfo(uint8_t slot, app_header_t *out_header);
|
|||||||
uint8_t APP_SlotErase(uint8_t slot);
|
uint8_t APP_SlotErase(uint8_t slot);
|
||||||
uint8_t APP_SlotWrite(uint8_t slot, uint32_t offset, const uint8_t *data, uint32_t len);
|
uint8_t APP_SlotWrite(uint8_t slot, uint32_t offset, const uint8_t *data, uint32_t len);
|
||||||
|
|
||||||
|
/* Change token used by the modal Apps selector. A completed host install is
|
||||||
|
* published after validation; erasing a slot publishes directly. */
|
||||||
|
uint8_t APP_SlotRevision(void);
|
||||||
|
void APP_NotifySlotChanged(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* APPS_APP_OVERLAY_H */
|
#endif /* APPS_APP_OVERLAY_H */
|
||||||
Reference in new issue
Block a user