diff --git a/Makefile b/Makefile index 43bf649db..74867d673 100644 --- a/Makefile +++ b/Makefile @@ -174,9 +174,14 @@ CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delet ifeq ($(ENABLE_LTO), 1) # CFLAGS += -flto CFLAGS += -flto=2 +else +# We get most of the space savings if LTO creates problems + CFLAGS += -ffunction-sections -fdata-sections endif +# May cause unhelpful build failures #CFLAGS += -Wpadded + CFLAGS += -DPRINTF_INCLUDE_CONFIG_H CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" @@ -288,6 +293,11 @@ LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld # Use newlib-nano instead of newlib LDFLAGS += --specs=nano.specs +ifeq ($(ENABLE_LTO), 0) +# Throw away unneeded func/data sections like LTO does + LDFLAGS += -Wl,--gc-sections +endif + ifeq ($(DEBUG),1) ASFLAGS += -g CFLAGS += -g diff --git a/README.md b/README.md index 553177e84..701654f70 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,12 @@ ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO #ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter ``` +# New/modified function keys + +* Long-press 'M' = Copy selected channel into the same VFO, then switches to frequency mode +* Long-press '5' = Toggle a selected channels scanlist setting .. if NOAA is disable in Makefile +* Long-press '*' = Toggles the scanlist number 1, 2 or ALL channels .. if in channel scan mode + # Some changes made from the Quansheng firmware * Various Quansheng firmware bugs fixed diff --git a/app/action.c b/app/action.c index 729e34fe7..c931d4fbf 100644 --- a/app/action.c +++ b/app/action.c @@ -186,7 +186,7 @@ void ACTION_Scan(bool bRestart) { #if 1 // keep scanning but toggle between scan lists - gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) & 1u; + gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3; gUpdateStatus = true; #else SCANNER_Stop(); @@ -217,7 +217,7 @@ void ACTION_Scan(bool bRestart) else if (!bRestart) { // keep scanning but toggle between scan lists - gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) & 1u; + gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3; gUpdateStatus = true; } else diff --git a/app/app.c b/app/app.c index d4b073f6e..9a7f78394 100644 --- a/app/app.c +++ b/app/app.c @@ -639,12 +639,12 @@ static void FREQ_NextChannel(void) static void MR_NextChannel(void) { - static unsigned int prev_mr_chan = 0; - const bool enabled = gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT]; - const unsigned int chan1 = gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT]; - const unsigned int chan2 = gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT]; - const unsigned int prev_chan = gNextMrChannel; - unsigned int chan = 0; + static int prev_mr_chan = 0; + const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true; + const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1; + const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1; + const int prev_chan = gNextMrChannel; + int chan = 0; if (enabled) { @@ -652,21 +652,28 @@ static void MR_NextChannel(void) { case SCAN_NEXT_CHAN_SCANLIST1: prev_mr_chan = gNextMrChannel; - if (RADIO_CheckValidChannel(chan1, false, 0)) + + if (chan1 >= 0) { - //gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; - gNextMrChannel = chan1; - break; + if (RADIO_CheckValidChannel(chan1, false, 0)) + { + //gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; + gNextMrChannel = chan1; + break; + } } - + case SCAN_NEXT_CHAN_SCANLIST2: - if (RADIO_CheckValidChannel(chan2, false, 0)) + if (chan2 >= 0) { - gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2; - gNextMrChannel = chan2; - break; + if (RADIO_CheckValidChannel(chan2, false, 0)) + { + gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2; + gNextMrChannel = chan2; + break; + } } - + // this bit doesn't work at all - yet :( case SCAN_NEXT_CHAN_DUAL_WATCH: // if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) @@ -693,7 +700,7 @@ static void MR_NextChannel(void) if (!enabled || chan == 0xffffffff) { - chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, true, gEeprom.SCAN_LIST_DEFAULT); + chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT); if (chan == 0xFF) return; diff --git a/app/main.c b/app/main.c index dbe2c3767..34767352c 100644 --- a/app/main.c +++ b/app/main.c @@ -51,7 +51,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) #else - // TODO: do something useful with the key + // TODO: make use of this function key #endif @@ -170,6 +170,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) case KEY_5: if(beep) { #ifdef ENABLE_NOAA + if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_CHANNEL]; @@ -189,26 +190,30 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) #endif } else { - // toggle scanlist-1 and scanlist 2 + // toggle the selected channels scanlist setting + if (gScreenToDisplay != DISPLAY_SCANNER) { - if (gTxVfo->SCANLIST1_PARTICIPATION) + if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { - if (gTxVfo->SCANLIST2_PARTICIPATION) - gTxVfo->SCANLIST1_PARTICIPATION = 0; + if (gTxVfo->SCANLIST1_PARTICIPATION) + { + if (gTxVfo->SCANLIST2_PARTICIPATION) + gTxVfo->SCANLIST1_PARTICIPATION = 0; + else + gTxVfo->SCANLIST2_PARTICIPATION = 1; + } else - gTxVfo->SCANLIST2_PARTICIPATION = 1; + { + if (gTxVfo->SCANLIST2_PARTICIPATION) + gTxVfo->SCANLIST2_PARTICIPATION = 0; + else + gTxVfo->SCANLIST1_PARTICIPATION = 1; + } + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gVfoConfigureMode = VFO_CONFIGURE; + gFlagResetVfos = true; } - else - { - if (gTxVfo->SCANLIST2_PARTICIPATION) - gTxVfo->SCANLIST2_PARTICIPATION = 0; - else - gTxVfo->SCANLIST1_PARTICIPATION = 1; - } - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); - gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; } } break; @@ -223,7 +228,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) #else - // TODO: make use of the function key press + // TODO: make use of this function key #endif @@ -564,20 +569,30 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) int channel = -1; int vfo = -1; - if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) && - IS_MR_CHANNEL(gEeprom.ScreenChannel[1])) - { - channel = gEeprom.ScreenChannel[1]; - vfo = 0; - } - else - if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1]) && - IS_MR_CHANNEL(gEeprom.ScreenChannel[0])) - { - channel = gEeprom.ScreenChannel[0]; - vfo = 1; - } - + #if 0 + // copy channel to opposite VFO + if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) && + IS_MR_CHANNEL(gEeprom.ScreenChannel[1])) + { + channel = gEeprom.ScreenChannel[1]; + vfo = 0; + } + else + if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1]) && + IS_MR_CHANNEL(gEeprom.ScreenChannel[0])) + { + channel = gEeprom.ScreenChannel[0]; + vfo = 1; + } + #else + // copy channel to same VFO + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[gEeprom.RX_CHANNEL])) + { + channel = gEeprom.ScreenChannel[gEeprom.RX_CHANNEL]; + vfo = gEeprom.RX_CHANNEL; + } + #endif + if (channel >= 0 && vfo >= 0) { // copy the channel into the VFO diff --git a/app/menu.c b/app/menu.c index 1f874fc92..7c338ca8a 100644 --- a/app/menu.c +++ b/app/menu.c @@ -284,7 +284,8 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) break; case MENU_S_LIST: - *pMin = 1; + *pMin = 0; +// *pMax = 1; *pMax = 2; break; @@ -612,7 +613,7 @@ void MENU_AcceptSetting(void) break; case MENU_S_LIST: - gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection - 1; + gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection; break; #ifdef ENABLE_ALARM @@ -1018,7 +1019,7 @@ void MENU_ShowCurrentSetting(void) break; case MENU_S_LIST: - gSubMenuSelection = gEeprom.SCAN_LIST_DEFAULT + 1; + gSubMenuSelection = gEeprom.SCAN_LIST_DEFAULT; break; case MENU_SLIST1: diff --git a/board.c b/board.c index 528ca604e..75733e65c 100644 --- a/board.c +++ b/board.c @@ -624,7 +624,7 @@ void BOARD_EEPROM_Init(void) gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#'; gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0; - gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 10) ? Data[4] : 10; + gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10; gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300; gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100; gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100; diff --git a/driver/bk4819.c b/driver/bk4819.c index 5f654b558..695d11f29 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -913,7 +913,7 @@ void BK4819_EnableDTMF(void) // REG_24 <3:0> 14 Max symbol number for SelCall detection // const uint16_t threshold = 24; // doesn't decode non-QS radios - const uint16_t threshold = 200; // but 128 ~ 247 does + const uint16_t threshold = 160; // but 128 ~ 247 does BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110 (1u << BK4819_REG_24_SHIFT_UNKNOWN_15) | (threshold << BK4819_REG_24_SHIFT_THRESHOLD) // 0 ~ 255 diff --git a/firmware.ld b/firmware.ld index c00d2baf8..a7bd16bb8 100644 --- a/firmware.ld +++ b/firmware.ld @@ -17,7 +17,7 @@ SECTIONS .text : { . = ALIGN(4); - *(.text.isr) /* .text sections of code */ + KEEP(*(.text.isr)) /* .text sections of code */ *(.text) /* .text sections of code */ *(.text*) /* .text* sections of code */ *(.rodata) /* .rodata sections */ diff --git a/ui/main.c b/ui/main.c index 651281651..60c2c815e 100644 --- a/ui/main.c +++ b/ui/main.c @@ -91,9 +91,11 @@ void UI_drawBars(uint8_t *p, const unsigned int level) #if 1 // TX audio level - if (gCurrentFunction != FUNCTION_TRANSMIT) - return; - + if (gCurrentFunction != FUNCTION_TRANSMIT || + gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) + return; // screen is in use + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) if (gAlarmState != ALARM_STATE_OFF) return; @@ -170,7 +172,9 @@ void UI_drawBars(uint8_t *p, const unsigned int level) if (gEeprom.KEY_LOCK && gKeypadLocked > 0) return; // display is in use - if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) + if (gCurrentFunction == FUNCTION_TRANSMIT || + gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) return; // display is in use if (now) @@ -719,6 +723,10 @@ void UI_DisplayMain(void) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) if (rx && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix) { + if (gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) + return; + center_line = CENTER_LINE_AM_FIX_DATA; AM_fix_print_data(gEeprom.RX_CHANNEL, String); UI_PrintStringSmall(String, 2, 0, 3); @@ -742,7 +750,13 @@ void UI_DisplayMain(void) { // show live DTMF decode const unsigned int len = strlen(gDTMF_RX_live); const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars + + if (gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) + return; + center_line = CENTER_LINE_DTMF_DEC; + strcpy(String, "DTMF "); strcat(String, gDTMF_RX_live + idx); UI_PrintStringSmall(String, 2, 0, 3); @@ -752,7 +766,13 @@ void UI_DisplayMain(void) { // show live DTMF decode const unsigned int len = gDTMF_RX_index; const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars + + if (gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) + return; + center_line = CENTER_LINE_DTMF_DEC; + strcpy(String, "DTMF "); strcat(String, gDTMF_RX + idx); UI_PrintStringSmall(String, 2, 0, 3); @@ -763,7 +783,12 @@ void UI_DisplayMain(void) else if (gChargingWithTypeC) { // charging .. show the battery state + if (gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) + return; + center_line = CENTER_LINE_CHARGE_DATA; + sprintf(String, "Charge %u.%02uV %u%%", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, BATTERY_VoltsToPercent(gBatteryVoltageAverage)); diff --git a/ui/menu.c b/ui/menu.c index 585d23f39..424e137ca 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -709,7 +709,10 @@ void UI_DisplayMenu(void) break; case MENU_S_LIST: - sprintf(String, "LIST%u", gSubMenuSelection); + if (gSubMenuSelection < 2) + sprintf(String, "LIST%u", 1 + gSubMenuSelection); + else + strcpy(String, "ALL"); break; #ifdef ENABLE_ALARM diff --git a/ui/status.c b/ui/status.c index b1e94bc5b..0927afafe 100644 --- a/ui/status.c +++ b/ui/status.c @@ -100,8 +100,13 @@ void UI_DisplayStatus(const bool test_display) // memmove(line + x, BITMAP_SC1, sizeof(BITMAP_SC1)); UI_PrintStringSmallBuffer("1", line + x); else + if (gEeprom.SCAN_LIST_DEFAULT == 1) // memmove(line + x, BITMAP_SC2, sizeof(BITMAP_SC2)); UI_PrintStringSmallBuffer("2", line + x); + else + if (gEeprom.SCAN_LIST_DEFAULT == 2) +// memmove(line + x, BITMAP_SCA, sizeof(BITMAP_SCA)); + UI_PrintStringSmallBuffer("*", line + x); // x1 = x + sizeof(BITMAP_SC1); x1 = x + 7; }