diff --git a/Makefile b/Makefile index 642c21a..aeca797 100755 --- a/Makefile +++ b/Makefile @@ -86,6 +86,7 @@ OBJS += frequencies.o OBJS += functions.o OBJS += helper/battery.o OBJS += helper/boot.o +OBJS += helper/measurements.o OBJS += misc.o OBJS += radio.o OBJS += scheduler.o diff --git a/app/spectrum.c b/app/spectrum.c index ff65085..8ef5377 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -35,8 +35,6 @@ bool preventKeypress = true; bool isListening = false; bool isTransmitting = false; -bool isPttPressed = false; - State currentState = SPECTRUM, previousState = SPECTRUM; PeakInfo peak; @@ -48,15 +46,17 @@ const char *modulationTypeOptions[] = {" FM", " AM", "USB"}; const uint8_t modulationTypeTuneSteps[] = {100, 50, 10}; const uint8_t modTypeReg47Values[] = {1, 7, 5}; -SpectrumSettings settings = {STEPS_64, - S_STEP_25_0kHz, - 80000, - 3200, - 150, - true, - BK4819_FILTER_BW_WIDE, - BK4819_FILTER_BW_WIDE, - false}; +SpectrumSettings settings = { + .stepsCount = STEPS_64, + .scanStepIndex = S_STEP_25_0kHz, + .frequencyChangeStep = 80000, + .scanDelay = 3200, + .rssiTriggerLevel = 150, + .backlightState = true, + .bw = BK4819_FILTER_BW_WIDE, + .listenBw = BK4819_FILTER_BW_WIDE, + .modulationType = false, +}; uint32_t fMeasure = 0; uint32_t fTx = 0; @@ -100,19 +100,6 @@ uint16_t statuslineUpdateTimer = 0; bool isMovingInitialized = false; uint8_t lastStepsCount = 0; -static uint8_t DBm2S(int dbm) { - uint8_t i = 0; - dbm *= -1; - for (i = 0; i < ARRAY_SIZE(U8RssiMap); i++) { - if (dbm >= U8RssiMap[i]) { - return i; - } - } - return i; -} - -static int Rssi2DBm(uint16_t rssi) { return (rssi >> 1) - 160; } - uint8_t CountBits(uint16_t n) { uint8_t count = 0; while (n) { @@ -149,56 +136,6 @@ static void UpdateRegMenuValue(RegisterSpec s, bool add) { redrawScreen = true; } -// GUI functions - -static void PutPixel(uint8_t x, uint8_t y, bool fill) { - if (fill) { - gFrameBuffer[y >> 3][x] |= 1 << (y & 7); - } else { - gFrameBuffer[y >> 3][x] &= ~(1 << (y & 7)); - } -} - -static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { - if (fill) { - gStatusLine[x] |= 1 << y; - } else { - gStatusLine[x] &= ~(1 << y); - } -} - -static void DrawHLine(int sy, int ey, int nx, bool fill) { - for (int i = sy; i <= ey; i++) { - if (i < 56 && nx < 128) { - PutPixel(nx, i, fill); - } - } -} - -static void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, - bool statusbar, bool fill) { - uint8_t c; - uint8_t pixels; - const uint8_t *p = (const uint8_t *)pString; - - while ((c = *p++) && c != '\0') { - c -= 0x20; - for (int i = 0; i < 3; ++i) { - pixels = gFont3x5[c][i]; - for (int j = 0; j < 6; ++j) { - if (pixels & 1) { - if (statusbar) - PutPixelStatus(x + i, y + j, fill); - else - PutPixel(x + i, y + j, fill); - } - pixels >>= 1; - } - } - x += 4; - } -} - // Utility functions KEY_Code_t GetKey() { @@ -209,12 +146,6 @@ KEY_Code_t GetKey() { return btn; } -static int clamp(int v, int min, int max) { - return v <= min ? min : (v >= max ? max : v); -} - -static uint8_t my_abs(signed v) { return v > 0 ? v : -v; } - void SetState(State state) { previousState = currentState; currentState = state; @@ -224,14 +155,6 @@ void SetState(State state) { // Radio functions -static void ToggleAFBit(bool on) { - uint16_t reg = BK4819_ReadRegister(BK4819_REG_47); - reg &= ~(1 << 8); - if (on) - reg |= on << 8; - BK4819_WriteRegister(BK4819_REG_47, reg); -} - static void BackupRegisters() { R30 = BK4819_ReadRegister(0x30); R37 = BK4819_ReadRegister(0x37); @@ -264,14 +187,6 @@ static void SetModulation(ModulationType type) { } } -static void ToggleAFDAC(bool on) { - uint32_t Reg = BK4819_ReadRegister(BK4819_REG_30); - Reg &= ~(1 << 9); - if (on) - Reg |= (1 << 9); - BK4819_WriteRegister(BK4819_REG_30, Reg); -} - static void SetF(uint32_t f) { fMeasure = f; @@ -416,7 +331,7 @@ uint32_t GetOffsetedF(uint32_t f) { break; } - return clamp(f, FrequencyBandTable[0].lower, + return Clamp(f, FrequencyBandTable[0].lower, FrequencyBandTable[ARRAY_SIZE(FrequencyBandTable) - 1].upper); } @@ -446,8 +361,8 @@ static void ToggleRX(bool on) { BK4819_RX_TurnOn(); ToggleAudio(on); - ToggleAFDAC(on); - ToggleAFBit(on); + BK4819_ToggleAFDAC(on); + BK4819_ToggleAFBit(on); if (on) { listenT = 1000; @@ -566,7 +481,7 @@ static void UpdateScanInfo() { static void AutoTriggerLevel() { if (settings.rssiTriggerLevel == RSSI_MAX_VALUE) { - settings.rssiTriggerLevel = clamp(mov.max + 8, 0, RSSI_MAX_VALUE); + settings.rssiTriggerLevel = Clamp(mov.max + 8, 0, RSSI_MAX_VALUE); } } @@ -790,18 +705,6 @@ static void Blacklist() { // Draw things -static int ConvertDomain(int aValue, int aMin, int aMax, int bMin, int bMax) { - const int aRange = aMax - aMin; - const int bRange = bMax - bMin; - aValue = clamp(aValue, aMin, aMax); - return ((aValue - aMin) * bRange + aRange / 2) / aRange + bMin; -} - -// applied x2 to prevent initial rounding -static uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) { - return ConvertDomain(rssi - 320, -260, -120, pxMin, pxMax); -} - static uint8_t Rssi2Y(uint16_t rssi) { return DrawingEndY - ConvertDomain(rssi, mov.min - 2, mov.max + 30 + (mov.max - mov.min) / 3, 0, @@ -867,7 +770,7 @@ static void DrawStatus() { static void DrawF(uint32_t f) { sprintf(String, "%u.%05u", f / 100000, f % 100000); - if (currentState == STILL && isPttPressed) { + if (currentState == STILL && kbd.current == KEY_PTT) { if (gBatteryDisplayLevel == 6) { sprintf(String, "VOLTAGE HIGH"); } else if (!IsTXAllowed()) { @@ -880,34 +783,34 @@ static void DrawF(uint32_t f) { UI_PrintStringSmall(String, 8, 127, 0); sprintf(String, "%s", modulationTypeOptions[settings.modulationType]); - GUI_DisplaySmallest(String, 116, 1, false, true); + UI_PrintStringSmallest(String, 116, 1, false, true); sprintf(String, "%s", bwOptions[settings.listenBw]); - GUI_DisplaySmallest(String, 108, 7, false, true); + UI_PrintStringSmallest(String, 108, 7, false, true); } static void DrawNums() { if (currentState == SPECTRUM) { sprintf(String, "%ux", GetStepsCount()); - GUI_DisplaySmallest(String, 0, 1, false, true); + UI_PrintStringSmallest(String, 0, 1, false, true); sprintf(String, "%u.%02uk", GetScanStep() / 100, GetScanStep() % 100); - GUI_DisplaySmallest(String, 0, 7, false, true); + UI_PrintStringSmallest(String, 0, 7, false, true); } if (IsCenterMode()) { sprintf(String, "%u.%05u \xB1%u.%02uk", currentFreq / 100000, currentFreq % 100000, settings.frequencyChangeStep / 100, settings.frequencyChangeStep % 100); - GUI_DisplaySmallest(String, 36, 49, false, true); + UI_PrintStringSmallest(String, 36, 49, false, true); } else { sprintf(String, "%u.%05u", GetFStart() / 100000, GetFStart() % 100000); - GUI_DisplaySmallest(String, 0, 49, false, true); + UI_PrintStringSmallest(String, 0, 49, false, true); sprintf(String, "\xB1%u.%02uk", settings.frequencyChangeStep / 100, settings.frequencyChangeStep % 100); - GUI_DisplaySmallest(String, 48, 49, false, true); + UI_PrintStringSmallest(String, 48, 49, false, true); sprintf(String, "%u.%05u", GetFEnd() / 100000, GetFEnd() % 100000); - GUI_DisplaySmallest(String, 93, 49, false, true); + UI_PrintStringSmallest(String, 93, 49, false, true); } } @@ -954,8 +857,9 @@ static void DrawTicks() { static void DrawArrow(uint8_t x) { for (signed i = -2; i <= 2; ++i) { signed v = x + i; + uint8_t a = i > 0 ? i : -i; if (!(v & 128)) { - gFrameBuffer[5][v] |= (0b01111000 << my_abs(i)) & 0b01111000; + gFrameBuffer[5][v] |= (0b01111000 << a) & 0b01111000; } } } @@ -1112,7 +1016,6 @@ void OnKeyDownStill(KEY_Code_t key) { case KEY_PTT: // start transmit UpdateBatteryInfo(); - isPttPressed = true; if (gBatteryDisplayLevel != 6 && IsTXAllowed()) { ToggleTX(true); } @@ -1141,7 +1044,6 @@ void OnKeyDownStill(KEY_Code_t key) { } static void OnKeysReleased() { - isPttPressed = false; if (isTransmitting) { ToggleTX(false); } @@ -1195,9 +1097,9 @@ static void RenderStill() { } else { sprintf(String, "S9+%u0", s - 9); } - GUI_DisplaySmallest(String, 4, 9, false, true); + UI_PrintStringSmallest(String, 4, 9, false, true); sprintf(String, "%d dBm", dbm); - GUI_DisplaySmallest(String, 32, 9, false, true); + UI_PrintStringSmallest(String, 32, 9, false, true); if (isTransmitting) { uint8_t afDB = BK4819_ReadRegister(0x6F) & 0b1111111; @@ -1231,11 +1133,11 @@ static void RenderStill() { } RegisterSpec s = registerSpecs[idx]; sprintf(String, "%s", s.name); - GUI_DisplaySmallest(String, offset + 2, row * 8 + 2, false, - menuState != idx); + UI_PrintStringSmallest(String, offset + 2, row * 8 + 2, false, + menuState != idx); sprintf(String, "%u", GetRegMenuValue(s)); - GUI_DisplaySmallest(String, offset + 2, (row + 1) * 8 + 1, false, - menuState != idx); + UI_PrintStringSmallest(String, offset + 2, (row + 1) * 8 + 1, false, + menuState != idx); } } diff --git a/app/spectrum.h b/app/spectrum.h index 6c1d212..8769a8a 100644 --- a/app/spectrum.h +++ b/app/spectrum.h @@ -31,6 +31,7 @@ #include "../font.h" #include "../frequencies.h" #include "../helper/battery.h" +#include "../helper/measurements.h" #include "../misc.h" #include "../radio.h" #include "../settings.h" @@ -41,10 +42,6 @@ static const uint8_t DrawingEndY = 40; -static const uint8_t U8RssiMap[] = { - 141, 135, 129, 123, 117, 111, 105, 99, 93, 83, 73, 63, -}; - static const uint16_t scanStepValues[] = { 1, 10, 50, 100, diff --git a/driver/bk4819.c b/driver/bk4819.c index 033c6dc..0baf7eb 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -972,3 +972,18 @@ void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code) BK4819_ExitTxMute(); } +void BK4819_ToggleAFBit(bool on) { + uint16_t reg = BK4819_ReadRegister(BK4819_REG_47); + reg &= ~(1 << 8); + if (on) + reg |= on << 8; + BK4819_WriteRegister(BK4819_REG_47, reg); +} + +void BK4819_ToggleAFDAC(bool on) { + uint32_t Reg = BK4819_ReadRegister(BK4819_REG_30); + Reg &= ~(1 << 9); + if (on) + Reg |= (1 << 9); + BK4819_WriteRegister(BK4819_REG_30, Reg); +} diff --git a/driver/bk4819.h b/driver/bk4819.h index fccb2a2..20efec6 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -139,5 +139,8 @@ void BK4819_GetVoxAmp(uint16_t *pResult); void BK4819_SetScrambleFrequencyControlWord(uint32_t Frequency); void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code); +void BK4819_ToggleAFBit(bool on); +void BK4819_ToggleAFDAC(bool on); + #endif diff --git a/helper/measurements.c b/helper/measurements.c new file mode 100644 index 0000000..43267c6 --- /dev/null +++ b/helper/measurements.c @@ -0,0 +1,46 @@ +/* Copyright 2023 fagci + * https://github.com/fagci + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "../helper/measurements.h" + +int Clamp(int v, int min, int max) { + return v <= min ? min : (v >= max ? max : v); +} + +int ConvertDomain(int aValue, int aMin, int aMax, int bMin, int bMax) { + const int aRange = aMax - aMin; + const int bRange = bMax - bMin; + aValue = Clamp(aValue, aMin, aMax); + return ((aValue - aMin) * bRange + aRange / 2) / aRange + bMin; +} + +uint8_t DBm2S(int dbm) { + uint8_t i = 0; + dbm *= -1; + for (i = 0; i < ARRAY_SIZE(U8RssiMap); i++) { + if (dbm >= U8RssiMap[i]) { + return i; + } + } + return i; +} + +int Rssi2DBm(uint16_t rssi) { return (rssi >> 1) - 160; } + +// applied x2 to prevent initial rounding +uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) { + return ConvertDomain(rssi - 320, -260, -120, pxMin, pxMax); +} diff --git a/helper/measurements.h b/helper/measurements.h new file mode 100644 index 0000000..d039ed1 --- /dev/null +++ b/helper/measurements.h @@ -0,0 +1,19 @@ +#ifndef MEASUREMENTS_H +#define MEASUREMENTS_H + +#include "../misc.h" +#include + +static const uint8_t U8RssiMap[] = { + 141, 135, 129, 123, 117, 111, 105, 99, 93, 83, 73, 63, +}; + +int Clamp(int v, int min, int max); +int ConvertDomain(int aValue, int aMin, int aMax, int bMin, int bMax); +uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax); +uint8_t DBm2S(int dbm); +int Rssi2DBm(uint16_t rssi); + +#endif /* end of include guard: MEASUREMENTS_H */ + +// vim: ft=c diff --git a/ui/helper.c b/ui/helper.c index 6315ba1..18dab58 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -141,3 +141,50 @@ void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t } } +void PutPixel(uint8_t x, uint8_t y, bool fill) { + if (fill) { + gFrameBuffer[y >> 3][x] |= 1 << (y & 7); + } else { + gFrameBuffer[y >> 3][x] &= ~(1 << (y & 7)); + } +} + +void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { + if (fill) { + gStatusLine[x] |= 1 << y; + } else { + gStatusLine[x] &= ~(1 << y); + } +} + +void DrawHLine(int sy, int ey, int nx, bool fill) { + for (int i = sy; i <= ey; i++) { + if (i < 56 && nx < 128) { + PutPixel(nx, i, fill); + } + } +} + +void UI_PrintStringSmallest(const char *pString, uint8_t x, uint8_t y, + bool statusbar, bool fill) { + uint8_t c; + uint8_t pixels; + const uint8_t *p = (const uint8_t *)pString; + + while ((c = *p++) && c != '\0') { + c -= 0x20; + for (int i = 0; i < 3; ++i) { + pixels = gFont3x5[c][i]; + for (int j = 0; j < 6; ++j) { + if (pixels & 1) { + if (statusbar) + PutPixelStatus(x + i, y + j, fill); + else + PutPixel(x + i, y + j, fill); + } + pixels >>= 1; + } + } + x += 4; + } +} diff --git a/ui/helper.h b/ui/helper.h index 7b7cdf2..cbd8b1b 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -21,11 +21,20 @@ #include void UI_GenerateChannelString(char *pString, uint8_t Channel); -void UI_GenerateChannelStringEx(char *pString, bool bShowPrefix, uint8_t ChannelNumber); -void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width, bool bCentered); -void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); -void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag); -void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t Y); +void UI_GenerateChannelStringEx(char *pString, bool bShowPrefix, + uint8_t ChannelNumber); +void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, + uint8_t Line, uint8_t Width, bool bCentered); +void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, + uint8_t Line); +void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, + bool bDisplayLeadingZero, bool bFlag); +void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, + uint8_t Y); +void PutPixel(uint8_t x, uint8_t y, bool fill); +void PutPixelStatus(uint8_t x, uint8_t y, bool fill); +void DrawHLine(int sy, int ey, int nx, bool fill); +void UI_PrintStringSmallest(const char *pString, uint8_t x, uint8_t y, + bool statusbar, bool fill); #endif - diff --git a/ui/main.c b/ui/main.c index 05dfa55..324e82e 100644 --- a/ui/main.c +++ b/ui/main.c @@ -14,414 +14,426 @@ * limitations under the License. */ +#include "../ui/main.h" +#include "../app/dtmf.h" +#include "../bitmaps.h" +#include "../driver/bk4819.h" +#include "../driver/st7565.h" +#include "../external/printf/printf.h" +#include "../functions.h" +#include "../helper/measurements.h" +#include "../misc.h" +#include "../radio.h" +#include "../settings.h" +#include "../ui/helper.h" +#include "../ui/inputbox.h" #include -#include "app/dtmf.h" -#include "bitmaps.h" -#include "driver/st7565.h" -#include "external/printf/printf.h" -#include "functions.h" -#include "misc.h" -#include "radio.h" -#include "settings.h" -#include "ui/helper.h" -#include "ui/inputbox.h" -#include "ui/main.h" -#include "driver/bk4819.h" #if defined(ENABLE_RSSIBAR) -void UI_DisplayRSSIBar(int16_t rssi) -{ - char String[16]; - const int16_t dBm = (rssi / 2) - 160; - - const unsigned int line = 3; - const unsigned int bar_width = 92; - - const unsigned int max = 350; - const unsigned int min = 80; - const unsigned int adjusted_max = max - min; - const unsigned int level = (((rssi - min) * bar_width) + (adjusted_max / 2)) / adjusted_max; - const unsigned int len = level < bar_width ? level : bar_width; - - uint8_t *pLine = gFrameBuffer[line]; - - for (unsigned int i = 34; i < (len+35); i += 2) - pLine[i] = 0x3e; - - sprintf(String, "%d", dBm); - UI_PrintStringSmall(String, 0, 0, 3); +void UI_DisplayRSSIBar(int16_t rssi) { + char String[16]; + + const uint8_t LINE = 3; + const uint8_t BAR_WIDTH = 92; + const uint8_t BAR_LEFT_MARGIN = 34; + + uint8_t length = Rssi2PX(rssi, 0, BAR_WIDTH); + + for (int i = BAR_LEFT_MARGIN; i < BAR_LEFT_MARGIN + length; i += 2) { + gFrameBuffer[LINE][i] = 0x3e; + } + + sprintf(String, "%d", Rssi2DBm(rssi)); + UI_PrintStringSmall(String, 0, 0, 3); } #endif -void UI_DisplayMain(void) -{ - char String[16]; - uint8_t i; - - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); - if (gEeprom.KEY_LOCK && gKeypadLocked) { - UI_PrintString("Long Press #", 0, 127, 1, 8, true); - UI_PrintString("To Unlock", 0, 127, 3, 8, true); - ST7565_BlitFullScreen(); - return; - } - - for (i = 0; i < 2; i++) { - uint8_t *pLine0; - uint8_t *pLine1; - uint8_t Line; - uint8_t Channel; - bool bIsSameVfo; - - if (i == 0) { - pLine0 = gFrameBuffer[0]; - pLine1 = gFrameBuffer[1]; - Line = 0; - } else { - pLine0 = gFrameBuffer[4]; - pLine1 = gFrameBuffer[5]; - Line = 4; - } - - Channel = gEeprom.TX_CHANNEL; - bIsSameVfo = !!(Channel == i); - - if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) { - Channel = gEeprom.RX_CHANNEL; - } - - if (Channel != i) { - if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) { - char Contact[16]; - - if (!gDTMF_InputMode) { - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { - if (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) { - strcpy(String, "CALL OUT(RSP)"); - } else { - strcpy(String, "CALL OUT"); - } - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) { - if (DTMF_FindContact(gDTMF_Caller, Contact)) { - sprintf(String, "CALL:%s", Contact); - } else { - sprintf(String, "CALL:%s", gDTMF_Caller); - } - } else if (gDTMF_IsTx) { - if (gDTMF_State == DTMF_STATE_TX_SUCC) { - strcpy(String, "DTMF TX(SUCC)"); - } else { - strcpy(String, "DTMF TX"); - } - } - } else { - sprintf(String, ">%s", gDTMF_InputBox); - } - UI_PrintString(String, 2, 127, i * 3, 8, false); - - memset(String, 0, sizeof(String)); - memset(Contact, 0, sizeof(Contact)); - - if (!gDTMF_InputMode) { - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { - if (DTMF_FindContact(gDTMF_String, Contact)) { - sprintf(String, ">%s", Contact); - } else { - sprintf(String, ">%s", gDTMF_String); - } - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) { - if (DTMF_FindContact(gDTMF_Callee, Contact)) { - sprintf(String, ">%s", Contact); - } else { - sprintf(String, ">%s", gDTMF_Callee); - } - } else if (gDTMF_IsTx) { - sprintf(String, ">%s", gDTMF_String); - } - } - UI_PrintString(String, 2, 127, 2 + (i * 3), 8, false); - continue; - } else if (bIsSameVfo) { - memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); - } - } else { - if (bIsSameVfo) { - memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); - } else { - memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); - } - } - - // 0x8EE2 - uint32_t SomeValue = 0; - - if (gCurrentFunction == FUNCTION_TRANSMIT) { +void UI_DisplayMain(void) { + char String[16]; + uint8_t i; + + memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + if (gEeprom.KEY_LOCK && gKeypadLocked) { + UI_PrintString("Long Press #", 0, 127, 1, 8, true); + UI_PrintString("To Unlock", 0, 127, 3, 8, true); + ST7565_BlitFullScreen(); + return; + } + + for (i = 0; i < 2; i++) { + uint8_t *pLine0; + uint8_t *pLine1; + uint8_t Line; + uint8_t Channel; + bool bIsSameVfo; + + if (i == 0) { + pLine0 = gFrameBuffer[0]; + pLine1 = gFrameBuffer[1]; + Line = 0; + } else { + pLine0 = gFrameBuffer[4]; + pLine1 = gFrameBuffer[5]; + Line = 4; + } + + Channel = gEeprom.TX_CHANNEL; + bIsSameVfo = !!(Channel == i); + + if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) { + Channel = gEeprom.RX_CHANNEL; + } + + if (Channel != i) { + if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || + gDTMF_InputMode) { + char Contact[16]; + + if (!gDTMF_InputMode) { + if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { + if (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) { + strcpy(String, "CALL OUT(RSP)"); + } else { + strcpy(String, "CALL OUT"); + } + } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) { + if (DTMF_FindContact(gDTMF_Caller, Contact)) { + sprintf(String, "CALL:%s", Contact); + } else { + sprintf(String, "CALL:%s", gDTMF_Caller); + } + } else if (gDTMF_IsTx) { + if (gDTMF_State == DTMF_STATE_TX_SUCC) { + strcpy(String, "DTMF TX(SUCC)"); + } else { + strcpy(String, "DTMF TX"); + } + } + } else { + sprintf(String, ">%s", gDTMF_InputBox); + } + UI_PrintString(String, 2, 127, i * 3, 8, false); + + memset(String, 0, sizeof(String)); + memset(Contact, 0, sizeof(Contact)); + + if (!gDTMF_InputMode) { + if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { + if (DTMF_FindContact(gDTMF_String, Contact)) { + sprintf(String, ">%s", Contact); + } else { + sprintf(String, ">%s", gDTMF_String); + } + } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) { + if (DTMF_FindContact(gDTMF_Callee, Contact)) { + sprintf(String, ">%s", Contact); + } else { + sprintf(String, ">%s", gDTMF_Callee); + } + } else if (gDTMF_IsTx) { + sprintf(String, ">%s", gDTMF_String); + } + } + UI_PrintString(String, 2, 127, 2 + (i * 3), 8, false); + continue; + } else if (bIsSameVfo) { + memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + } + } else { + if (bIsSameVfo) { + memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + } else { + memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, + sizeof(BITMAP_VFO_NotDefault)); + } + } + + // 0x8EE2 + uint32_t SomeValue = 0; + + if (gCurrentFunction == FUNCTION_TRANSMIT) { #if defined(ENABLE_ALARM) - if (gAlarmState == ALARM_STATE_ALARM) { - SomeValue = 2; - } else { + if (gAlarmState == ALARM_STATE_ALARM) { + SomeValue = 2; + } else { #else - if (1) { + if (1) { #endif - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { - Channel = gEeprom.RX_CHANNEL; - } else { - Channel = gEeprom.TX_CHANNEL; - } - if (Channel == i) { - SomeValue = 1; - memcpy(pLine0 + 14, BITMAP_TX, sizeof(BITMAP_TX)); - } - } - } else { - SomeValue = 2; - if ((gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) && gEeprom.RX_CHANNEL == i) { - memcpy(pLine0 + 14, BITMAP_RX, sizeof(BITMAP_RX)); - } - } - - // 0x8F3C - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) { - memcpy(pLine1 + 2, BITMAP_M, sizeof(BITMAP_M)); - if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != i) { - NUMBER_ToDigits(gEeprom.ScreenChannel[i] + 1, String); - } else { - memcpy(String + 5, gInputBox, 3); - } - UI_DisplaySmallDigits(3, String + 5, 10, Line + 1); - } else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[i])) { - char c; - - memcpy(pLine1 + 14, BITMAP_F, sizeof(BITMAP_F)); - c = (gEeprom.ScreenChannel[i] - FREQ_CHANNEL_FIRST) + 1; - UI_DisplaySmallDigits(1, &c, 22, Line + 1); - } else { + if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { + Channel = gEeprom.RX_CHANNEL; + } else { + Channel = gEeprom.TX_CHANNEL; + } + if (Channel == i) { + SomeValue = 1; + memcpy(pLine0 + 14, BITMAP_TX, sizeof(BITMAP_TX)); + } + } + } else { + SomeValue = 2; + if ((gCurrentFunction == FUNCTION_RECEIVE || + gCurrentFunction == FUNCTION_MONITOR) && + gEeprom.RX_CHANNEL == i) { + memcpy(pLine0 + 14, BITMAP_RX, sizeof(BITMAP_RX)); + } + } + + // 0x8F3C + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) { + memcpy(pLine1 + 2, BITMAP_M, sizeof(BITMAP_M)); + if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != i) { + NUMBER_ToDigits(gEeprom.ScreenChannel[i] + 1, String); + } else { + memcpy(String + 5, gInputBox, 3); + } + UI_DisplaySmallDigits(3, String + 5, 10, Line + 1); + } else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[i])) { + char c; + + memcpy(pLine1 + 14, BITMAP_F, sizeof(BITMAP_F)); + c = (gEeprom.ScreenChannel[i] - FREQ_CHANNEL_FIRST) + 1; + UI_DisplaySmallDigits(1, &c, 22, Line + 1); + } else { #if defined(ENABLE_NOAA) - memcpy(pLine1 + 7, BITMAP_NarrowBand, sizeof(BITMAP_NarrowBand)); - if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != i) { - NUMBER_ToDigits((gEeprom.ScreenChannel[i] - NOAA_CHANNEL_FIRST) + 1, String); - } else { - String[6] = gInputBox[0]; - String[7] = gInputBox[1]; - } - UI_DisplaySmallDigits(2, String + 6, 15, Line + 1); + memcpy(pLine1 + 7, BITMAP_NarrowBand, sizeof(BITMAP_NarrowBand)); + if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != i) { + NUMBER_ToDigits((gEeprom.ScreenChannel[i] - NOAA_CHANNEL_FIRST) + 1, + String); + } else { + String[6] = gInputBox[0]; + String[7] = gInputBox[1]; + } + UI_DisplaySmallDigits(2, String + 6, 15, Line + 1); #endif - } + } - // 0x8FEC + // 0x8FEC - uint8_t State = VfoState[i]; + uint8_t State = VfoState[i]; #if defined(ENABLE_ALARM) - if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) { - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { - Channel = gEeprom.RX_CHANNEL; - } else { - Channel = gEeprom.TX_CHANNEL; - } - if (Channel == i) { - State = VFO_STATE_ALARM; - } - } + if (gCurrentFunction == FUNCTION_TRANSMIT && + gAlarmState == ALARM_STATE_ALARM) { + if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { + Channel = gEeprom.RX_CHANNEL; + } else { + Channel = gEeprom.TX_CHANNEL; + } + if (Channel == i) { + State = VFO_STATE_ALARM; + } + } #endif - if (State) { - uint8_t Width = 10; - - memset(String, 0, sizeof(String)); - switch (State) { - case 1: - strcpy(String, "BUSY"); - Width = 15; - break; - case 2: - strcpy(String, "BAT LOW"); - break; - case 3: - strcpy(String, "DISABLE"); - break; - case 4: - strcpy(String, "TIMEOUT"); - break; + if (State) { + uint8_t Width = 10; + + memset(String, 0, sizeof(String)); + switch (State) { + case 1: + strcpy(String, "BUSY"); + Width = 15; + break; + case 2: + strcpy(String, "BAT LOW"); + break; + case 3: + strcpy(String, "DISABLE"); + break; + case 4: + strcpy(String, "TIMEOUT"); + break; #if defined(ENABLE_ALARM) - case 5: - strcpy(String, "ALARM"); - break; + case 5: + strcpy(String, "ALARM"); + break; #endif - case 6: - sprintf(String, "VOL HIGH"); - Width = 8; - break; - } - UI_PrintString(String, 31, 111, i * 4, Width, true); - } else { - if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[i]) && gEeprom.TX_CHANNEL == i) { - UI_DisplayFrequency(gInputBox, 31, i * 4, true, false); - } else { - uint32_t frequency = gEeprom.VfoInfo[i].pRX->Frequency; - if (!IS_MR_CHANNEL(gEeprom.ScreenChannel[i]) || gEeprom.CHANNEL_DISPLAY_MODE == MDF_FREQUENCY) { - if (gCurrentFunction == FUNCTION_TRANSMIT) { - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { - Channel = gEeprom.RX_CHANNEL; - } else { - Channel = gEeprom.TX_CHANNEL; - } - if (Channel == i) { - frequency = gEeprom.VfoInfo[i].pTX->Frequency; - } else { - frequency = gEeprom.VfoInfo[i].pRX->Frequency; - } - } else { - frequency = gEeprom.VfoInfo[i].pRX->Frequency; - } - // UI_DisplayFrequency(String, 31, i * 4, false, false); - sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); - UI_PrintString(String, 31, 112, i * 4, 8, true); - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) { - const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[i]]; - if (Attributes & MR_CH_SCANLIST1) { - memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - } - if (Attributes & MR_CH_SCANLIST2) { - memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - } - } - } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_CHANNEL) { - sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); - UI_PrintString(String, 31, 112, i * 4, 8, true); - } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { - if(gEeprom.VfoInfo[i].Name[0] == 0 || gEeprom.VfoInfo[i].Name[0] == 0xFF) { - sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); - UI_PrintString(String, 31, 112, i * 4, 8, true); - } else { - UI_PrintString(gEeprom.VfoInfo[i].Name, 31, 112, i * 4, 8, true); - } - } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME_FREQ) { - if (gEeprom.VfoInfo[i].Name[0] <= 32 || - gEeprom.VfoInfo[i].Name[0] >= 127) - { // no channel name, show channel number instead - sprintf(String, "CH-%03u", gEeprom.ScreenChannel[i] + 1); - } - else - { // channel name - memset(String, 0, sizeof(String)); - memmove(String, gEeprom.VfoInfo[i].Name, 10); - } - UI_PrintStringSmall(String, 31 + 8, 0, Line); - - // show the channel frequency below the channel number/name - sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); - UI_PrintStringSmall(String, 31 + 8, 0, Line + 1); - } - } - } - - // 0x926E - uint8_t Level = 0; - - if (SomeValue == 1) { - if (gRxVfo->OUTPUT_POWER == OUTPUT_POWER_LOW) { - Level = 2; - } else if (gRxVfo->OUTPUT_POWER == OUTPUT_POWER_MID) { - Level = 4; - } else { - Level = 6; - } - } else if (SomeValue == 2) { - if (gVFO_RSSI_Level[i]) { - Level = gVFO_RSSI_Level[i]; - } - } - - // TODO: not quite how the original does it, but it's quite entangled in Ghidra. - if (Level) { - memcpy(pLine1 + 128 + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); - memcpy(pLine1 + 128 + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); - if (Level >= 2) { - memcpy(pLine1 + 128 + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); - } - if (Level >= 3) { - memcpy(pLine1 + 128 + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); - } - if (Level >= 4) { - memcpy(pLine1 + 128 + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); - } - if (Level >= 5) { - memcpy(pLine1 + 128 + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); - } - if (Level >= 6) { - memcpy(pLine1 + 128 + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); - } - } - - // 0x931E - if (gEeprom.VfoInfo[i].IsAM) { - memcpy(pLine1 + 128 + 27, BITMAP_AM, sizeof(BITMAP_AM)); - } else { - const FREQ_Config_t *pConfig; - - if (SomeValue == 1) { - pConfig = gEeprom.VfoInfo[i].pTX; - } else { - pConfig = gEeprom.VfoInfo[i].pRX; - } - switch (pConfig->CodeType) { - case CODE_TYPE_CONTINUOUS_TONE: - memcpy(pLine1 + 128 + 27, BITMAP_CT, sizeof(BITMAP_CT)); - break; - case CODE_TYPE_DIGITAL: - case CODE_TYPE_REVERSE_DIGITAL: - memcpy(pLine1 + 128 + 24, BITMAP_DCS, sizeof(BITMAP_DCS)); - break; - default: - break; - } - } - - // 0x936C - switch (gEeprom.VfoInfo[i].OUTPUT_POWER) { - case OUTPUT_POWER_LOW: - memcpy(pLine1 + 128 + 44, BITMAP_PowerLow, sizeof(BITMAP_PowerLow)); - break; - case OUTPUT_POWER_MID: - memcpy(pLine1 + 128 + 44, BITMAP_PowerMid, sizeof(BITMAP_PowerMid)); - break; - case OUTPUT_POWER_HIGH: - memcpy(pLine1 + 128 + 44, BITMAP_PowerHigh, sizeof(BITMAP_PowerHigh)); - break; - } - - if (gEeprom.VfoInfo[i].ConfigRX.Frequency != gEeprom.VfoInfo[i].ConfigTX.Frequency) { - if (gEeprom.VfoInfo[i].FREQUENCY_DEVIATION_SETTING == FREQUENCY_DEVIATION_ADD) { - memcpy(pLine1 + 128 + 54, BITMAP_Add, sizeof(BITMAP_Add)); - } - if (gEeprom.VfoInfo[i].FREQUENCY_DEVIATION_SETTING == FREQUENCY_DEVIATION_SUB) { - memcpy(pLine1 + 128 + 54, BITMAP_Sub, sizeof(BITMAP_Sub)); - } - - } - - if (gEeprom.VfoInfo[i].FrequencyReverse) { - memcpy(pLine1 + 128 + 64, BITMAP_ReverseMode, sizeof(BITMAP_ReverseMode)); - } - if (gEeprom.VfoInfo[i].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) { - memcpy(pLine1 + 128 + 74, BITMAP_NarrowBand, sizeof(BITMAP_NarrowBand)); - } - if (gEeprom.VfoInfo[i].DTMF_DECODING_ENABLE || gSetting_KILLED) { - memcpy(pLine1 + 128 + 84, BITMAP_DTMF, sizeof(BITMAP_DTMF)); - } - if (gEeprom.VfoInfo[i].SCRAMBLING_TYPE && gSetting_ScrambleEnable) { - memcpy(pLine1 + 128 + 110, BITMAP_Scramble, sizeof(BITMAP_Scramble)); - } - } + case 6: + sprintf(String, "VOL HIGH"); + Width = 8; + break; + } + UI_PrintString(String, 31, 111, i * 4, Width, true); + } else { + if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[i]) && + gEeprom.TX_CHANNEL == i) { + UI_DisplayFrequency(gInputBox, 31, i * 4, true, false); + } else { + uint32_t frequency = gEeprom.VfoInfo[i].pRX->Frequency; + if (!IS_MR_CHANNEL(gEeprom.ScreenChannel[i]) || + gEeprom.CHANNEL_DISPLAY_MODE == MDF_FREQUENCY) { + if (gCurrentFunction == FUNCTION_TRANSMIT) { + if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) { + Channel = gEeprom.RX_CHANNEL; + } else { + Channel = gEeprom.TX_CHANNEL; + } + if (Channel == i) { + frequency = gEeprom.VfoInfo[i].pTX->Frequency; + } else { + frequency = gEeprom.VfoInfo[i].pRX->Frequency; + } + } else { + frequency = gEeprom.VfoInfo[i].pRX->Frequency; + } + // UI_DisplayFrequency(String, 31, i * 4, false, false); + sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); + UI_PrintString(String, 31, 112, i * 4, 8, true); + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[i])) { + const uint8_t Attributes = + gMR_ChannelAttributes[gEeprom.ScreenChannel[i]]; + if (Attributes & MR_CH_SCANLIST1) { + memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); + } + if (Attributes & MR_CH_SCANLIST2) { + memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); + } + } + } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_CHANNEL) { + sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); + UI_PrintString(String, 31, 112, i * 4, 8, true); + } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { + if (gEeprom.VfoInfo[i].Name[0] == 0 || + gEeprom.VfoInfo[i].Name[0] == 0xFF) { + sprintf(String, "CH-%03d", gEeprom.ScreenChannel[i] + 1); + UI_PrintString(String, 31, 112, i * 4, 8, true); + } else { + UI_PrintString(gEeprom.VfoInfo[i].Name, 31, 112, i * 4, 8, true); + } + } else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME_FREQ) { + if (gEeprom.VfoInfo[i].Name[0] <= 32 || + gEeprom.VfoInfo[i].Name[0] >= + 127) { // no channel name, show channel number instead + sprintf(String, "CH-%03u", gEeprom.ScreenChannel[i] + 1); + } else { // channel name + memset(String, 0, sizeof(String)); + memmove(String, gEeprom.VfoInfo[i].Name, 10); + } + UI_PrintStringSmall(String, 31 + 8, 0, Line); + + // show the channel frequency below the channel number/name + sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); + UI_PrintStringSmall(String, 31 + 8, 0, Line + 1); + } + } + } + + // 0x926E + uint8_t Level = 0; + + if (SomeValue == 1) { + if (gRxVfo->OUTPUT_POWER == OUTPUT_POWER_LOW) { + Level = 2; + } else if (gRxVfo->OUTPUT_POWER == OUTPUT_POWER_MID) { + Level = 4; + } else { + Level = 6; + } + } else if (SomeValue == 2) { + if (gVFO_RSSI_Level[i]) { + Level = gVFO_RSSI_Level[i]; + } + } + + // TODO: not quite how the original does it, but it's quite entangled in + // Ghidra. + if (Level) { + memcpy(pLine1 + 128 + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); + memcpy(pLine1 + 128 + 5, BITMAP_AntennaLevel1, + sizeof(BITMAP_AntennaLevel1)); + if (Level >= 2) { + memcpy(pLine1 + 128 + 8, BITMAP_AntennaLevel2, + sizeof(BITMAP_AntennaLevel2)); + } + if (Level >= 3) { + memcpy(pLine1 + 128 + 11, BITMAP_AntennaLevel3, + sizeof(BITMAP_AntennaLevel3)); + } + if (Level >= 4) { + memcpy(pLine1 + 128 + 14, BITMAP_AntennaLevel4, + sizeof(BITMAP_AntennaLevel4)); + } + if (Level >= 5) { + memcpy(pLine1 + 128 + 17, BITMAP_AntennaLevel5, + sizeof(BITMAP_AntennaLevel5)); + } + if (Level >= 6) { + memcpy(pLine1 + 128 + 20, BITMAP_AntennaLevel6, + sizeof(BITMAP_AntennaLevel6)); + } + } + + // 0x931E + if (gEeprom.VfoInfo[i].IsAM) { + memcpy(pLine1 + 128 + 27, BITMAP_AM, sizeof(BITMAP_AM)); + } else { + const FREQ_Config_t *pConfig; + + if (SomeValue == 1) { + pConfig = gEeprom.VfoInfo[i].pTX; + } else { + pConfig = gEeprom.VfoInfo[i].pRX; + } + switch (pConfig->CodeType) { + case CODE_TYPE_CONTINUOUS_TONE: + memcpy(pLine1 + 128 + 27, BITMAP_CT, sizeof(BITMAP_CT)); + break; + case CODE_TYPE_DIGITAL: + case CODE_TYPE_REVERSE_DIGITAL: + memcpy(pLine1 + 128 + 24, BITMAP_DCS, sizeof(BITMAP_DCS)); + break; + default: + break; + } + } + + // 0x936C + switch (gEeprom.VfoInfo[i].OUTPUT_POWER) { + case OUTPUT_POWER_LOW: + memcpy(pLine1 + 128 + 44, BITMAP_PowerLow, sizeof(BITMAP_PowerLow)); + break; + case OUTPUT_POWER_MID: + memcpy(pLine1 + 128 + 44, BITMAP_PowerMid, sizeof(BITMAP_PowerMid)); + break; + case OUTPUT_POWER_HIGH: + memcpy(pLine1 + 128 + 44, BITMAP_PowerHigh, sizeof(BITMAP_PowerHigh)); + break; + } + + if (gEeprom.VfoInfo[i].ConfigRX.Frequency != + gEeprom.VfoInfo[i].ConfigTX.Frequency) { + if (gEeprom.VfoInfo[i].FREQUENCY_DEVIATION_SETTING == + FREQUENCY_DEVIATION_ADD) { + memcpy(pLine1 + 128 + 54, BITMAP_Add, sizeof(BITMAP_Add)); + } + if (gEeprom.VfoInfo[i].FREQUENCY_DEVIATION_SETTING == + FREQUENCY_DEVIATION_SUB) { + memcpy(pLine1 + 128 + 54, BITMAP_Sub, sizeof(BITMAP_Sub)); + } + } + + if (gEeprom.VfoInfo[i].FrequencyReverse) { + memcpy(pLine1 + 128 + 64, BITMAP_ReverseMode, sizeof(BITMAP_ReverseMode)); + } + if (gEeprom.VfoInfo[i].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) { + memcpy(pLine1 + 128 + 74, BITMAP_NarrowBand, sizeof(BITMAP_NarrowBand)); + } + if (gEeprom.VfoInfo[i].DTMF_DECODING_ENABLE || gSetting_KILLED) { + memcpy(pLine1 + 128 + 84, BITMAP_DTMF, sizeof(BITMAP_DTMF)); + } + if (gEeprom.VfoInfo[i].SCRAMBLING_TYPE && gSetting_ScrambleEnable) { + memcpy(pLine1 + 128 + 110, BITMAP_Scramble, sizeof(BITMAP_Scramble)); + } + } #if defined(ENABLE_RSSIBAR) - int16_t rssi; - - if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_INCOMING) { - rssi = BK4819_GetRSSI(); - UI_DisplayRSSIBar(rssi); - } + int16_t rssi; + + if (gCurrentFunction == FUNCTION_RECEIVE || + gCurrentFunction == FUNCTION_MONITOR || + gCurrentFunction == FUNCTION_INCOMING) { + rssi = BK4819_GetRSSI(); + UI_DisplayRSSIBar(rssi); + } #endif - ST7565_BlitFullScreen(); + ST7565_BlitFullScreen(); } -