Refactoring status and save 40 bytes
This commit is contained in:
@@ -29,9 +29,9 @@ const uint8_t gFontFM[2][6] =
|
|||||||
{0x00, 0x7f, 0x2, 0x1c, 0x2, 0x7f},
|
{0x00, 0x7f, 0x2, 0x1c, 0x2, 0x7f},
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t gFontKeyLock[1][8] =
|
const uint8_t gFontKeyLock[1][9] =
|
||||||
{
|
{
|
||||||
{0x7c, 0x46, 0x45, 0x45, 0x45, 0x45, 0x46, 0x7c}
|
{0x7c, 0x46, 0x45, 0x45, 0x45, 0x45, 0x45, 0x46, 0x7c}
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t gFontScanAll[9] =
|
const uint8_t gFontScanAll[9] =
|
||||||
|
@@ -8,7 +8,7 @@ extern const uint8_t gFontPowerSave[2][6];
|
|||||||
extern const uint8_t gFontPttOnePush[2][6];
|
extern const uint8_t gFontPttOnePush[2][6];
|
||||||
extern const uint8_t gFontPttClassic[2][6];
|
extern const uint8_t gFontPttClassic[2][6];
|
||||||
extern const uint8_t gFontFM[2][6];
|
extern const uint8_t gFontFM[2][6];
|
||||||
extern const uint8_t gFontKeyLock[1][8];
|
extern const uint8_t gFontKeyLock[1][9];
|
||||||
extern const uint8_t gFontScanAll[9];
|
extern const uint8_t gFontScanAll[9];
|
||||||
extern const uint8_t gFontLight[9];
|
extern const uint8_t gFontLight[9];
|
||||||
|
|
||||||
|
56
ui/status.c
56
ui/status.c
@@ -34,10 +34,13 @@
|
|||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "ui/status.h"
|
#include "ui/status.h"
|
||||||
|
|
||||||
static void convertTime(uint8_t *line, uint8_t type) {
|
|
||||||
|
static void convertTime(uint8_t *line, uint8_t type)
|
||||||
|
{
|
||||||
|
char str[8] = "";
|
||||||
|
|
||||||
uint8_t m, s; // Declare variables for seconds, hours, minutes, and seconds
|
uint8_t m, s; // Declare variables for seconds, hours, minutes, and seconds
|
||||||
uint16_t t;
|
uint16_t t;
|
||||||
char str[7];
|
|
||||||
|
|
||||||
if(type == 0) // Tx timer
|
if(type == 0) // Tx timer
|
||||||
t = (gTxTimerCountdown_500ms / 2);
|
t = (gTxTimerCountdown_500ms / 2);
|
||||||
@@ -56,6 +59,8 @@ static void convertTime(uint8_t *line, uint8_t type) {
|
|||||||
|
|
||||||
void UI_DisplayStatus()
|
void UI_DisplayStatus()
|
||||||
{
|
{
|
||||||
|
char str[8] = "";
|
||||||
|
|
||||||
gUpdateStatus = false;
|
gUpdateStatus = false;
|
||||||
memset(gStatusLine, 0, sizeof(gStatusLine));
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
||||||
|
|
||||||
@@ -122,9 +127,8 @@ void UI_DisplayStatus()
|
|||||||
bool debug = false;
|
bool debug = false;
|
||||||
if(debug)
|
if(debug)
|
||||||
{
|
{
|
||||||
char sDebug[8] = "";
|
sprintf(str, "%d", gDebug);
|
||||||
sprintf(sDebug, "%d", gDebug);
|
UI_PrintStringSmallBufferNormal(str, line + x + 1);
|
||||||
UI_PrintStringSmallBufferNormal(sDebug, line + x + 1);
|
|
||||||
x += 16;
|
x += 16;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -197,31 +201,28 @@ void UI_DisplayStatus()
|
|||||||
// KEY-LOCK indicator
|
// KEY-LOCK indicator
|
||||||
if (gEeprom.KEY_LOCK) {
|
if (gEeprom.KEY_LOCK) {
|
||||||
memcpy(line + x + 1, gFontKeyLock, sizeof(gFontKeyLock));
|
memcpy(line + x + 1, gFontKeyLock, sizeof(gFontKeyLock));
|
||||||
x += sizeof(gFontKeyLock);
|
|
||||||
x1 = x;
|
|
||||||
}
|
}
|
||||||
else if (gWasFKeyPressed) {
|
else if (gWasFKeyPressed) {
|
||||||
UI_PrintStringSmallBufferNormal("F", line + x + 1);
|
UI_PrintStringSmallBufferNormal("F", line + x + 1);
|
||||||
x += sizeof(gFontKeyLock);
|
|
||||||
|
|
||||||
for (uint8_t i = 71; i < 79; i++)
|
for (uint8_t i = 71; i < 79; i++)
|
||||||
{
|
{
|
||||||
gStatusLine[i] ^= 0x7F;
|
gStatusLine[i] ^= 0x7F;
|
||||||
}
|
}
|
||||||
x1 = x;
|
|
||||||
}
|
}
|
||||||
else if(gBackLight)
|
else if (gBackLight)
|
||||||
{
|
{
|
||||||
memcpy(line + x + 1, gFontLight, sizeof(gFontLight));
|
memcpy(line + x + 1, gFontLight, sizeof(gFontLight));
|
||||||
x += sizeof(gFontLight);
|
}
|
||||||
x1 = x;
|
else if (gChargingWithTypeC)
|
||||||
|
{
|
||||||
|
memcpy(line + x + 1, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // battery voltage or percentage
|
// Battery
|
||||||
char s[8] = "";
|
|
||||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0;
|
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0;
|
||||||
if (gChargingWithTypeC)
|
|
||||||
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
UI_DrawBattery(line + x2, gBatteryDisplayLevel, gLowBatteryBlink);
|
||||||
|
|
||||||
switch (gSetting_battery_text) {
|
switch (gSetting_battery_text) {
|
||||||
default:
|
default:
|
||||||
@@ -231,33 +232,20 @@ void UI_DisplayStatus()
|
|||||||
case 1: { // voltage
|
case 1: { // voltage
|
||||||
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
||||||
#ifdef ENABLE_FEAT_F4HWN
|
#ifdef ENABLE_FEAT_F4HWN
|
||||||
sprintf(s, "%u.%02u", voltage / 100, voltage % 100);
|
sprintf(str, "%u.%02u", voltage / 100, voltage % 100);
|
||||||
#else
|
#else
|
||||||
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
sprintf(str, "%u.%02uV", voltage / 100, voltage % 100);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2: // percentage
|
case 2: // percentage
|
||||||
sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
sprintf(str, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int space_needed = (7 * strlen(s));
|
x2 -= (7 * strlen(str));
|
||||||
if (x2 >= (x1 + space_needed))
|
UI_PrintStringSmallBufferNormal(str, line + x2);
|
||||||
UI_PrintStringSmallBufferNormal(s, line + x2 - space_needed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// move to right side of the screen
|
|
||||||
x = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - sizeof(BITMAP_USB_C);
|
|
||||||
|
|
||||||
// USB-C charge indicator
|
|
||||||
if (gChargingWithTypeC)
|
|
||||||
memcpy(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
|
||||||
x += sizeof(BITMAP_USB_C);
|
|
||||||
|
|
||||||
// BATTERY LEVEL indicator
|
|
||||||
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink);
|
|
||||||
|
|
||||||
// **************
|
// **************
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user