Add gauge

This commit is contained in:
Armel FAUVEAU
2024-12-23 05:02:56 +01:00
parent 2006ef9820
commit b4099fc1e7
5 changed files with 30 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ bandscope() {
ENABLE_AIRCOPY=1 \
ENABLE_NOAA=0 \
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
ENABLE_FEAT_F4HWN_CHARGING_C=0 \
EDITION_STRING=Bandscope \
TARGET=f4hwn.bandscope \
&& cp f4hwn.bandscope* compiled-firmware/"

View File

@@ -219,6 +219,25 @@ uint8_t cmds[] = {
ST7565_Cmd(i);
}
}
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void ST7565_Gauge(uint8_t line, uint8_t min, uint8_t max, uint8_t value)
{
gFrameBuffer[line][54] = 0x0c;
gFrameBuffer[line][55] = 0x12;
gFrameBuffer[line][121] = 0x12;
gFrameBuffer[line][122] = 0x0c;
uint8_t filled = map(value, min, max, 56, 120);
for (uint8_t i = 56; i <= 120; i++) {
gFrameBuffer[line][i] = (i <= filled) ? 0x2d : 0x21;
}
}
#endif
void ST7565_Init(void)

View File

@@ -43,6 +43,8 @@ void ST7565_WriteByte(uint8_t Value);
#ifdef ENABLE_FEAT_F4HWN
void ST7565_ContrastAndInv(void);
void ST7565_Gauge(uint8_t line, uint8_t min, uint8_t max, uint8_t value);
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max);
#endif
#endif

View File

@@ -53,10 +53,6 @@ center_line_t center_line = CENTER_LINE_NONE;
bool isMainOnlyInputDTMF = false;
static int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
static bool isMainOnly()
{
return (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) && (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF);

View File

@@ -706,6 +706,7 @@ void UI_DisplayMenu(void)
else if(gSubMenuSelection < 61)
{
sprintf(String, "%02dm:%02ds", (((gSubMenuSelection) * 5) / 60), (((gSubMenuSelection) * 5) % 60));
ST7565_Gauge(4, 1, 60, gSubMenuSelection);
}
else
{
@@ -735,7 +736,10 @@ void UI_DisplayMenu(void)
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
else
{
sprintf(String, "%02dm:%02ds", ((gSubMenuSelection * 15) / 60), ((gSubMenuSelection * 15) % 60));
ST7565_Gauge(4, 1, 40, gSubMenuSelection);
}
break;
case MENU_COMPAND:
@@ -849,6 +853,7 @@ void UI_DisplayMenu(void)
case MENU_TOT:
sprintf(String, "%02dm:%02ds", (((gSubMenuSelection + 1) * 5) / 60), (((gSubMenuSelection + 1) * 5) % 60));
ST7565_Gauge(4, 5, 180, gSubMenuSelection);
break;
#ifdef ENABLE_VOICE
@@ -865,10 +870,12 @@ void UI_DisplayMenu(void)
else if(gSubMenuSelection < 81)
{
sprintf(String, "CARRIER\n%02ds:%03dms", ((gSubMenuSelection * 250) / 1000), ((gSubMenuSelection * 250) % 1000));
ST7565_Gauge(5, 1, 80, gSubMenuSelection);
}
else
{
sprintf(String, "TIMEOUT\n%02dm:%02ds", (((gSubMenuSelection - 80) * 5) / 60), (((gSubMenuSelection - 80) * 5) % 60));
ST7565_Gauge(5, 80, 104, gSubMenuSelection);
}
break;
@@ -1020,6 +1027,7 @@ void UI_DisplayMenu(void)
else if(gSubMenuSelection < 121)
{
sprintf(String, "%dh:%02dm", (gSubMenuSelection / 60), (gSubMenuSelection % 60));
ST7565_Gauge(4, 1, 120, gSubMenuSelection);
}
break;
#endif