0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

1 sec status bar update rate is volt/percent is enabled

This commit is contained in:
OneOfEleven
2023-09-19 10:23:50 +01:00
parent aeb22b7028
commit 88a556db81
19 changed files with 134 additions and 126 deletions

View File

@ -901,7 +901,7 @@ void APP_CheckRadioInterrupts(void)
if (gCurrentFunction == FUNCTION_RECEIVE)
{
#ifdef ENABLE_DTMF_DECODER
{ // live DTMF decoder
gDTMF_RecvTimeoutSaved = DTMF_RX_timeout_saved_500ms;
size_t len = strlen(gDTMF_ReceivedSaved);
// shift the RX buffer down one - if need be
@ -910,7 +910,7 @@ void APP_CheckRadioInterrupts(void)
gDTMF_ReceivedSaved[len++] = c;
gDTMF_ReceivedSaved[len] = '\0';
gUpdateDisplay = true;
#endif
}
DTMF_HandleRequest();
}
@ -1788,6 +1788,14 @@ void APP_TimeSlice500ms(void)
gBatteryVoltageIndex = 0;
BATTERY_GetReadings(true);
#if defined(ENABLE_STATUSBAR_VOLTAGE) || defined(ENABLE_STATUSBAR_PERCENTAGE)
// regular statusbar updates (once per sec) if battery voltage or percentage is enabled
gUpdateStatus = true;
#else
if (gChargingWithTypeC)
gUpdateDisplay = true;
#endif
}
if (gCurrentFunction != FUNCTION_POWER_SAVE)
@ -1977,16 +1985,14 @@ void APP_TimeSlice500ms(void)
}
}
#ifdef ENABLE_DTMF_DECODER
if (gDTMF_RecvTimeoutSaved > 0)
if (gDTMF_RecvTimeoutSaved > 0)
{
if (--gDTMF_RecvTimeoutSaved == 0)
{
if (--gDTMF_RecvTimeoutSaved == 0)
{
gDTMF_ReceivedSaved[0] = '\0';
gUpdateDisplay = true;
}
gDTMF_ReceivedSaved[0] = '\0';
gUpdateDisplay = true;
}
#endif
}
}
#ifdef ENABLE_ALARM

View File

@ -40,10 +40,8 @@ uint8_t gDTMF_WriteIndex = 0;
uint8_t gDTMF_PreviousIndex = 0;
uint8_t gDTMF_RecvTimeout = 0;
#ifdef ENABLE_DTMF_DECODER
char gDTMF_ReceivedSaved[17];
uint8_t gDTMF_RecvTimeoutSaved = 0;
#endif
char gDTMF_ReceivedSaved[17];
uint8_t gDTMF_RecvTimeoutSaved = 0;
bool gIsDtmfContactValid;
char gDTMF_ID[4];

View File

@ -61,10 +61,8 @@ extern uint8_t gDTMF_WriteIndex;
extern uint8_t gDTMF_PreviousIndex;
extern uint8_t gDTMF_RecvTimeout;
#ifdef ENABLE_DTMF_DECODER
extern char gDTMF_ReceivedSaved[17];
extern uint8_t gDTMF_RecvTimeoutSaved;
#endif
extern char gDTMF_ReceivedSaved[17];
extern uint8_t gDTMF_RecvTimeoutSaved;
extern bool gIsDtmfContactValid;
extern char gDTMF_ID[4];

View File

@ -103,12 +103,13 @@
VOICE_ID_INVALID,
VOICE_ID_INVALID,
VOICE_ID_INVALID,
VOICE_ID_INVALID,
#ifdef ENABLE_NOAA
VOICE_ID_INVALID,
#endif
VOICE_ID_DELETE_CHANNEL,
VOICE_ID_INITIALISATION,
// hidden items
VOICE_ID_INVALID,
@ -118,6 +119,7 @@
VOICE_ID_INVALID,
VOICE_ID_INVALID,
VOICE_ID_INVALID,
VOICE_ID_INVALID
};
#endif
@ -257,6 +259,7 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_STE:
case MENU_D_ST:
case MENU_D_DCD:
case MENU_D_LIVE_DEC:
case MENU_AM:
#ifdef ENABLE_NOAA
case MENU_NOAA_S:
@ -613,6 +616,11 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1;
return;
case MENU_D_LIVE_DEC:
gSetting_live_DTMF_decoder = gSubMenuSelection;
gRequestSaveSettings = true;
return;
case MENU_D_LIST:
gDTMFChosenContact = gSubMenuSelection - 1;
if (gIsDtmfContactValid)
@ -982,6 +990,10 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gDTMFChosenContact + 1;
break;
case MENU_D_LIVE_DEC:
gSubMenuSelection = gSetting_live_DTMF_decoder;
break;
case MENU_PONMSG:
gSubMenuSelection = gEeprom.POWER_ON_DISPLAY_MODE;
break;

View File

