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_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_BOOT_BEEPS := 0 ENABLE_BOOT_BEEPS := 0
ENABLE_SHOW_CHARGE_LEVEL := 1 ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_REVERSE_BAT_SYMBOL := 0
ENABLE_CODE_SCAN_TIMEOUT := 0 ENABLE_CODE_SCAN_TIMEOUT := 0
ENABLE_AM_FIX := 1 ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 0 ENABLE_AM_FIX_SHOW_DATA := 0

View File

@@ -1189,8 +1189,7 @@ void APP_Update(void)
{ {
gBatterySaveCountdown_10ms = battery_save_count_10ms; gBatterySaveCountdown_10ms = battery_save_count_10ms;
} }
else else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
{ {
//if (gCurrentFunction != FUNCTION_POWER_SAVE) //if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE); FUNCTION_Select(FUNCTION_POWER_SAVE);
@@ -1288,16 +1287,15 @@ void APP_Update(void)
// called every 10ms // called every 10ms
void APP_CheckKeys(void) void APP_CheckKeys(void)
{ {
KEY_Code_t Key; #ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
#ifdef ENABLE_AIRCOPY return;
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)) #else
return; if (gSetting_KILLED)
#else return;
if (gSetting_KILLED) #endif
return;
#endif
// -------------------- PTT ------------------------
if (gPttIsPressed) if (gPttIsPressed)
{ {
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0) if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0)
@@ -1313,8 +1311,7 @@ void APP_CheckKeys(void)
else else
gPttDebounceCounter = 0; gPttDebounceCounter = 0;
} }
else else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
{ // PTT pressed { // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting { // start transmitting
@@ -1327,16 +1324,16 @@ void APP_CheckKeys(void)
else else
gPttDebounceCounter = 0; gPttDebounceCounter = 0;
// ***************** // --------------------- OTHER KEYS ----------------------------
// scan the hardware 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 boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
if (gKeyReading0 != Key) if (gKeyReading0 != Key) // new key pressed
{ // new key pressed {
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID) if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
@@ -1346,18 +1343,19 @@ void APP_CheckKeys(void)
return; return;
} }
if (++gDebounceCounter == key_debounce_10ms) gDebounceCounter++;
{ // debounced new key pressed
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; gKeyReading1 = KEY_INVALID;
} }
} }
else else // process new key pressed
{ {
gKeyReading1 = Key; gKeyReading1 = Key;
APP_ProcessKey(Key, true, false); APP_ProcessKey(Key, true, false);
@@ -1367,21 +1365,19 @@ void APP_CheckKeys(void)
return; 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; return;
// key is being held pressed if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
{
if (gDebounceCounter == key_repeat_delay_10ms)
{ // initial key repeat delay after pressed
if (Key != KEY_PTT) if (Key != KEY_PTT)
{ {
gKeyBeingHeld = true; gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true); APP_ProcessKey(Key, true, true);
} }
} }
else else //subsequent fast key repeats
{ // key repeat {
if (Key == KEY_UP || Key == KEY_DOWN) if (Key == KEY_UP || Key == KEY_DOWN)
{ {
gKeyBeingHeld = true; gKeyBeingHeld = true;
@@ -1392,7 +1388,7 @@ void APP_CheckKeys(void)
if (gDebounceCounter < 0xFFFF) if (gDebounceCounter < 0xFFFF)
return; 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 else if (gPttWasReleased)
if (gPttWasReleased)
{ {
if (bKeyHeld) if (bKeyHeld)
bFlag = true; bFlag = true;
@@ -2249,9 +2244,9 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF) if (gAlarmState == ALARM_STATE_OFF)
#endif #endif
{ {
char Code; 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); BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
} }
} }
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
else else
if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) 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) if (!bKeyHeld)
gPttWasReleased = true; gPttWasReleased = true;
} }
#endif #endif
} }
else else
if (Key != KEY_SIDE1 && Key != KEY_SIDE2) 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) switch (gScreenToDisplay)
{ {
case DISPLAY_MAIN: case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
// bKeyHeld = false; // allow the channel setting to be saved // bKeyHeld = false; // allow the channel setting to be saved
break; break;
@@ -2361,16 +2357,15 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
else else
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY) if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else #else
if (gScreenToDisplay != DISPLAY_SCANNER) if (gScreenToDisplay != DISPLAY_SCANNER)
#endif #endif
{ {
ACTION_Handle(Key, bKeyPressed, bKeyHeld); ACTION_Handle(Key, bKeyPressed, bKeyHeld);
} }
else else if (!bKeyHeld && bKeyPressed)
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; 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 (gInputBoxIndex > 0)
{ {
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed) // short pressed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; 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; return;
if (!bKeyPressed) if (!bKeyPressed) // won't ever pass
return; return;
if (gScreenToDisplay != DISPLAY_MENU && if (gScreenToDisplay != DISPLAY_MENU &&
gScreenToDisplay != DISPLAY_FM &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gCurrentFunction != FUNCTION_TRANSMIT) gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock { // toggle the keyboad lock
@@ -69,7 +65,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gRequestSaveSettings = true; gRequestSaveSettings = true;
} }
} }
else else // released
{ {
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM) if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
@@ -79,7 +75,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return; return;
#endif #endif
gWasFKeyPressed = !gWasFKeyPressed; gWasFKeyPressed = !gWasFKeyPressed; // toggle F function
if (gWasFKeyPressed) if (gWasFKeyPressed)
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
@@ -92,7 +88,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gUpdateStatus = true; gUpdateStatus = true;
} }
} }
else else // short pressed
{ {
if (gScreenToDisplay != DISPLAY_FM) if (gScreenToDisplay != DISPLAY_FM)
{ {
@@ -101,7 +97,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF) if (gFM_ScanState == FM_SCAN_OFF) // not scanning
{ {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
@@ -120,7 +116,6 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (!bKeyPressed || gSerialConfigCountDown_500ms > 0) if (!bKeyPressed || gSerialConfigCountDown_500ms > 0)
{ // PTT released { // PTT released
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // we are transmitting .. stop { // we are transmitting .. stop
@@ -185,22 +180,22 @@ void GENERIC_Key_PTT(bool bKeyPressed)
goto cancel_tx; goto cancel_tx;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF) if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop { // FM radio is scanning .. stop
FM_PlayAndUpdate(); FM_PlayAndUpdate();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx; goto cancel_tx;
} }
#endif #endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_FM) if (gScreenToDisplay == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing goto start_tx; // listening to the FM radio .. start TX'ing
#endif #endif
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0) if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0)
{ // already transmitting { // already transmitting
@@ -259,7 +254,6 @@ start_tx:
cancel_tx: cancel_tx:
if (gPttIsPressed) if (gPttIsPressed)
{ {
gPttIsPressed = false;
gPttWasPressed = true; gPttWasPressed = true;
} }

View File

@@ -24,34 +24,33 @@
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink) void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
{ {
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); if (level < 2 && blink == 1) {
memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1));
if (level >= 1) }
else
{ {
unsigned int i; memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
uint8_t bars = level > 0 ? level - 1 : 0; if (level > 1)
if(bars>4) bars = 4;
for (i = 0; i < bars; i++)
{ {
#ifndef ENABLE_REVERSE_BAT_SYMBOL unsigned int i;
memcpy(bitmap + sizeof(bitmap) - 4 - (i * 3), BITMAP_BatteryLevel, 2); uint8_t bars = level - 1;
#else if (bars > 4)
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2); bars = 4;
#endif 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) void UI_DisplayBattery(uint8_t level, uint8_t blink)
{ {
if (gCurrentFunction != FUNCTION_TRANSMIT) { uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; UI_DrawBattery(bitmap, level, blink);
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
UI_DrawBattery(bitmap, level, blink);
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
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); x += sizeof(BITMAP_USB_C);
// BATTERY LEVEL indicator // BATTERY LEVEL indicator
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBattery); UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink);
// ************** // **************