0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Show "TX DISABLE" on the correct VFO/screen line

This commit is contained in:
OneOfEleven 2023-10-01 10:15:24 +01:00
parent 7df7461d31
commit ba3decad78

132
ui/main.c
View File

@ -96,18 +96,18 @@ bool center_line_is_free = true;
#endif #endif
uint8_t *pLine = gFrameBuffer[line]; uint8_t *p_line = gFrameBuffer[line];
memset(pLine, 0, LCD_WIDTH); memset(p_line, 0, LCD_WIDTH);
#if 1 #if 1
// solid bar // solid bar
for (i = 0; i < bar_width; i++) for (i = 0; i < bar_width; i++)
pLine[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e; p_line[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e;
#else #else
// knuled bar // knuled bar
for (i = 0; i < bar_width; i += 2) for (i = 0; i < bar_width; i += 2)
pLine[bar_x + i] = (i <= len) ? 0x7f : 0x41; p_line[bar_x + i] = (i <= len) ? 0x7f : 0x41;
#endif #endif
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
@ -139,7 +139,7 @@ bool center_line_is_free = true;
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 *pLine = gFrameBuffer[line]; uint8_t *p_line = gFrameBuffer[line];
char s[16]; char s[16];
unsigned int i; unsigned int i;
@ -150,7 +150,7 @@ bool center_line_is_free = true;
return; // display is in use return; // display is in use
if (now) if (now)
memset(pLine, 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
@ -168,11 +168,11 @@ bool center_line_is_free = true;
#if 1 #if 1
// solid bar // solid bar
for (i = 0; i < bar_width; i++) for (i = 0; i < bar_width; i++)
pLine[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e; p_line[bar_x + i] = (i > len) ? ((i & 1) == 0) ? 0x41 : 0x00 : ((i & 1) == 0) ? 0x7f : 0x3e;
#else #else
// knuled bar // knuled bar
for (i = 0; i < bar_width; i += 2) for (i = 0; i < bar_width; i += 2)
pLine[bar_x + i] = (i <= len) ? 0x7f : 0x41; p_line[bar_x + i] = (i <= len) ? 0x7f : 0x41;
#endif #endif
if (now) if (now)
@ -204,7 +204,7 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
// 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 *pLine = gFrameBuffer[Line - 1]; uint8_t *p_line = gFrameBuffer[Line - 1];
// TODO: sort out all 8 values from the eeprom // TODO: sort out all 8 values from the eeprom
@ -259,31 +259,31 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN)
return; // display is in use return; // display is in use
pLine = gFrameBuffer[Line - 1]; p_line = gFrameBuffer[Line - 1];
memset(pLine, 0, 23); memset(p_line, 0, 23);
if (rssi_level > 0) if (rssi_level > 0)
{ {
//if (rssi_level >= 1) //if (rssi_level >= 1)
memmove(pLine, BITMAP_Antenna, 5); memmove(p_line, BITMAP_Antenna, 5);
if (rssi_level >= 2) if (rssi_level >= 2)
memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); memmove(p_line + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (rssi_level >= 3) if (rssi_level >= 3)
memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); memmove(p_line + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
if (rssi_level >= 4) if (rssi_level >= 4)
memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); memmove(p_line + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
if (rssi_level >= 5) if (rssi_level >= 5)
memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); memmove(p_line + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
if (rssi_level >= 6) if (rssi_level >= 6)
memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); memmove(p_line + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
if (rssi_level >= 7) if (rssi_level >= 7)
memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); memmove(p_line + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
} }
else else
pLine = NULL; p_line = NULL;
ST7565_DrawLine(0, Line, 23, pLine); ST7565_DrawLine(0, Line, 23, p_line);
#endif #endif
} }
@ -291,9 +291,12 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
void UI_DisplayMain(void) void UI_DisplayMain(void)
{ {
char String[16]; const unsigned int line0 = 0; // text screen line
unsigned int vfo_num; const unsigned int line1 = 4;
char String[16];
unsigned int vfo_num;
// true is the center screen line is not in use
center_line_is_free = true; center_line_is_free = true;
// #ifdef SINGLE_VFO_CHAN // #ifdef SINGLE_VFO_CHAN
@ -302,6 +305,7 @@ void UI_DisplayMain(void)
const bool single_vfo = false; const bool single_vfo = false;
// #endif // #endif
// clear the screen
memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (gEeprom.KEY_LOCK && gKeypadLocked > 0)
@ -314,25 +318,26 @@ void UI_DisplayMain(void)
for (vfo_num = 0; vfo_num < 2; vfo_num++) for (vfo_num = 0; vfo_num < 2; vfo_num++)
{ {
uint8_t Channel = gEeprom.TX_CHANNEL; const unsigned int rx_line = (gEeprom.RX_CHANNEL == 0) ? line0 : line1;
bool bIsSameVfo = !!(Channel == vfo_num); const unsigned int tx_line = (gEeprom.TX_CHANNEL == 0) ? line0 : line1;
uint8_t Line = (vfo_num == 0) ? 0 : 4; uint8_t channel = gEeprom.TX_CHANNEL;
uint8_t *pLine0 = gFrameBuffer[Line + 0]; const bool same_vfo = (channel == vfo_num) ? true : false;
uint8_t *pLine1 = gFrameBuffer[Line + 1]; uint8_t *p_line0 = gFrameBuffer[tx_line + 0];
uint8_t *p_line1 = gFrameBuffer[tx_line + 1];
if (single_vfo) if (single_vfo)
{ // we're in single VFO mode - screen is dedicated to just one VFO { // we're in single VFO mode - screen is dedicated to just one VFO
if (!bIsSameVfo) if (!same_vfo)
continue; // skip the unused vfo continue; // skip the unused vfo
} }
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive)
Channel = gEeprom.RX_CHANNEL; // we're currently monitoring the other VFO channel = gEeprom.RX_CHANNEL; // we're currently monitoring the other VFO
if (Channel != vfo_num) if (channel != vfo_num)
{ {
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
@ -383,20 +388,20 @@ void UI_DisplayMain(void)
} }
// highlight the selected/used VFO with a marker // highlight the selected/used VFO with a marker
if (!single_vfo && bIsSameVfo) if (!single_vfo && same_vfo)
memmove(pLine0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
else else
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
memmove(pLine0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
} }
else else
if (!single_vfo) if (!single_vfo)
{ // highlight the selected/used VFO with a marker { // highlight the selected/used VFO with a marker
if (bIsSameVfo) if (same_vfo)
memmove(pLine0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
else else
//if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) //if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
memmove(pLine0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
} }
uint32_t duff_beer = 0; uint32_t duff_beer = 0;
@ -410,8 +415,8 @@ void UI_DisplayMain(void)
else else
#endif #endif
{ {
Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL;
if (Channel == vfo_num) if (channel == vfo_num)
{ // show the TX symbol { // show the TX symbol
duff_beer = 1; duff_beer = 1;
UI_PrintStringSmall("TX", 14, 0, Line); UI_PrintStringSmall("TX", 14, 0, Line);
@ -462,29 +467,22 @@ void UI_DisplayMain(void)
// ************ // ************
uint8_t State = VfoState[vfo_num]; uint8_t 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)
{ {
Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL;
if (Channel == vfo_num) if (channel == vfo_num)
State = VFO_STATE_ALARM; state = VFO_STATE_ALARM;
} }
#endif #endif
if (State != VFO_STATE_NORMAL) if (state != VFO_STATE_NORMAL)
{ {
const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"}; const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"};
if (State >= 0 && State < ARRAY_SIZE(state_list)) if (state >= 0 && state < ARRAY_SIZE(state_list))
{ UI_PrintString(state_list[state], 31, 0, tx_line, 8);
UI_PrintString(state_list[State], 31, 0, Line, 8);
}
//else
//{
// sprintf(String, "State %u ?", State);
// UI_PrintString(String, 31, 0, Line, 8);
//}
} }
else else
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
@ -498,7 +496,7 @@ void UI_DisplayMain(void)
uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency; uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL;
if (Channel == vfo_num) if (Channel == vfo_num)
frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency; frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency;
} }
@ -509,13 +507,13 @@ 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_SCANLIST1) if (attributes & MR_CH_SCANLIST1)
memmove(pLine0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
if (attributes & MR_CH_SCANLIST2) if (attributes & MR_CH_SCANLIST2)
memmove(pLine0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
#ifndef ENABLE_BIG_FREQ #ifndef ENABLE_BIG_FREQ
#ifdef ENABLE_COMPANDER #ifdef ENABLE_COMPANDER
if ((attributes & MR_CH_COMPAND) > 0) if ((attributes & MR_CH_COMPAND) > 0)
memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#endif #endif
#endif #endif
@ -588,9 +586,9 @@ void UI_DisplayMain(void)
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(pLine0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#endif #endif
#endif #endif
} }
@ -622,20 +620,20 @@ void UI_DisplayMain(void)
if (Level >= 1) if (Level >= 1)
{ {
uint8_t *pLine = pLine1 + LCD_WIDTH; uint8_t *p_line = p_line1 + LCD_WIDTH;
memmove(pLine + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); memmove(p_line + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna));
if (Level >= 2) if (Level >= 2)
memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); memmove(p_line + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (Level >= 3) if (Level >= 3)
memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); memmove(p_line + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
if (Level >= 4) if (Level >= 4)
memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); memmove(p_line + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
if (Level >= 5) if (Level >= 5)
memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); memmove(p_line + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
if (Level >= 6) if (Level >= 6)
memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); memmove(p_line + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
if (Level >= 7) if (Level >= 7)
memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); memmove(p_line + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
} }
} }
@ -656,7 +654,7 @@ void UI_DisplayMain(void)
} }
UI_PrintStringSmall(String, LCD_WIDTH + 24, 0, Line + 1); UI_PrintStringSmall(String, LCD_WIDTH + 24, 0, Line + 1);
if (State != VFO_STATE_TX_DISABLE) if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
{ // show the TX power { // show the TX power
const char pwr_list[] = "LMH"; const char pwr_list[] = "LMH";
const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER; const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER;