Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/OneOfEleven/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Oct 4, 2023
2 parents bee4a8c + 6e7f8b1 commit ced053b
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 61 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)\"

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
41 changes: 24 additions & 17 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,34 +639,41 @@ 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)
{
switch (gCurrentScanList)
{
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)
Expand All @@ -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;

Expand Down
77 changes: 46 additions & 31 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion firmware.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
33 changes: 29 additions & 4 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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));
Expand Down
5 changes: 4 additions & 1 deletion ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ced053b

Please sign in to comment.