4 Commits
v0.9 ... v0.10

Author SHA1 Message Date
Krzysiek Egzmont
06c2ddf543 BUG FIX: power save never activated 2023-10-10 19:36:12 +02:00
Krzysiek Egzmont
47f1e80252 Fix #25: When you stop the scan with the PTT the Walkie stays in permanent TX 2023-10-10 17:32:58 +02:00
Krzysiek Egzmont
64bc29d362 FIX #24: lock/unlock doesn't work when FM radio active 2023-10-10 14:29:51 +02:00
Krzysiek Egzmont
8d17f5922c FIX #21: Battery symbol fix of a fix 2023-10-10 02:39:02 +02:00
5 changed files with 88 additions and 100 deletions

View File

@@ -25,7 +25,7 @@ ENABLE_F_CAL_MENU := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_BOOT_BEEPS := 0
ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_REVERSE_BAT_SYMBOL := 0
ENABLE_CODE_SCAN_TIMEOUT := 0
ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 0

View File

@@ -1189,8 +1189,7 @@ void APP_Update(void)
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
}
else
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
{
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
@@ -1288,16 +1287,15 @@ void APP_Update(void)
// called every 10ms
void APP_CheckKeys(void)
{
KEY_Code_t Key;
#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
return;
#else
if (gSetting_KILLED)
return;
#endif
#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
return;
#else
if (gSetting_KILLED)
return;
#endif
// -------------------- PTT ------------------------
if (gPttIsPressed)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0)
@@ -1313,8 +1311,7 @@ void APP_CheckKeys(void)
else
gPttDebounceCounter = 0;
}
else
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
{ // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
@@ -1327,16 +1324,16 @@ void APP_CheckKeys(void)
else
gPttDebounceCounter = 0;
// *****************
// --------------------- OTHER KEYS ----------------------------
// scan the hardware keys
Key = KEYBOARD_Poll();
KEY_Code_t Key = KEYBOARD_Poll();
if (Key != KEY_INVALID)
if (Key != KEY_INVALID) // any key pressed
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
if (gKeyReading0 != Key)
{ // new key pressed
if (gKeyReading0 != Key) // new key pressed
{
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
@@ -1346,18 +1343,19 @@ void APP_CheckKeys(void)
return;
}
if (++gDebounceCounter == key_debounce_10ms)
{ // debounced new key pressed
gDebounceCounter++;
if (Key == KEY_INVALID)
if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
{
if (Key == KEY_INVALID) //all PTT keys released
{
if (gKeyReading1 != KEY_INVALID)
if (gKeyReading1 != KEY_INVALID) // some button was pressed before
{
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld);
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // process last button released event
gKeyReading1 = KEY_INVALID;
}
}
else
else // process new key pressed
{
gKeyReading1 = Key;
APP_ProcessKey(Key, true, false);
@@ -1367,21 +1365,19 @@ void APP_CheckKeys(void)
return;
}
if (gDebounceCounter < key_repeat_delay_10ms)
if (gDebounceCounter < key_repeat_delay_10ms || Key == KEY_INVALID) // the button is not held long enough for repeat yet, or not really pressed
return;
// key is being held pressed
if (gDebounceCounter == key_repeat_delay_10ms)
{ // initial key repeat delay after pressed
if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
{
if (Key != KEY_PTT)
{
gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true);
}
}
else
{ // key repeat
else //subsequent fast key repeats
{
if (Key == KEY_UP || Key == KEY_DOWN)
{
gKeyBeingHeld = true;
@@ -1392,7 +1388,7 @@ void APP_CheckKeys(void)
if (gDebounceCounter < 0xFFFF)
return;
gDebounceCounter = key_repeat_delay_10ms;
gDebounceCounter = key_repeat_delay_10ms+1;
}
}
@@ -2226,8 +2222,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
}
else
if (gPttWasReleased)
else if (gPttWasReleased)
{
if (bKeyHeld)
bFlag = true;
@@ -2249,9 +2244,9 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF)
#endif
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF)
#endif
{
char Code;
@@ -2306,7 +2301,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
}
}
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
else
if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed))
{
@@ -2323,7 +2318,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!bKeyHeld)
gPttWasReleased = true;
}
#endif
#endif
}
else
if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
@@ -2331,6 +2326,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
switch (gScreenToDisplay)
{
case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
// bKeyHeld = false; // allow the channel setting to be saved
break;
@@ -2361,16 +2357,15 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
else
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else
if (gScreenToDisplay != DISPLAY_SCANNER)
#endif
{
ACTION_Handle(Key, bKeyPressed, bKeyHeld);
}
else
if (!bKeyHeld && bKeyPressed)
else if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
}