@ -139,9 +139,11 @@ typedef struct {
static const uint8_t Obfuscation[16] = { 0x16, 0x6C, 0x14, 0xE6, 0x2E, 0x91, 0x0D, 0x40, 0x21, 0x35, 0xD5, 0x40, 0x13, 0x03, 0xE9, 0x80 };
static union {
static union
{
uint8_t Buffer[256];
struct {
struct
{
Header_t Header;
uint8_t Data[252];
};
@ -149,7 +151,7 @@ static union {
static uint32_t Timestamp;
static uint16_t gUART_WriteIndex;
static bool bIsEncrypted = true;
static bool bIsEncrypted = true;
static void SendReply(void *pReply, uint16_t Size)
{
@ -158,21 +160,24 @@ static void SendReply(void *pReply, uint16_t Size)
uint8_t *pBytes;
uint16_t i;
if (bIsEncrypted) {
if (bIsEncrypted)
{
pBytes = (uint8_t *)pReply;
for (i = 0; i < Size; i++) {
for (i = 0; i < Size; i++)
pBytes[i] ^= Obfuscation[i % 16];
}
}
Header.ID = 0xCDAB;
Header.Size = Size;
UART_Send(&Header, sizeof(Header));
UART_Send(pReply, Size);
if (bIsEncrypted) {
if (bIsEncrypted)
{
Footer.Padding[0] = Obfuscation[(Size + 0) % 16] ^ 0xFF;
Footer.Padding[1] = Obfuscation[(Size + 1) % 16] ^ 0xFF;
} else {
}
else
{
Footer.Padding[0] = 0xFF;
Footer.Padding[1] = 0xFF;
}
@ -208,11 +213,9 @@ static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint
IV[2] = 0;
IV[3] = 0;
AES_Encrypt(pKey, IV, pIn, IV, true);
for (i = 0; i < 4; i++) {
if (IV[i] != pResponse[i]) {
for (i = 0; i < 4; i++)
if (IV[i] != pResponse[i])
return true;
}
}
return false;
}
@ -232,12 +235,11 @@ static void CMD_0514(const uint8_t *pBuffer)
static void CMD_051B(const uint8_t *pBuffer)
{
const CMD_051B_t *pCmd = (const CMD_051B_t *)pBuffer;
REPLY_051B_t Reply;
bool bLocked = false;
REPLY_051B_t Reply;
bool bLocked = false;
if (pCmd->Timestamp != Timestamp) {
if (pCmd->Timestamp != Timestamp)
return;
}
#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
@ -248,13 +250,11 @@ static void CMD_051B(const uint8_t *pBuffer)
Reply.Data.Offset = pCmd->Offset;
Reply.Data.Size = pCmd->Size;
if (bHasCustomAesKey) {
if (bHasCustomAesKey)
bLocked = gIsLocked;
}
if (!bLocked) {
if (!bLocked)
EEPROM_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size);
}
SendReply(&Reply, pCmd->Size + 8);
}
@ -266,44 +266,37 @@ static void CMD_051D(const uint8_t *pBuffer)
bool bReloadEeprom;
bool bIsLocked;
if (pCmd->Timestamp != Timestamp) {
if (pCmd->Timestamp != Timestamp)
return;
}
bReloadEeprom = false;
#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
#endif
Reply.Header.ID = 0x051E;
Reply.Header.ID = 0x051E;
Reply.Header.Size = sizeof(Reply.Data);
Reply.Data.Offset = pCmd->Offset;
bIsLocked = bHasCustomAesKey;
if (bHasCustomAesKey) {
bIsLocked = gIsLocked;
}
bIsLocked = bHasCustomAesKey ? gIsLocked : bHasCustomAesKey;
if (!bIsLocked) {
if (!bIsLocked)
{
uint16_t i;
for (i = 0; i < (pCmd->Size / 8); i++)
{
const uint16_t Offset = pCmd->Offset + (i * 8U);
for (i = 0; i < (pCmd->Size / 8U); i++) {
uint16_t Offset = pCmd->Offset + (i * 8U);
if (Offset >= 0x0F30 && Offset < 0x0F40) {
if (!gIsLocked) {
if (Offset >= 0x0F30 && Offset < 0x0F40)
if (!gIsLocked)
bReloadEeprom = true;
}
}
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword) {
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword)
EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U]);
}
}
if (bReloadEeprom) {
if (bReloadEeprom)
BOARD_EEPROM_Init();
}
}
SendReply(&Reply, sizeof(Reply));
@ -347,25 +340,30 @@ static void CMD_052D(const uint8_t *pBuffer)
bIsLocked = bHasCustomAesKey;
if (!bIsLocked) {
if (!bIsLocked)
bIsLocked = IsBadChallenge(gCustomAesKey, gChallenge, pCmd->Response);
}
if (!bIsLocked) {
if (!bIsLocked)
{
bIsLocked = IsBadChallenge(gDefaultAesKey, gChallenge, pCmd->Response);
if (bIsLocked) {
if (bIsLocked)
gTryCount++;
}
}
if (gTryCount < 3) {
if (!bIsLocked) {
if (gTryCount < 3)
{
if (!bIsLocked)
gTryCount = 0;
}
} else {
}
else
{
gTryCount = 3;
bIsLocked = true;
}
gIsLocked = bIsLocked;
gIsLocked = bIsLocked;
Reply.Data.bIsLocked = bIsLocked;
SendReply(&Reply, sizeof(Reply));
}