mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Optimize FoxHunt Flash usage
This commit is contained in:
1 parent
b0143f9f9c
commit
3f958f637d
3 files changed
+35
-56
No files matched your search
+6
-22
@@ -26,6 +26,8 @@
|
|||||||
#include "k5viewer.h"
|
#include "k5viewer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "ui/status.h"
|
||||||
|
|
||||||
// Signal window mapped onto the RSSI bar, in dBm.
|
// Signal window mapped onto the RSSI bar, in dBm.
|
||||||
// Roughly S0 (empty) to S9 + 40 dB (full), IARU VHF/UHF scale.
|
// Roughly S0 (empty) to S9 + 40 dB (full), IARU VHF/UHF scale.
|
||||||
#define FOXHUNT_DBM_FLOOR (-141)
|
#define FOXHUNT_DBM_FLOOR (-141)
|
||||||
@@ -439,24 +441,6 @@ static void FOXHUNT_DrawRightSmall(const char *s, uint8_t rightX, uint8_t line)
|
|||||||
UI_PrintStringSmallNormal(s, (uint8_t)(rightX - strlen(s) * 7), 0, line);
|
UI_PrintStringSmallNormal(s, (uint8_t)(rightX - strlen(s) * 7), 0, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Battery icon plus the optional voltage/percentage text, top-right of the status
|
|
||||||
// line — shared by the hunt and beacon screens.
|
|
||||||
static void FOXHUNT_DrawStatusBattery(void)
|
|
||||||
{
|
|
||||||
unsigned int bx = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1);
|
|
||||||
UI_DrawBattery(gStatusLine + bx, gBatteryDisplayLevel, gLowBatteryBlink);
|
|
||||||
if (gSetting_battery_text != 0) {
|
|
||||||
if (gSetting_battery_text == 1) { // voltage
|
|
||||||
const uint16_t v = MIN(gBatteryVoltageAverage, 999);
|
|
||||||
sprintf(str, "%u.%02u", v / 100, v % 100);
|
|
||||||
} else { // percentage
|
|
||||||
sprintf(str, "%02u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
|
||||||
}
|
|
||||||
bx -= 7 * strlen(str);
|
|
||||||
UI_PrintStringSmallBufferNormal(str, gStatusLine + bx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Right-aligned frequency on the bottom line (line 6), shared by the hunt and
|
// Right-aligned frequency on the bottom line (line 6), shared by the hunt and
|
||||||
// beacon screens.
|
// beacon screens.
|
||||||
static void FOXHUNT_DrawFreqBR(uint32_t freq)
|
static void FOXHUNT_DrawFreqBR(uint32_t freq)
|
||||||
@@ -472,7 +456,7 @@ static void FOXHUNT_BeaconChrome(void)
|
|||||||
UI_DisplayClear();
|
UI_DisplayClear();
|
||||||
UI_StatusClear();
|
UI_StatusClear();
|
||||||
GUI_DisplaySmallestInverse("BEACON", 2, 0, true, true, 26);
|
GUI_DisplaySmallestInverse("BEACON", 2, 0, true, true, 26);
|
||||||
FOXHUNT_DrawStatusBattery();
|
UI_DrawStatusBattery(gStatusLine, str);
|
||||||
FOXHUNT_DrawFKey();
|
FOXHUNT_DrawFKey();
|
||||||
FOXHUNT_DrawFreqBR(gTxVfo->pTX->Frequency);
|
FOXHUNT_DrawFreqBR(gTxVfo->pTX->Frequency);
|
||||||
}
|
}
|
||||||
@@ -490,7 +474,7 @@ static void FOXHUNT_Draw(void)
|
|||||||
GUI_DisplaySmallestInverse("FOX HUNT", 2, 0, true, true, 34);
|
GUI_DisplaySmallestInverse("FOX HUNT", 2, 0, true, true, 34);
|
||||||
|
|
||||||
// Battery (icon + optional percentage/voltage) top-right, as on the main screens.
|
// Battery (icon + optional percentage/voltage) top-right, as on the main screens.
|
||||||
FOXHUNT_DrawStatusBattery();
|
UI_DrawStatusBattery(gStatusLine, str);
|
||||||
FOXHUNT_DrawFKey();
|
FOXHUNT_DrawFKey();
|
||||||
|
|
||||||
// Gauge-mode icon (2 key), between the label and the audio icon: ascending
|
// Gauge-mode icon (2 key), between the label and the audio icon: ascending
|
||||||
@@ -571,7 +555,7 @@ static void FOXHUNT_Draw(void)
|
|||||||
// the burst end, fox at the next repeat), so cycling any of them is safe at any time.
|
// the burst end, fox at the next repeat), so cycling any of them is safe at any time.
|
||||||
|
|
||||||
// Wrap a 0..count-1 index one step forward (dir > 0) or backward, both ways round.
|
// Wrap a 0..count-1 index one step forward (dir > 0) or backward, both ways round.
|
||||||
static uint8_t FOXHUNT_WrapStep(uint8_t v, uint8_t count, int8_t dir)
|
static __attribute__((noinline)) uint8_t FOXHUNT_WrapStep(uint8_t v, uint8_t count, int8_t dir)
|
||||||
{
|
{
|
||||||
return (uint8_t)((v + (dir > 0 ? 1u : (unsigned)(count - 1u))) % count);
|
return (uint8_t)((v + (dir > 0 ? 1u : (unsigned)(count - 1u))) % count);
|
||||||
}
|
}
|
||||||
@@ -1317,7 +1301,7 @@ static void FOXHUNT_BeaconTick(void)
|
|||||||
static uint8_t foxCfgSaved[FOXHUNT_CFG_LEN];
|
static uint8_t foxCfgSaved[FOXHUNT_CFG_LEN];
|
||||||
|
|
||||||
// Pack the live settings into the on-flash layout.
|
// Pack the live settings into the on-flash layout.
|
||||||
static void FOXHUNT_ConfigPack(uint8_t out[FOXHUNT_CFG_LEN])
|
static __attribute__((noinline)) void FOXHUNT_ConfigPack(uint8_t out[FOXHUNT_CFG_LEN])
|
||||||
{
|
{
|
||||||
out[0] = FOXHUNT_CFG_MAGIC;
|
out[0] = FOXHUNT_CFG_MAGIC;
|
||||||
out[1] = attStep;
|
out[1] = attStep;
|
||||||
|
|||||||
+24
-33
@@ -54,6 +54,29 @@ static void convertTime(uint8_t *line, uint8_t type)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_FEAT_F4HWN_FOXHUNT
|
||||||
|
void UI_DrawStatusBattery(uint8_t *line, char *str)
|
||||||
|
#else
|
||||||
|
static __attribute__((always_inline)) inline void UI_DrawStatusBattery(uint8_t *line, char *str)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
unsigned int x = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1);
|
||||||
|
|
||||||
|
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink);
|
||||||
|
|
||||||
|
if (gSetting_battery_text == 1) {
|
||||||
|
const uint16_t voltage = MIN(gBatteryVoltageAverage, 999);
|
||||||
|
sprintf(str, "%u.%02u", voltage / 100, voltage % 100);
|
||||||
|
} else if (gSetting_battery_text == 2) {
|
||||||
|
sprintf(str, "%02u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x -= 7 * strlen(str);
|
||||||
|
UI_PrintStringSmallBufferNormal(str, line + x);
|
||||||
|
}
|
||||||
|
|
||||||
void UI_DisplayStatus()
|
void UI_DisplayStatus()
|
||||||
{
|
{
|
||||||
gUpdateStatus = false;
|
gUpdateStatus = false;
|
||||||
@@ -314,39 +337,7 @@ void UI_DisplayStatus()
|
|||||||
memcpy(line + x + 1, src, size);
|
memcpy(line + x + 1, src, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Battery
|
UI_DrawStatusBattery(line, str);
|
||||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0;
|
|
||||||
|
|
||||||
UI_DrawBattery(line + x2, gBatteryDisplayLevel, gLowBatteryBlink);
|
|
||||||
|
|
||||||
switch (gSetting_battery_text) {
|
|
||||||
default:
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // voltage
|
|
||||||
case 2: // percentage
|
|
||||||
if (gSetting_battery_text == 1) {
|
|
||||||
const uint16_t voltage = MIN(gBatteryVoltageAverage, 999); // limit to 9.99V
|
|
||||||
sprintf(str, "%u.%02u", voltage / 100, voltage % 100);
|
|
||||||
} else {
|
|
||||||
//gBatteryVoltageAverage = 999;
|
|
||||||
sprintf(str, "%02u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
|
||||||
}
|
|
||||||
|
|
||||||
x2 -= (7 * strlen(str));
|
|
||||||
UI_PrintStringSmallBufferNormal(str, line + x2);
|
|
||||||
/*
|
|
||||||
uint8_t shift = (strlen(str) < 5) ? 92 : 88;
|
|
||||||
GUI_DisplaySmallest(str, shift, 1, true, true);
|
|
||||||
|
|
||||||
for (uint8_t i = shift - 2; i < 110; i++) {
|
|
||||||
gStatusLine[i] ^= 0x7F; // invert
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// **************
|
// **************
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -17,7 +17,11 @@
|
|||||||
#ifndef UI_STATUS_H
|
#ifndef UI_STATUS_H
|
||||||
#define UI_STATUS_H
|
#define UI_STATUS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef ENABLE_FEAT_F4HWN_FOXHUNT
|
||||||
|
void UI_DrawStatusBattery(uint8_t *line, char *str);
|
||||||
|
#endif
|
||||||
void UI_DisplayStatus();
|
void UI_DisplayStatus();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Reference in new issue
Block a user