View File

@@ -37,26 +37,22 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
{
if (gInputBoxIndex > 0)
{
if (!bKeyHeld && bKeyPressed)
if (!bKeyHeld && bKeyPressed) // short pressed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (bKeyHeld || !bKeyPressed)
if (bKeyHeld || !bKeyPressed) // held or released
{
if (bKeyHeld || bKeyPressed)
if (bKeyHeld || bKeyPressed) // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
{
if (!bKeyHeld)
if (!bKeyHeld) // won't ever pass
return;
if (!bKeyPressed)
if (!bKeyPressed) // won't ever pass
return;
if (gScreenToDisplay != DISPLAY_MENU &&
gScreenToDisplay != DISPLAY_FM &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock
@@ -69,7 +65,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gRequestSaveSettings = true;
}
}
else
else // released
{
#ifdef ENABLE_FMRADIO
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
@@ -79,7 +75,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return;
#endif
gWasFKeyPressed = !gWasFKeyPressed;
gWasFKeyPressed = !gWasFKeyPressed; // toggle F function
if (gWasFKeyPressed)
gKeyInputCountdown = key_input_timeout_500ms;
@@ -92,7 +88,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gUpdateStatus = true;
}
}
else
else // short pressed
{
if (gScreenToDisplay != DISPLAY_FM)
{
@@ -101,7 +97,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
}
#ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF)
if (gFM_ScanState == FM_SCAN_OFF) // not scanning
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
@@ -120,7 +116,6 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (!bKeyPressed || gSerialConfigCountDown_500ms > 0)
{ // PTT released
if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // we are transmitting .. stop
@@ -185,22 +180,22 @@ void GENERIC_Key_PTT(bool bKeyPressed)
goto cancel_tx;
}
#ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx;
}
#endif
#ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx;
}
#endif
#ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing
#endif
#ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing
#endif
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0)
{ // already transmitting
@@ -259,7 +254,6 @@ start_tx:
cancel_tx:
if (gPttIsPressed)
{
gPttIsPressed = false;
gPttWasPressed = true;
}

View File

@@ -24,34 +24,33 @@
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
{
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
if (level >= 1)
if (level < 2 && blink == 1) {
memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1));
}
else
{
unsigned int i;
uint8_t bars = level > 0 ? level - 1 : 0;
if(bars>4) bars = 4;
for (i = 0; i < bars; i++)
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
if (level > 1)
{
#ifndef ENABLE_REVERSE_BAT_SYMBOL
memcpy(bitmap + sizeof(bitmap) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
#else
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
#endif
unsigned int i;
uint8_t bars = level - 1;
if (bars > 4)
bars = 4;
for (i = 0; i < bars; i++)
{
#ifndef ENABLE_REVERSE_BAT_SYMBOL
memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
#else
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
#endif
}
}
}
else
if (blink == 0)
memset(bitmap, 0, sizeof(bitmap));
}
void UI_DisplayBattery(uint8_t level, uint8_t blink)
{
if (gCurrentFunction != FUNCTION_TRANSMIT) {
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
UI_DrawBattery(bitmap, level, blink);
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
}
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
UI_DrawBattery(bitmap, level, blink);
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
}

View File

@@ -218,7 +218,7 @@ void UI_DisplayStatus(const bool test_display)
x += sizeof(BITMAP_USB_C);
// BATTERY LEVEL indicator
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBattery);
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink);
// **************