Refactoring, cleanup, comments

This commit is contained in:
Krzysiek Egzmont
2023-10-19 21:42:56 +02:00
parent a21c8a62ac
commit a5fa0b1e4b
4 changed files with 253 additions and 261 deletions

View File

@@ -535,6 +535,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms;
gScheduleDualWatch = false;
// when crossband is active only the main VFO should be used for TX
if(gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
gRxVfoIsActive = true;

3
misc.h
View File

@@ -280,7 +280,8 @@ extern ReceptionMode_t gRxReceptionMode;
extern scan_next_chan_t gCurrentScanList;
extern uint32_t gRestoreFrequency;
extern bool gRxVfoIsActive; //TRUE when dual watch is momentarly suspended and RX_VFO is locked to either last TX or RX
//TRUE when dual watch is momentarly suspended and RX_VFO is locked to either last TX or RX
extern bool gRxVfoIsActive;
extern uint8_t gAlarmToneCounter;
extern uint16_t gAlarmRunningCounter;
extern bool gKeyBeingHeld;

View File

@@ -555,9 +555,10 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
static void RADIO_SelectCurrentVfo(void)
{
// if crossband is active the current is gTxVfo (gTxVfo/TX_VFO is only ever changed by the user)
// otherwise it is set to gRxVfo (gRxVfo/RX_VFO is equal to TX when dual watch is turned off)
// if crossband is active the gCurrentVfo is gTxVfo (gTxVfo/TX_VFO is only ever changed by the user)
// otherwise it is set to gRxVfo
// so in the end gCurrentVfo is equal to gTxVfo unless dual watch changes it on incomming transmition (again, this can only happen when XB off)
// note: it is called only in certain situations so could not by up-to-date
gCurrentVfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gRxVfo : gTxVfo;
}

View File

@@ -66,8 +66,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
while (bit)
{
const unsigned int temp = ((sqrti << 1) | bit) << shift--;
if (value >= temp)
{
if (value >= temp) {
value -= temp;
sqrti |= bit;
}
@@ -293,12 +292,12 @@ void UI_DisplayMain(void)
for (vfo_num = 0; vfo_num < 2; vfo_num++)
{
const unsigned int line = (vfo_num == 0) ? line0 : line1;
const bool isSelectedVFO = (vfo_num == gEeprom.TX_VFO);
const bool isMainVFO = (vfo_num == gEeprom.TX_VFO);
uint8_t *p_line0 = gFrameBuffer[line + 0];
uint8_t *p_line1 = gFrameBuffer[line + 1];
unsigned int mode = 0;
if (activeTxVFO != vfo_num)
if (activeTxVFO != vfo_num) // this is not active TX VFO
{
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode)
{ // show DTMF stuff
@@ -343,12 +342,12 @@ void UI_DisplayMain(void)
}
// highlight the selected/used VFO with a marker
if (isSelectedVFO)
if (isMainVFO)
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
}
else
else // active TX VFO
{ // highlight the selected/used VFO with a marker
if (isSelectedVFO)
if (isMainVFO)
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
else
memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
@@ -400,8 +399,7 @@ void UI_DisplayMain(void)
sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text
UI_PrintStringSmall(String, x, 0, line + 1);
}
else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // frequency mode
// show the frequency band number
const unsigned int x = 2;
@@ -429,8 +427,7 @@ void UI_DisplayMain(void)
unsigned int state = VfoState[vfo_num];
#ifdef ENABLE_ALARM
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM)
{
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) {
if (activeTxVFO == vfo_num)
state = VFO_STATE_ALARM;
}
@@ -442,8 +439,7 @@ void UI_DisplayMain(void)
if (state < ARRAY_SIZE(state_list))
UI_PrintString(state_list[state], 31, 0, line, 8);
}
else
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
{ // user entering a frequency
const char * ascii = INPUTBOX_GetAscii();
sprintf(String, "%.3s.%.3s", ascii, ascii + 3);
@@ -511,18 +507,15 @@ void UI_DisplayMain(void)
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
}
if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME)
{
if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) {
UI_PrintString(String, 32, 0, line, 8);
}
else
{
else {
#ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold(String, 32 + 4, 0, line);
#else
UI_PrintStringSmall(String, 32 + 4, 0, line);
#endif
// show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
UI_PrintStringSmall(String, 32 + 4, 0, line + 1);
@@ -654,8 +647,7 @@ void UI_DisplayMain(void)
gCurrentFunction == FUNCTION_INCOMING);
#ifdef ENABLE_AUDIO_BAR
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT)
{
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) {
center_line = CENTER_LINE_AUDIO_BAR;
UI_DisplayAudioBar();
}
@@ -677,14 +669,12 @@ void UI_DisplayMain(void)
#endif
#ifdef ENABLE_RSSI_BAR
if (rx)
{
if (rx) {
center_line = CENTER_LINE_RSSI;
UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false);
}
else
#endif
if (rx || gCurrentFunction == FUNCTION_FOREGROUND || gCurrentFunction == FUNCTION_POWER_SAVE)
{
#if 1
@@ -722,8 +712,7 @@ void UI_DisplayMain(void)
#endif
#ifdef ENABLE_SHOW_CHARGE_LEVEL
else
if (gChargingWithTypeC)
else if (gChargingWithTypeC)
{ // charging .. show the battery state
if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)