mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Battery symbol fix
This commit is contained in:
parent
b385b53af0
commit
2790873d87
@ -1681,11 +1681,9 @@ void cancelUserInputModes(void)
|
||||
{
|
||||
gKeyInputCountdown = 0;
|
||||
|
||||
if (gDTMF_InputMode || gDTMF_InputBox_Index > 0)
|
||||
// if (gDTMF_InputMode || gInputBoxIndex > 0)
|
||||
if (gDTMF_InputMode || gDTMF_InputBox_Index > 0 || gInputBoxIndex > 0)
|
||||
{
|
||||
DTMF_clear_input_box();
|
||||
gDTMF_PreviousIndex = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
@ -526,7 +526,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
if (bKeyHeld && bKeyPressed)
|
||||
{ // exit key held down
|
||||
|
||||
if (gInputBoxIndex > 0)
|
||||
if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || gDTMF_InputMode)
|
||||
{ // cancel key input mode (channel/frequency entry)
|
||||
gDTMF_InputMode = false;
|
||||
gDTMF_InputBox_Index = 0;
|
||||
|
40
app/menu.c
40
app/menu.c
@ -194,6 +194,14 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MENU_SIDE1_SHORT:
|
||||
case MENU_SIDE1_LONG:
|
||||
case MENU_SIDE2_SHORT:
|
||||
case MENU_SIDE2_LONG:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(gSubMenu_SIDE_BUTT) - 1;
|
||||
break;
|
||||
|
||||
case MENU_RESET:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(gSubMenu_RESET) - 1;
|
||||
@ -722,6 +730,22 @@ void MENU_AcceptSetting(void)
|
||||
gFlagResetVfos = true;
|
||||
return;
|
||||
|
||||
case MENU_SIDE1_SHORT:
|
||||
gEeprom.KEY_1_SHORT_PRESS_ACTION = gSubMenuSelection;
|
||||
break;
|
||||
|
||||
case MENU_SIDE1_LONG:
|
||||
gEeprom.KEY_1_LONG_PRESS_ACTION = gSubMenuSelection;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_SHORT:
|
||||
gEeprom.KEY_2_SHORT_PRESS_ACTION = gSubMenuSelection;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_LONG:
|
||||
gEeprom.KEY_2_LONG_PRESS_ACTION = gSubMenuSelection;
|
||||
break;
|
||||
|
||||
case MENU_RESET:
|
||||
BOARD_FactoryReset(gSubMenuSelection);
|
||||
return;
|
||||
@ -1115,6 +1139,22 @@ void MENU_ShowCurrentSetting(void)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case MENU_SIDE1_SHORT:
|
||||
gSubMenuSelection = gEeprom.KEY_1_SHORT_PRESS_ACTION;
|
||||
break;
|
||||
|
||||
case MENU_SIDE1_LONG:
|
||||
gSubMenuSelection = gEeprom.KEY_1_LONG_PRESS_ACTION;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_SHORT:
|
||||
gSubMenuSelection = gEeprom.KEY_2_SHORT_PRESS_ACTION;
|
||||
break;
|
||||
|
||||
case MENU_SIDE2_LONG:
|
||||
gSubMenuSelection = gEeprom.KEY_2_LONG_PRESS_ACTION;
|
||||
break;
|
||||
|
||||
case MENU_350TX:
|
||||
gSubMenuSelection = gSetting_350TX;
|
||||
break;
|
||||
|
10
bitmaps.c
10
bitmaps.c
@ -53,15 +53,9 @@ const uint8_t BITMAP_RX[8] =
|
||||
0b00000000
|
||||
};
|
||||
|
||||
const uint8_t BITMAP_BatteryLevel[2] =
|
||||
{
|
||||
0b01011101,
|
||||
0b01011101
|
||||
};
|
||||
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
// Quansheng way (+ pole to the left)
|
||||
const uint8_t BITMAP_BatteryLevel1[17] =
|
||||
const uint8_t BITMAP_BATTERY_LEVEL[17] =
|
||||
{
|
||||
0b00000000,
|
||||
0b00111110,
|
||||
@ -83,7 +77,7 @@ const uint8_t BITMAP_BatteryLevel[2] =
|
||||
};
|
||||
#else
|
||||
// reversed (+ pole to the right)
|
||||
const uint8_t BITMAP_BatteryLevel1[17] =
|
||||
const uint8_t BITMAP_BATTERY_LEVEL[17] =
|
||||
{
|
||||
0b00000000,
|
||||
0b01111111,
|
||||
|
@ -8,12 +8,7 @@ extern const uint8_t BITMAP_POWERSAVE[8];
|
||||
extern const uint8_t BITMAP_TX[8];
|
||||
extern const uint8_t BITMAP_RX[8];
|
||||
|
||||
extern const uint8_t BITMAP_BatteryLevel[2];
|
||||
extern const uint8_t BITMAP_BatteryLevel1[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel2[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel3[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel4[17];
|
||||
extern const uint8_t BITMAP_BatteryLevel5[17];
|
||||
extern const uint8_t BITMAP_BATTERY_LEVEL[17];
|
||||
|
||||
extern const uint8_t BITMAP_USB_C[9];
|
||||
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
5
misc.c
5
misc.c
@ -101,6 +101,11 @@ uint8_t gSetting_backlight_on_tx_rx;
|
||||
bool gSetting_live_DTMF_decoder;
|
||||
uint8_t gSetting_battery_text;
|
||||
|
||||
uint8_t gSetting_side1_short;
|
||||
uint8_t gSetting_side1_long;
|
||||
uint8_t gSetting_side2_short;
|
||||
uint8_t gSetting_side2_long;
|
||||
|
||||
bool gMonitor = false; // true opens the squelch
|
||||
|
||||
uint32_t gCustomAesKey[4];
|
||||
|
5
misc.h
5
misc.h
@ -174,6 +174,11 @@ extern uint8_t gSetting_backlight_on_tx_rx;
|
||||
extern bool gSetting_live_DTMF_decoder;
|
||||
extern uint8_t gSetting_battery_text;
|
||||
|
||||
extern uint8_t gSetting_side1_short;
|
||||
extern uint8_t gSetting_side1_long;
|
||||
extern uint8_t gSetting_side2_short;
|
||||
extern uint8_t gSetting_side2_long;
|
||||
|
||||
extern bool gMonitor;
|
||||
|
||||
extern const uint32_t gDefaultAesKey[4];
|
||||
|
21
settings.c
21
settings.c
@ -74,8 +74,7 @@ void SETTINGS_SaveVfoIndices(void)
|
||||
|
||||
void SETTINGS_SaveSettings(void)
|
||||
{
|
||||
uint8_t State[8];
|
||||
uint32_t Password[2];
|
||||
uint8_t State[8];
|
||||
|
||||
State[0] = gEeprom.CHAN_1_CALL;
|
||||
State[1] = gEeprom.SQUELCH_LEVEL;
|
||||
@ -116,11 +115,19 @@ void SETTINGS_SaveSettings(void)
|
||||
State[7] = gEeprom.POWER_ON_DISPLAY_MODE;
|
||||
EEPROM_WriteBuffer(0x0E90, State);
|
||||
|
||||
memset(Password, 0xFF, sizeof(Password));
|
||||
#ifdef ENABLE_PWRON_PASSWORD
|
||||
Password[0] = gEeprom.POWER_ON_PASSWORD;
|
||||
#endif
|
||||
EEPROM_WriteBuffer(0x0E98, Password);
|
||||
{
|
||||
struct {
|
||||
uint32_t password;
|
||||
uint32_t spare;
|
||||
} __attribute__((packed)) array;
|
||||
|
||||
memset(&array, 0xff, sizeof(array));
|
||||
#ifdef ENABLE_PWRON_PASSWORD
|
||||
array.password = gEeprom.POWER_ON_PASSWORD;
|
||||
#endif
|
||||
|
||||
EEPROM_WriteBuffer(0x0E98, &array);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
memset(State, 0xFF, sizeof(State));
|
||||
|
73
ui/battery.c
73
ui/battery.c
@ -22,66 +22,31 @@
|
||||
#include "functions.h"
|
||||
#include "ui/battery.h"
|
||||
|
||||
void UI_DisplayBattery(const uint8_t level, const uint8_t blink)
|
||||
void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
||||
{
|
||||
// if (gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
||||
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
|
||||
if (level >= 1)
|
||||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
|
||||
|
||||
#if 1
|
||||
|
||||
if (level >= 2)
|
||||
unsigned int i;
|
||||
const uint8_t bars = (level <= 5) - 1 ? level - 1 : 5 - 1;
|
||||
for (i = 0; i < bars; i++)
|
||||
{
|
||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
uint8_t *pb = bitmap + sizeof(BITMAP_BatteryLevel1);
|
||||
if (level >= 2)
|
||||
memmove(pb - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 5)
|
||||
memmove(pb - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 7)
|
||||
memmove(pb - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 9)
|
||||
memmove(pb - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
|
||||
#else
|
||||
if (level >= 2)
|
||||
memmove(bitmap + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 5)
|
||||
memmove(bitmap + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 7)
|
||||
memmove(bitmap + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
if (level >= 9)
|
||||
memmove(bitmap + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
bitmap[3 + (i * 3) + 0] = 0b01011101;
|
||||
bitmap[3 + (i * 3) + 1] = 0b01011101;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if (blink == 1)
|
||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
else
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
#else
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
const uint8_t lev = (level <= 11) ? level : 11;
|
||||
|
||||
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
|
||||
#ifdef ENABLE_REVERSE_BAT_SYMBOL
|
||||
for (uint8_t i = 0; i < lev; i++)
|
||||
bitmap[3 + i] = (i & 1u) ? 0b01011101 : 0b01011101;
|
||||
#else
|
||||
for (uint8_t i = 0; i < lev; i++)
|
||||
bitmap[sizeof(bitmap) - 3 - i] = (i & 1u) ? 0b01011101 : 0b01011101;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
#endif
|
||||
|
||||
// col lne, siz, bm
|
||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||
}
|
||||
else
|
||||
if (blink == 0)
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
// col lne, siz, bm
|
||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void UI_DisplayBattery(const uint8_t Level, const uint8_t blink);
|
||||
void UI_DisplayBattery(const unsigned int Level, const unsigned int blink);
|
||||
|
||||
#endif
|
||||
|
||||
|
24
ui/menu.c
24
ui/menu.c
@ -115,6 +115,10 @@ const t_menu_item MenuList[] =
|
||||
#ifdef ENABLE_NOAA
|
||||
{"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S },
|
||||
#endif
|
||||
{"SIDE1S", VOICE_ID_INVALID, MENU_SIDE1_SHORT },
|
||||
{"SIDE1L", VOICE_ID_INVALID, MENU_SIDE1_LONG },
|
||||
{"SIDE2S", VOICE_ID_INVALID, MENU_SIDE2_SHORT },
|
||||
{"SIDE2L", VOICE_ID_INVALID, MENU_SIDE2_LONG },
|
||||
{"RESET", VOICE_ID_INITIALISATION, MENU_RESET }, // might be better to move this to the hidden menu items ?
|
||||
|
||||
// hidden menu items from here on
|
||||
@ -332,6 +336,19 @@ const char gSubMenu_SCRAMBLER[11][7] =
|
||||
"3500Hz"
|
||||
};
|
||||
|
||||
const char gSubMenu_SIDE_BUTT[9][16] =
|
||||
{
|
||||
"NONE",
|
||||
"FLASH\nLIGHT",
|
||||
"TX\nPOWER",
|
||||
"MONITOR",
|
||||
"SCAN\non\\off",
|
||||
"VOX\non\\off",
|
||||
"ALARM\non\\off",
|
||||
"FM RADIO\non\\off",
|
||||
"TX\n1750Hz"
|
||||
};
|
||||
|
||||
bool gIsInSubMenu;
|
||||
uint8_t gMenuCursor;
|
||||
int8_t gMenuScrollDirection;
|
||||
@ -779,6 +796,13 @@ void UI_DisplayMenu(void)
|
||||
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
||||
break;
|
||||
|
||||
case MENU_SIDE1_SHORT:
|
||||
case MENU_SIDE1_LONG:
|
||||
case MENU_SIDE2_SHORT:
|
||||
case MENU_SIDE2_LONG:
|
||||
strcpy(String, gSubMenu_SIDE_BUTT[gSubMenuSelection]);
|
||||
break;
|
||||
|
||||
case MENU_RESET:
|
||||
strcpy(String, gSubMenu_RESET[gSubMenuSelection]);
|
||||
break;
|
||||
|
@ -110,6 +110,10 @@ enum
|
||||
#ifdef ENABLE_NOAA
|
||||
MENU_NOAA_S,
|
||||
#endif
|
||||
MENU_SIDE1_SHORT,
|
||||
MENU_SIDE1_LONG,
|
||||
MENU_SIDE2_SHORT,
|
||||
MENU_SIDE2_LONG,
|
||||
MENU_RESET,
|
||||
|
||||
// items after here are normally hidden
|
||||
@ -161,6 +165,8 @@ extern const char gSubMenu_BAT_TXT[3][8];
|
||||
|
||||
extern const char gSubMenu_SCRAMBLER[11][7];
|
||||
|
||||
extern const char gSubMenu_SIDE_BUTT[9][16];
|
||||
|
||||
extern bool gIsInSubMenu;
|
||||
|
||||
extern uint8_t gMenuCursor;
|
||||
|
62
ui/status.c
62
ui/status.c
@ -174,7 +174,7 @@ void UI_DisplayStatus(const bool test_display)
|
||||
char s[8];
|
||||
unsigned int space_needed;
|
||||
|
||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel5) - 3;
|
||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - 3;
|
||||
|
||||
if (gChargingWithTypeC)
|
||||
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
||||
@ -209,57 +209,39 @@ void UI_DisplayStatus(const bool test_display)
|
||||
}
|
||||
|
||||
// move to right side of the screen
|
||||
x = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - sizeof(BITMAP_USB_C);
|
||||
x = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - sizeof(BITMAP_USB_C);
|
||||
|
||||
// USB-C charge indicator
|
||||
if (gChargingWithTypeC || test_display)
|
||||
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||
x += sizeof(BITMAP_USB_C);
|
||||
|
||||
// BATTERY LEVEL indicator
|
||||
if (gBatteryDisplayLevel >= 2 && !gLowBattery)
|
||||
{
|
||||
line += x;
|
||||
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
{ // BATTERY LEVEL indicator
|
||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
||||
unsigned int i = gBatteryDisplayLevel;
|
||||
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
line += sizeof(BITMAP_BatteryLevel1);
|
||||
{
|
||||
const int8_t pos[] = {-4, -7, -10, 13};
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(pos); i++)
|
||||
if (gBatteryDisplayLevel >= (2 + i))
|
||||
memmove(line + pos[i], BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
|
||||
/* switch (gBatteryDisplayLevel)
|
||||
{
|
||||
default:
|
||||
case 5: memmove(line - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
case 4: memmove(line - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
case 3: memmove(line - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
case 2: memmove(line - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
}
|
||||
*/ }
|
||||
#else
|
||||
if (i >= 1)
|
||||
{
|
||||
const int8_t pos[] = {3, 6, 9, 12};
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(pos); i++)
|
||||
if (gBatteryDisplayLevel >= (2 + i))
|
||||
memmove(line + pos[i], BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
/*
|
||||
switch (gBatteryDisplayLevel)
|
||||
const uint8_t bars = (i <= 5) - 1 ? i - 1 : 5 - 1;
|
||||
for (i = 0; i < bars; i++)
|
||||
{
|
||||
default:
|
||||
case 5: memmove(line + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
case 4: memmove(line + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
case 3: memmove(line + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
case 2: memmove(line + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
|
||||
#else
|
||||
bitmap[3 + (i * 3) + 0] = 0b01011101;
|
||||
bitmap[3 + (i * 3) + 1] = 0b01011101;
|
||||
#endif
|
||||
}
|
||||
*/ }
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if (gLowBattery)
|
||||
memset(bitmap, 0, sizeof(bitmap));
|
||||
|
||||
memmove(line + x, bitmap, sizeof(bitmap));
|
||||
}
|
||||
else
|
||||
if (gLowBatteryBlink == 1)
|
||||
memmove(line + x, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
||||
|
||||
// **************
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user