Skip to content

Commit

Permalink
Battery symbol fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Oct 6, 2023
1 parent b385b53 commit 2790873
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 126 deletions.
4 changes: 1 addition & 3 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 40 additions & 0 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 2 additions & 8 deletions bitmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions bitmaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
5 changes: 5 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
23 changes: 15 additions & 8 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,12 +115,20 @@ 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));
State[0] = gEeprom.VOICE_PROMPT;
Expand Down
73 changes: 19 additions & 54 deletions ui/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_BatteryLevel1)];

#if 1

if (level >= 2)
{
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));
#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));
#endif
}
else
if (blink == 1)
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
else
memset(bitmap, 0, sizeof(bitmap));
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];

#else
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));

if (level > 0)
if (level >= 1)
{
unsigned int i;
const uint8_t bars = (level <= 5) - 1 ? level - 1 : 5 - 1;
for (i = 0; i < bars; i++)
{
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;
#ifndef ENABLE_REVERSE_BAT_SYMBOL
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
#else
for (uint8_t i = 0; i < lev; i++)
bitmap[sizeof(bitmap) - 3 - i] = (i & 1u) ? 0b01011101 : 0b01011101;
bitmap[3 + (i * 3) + 0] = 0b01011101;
bitmap[3 + (i * 3) + 1] = 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);
}
2 changes: 1 addition & 1 deletion ui/battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

26 changes: 25 additions & 1 deletion ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -768,7 +785,7 @@ void UI_DisplayMenu(void)
case MENU_PONMSG:
strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]);
break;

case MENU_ROGER:
strcpy(String, gSubMenu_ROGER[gSubMenuSelection]);
break;
Expand All @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions ui/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -160,13 +164,15 @@ extern const char gSubMenu_RX_TX[4][6];
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;
extern int8_t gMenuScrollDirection;
extern int32_t gSubMenuSelection;

extern char edit_original[17];
extern char edit[17];
extern int edit_index;
Expand Down
Loading

0 comments on commit 2790873

Please sign in to comment.