diff --git a/ui/main.c b/ui/main.c index 2ada8a1..141ff4d 100644 --- a/ui/main.c +++ b/ui/main.c @@ -96,18 +96,18 @@ bool center_line_is_free = true; #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 // solid bar 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 // knuled bar 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 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 line = 3; - uint8_t *pLine = gFrameBuffer[line]; + uint8_t *p_line = gFrameBuffer[line]; char s[16]; unsigned int i; @@ -150,7 +150,7 @@ bool center_line_is_free = true; return; // display is in use if (now) - memset(pLine, 0, LCD_WIDTH); + memset(p_line, 0, LCD_WIDTH); if (rssi_dBm >= (s9_dBm + 6)) { // S9+XXdB, 1dB increment @@ -168,11 +168,11 @@ bool center_line_is_free = true; #if 1 // solid bar 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 // knuled bar 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 if (now) @@ -204,7 +204,7 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) // const int16_t dBm = (rssi / 2) - 160; 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 @@ -259,31 +259,31 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) 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 >= 1) - memmove(pLine, BITMAP_Antenna, 5); + memmove(p_line, BITMAP_Antenna, 5); 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) - memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); + memmove(p_line + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); 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) - memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); + memmove(p_line + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); 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) - memmove(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); + memmove(p_line + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); } else - pLine = NULL; + p_line = NULL; - ST7565_DrawLine(0, Line, 23, pLine); + ST7565_DrawLine(0, Line, 23, p_line); #endif } @@ -291,9 +291,12 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) void UI_DisplayMain(void) { - char String[16]; - unsigned int vfo_num; + const unsigned int line0 = 0; // text screen line + 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; // #ifdef SINGLE_VFO_CHAN @@ -302,6 +305,7 @@ void UI_DisplayMain(void) const bool single_vfo = false; // #endif + // clear the screen memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); if (gEeprom.KEY_LOCK && gKeypadLocked > 0) @@ -314,25 +318,26 @@ void UI_DisplayMain(void) for (vfo_num = 0; vfo_num < 2; vfo_num++) { - uint8_t Channel = gEeprom.TX_CHANNEL; - bool bIsSameVfo = !!(Channel == vfo_num); - uint8_t Line = (vfo_num == 0) ? 0 : 4; - uint8_t *pLine0 = gFrameBuffer[Line + 0]; - uint8_t *pLine1 = gFrameBuffer[Line + 1]; + const unsigned int rx_line = (gEeprom.RX_CHANNEL == 0) ? line0 : line1; + const unsigned int tx_line = (gEeprom.TX_CHANNEL == 0) ? line0 : line1; + uint8_t channel = gEeprom.TX_CHANNEL; + const bool same_vfo = (channel == vfo_num) ? true : false; + uint8_t *p_line0 = gFrameBuffer[tx_line + 0]; + uint8_t *p_line1 = gFrameBuffer[tx_line + 1]; if (single_vfo) { // we're in single VFO mode - screen is dedicated to just one VFO - if (!bIsSameVfo) + if (!same_vfo) continue; // skip the unused vfo } 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) { // show DTMF stuff @@ -383,20 +388,20 @@ void UI_DisplayMain(void) } // highlight the selected/used VFO with a marker - if (!single_vfo && bIsSameVfo) - memmove(pLine0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + if (!single_vfo && same_vfo) + memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); else 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 if (!single_vfo) { // highlight the selected/used VFO with a marker - if (bIsSameVfo) - memmove(pLine0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + if (same_vfo) + memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); else //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; @@ -410,8 +415,8 @@ void UI_DisplayMain(void) else #endif { - Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; - if (Channel == vfo_num) + channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; + if (channel == vfo_num) { // show the TX symbol duff_beer = 1; 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 if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) { - Channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; - if (Channel == vfo_num) - State = VFO_STATE_ALARM; + channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; + if (channel == vfo_num) + state = VFO_STATE_ALARM; } #endif - if (State != VFO_STATE_NORMAL) + if (state != VFO_STATE_NORMAL) { const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"}; - if (State >= 0 && State < ARRAY_SIZE(state_list)) - { - UI_PrintString(state_list[State], 31, 0, Line, 8); - } - //else - //{ - // sprintf(String, "State %u ?", State); - // UI_PrintString(String, 31, 0, Line, 8); - //} + if (state >= 0 && state < ARRAY_SIZE(state_list)) + UI_PrintString(state_list[state], 31, 0, tx_line, 8); } else 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; if (gCurrentFunction == FUNCTION_TRANSMIT) { // 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) frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency; } @@ -509,13 +507,13 @@ void UI_DisplayMain(void) // show the channel symbols const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; 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) - memmove(pLine0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); #ifndef ENABLE_BIG_FREQ #ifdef ENABLE_COMPANDER 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 @@ -588,9 +586,9 @@ void UI_DisplayMain(void) const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; if ((attributes & MR_CH_COMPAND) > 0) #ifdef ENABLE_BIG_FREQ - memmove(pLine0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); + memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); #else - memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); #endif #endif } @@ -622,20 +620,20 @@ void UI_DisplayMain(void) if (Level >= 1) { - uint8_t *pLine = pLine1 + LCD_WIDTH; - memmove(pLine + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); + uint8_t *p_line = p_line1 + LCD_WIDTH; + memmove(p_line + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); if (Level >= 2) - memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); + memmove(p_line + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); if (Level >= 3) - memmove(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); + memmove(p_line + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); if (Level >= 4) - memmove(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); + memmove(p_line + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); if (Level >= 5) - memmove(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); + memmove(p_line + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); if (Level >= 6) - memmove(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); + memmove(p_line + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); 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); - if (State != VFO_STATE_TX_DISABLE) + if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) { // show the TX power const char pwr_list[] = "LMH"; const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER;