diff --git a/Makefile b/Makefile index f4ad3b3..08b83a2 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ ENABLE_OVERLAY := 0 ENABLE_LTO := 1 ENABLE_UART := 1 ENABLE_AIRCOPY := 0 -ENABLE_FMRADIO := 0 +ENABLE_FMRADIO := 1 ENABLE_NOAA := 0 ENABLE_VOICE := 0 ENABLE_ALARM := 0 @@ -22,7 +22,7 @@ ENABLE_F_CAL_MENU := 0 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_MAIN_KEY_HOLD := 1 ENABLE_BOOT_BEEPS := 0 -ENABLE_COMPANDER := 1 +ENABLE_COMPANDER := 0 ENABLE_SHOW_CHARGE_LEVEL := 1 ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_CODE_SCAN_TIMEOUT := 0 diff --git a/README.md b/README.md index 40be7d3..ed723c4 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden freque ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead just hold down keys 0-9 to access the secondary butt functions ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up -ENABLE_COMPANDER := 1 compander option (per channel) +ENABLE_COMPANDER := 0 this is broken, don't bother with it for now .. compander option (per channel) ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right) ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan) diff --git a/app/app.c b/app/app.c index b457f23..c691ab1 100644 --- a/app/app.c +++ b/app/app.c @@ -574,7 +574,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) #ifdef ENABLE_VOICE - if (gVoiceWriteIndex == 0) +// if (gVoiceWriteIndex == 0) #endif BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN); @@ -591,6 +591,8 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) } else gUpdateDisplay = true; + + gUpdateStatus = true; } uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) @@ -1002,7 +1004,7 @@ static void APP_HandleVox(void) if (gCurrentFunction == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0) { gDTMF_ReplyState = DTMF_REPLY_NONE; RADIO_PrepareTX(); @@ -1021,8 +1023,8 @@ void APP_Update(void) } #endif - if (gCurrentFunction == FUNCTION_TRANSMIT && gTxTimeoutReached) - { // transmitter timed out + if ((gCurrentFunction == FUNCTION_TRANSMIT && gTxTimeoutReached) || gSerialConfigCountDown_500ms > 0) + { // transmitter timed out or must de-key gTxTimeoutReached = false; gFlagEndTransmission = true; @@ -1747,30 +1749,27 @@ void APP_TimeSlice500ms(void) // Skipped authentic device check + if ((gBatteryCheckCounter & 1) == 0) + { + BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); + if (gBatteryVoltageIndex > 3) + gBatteryVoltageIndex = 0; + BATTERY_GetReadings(true); + } + + // regular display updates (once every 2 sec) - if need be + if ((gBatteryCheckCounter & 3) == 0) + { + if (gChargingWithTypeC || gSetting_battery_text > 0) + gUpdateStatus = true; + #ifdef ENABLE_SHOW_CHARGE_LEVEL + if (gChargingWithTypeC) + gUpdateDisplay = true; + #endif + } + if (gCurrentFunction != FUNCTION_TRANSMIT) { - if ((gBatteryCheckCounter & 1) == 0) - { - BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); - - if (gBatteryVoltageIndex > 3) - gBatteryVoltageIndex = 0; - - BATTERY_GetReadings(true); - } - - // regular display updates (once every 2 sec) - if need be - if ((gBatteryCheckCounter & 3) == 0) - { - if (gChargingWithTypeC || gSetting_battery_text > 0) - gUpdateStatus = true; - - #ifdef ENABLE_SHOW_CHARGE_LEVEL - if (gChargingWithTypeC) - gUpdateDisplay = true; - #endif - } - if (gCurrentFunction != FUNCTION_POWER_SAVE) updateRSSI(gEeprom.RX_CHANNEL); diff --git a/app/generic.c b/app/generic.c index b96b700..fb378c1 100644 --- a/app/generic.c +++ b/app/generic.c @@ -104,7 +104,7 @@ void GENERIC_Key_PTT(bool bKeyPressed) { gInputBoxIndex = 0; - if (!bKeyPressed) + if (!bKeyPressed || gSerialConfigCountDown_500ms > 0) { //if (gScreenToDisplay == DISPLAY_MAIN) { diff --git a/audio.c b/audio.c index 94d54d6..eff3393 100644 --- a/audio.c +++ b/audio.c @@ -279,12 +279,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) SYSTEM_DelayMs(Delay * 10); if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) - { - if (gRxVfo->AM_mode) - BK4819_SetAF(BK4819_AF_AM); - else - BK4819_SetAF(BK4819_AF_OPEN); - } + BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN); #ifdef ENABLE_FMRADIO if (gFmRadioMode) diff --git a/bitmaps.c b/bitmaps.c index 3f5a105..0f6b6de 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -4,7 +4,7 @@ // all these images are on their right sides // turn your monitor 90-deg anti-clockwise to see the images -const uint8_t BITMAP_PowerSave[8] = +const uint8_t BITMAP_POWERSAVE[8] = { #if 0 // "S" @@ -29,6 +29,30 @@ const uint8_t BITMAP_PowerSave[8] = #endif }; +const uint8_t BITMAP_TX[8] = +{ // "TX" + 0b00000000, + 0b00000001, + 0b00000001, + 0b01111111, + 0b00000001, + 0b00000001, + 0b00000000, + 0b00000000 +}; + +const uint8_t BITMAP_RX[8] = +{ // "RX" + 0b00000000, + 0b01111111, + 0b00001001, + 0b00011001, + 0b01100110, + 0b00000000, + 0b00000000, + 0b00000000 +}; + const uint8_t BITMAP_BatteryLevel[2] = { 0b01011101, diff --git a/bitmaps.h b/bitmaps.h index 96b984a..51e2fbb 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -4,7 +4,9 @@ #include -extern const uint8_t BITMAP_PowerSave[8]; +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]; diff --git a/driver/bk4819.c b/driver/bk4819.c index 6ffff61..551de68 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -831,14 +831,16 @@ void BK4819_SetCompander(const unsigned int mode) // mode 2 .. RX // mode 3 .. TX and RX + const uint16_t r31 = BK4819_ReadRegister(BK4819_REG_31); + if (mode == 0) { // disable - BK4819_WriteRegister(BK4819_REG_31, BK4819_ReadRegister(BK4819_REG_31) & ~(1u < 3)); + BK4819_WriteRegister(BK4819_REG_31, r31 & ~(1u < 3)); return; } // enable - BK4819_WriteRegister(BK4819_REG_31, BK4819_ReadRegister(BK4819_REG_31) | (1u < 3)); + BK4819_WriteRegister(BK4819_REG_31, r31 | (1u < 3)); // set the compressor ratio // @@ -848,9 +850,18 @@ void BK4819_SetCompander(const unsigned int mode) // 10 = 2:1 // 11 = 4:1 // - const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 3 : 0; // 4:1 - BK4819_WriteRegister(BK4819_REG_29, (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14)); - + // REG_29 <13:7> 86 Compress (AF Tx) 0 dB point (dB) + // + // REG_29 <6:0> 64 Compress (AF Tx) noise point (dB) + // +// const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 2 : 0; // 2:1 +// const uint16_t compress_0dB = 86; +// const uint16_t compress_noise_dB = 64; +// BK4819_WriteRegister(BK4819_REG_29, // (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14)); +// (compress_ratio < 14) +// | (compress_0dB < 7) +// | (compress_noise_dB < 0)); + // set the expander ratio // // REG_28 <15:14> 01 Expander (AF Rx) Ratio @@ -859,8 +870,17 @@ void BK4819_SetCompander(const unsigned int mode) // 10 = 1:3 // 11 = 1:4 // - const uint16_t expand_ratio = (mode >= 2) ? 3 : 0; // 1:4 - BK4819_WriteRegister(BK4819_REG_28, (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14)); + // REG_28 <13:7> 86 Expander (AF Rx) 0 dB point (dB) + // + // REG_28 <6:0> 56 Expander (AF Rx) noise point (dB) + // +// const uint16_t expand_ratio = (mode >= 2) ? 1 : 0; // 1:2 +// const uint16_t expand_0dB = 86; +// const uint16_t expand_noise_dB = 56; +// BK4819_WriteRegister(BK4819_REG_28, // (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14)); +// (expand_ratio < 14) +// | (expand_0dB < 7) +// | (expand_noise_dB < 0)); } void BK4819_DisableVox(void) diff --git a/firmware.bin b/firmware.bin index 7b670ec..01a16ca 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 375e12c..1541aad 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index e95f9ce..232a01b 100644 --- a/functions.c +++ b/functions.c @@ -74,6 +74,8 @@ void FUNCTION_Init(void) #ifdef ENABLE_NOAA gNOAACountdown_10ms = 0; #endif + + gUpdateStatus = true; } void FUNCTION_Select(FUNCTION_Type_t Function) @@ -113,6 +115,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2); + gUpdateStatus = true; return; case FUNCTION_MONITOR: @@ -186,6 +189,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function) } #endif + gUpdateStatus = true; + GUI_DisplayScreen(); RADIO_SetTxParameters(); diff --git a/radio.c b/radio.c index 6cc9584..22c67e7 100644 --- a/radio.c +++ b/radio.c @@ -626,7 +626,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) #endif { if (gRxVfo->AM_mode == 0) - { + { // FM uint8_t CodeType = gSelectedCodeType; uint8_t Code = gSelectedCode; if (gCssScanMode == CSS_SCAN_MODE_OFF) @@ -939,8 +939,8 @@ void RADIO_PrepareTX(void) } else #endif - if (!gSetting_TX_EN) - { // TX is disabled + if (!gSetting_TX_EN || gSerialConfigCountDown_500ms > 0) + { // TX is disabled or config upload/download in progress State = VFO_STATE_TX_DISABLE; } else diff --git a/ui/main.c b/ui/main.c index 17638c9..12560ee 100644 --- a/ui/main.c +++ b/ui/main.c @@ -335,7 +335,7 @@ void UI_DisplayMain(void) const bool same_vfo = (channel == vfo_num) ? true : false; uint8_t *p_line0 = gFrameBuffer[line + 0]; uint8_t *p_line1 = gFrameBuffer[line + 1]; - uint32_t duff_beer = 0; + uint8_t mode = 0; uint8_t state; if (single_vfo) @@ -422,23 +422,36 @@ void UI_DisplayMain(void) #ifdef ENABLE_ALARM if (gAlarmState == ALARM_STATE_ALARM) - duff_beer = 2; + mode = 2; else #endif { channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; if (channel == vfo_num) { // show the TX symbol - duff_beer = 1; - UI_PrintStringSmall("TX", 14, 0, line); + mode = 1; + #ifdef ENABLE_SMALL_BOLD + UI_PrintStringSmallBold("TX", 14, 0, line); + #else + UI_PrintStringSmall("TX", 14, 0, line); + #endif } } } else { // receiving .. show the RX symbol - duff_beer = 2; - if ((gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) && gEeprom.RX_CHANNEL == vfo_num) - UI_PrintStringSmall("RX", 14, 0, line); + mode = 2; + if ((gCurrentFunction == FUNCTION_RECEIVE || + gCurrentFunction == FUNCTION_MONITOR || + gCurrentFunction == FUNCTION_INCOMING) && + gEeprom.RX_CHANNEL == vfo_num) + { + #ifdef ENABLE_SMALL_BOLD + UI_PrintStringSmallBold("RX", 14, 0, line); + #else + UI_PrintStringSmall("RX", 14, 0, line); + #endif + } } if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) @@ -610,7 +623,7 @@ void UI_DisplayMain(void) { // show the TX/RX level uint8_t Level = 0; - if (duff_beer == 1) + if (mode == 1) { // TX power level switch (gRxVfo->OUTPUT_POWER) { @@ -620,7 +633,7 @@ void UI_DisplayMain(void) } } else - if (duff_beer == 2) + if (mode == 2) { // RX signal level #ifndef ENABLE_RSSI_BAR // bar graph @@ -657,7 +670,7 @@ void UI_DisplayMain(void) } else { // or show the CTCSS/DCS symbol - const FREQ_Config_t *pConfig = (duff_beer == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; + const FREQ_Config_t *pConfig = (mode == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; const unsigned int code_type = pConfig->CodeType; const char *code_list[] = {"", "CT", "DCS", "DCR"}; if (code_type >= 0 && code_type < ARRAY_SIZE(code_list)) diff --git a/ui/status.c b/ui/status.c index 4eb5528..3db670e 100644 --- a/ui/status.c +++ b/ui/status.c @@ -45,12 +45,26 @@ void UI_DisplayStatus(const bool test_display) // ************** // POWER-SAVE indicator + if (gCurrentFunction == FUNCTION_TRANSMIT) + { + memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX)); + x1 = x + sizeof(BITMAP_TX); + } + else + if (gCurrentFunction == FUNCTION_RECEIVE || + gCurrentFunction == FUNCTION_MONITOR || + gCurrentFunction == FUNCTION_INCOMING) + { + memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX)); + x1 = x + sizeof(BITMAP_RX); + } + else if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display) { - memmove(line + x, BITMAP_PowerSave, sizeof(BITMAP_PowerSave)); - x1 = x + sizeof(BITMAP_PowerSave); + memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE)); + x1 = x + sizeof(BITMAP_POWERSAVE); } - x += sizeof(BITMAP_PowerSave); + x += sizeof(BITMAP_POWERSAVE); #ifdef ENABLE_NOAA // NOASS SCAN indicator