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; gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
// when crossband is active only the main VFO should be used for TX
if(gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) if(gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
gRxVfoIsActive = true; gRxVfoIsActive = true;

3
misc.h
View File

@@ -280,7 +280,8 @@ extern ReceptionMode_t gRxReceptionMode;
extern scan_next_chan_t gCurrentScanList; extern scan_next_chan_t gCurrentScanList;
extern uint32_t gRestoreFrequency; 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 uint8_t gAlarmToneCounter;
extern uint16_t gAlarmRunningCounter; extern uint16_t gAlarmRunningCounter;
extern bool gKeyBeingHeld; extern bool gKeyBeingHeld;

View File

@@ -555,9 +555,10 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
static void RADIO_SelectCurrentVfo(void) static void RADIO_SelectCurrentVfo(void)
{ {
// if crossband is active the current is gTxVfo (gTxVfo/TX_VFO is only ever changed by the user) // if crossband is active the gCurrentVfo 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) // 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) // 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; gCurrentVfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gRxVfo : gTxVfo;
} }

505
ui/main.c
View File

@@ -58,212 +58,211 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
unsigned int sqrt16(unsigned int value) unsigned int sqrt16(unsigned int value)
{ // return square root of 'value' { // return square root of 'value'
unsigned int shift = 16; // number of bits supplied in 'value' .. 2 ~ 32 unsigned int shift = 16; // number of bits supplied in 'value' .. 2 ~ 32
unsigned int bit = 1u << --shift; unsigned int bit = 1u << --shift;
unsigned int sqrti = 0; unsigned int sqrti = 0;
while (bit) while (bit)
{
const unsigned int temp = ((sqrti << 1) | bit) << shift--;
if (value >= temp)
{
value -= temp;
sqrti |= bit;
}
bit >>= 1;
}
return sqrti;
}
void UI_DisplayAudioBar(void)
{ {
if (gSetting_mic_bar) const unsigned int temp = ((sqrti << 1) | bit) << shift--;
{ if (value >= temp) {
const unsigned int line = 3; value -= temp;
const unsigned int bar_x = 2; sqrti |= bit;
const unsigned int bar_width = LCD_WIDTH - 2 - bar_x; }
unsigned int i; bit >>= 1;
}
return sqrti;
}
if (gCurrentFunction != FUNCTION_TRANSMIT || void UI_DisplayAudioBar(void)
gScreenToDisplay != DISPLAY_MAIN || {
gDTMF_CallState != DTMF_CALL_STATE_NONE) if (gSetting_mic_bar)
{ {
return; // screen is in use const unsigned int line = 3;
} const unsigned int bar_x = 2;
const unsigned int bar_width = LCD_WIDTH - 2 - bar_x;
unsigned int i;
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 defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState != ALARM_STATE_OFF) if (gAlarmState != ALARM_STATE_OFF)
return; return;
#endif #endif
const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0 const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0
// make non-linear to make more sensitive at low values
const unsigned int level = voice_amp * 8;
const unsigned int sqrt_level = sqrt16((level < 65535) ? level : 65535);
const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width;
uint8_t *p_line = gFrameBuffer[line]; // make non-linear to make more sensitive at low values
const unsigned int level = voice_amp * 8;
memset(p_line, 0, LCD_WIDTH); const unsigned int sqrt_level = sqrt16((level < 65535) ? level : 65535);
const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width;
for (i = 0; i < bar_width; i++)
p_line[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e;
if (gCurrentFunction == FUNCTION_TRANSMIT) uint8_t *p_line = gFrameBuffer[line];
ST7565_BlitFullScreen();
} memset(p_line, 0, LCD_WIDTH);
for (i = 0; i < bar_width; i++)
p_line[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e;
if (gCurrentFunction == FUNCTION_TRANSMIT)
ST7565_BlitFullScreen();
} }
}
#endif #endif
#if defined(ENABLE_RSSI_BAR) #if defined(ENABLE_RSSI_BAR)
void UI_DisplayRSSIBar(const int16_t rssi, const bool now) void UI_DisplayRSSIBar(const int16_t rssi, const bool now)
{ {
// const int16_t s0_dBm = -127; // S0 .. base level // const int16_t s0_dBm = -127; // S0 .. base level
const int16_t s0_dBm = -147; // S0 .. base level const int16_t s0_dBm = -147; // S0 .. base level
const int16_t s9_dBm = s0_dBm + (6 * 9); // S9 .. 6dB/S-Point const int16_t s9_dBm = s0_dBm + (6 * 9); // S9 .. 6dB/S-Point
const int16_t bar_max_dBm = s9_dBm + 30; // S9+30dB const int16_t bar_max_dBm = s9_dBm + 30; // S9+30dB
// const int16_t bar_min_dBm = s0_dBm + (6 * 0); // S0 // const int16_t bar_min_dBm = s0_dBm + (6 * 0); // S0
const int16_t bar_min_dBm = s0_dBm + (6 * 4); // S4 const int16_t bar_min_dBm = s0_dBm + (6 * 4); // S4
// ************ // ************
const unsigned int txt_width = 7 * 8; // 8 text chars const unsigned int txt_width = 7 * 8; // 8 text chars
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x; const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;
const int16_t rssi_dBm = (rssi / 2) - 160; const int16_t rssi_dBm = (rssi / 2) - 160;
const int16_t clamped_dBm = (rssi_dBm <= bar_min_dBm) ? bar_min_dBm : (rssi_dBm >= bar_max_dBm) ? bar_max_dBm : rssi_dBm; const int16_t clamped_dBm = (rssi_dBm <= bar_min_dBm) ? bar_min_dBm : (rssi_dBm >= bar_max_dBm) ? bar_max_dBm : rssi_dBm;
const unsigned int bar_range_dB = bar_max_dBm - bar_min_dBm; const unsigned int bar_range_dB = bar_max_dBm - bar_min_dBm;
const unsigned int len = ((clamped_dBm - bar_min_dBm) * bar_width) / bar_range_dB; const unsigned int len = ((clamped_dBm - bar_min_dBm) * bar_width) / bar_range_dB;
const unsigned int line = 3; const unsigned int line = 3;
uint8_t *p_line = gFrameBuffer[line]; uint8_t *p_line = gFrameBuffer[line];
char s[16]; char s[16];
unsigned int i; unsigned int i;
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || if (gCurrentFunction == FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
return; // display is in use return; // display is in use
if (now) if (now)
memset(p_line, 0, LCD_WIDTH); memset(p_line, 0, LCD_WIDTH);
if (rssi_dBm >= (s9_dBm + 6)) if (rssi_dBm >= (s9_dBm + 6))
{ // S9+XXdB, 1dB increment { // S9+XXdB, 1dB increment
const char *fmt[] = {"%3d 9+%u ", "%3d 9+%2u "}; const char *fmt[] = {"%3d 9+%u ", "%3d 9+%2u "};
const unsigned int s9_dB = ((rssi_dBm - s9_dBm) <= 99) ? rssi_dBm - s9_dBm : 99; const unsigned int s9_dB = ((rssi_dBm - s9_dBm) <= 99) ? rssi_dBm - s9_dBm : 99;
sprintf(s, (s9_dB < 10) ? fmt[0] : fmt[1], rssi_dBm, s9_dB); sprintf(s, (s9_dB < 10) ? fmt[0] : fmt[1], rssi_dBm, s9_dB);
}
else
{ // S0 ~ S9, 6dB per S-point
const unsigned int s_level = (rssi_dBm >= s0_dBm) ? (rssi_dBm - s0_dBm) / 6 : 0;
sprintf(s, "%4d S%u ", rssi_dBm, s_level);
}
UI_PrintStringSmall(s, 2, 0, line);
#if 1
// solid bar
for (i = 0; i < bar_width; i++)
p_line[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e;
#else
// knuled bar
for (i = 0; i < bar_width; i += 2)
p_line[bar_x + i] = (i <= len) ? 0x7f : 0x41;
#endif
if (now)
ST7565_BlitFullScreen();
} }
else
{ // S0 ~ S9, 6dB per S-point
const unsigned int s_level = (rssi_dBm >= s0_dBm) ? (rssi_dBm - s0_dBm) / 6 : 0;
sprintf(s, "%4d S%u ", rssi_dBm, s_level);
}
UI_PrintStringSmall(s, 2, 0, line);
#if 1
// solid bar
for (i = 0; i < bar_width; i++)
p_line[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e;
#else
// knuled bar
for (i = 0; i < bar_width; i += 2)
p_line[bar_x + i] = (i <= len) ? 0x7f : 0x41;
#endif
if (now)
ST7565_BlitFullScreen();
}
#endif #endif
void UI_UpdateRSSI(const int16_t rssi, const int vfo) void UI_UpdateRSSI(const int16_t rssi, const int vfo)
{ {
#ifdef ENABLE_RSSI_BAR #ifdef ENABLE_RSSI_BAR
(void)vfo; // unused (void)vfo; // unused
// optional larger RSSI dBm, S-point and bar level // optional larger RSSI dBm, S-point and bar level
if (center_line != CENTER_LINE_RSSI) if (center_line != CENTER_LINE_RSSI)
return; return;
if (gCurrentFunction == FUNCTION_RECEIVE || if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) gCurrentFunction == FUNCTION_INCOMING)
{ {
UI_DisplayRSSIBar(rssi, true); UI_DisplayRSSIBar(rssi, true);
} }
#else #else
// original little RS bars // original little RS bars
// const int16_t dBm = (rssi / 2) - 160; // const int16_t dBm = (rssi / 2) - 160;
const uint8_t Line = (vfo == 0) ? 3 : 7; const uint8_t Line = (vfo == 0) ? 3 : 7;
uint8_t *p_line = gFrameBuffer[Line - 1]; uint8_t *p_line = gFrameBuffer[Line - 1];
const unsigned int band = gRxVfo->Band; const unsigned int band = gRxVfo->Band;
const int16_t level0 = gEEPROM_RSSI_CALIB[band][0]; const int16_t level0 = gEEPROM_RSSI_CALIB[band][0];
const int16_t level1 = gEEPROM_RSSI_CALIB[band][1]; const int16_t level1 = gEEPROM_RSSI_CALIB[band][1];
const int16_t level2 = gEEPROM_RSSI_CALIB[band][2]; const int16_t level2 = gEEPROM_RSSI_CALIB[band][2];
const int16_t level3 = gEEPROM_RSSI_CALIB[band][3]; const int16_t level3 = gEEPROM_RSSI_CALIB[band][3];
const int16_t level01 = (level0 + level1) / 2; const int16_t level01 = (level0 + level1) / 2;
const int16_t level12 = (level1 + level2) / 2; const int16_t level12 = (level1 + level2) / 2;
const int16_t level23 = (level2 + level3) / 2; const int16_t level23 = (level2 + level3) / 2;
gVFO_RSSI[vfo] = rssi; gVFO_RSSI[vfo] = rssi;
uint8_t rssi_level = 0; uint8_t rssi_level = 0;
if (rssi >= level3) rssi_level = 7; if (rssi >= level3) rssi_level = 7;
else else
if (rssi >= level23) rssi_level = 6; if (rssi >= level23) rssi_level = 6;
else else
if (rssi >= level2) rssi_level = 5; if (rssi >= level2) rssi_level = 5;
else else
if (rssi >= level12) rssi_level = 4; if (rssi >= level12) rssi_level = 4;
else else
if (rssi >= level1) rssi_level = 3; if (rssi >= level1) rssi_level = 3;
else else
if (rssi >= level01) rssi_level = 2; if (rssi >= level01) rssi_level = 2;
else else
if (rssi >= level0) rssi_level = 1; if (rssi >= level0) rssi_level = 1;
if (gVFO_RSSI_bar_level[vfo] == rssi_level) if (gVFO_RSSI_bar_level[vfo] == rssi_level)
return; return;
gVFO_RSSI_bar_level[vfo] = rssi_level; gVFO_RSSI_bar_level[vfo] = rssi_level;
// ********************************************************** // **********************************************************
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN)
return; // display is in use return; // display is in use
p_line = gFrameBuffer[Line - 1]; p_line = gFrameBuffer[Line - 1];
memset(p_line, 0, 23); memset(p_line, 0, 23);
// untested !!! // untested !!!
if (rssi_level == 0) if (rssi_level == 0)
p_line = NULL; p_line = NULL;
else else
UI_drawBars(p_line, rssi_level); UI_drawBars(p_line, rssi_level);
ST7565_DrawLine(0, Line, 23, p_line); ST7565_DrawLine(0, Line, 23, p_line);
#endif #endif
} }
// *************************************************************************** // ***************************************************************************
@@ -293,12 +292,12 @@ void UI_DisplayMain(void)
for (vfo_num = 0; vfo_num < 2; vfo_num++) for (vfo_num = 0; vfo_num < 2; vfo_num++)
{ {
const unsigned int line = (vfo_num == 0) ? line0 : line1; 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_line0 = gFrameBuffer[line + 0];
uint8_t *p_line1 = gFrameBuffer[line + 1]; uint8_t *p_line1 = gFrameBuffer[line + 1];
unsigned int mode = 0; 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) if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode)
{ // show DTMF stuff { // show DTMF stuff
@@ -343,12 +342,12 @@ void UI_DisplayMain(void)
} }
// highlight the selected/used VFO with a marker // highlight the selected/used VFO with a marker
if (isSelectedVFO) if (isMainVFO)
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
} }
else else // active TX VFO
{ // highlight the selected/used VFO with a marker { // highlight the selected/used VFO with a marker
if (isSelectedVFO) if (isMainVFO)
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
else else
memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
@@ -366,11 +365,11 @@ void UI_DisplayMain(void)
if (activeTxVFO == vfo_num) if (activeTxVFO == vfo_num)
{ // show the TX symbol { // show the TX symbol
mode = 1; mode = 1;
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold("TX", 14, 0, line); UI_PrintStringSmallBold("TX", 14, 0, line);
#else #else
UI_PrintStringSmall("TX", 14, 0, line); UI_PrintStringSmall("TX", 14, 0, line);
#endif #endif
} }
} }
} }
@@ -382,11 +381,11 @@ void UI_DisplayMain(void)
gCurrentFunction == FUNCTION_INCOMING) && gCurrentFunction == FUNCTION_INCOMING) &&
gEeprom.RX_VFO == vfo_num) gEeprom.RX_VFO == vfo_num)
{ {
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold("RX", 14, 0, line); UI_PrintStringSmallBold("RX", 14, 0, line);
#else #else
UI_PrintStringSmall("RX", 14, 0, line); UI_PrintStringSmall("RX", 14, 0, line);
#endif #endif
} }
} }
@@ -397,11 +396,10 @@ void UI_DisplayMain(void)
if (!inputting) if (!inputting)
sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1); sprintf(String, "M%u", gEeprom.ScreenChannel[vfo_num] + 1);
else else
sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text
UI_PrintStringSmall(String, x, 0, line + 1); UI_PrintStringSmall(String, x, 0, line + 1);
} }
else else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // frequency mode { // frequency mode
// show the frequency band number // show the frequency band number
const unsigned int x = 2; const unsigned int x = 2;
@@ -409,32 +407,31 @@ void UI_DisplayMain(void)
sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf); sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf);
UI_PrintStringSmall(String, x, 0, line + 1); UI_PrintStringSmall(String, x, 0, line + 1);
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ {
if (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) if (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num)
{ // channel number { // channel number
sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST); sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST);
}
else
{ // user entering channel number
sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]);
}
UI_PrintStringSmall(String, 7, 0, line + 1);
} }
#endif else
{ // user entering channel number
sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]);
}
UI_PrintStringSmall(String, 7, 0, line + 1);
}
#endif
// ************ // ************
unsigned int state = VfoState[vfo_num]; unsigned int state = VfoState[vfo_num];
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) {
{
if (activeTxVFO == vfo_num) if (activeTxVFO == vfo_num)
state = VFO_STATE_ALARM; state = VFO_STATE_ALARM;
} }
#endif #endif
if (state != VFO_STATE_NORMAL) if (state != VFO_STATE_NORMAL)
{ {
@@ -442,8 +439,7 @@ void UI_DisplayMain(void)
if (state < ARRAY_SIZE(state_list)) if (state < ARRAY_SIZE(state_list))
UI_PrintString(state_list[state], 31, 0, line, 8); UI_PrintString(state_list[state], 31, 0, line, 8);
} }
else else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num)
{ // user entering a frequency { // user entering a frequency
const char * ascii = INPUTBOX_GetAscii(); const char * ascii = INPUTBOX_GetAscii();
sprintf(String, "%.3s.%.3s", ascii, ascii + 3); sprintf(String, "%.3s.%.3s", ascii, ascii + 3);
@@ -469,12 +465,12 @@ void UI_DisplayMain(void)
memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
// compander symbol // compander symbol
#ifndef ENABLE_BIG_FREQ #ifndef ENABLE_BIG_FREQ
if ((attributes & MR_CH_COMPAND) > 0) if ((attributes & MR_CH_COMPAND) > 0)
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
// TODO: // find somewhere else to put the symbol // TODO: // find somewhere else to put the symbol
#endif #endif
switch (gEeprom.CHANNEL_DISPLAY_MODE) switch (gEeprom.CHANNEL_DISPLAY_MODE)
{ {
@@ -511,18 +507,15 @@ void UI_DisplayMain(void)
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); 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); UI_PrintString(String, 32, 0, line, 8);
} }
else else {
{ #ifdef ENABLE_SMALL_BOLD
#ifdef ENABLE_SMALL_BOLD UI_PrintStringSmallBold(String, 32 + 4, 0, line);
UI_PrintStringSmallBold(String, 32 + 4, 0, line); #else
#else UI_PrintStringSmall(String, 32 + 4, 0, line);
UI_PrintStringSmall(String, 32 + 4, 0, line); #endif
#endif
// show the channel frequency below the channel number/name // show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
UI_PrintStringSmall(String, 32 + 4, 0, line + 1); UI_PrintStringSmall(String, 32 + 4, 0, line + 1);
@@ -553,11 +546,11 @@ void UI_DisplayMain(void)
// show the channel symbols // show the channel symbols
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
if ((attributes & MR_CH_COMPAND) > 0) if ((attributes & MR_CH_COMPAND) > 0)
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#endif #endif
} }
} }
@@ -653,38 +646,35 @@ void UI_DisplayMain(void)
gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING); gCurrentFunction == FUNCTION_INCOMING);
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) {
{ center_line = CENTER_LINE_AUDIO_BAR;
center_line = CENTER_LINE_AUDIO_BAR; UI_DisplayAudioBar();
UI_DisplayAudioBar(); }
} else
else #endif
#endif
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix) if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix)
{ {
if (gScreenToDisplay != DISPLAY_MAIN || if (gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
return; return;
center_line = CENTER_LINE_AM_FIX_DATA; center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(gEeprom.RX_VFO, String); AM_fix_print_data(gEeprom.RX_VFO, String);
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(String, 2, 0, 3);
} }
else else
#endif #endif
#ifdef ENABLE_RSSI_BAR
if (rx)
{
center_line = CENTER_LINE_RSSI;
UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false);
}
else
#endif
#ifdef ENABLE_RSSI_BAR
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 (rx || gCurrentFunction == FUNCTION_FOREGROUND || gCurrentFunction == FUNCTION_POWER_SAVE)
{ {
#if 1 #if 1
@@ -721,22 +711,21 @@ void UI_DisplayMain(void)
} }
#endif #endif
#ifdef ENABLE_SHOW_CHARGE_LEVEL #ifdef ENABLE_SHOW_CHARGE_LEVEL
else else if (gChargingWithTypeC)
if (gChargingWithTypeC) { // charging .. show the battery state
{ // charging .. show the battery state if (gScreenToDisplay != DISPLAY_MAIN ||
if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE)
gDTMF_CallState != DTMF_CALL_STATE_NONE) return;
return;
center_line = CENTER_LINE_CHARGE_DATA; center_line = CENTER_LINE_CHARGE_DATA;
sprintf(String, "Charge %u.%02uV %u%%", sprintf(String, "Charge %u.%02uV %u%%",
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
BATTERY_VoltsToPercent(gBatteryVoltageAverage)); BATTERY_VoltsToPercent(gBatteryVoltageAverage));
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(String, 2, 0, 3);
} }
#endif #endif
} }
} }