diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1fcecdd..afc27ce 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -21,13 +21,24 @@ - - - + + + + + + + + + + + - - + + + + + - - - - - + @@ -248,6 +254,8 @@ + + 1701693594928 diff --git a/Makefile b/Makefile index 8e82878..b5a3273 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ ENABLE_FLASHLIGHT ?= 1 # ---- CUSTOM MODS ---- ENABLE_BIG_FREQ ?= 1 -ENABLE_SMALL_BOLD ?= 0 ENABLE_KEEP_MEM_NAME ?= 1 ENABLE_WIDE_RX ?= 1 ENABLE_TX_WHEN_AM ?= 0 @@ -290,9 +289,7 @@ endif ifeq ($(ENABLE_BIG_FREQ),1) CFLAGS += -DENABLE_BIG_FREQ endif -ifeq ($(ENABLE_SMALL_BOLD),1) - CFLAGS += -DENABLE_SMALL_BOLD -endif + ifeq ($(ENABLE_NOAA),1) CFLAGS += -DENABLE_NOAA endif diff --git a/README.md b/README.md index f2a48a6..30db708 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,6 @@ ENABLE_PWRON_PASSWORD := 0 开机密码 ENABLE_DTMF_CALLING := 1 ENABLE_FLASHLIGHT := 1 ENABLE_BIG_FREQ := 1 频率模式大字体 -ENABLE_SMALL_BOLD := 1 粗体通道名称/编号(当名称+频率频道显示模式时) ENABLE_KEEP_MEM_NAME := 1 在(重新)保存信道时保持信道名称 ENABLE_WIDE_RX := 1 18MHz 至 1300MHz 接收(尽管前端/PA 不是为全范围设计的) ENABLE_TX_WHEN_AM := 0 当 RX 设置为 AM 时允许 FM 发射 diff --git a/app/chFrScanner.c b/app/chFrScanner.c index 8c32c49..e5d1cc4 100644 --- a/app/chFrScanner.c +++ b/app/chFrScanner.c @@ -11,6 +11,7 @@ bool gScanPauseMode; #ifdef ENABLE_SCAN_RANGES uint32_t gScanRangeStart; +uint32_t gScanRangeStop; #endif typedef enum { @@ -157,10 +158,8 @@ static void NextFreqChannel(void) { #ifdef ENABLE_SCAN_RANGES if(gScanRangeStart) { - uint32_t start = gScanRangeStart; - uint32_t end = gEeprom.VfoInfo[(gEeprom.TX_VFO+1)%2].freq_config_RX.Frequency; - gRxVfo->freq_config_RX.Frequency = APP_SetFreqByStepAndLimits(gRxVfo, gScanStateDir, MIN(start, end), MAX(start, end)); - } + gRxVfo->freq_config_RX.Frequency = APP_SetFreqByStepAndLimits(gRxVfo, gScanStateDir, gScanRangeStart, gScanRangeStop); + } else #endif gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir); diff --git a/app/chFrScanner.h b/app/chFrScanner.h index 5ae349f..e0fca88 100644 --- a/app/chFrScanner.h +++ b/app/chFrScanner.h @@ -12,6 +12,7 @@ extern bool gScanPauseMode; #ifdef ENABLE_SCAN_RANGES extern uint32_t gScanRangeStart; +extern uint32_t gScanRangeStop; #endif void CHFRSCANNER_Found(void); diff --git a/app/main.c b/app/main.c index 5f979b5..ad355a4 100644 --- a/app/main.c +++ b/app/main.c @@ -51,6 +51,9 @@ void toggle_chan_scanlist(void) { // toggle the selected channels scanlist se if (!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { #ifdef ENABLE_SCAN_RANGES gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency; + gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency; + if(gScanRangeStart > gScanRangeStop) + SWAP(gScanRangeStart, gScanRangeStop); #endif return; } diff --git a/app/spectrum.c b/app/spectrum.c index b390a87..56ecad7 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -13,14 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "app/spectrum.h" #include "am_fix.h" #include "audio.h" + +#ifdef ENABLE_SCAN_RANGES +#include "chFrScanner.h" +#endif + #include "driver/backlight.h" +#include "frequencies.h" #include "ui/helper.h" #include "ui/main.h" -#include "frequencies.h" + struct FrequencyBandInfo { uint32_t lower; uint32_t upper; @@ -52,6 +57,11 @@ PeakInfo peak; ScanInfo scanInfo; KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0}; +#ifdef ENABLE_SCAN_RANGES +static uint16_t blacklistFreqs[15]; +static uint8_t blacklistFreqsIdx; +#endif + const char *bwOptions[] = {" 25k", "12.5k", "6.25k"}; const uint8_t modulationTypeTuneSteps[] = {100, 50, 10}; const uint8_t modTypeReg47Values[] = {1, 7, 5}; @@ -259,12 +269,24 @@ static void ResetPeak() { } bool IsCenterMode() { return settings.scanStepIndex < S_STEP_2_5kHz; } -uint8_t GetStepsCount() { return 128 >> settings.stepsCount; } +// scan step in 0.01khz uint16_t GetScanStep() { return scanStepValues[settings.scanStepIndex]; } + +uint16_t GetStepsCount() +{ +#ifdef ENABLE_SCAN_RANGES + if(gScanRangeStart) { + return (gScanRangeStop - gScanRangeStart) / GetScanStep(); + } +#endif + return 128 >> settings.stepsCount; +} + uint32_t GetBW() { return GetStepsCount() * GetScanStep(); } uint32_t GetFStart() { return IsCenterMode() ? currentFreq - (GetBW() >> 1) : currentFreq; } + uint32_t GetFEnd() { return currentFreq + GetBW(); } static void TuneToPeak() { @@ -351,6 +373,10 @@ static void ResetBlacklist() { if (rssiHistory[i] == RSSI_MAX_VALUE) rssiHistory[i] = 0; } +#ifdef ENABLE_SCAN_RANGES + memset(blacklistFreqs, 0, sizeof(blacklistFreqs)); + blacklistFreqsIdx = 0; +#endif } static void RelaunchScan() { @@ -397,7 +423,25 @@ static void UpdatePeakInfo() { UpdatePeakInfoForce(); } -static void Measure() { rssiHistory[scanInfo.i] = scanInfo.rssi = GetRssi(); } +static void SetRssiHistory(uint16_t idx, uint16_t rssi) +{ +#ifdef ENABLE_SCAN_RANGES + if(scanInfo.measurementsCount > 128) { + uint8_t i = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * idx / 1000; + if(rssiHistory[i] < rssi || isListening) + rssiHistory[i] = rssi; + rssiHistory[(i+1)%128] = 0; + return; + } +#endif + rssiHistory[idx] = rssi; +} + +static void Measure() +{ + uint16_t rssi = scanInfo.rssi = GetRssi(); + SetRssiHistory(scanInfo.i, rssi); +} // Update things by keypress @@ -594,12 +638,26 @@ static void UpdateFreqInput(KEY_Code_t key) { } static void Blacklist() { - rssiHistory[peak.i] = RSSI_MAX_VALUE; +#ifdef ENABLE_SCAN_RANGES + blacklistFreqs[blacklistFreqsIdx++ % ARRAY_SIZE(blacklistFreqs)] = peak.i; +#endif + + SetRssiHistory(peak.i, RSSI_MAX_VALUE); ResetPeak(); ToggleRX(false); - newScanStart = true; + ResetScanStats(); } +#ifdef ENABLE_SCAN_RANGES +static bool IsBlacklisted(uint16_t idx) +{ + for(uint8_t i = 0; i < ARRAY_SIZE(blacklistFreqs); i++) + if(blacklistFreqs[i] == idx) + return true; + return false; +} +#endif + // Draw things // applied x2 to prevent initial rounding @@ -709,9 +767,11 @@ static void DrawRssiTriggerLevel() { } static void DrawTicks() { - uint32_t f = GetFStart() % 100000; - uint32_t step = GetScanStep(); - for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount), f += step) { + uint32_t f = GetFStart(); + uint32_t span = GetFEnd() - GetFStart(); + uint32_t step = span / 128; + for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount)) { + f = GetFStart() + span * i / 128; uint8_t barValue = 0b00000001; (f % 10000) < step && (barValue |= 0b00000010); (f % 50000) < step && (barValue |= 0b00000100); @@ -763,9 +823,15 @@ static void OnKeyDown(uint8_t key) { UpdateFreqChangeStep(false); break; case KEY_UP: +#ifdef ENABLE_SCAN_RANGES + if(!gScanRangeStart) +#endif UpdateCurrentFreq(true); break; case KEY_DOWN: +#ifdef ENABLE_SCAN_RANGES + if(!gScanRangeStart) +#endif UpdateCurrentFreq(false); break; case KEY_SIDE1: @@ -778,6 +844,9 @@ static void OnKeyDown(uint8_t key) { UpdateRssiTriggerLevel(false); break; case KEY_5: +#ifdef ENABLE_SCAN_RANGES + if(!gScanRangeStart) +#endif FreqInput(); break; case KEY_0: @@ -787,6 +856,9 @@ static void OnKeyDown(uint8_t key) { ToggleListeningBW(); break; case KEY_4: +#ifdef ENABLE_SCAN_RANGES + if(!gScanRangeStart) +#endif ToggleStepsCount(); break; case KEY_SIDE2: @@ -931,7 +1003,7 @@ static void RenderStatus() { static void RenderSpectrum() { DrawTicks(); - DrawArrow(peak.i << settings.stepsCount); + DrawArrow(128u * peak.i / GetStepsCount()); DrawSpectrum(); DrawRssiTriggerLevel(); DrawF(peak.f); @@ -952,6 +1024,7 @@ static void RenderStill() { for (int i = 0; i < 121; i+=10) { gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000; } + uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121); for (int i = 0; i < x; ++i) { if (i % 5) { @@ -1047,7 +1120,11 @@ bool HandleUserInput() { } static void Scan() { - if (rssiHistory[scanInfo.i] != RSSI_MAX_VALUE) { + if (rssiHistory[scanInfo.i] != RSSI_MAX_VALUE +#ifdef ENABLE_SCAN_RANGES + && !IsBlacklisted(scanInfo.i) +#endif + ) { SetF(scanInfo.f); Measure(); UpdateScanInfo(); @@ -1068,6 +1145,10 @@ static void UpdateScan() { return; } + if(scanInfo.measurementsCount < 128) + memset(&rssiHistory[scanInfo.measurementsCount], 0, + sizeof(rssiHistory) - scanInfo.measurementsCount*sizeof(rssiHistory[0])); + redrawScreen = true; preventKeypress = false; @@ -1120,19 +1201,39 @@ static void UpdateListening() { } ToggleRX(false); - newScanStart = true; + ResetScanStats(); } static void Tick() { #ifdef ENABLE_AM_FIX if (gNextTimeslice) { gNextTimeslice = false; - if(settings.modulationType == MODULATION_AM && !lockAGC) { + if(settings.modulationType == MODULATION_AM && !lockAGC) { AM_fix_10ms(vfo); //allow AM_Fix to apply its AGC action } } #endif +#ifdef ENABLE_SCAN_RANGES + if (gNextTimeslice_500ms) { + gNextTimeslice_500ms = false; + + // if a lot of steps then it takes long time + // we don't want to wait for whole scan + // listening has it's own timer + if(GetStepsCount()>128 && !isListening) { + UpdatePeakInfo(); + if (IsPeakOverLevel()) { + ToggleRX(true); + TuneToPeak(); + return; + } + redrawScreen = true; + preventKeypress = false; + } + } +#endif + if (!preventKeypress) { HandleUserInput(); } @@ -1164,18 +1265,32 @@ void APP_RunSpectrum() { // TX here coz it always? set to active VFO vfo = gEeprom.TX_VFO; // set the current frequency in the middle of the display - currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency - +#ifdef ENABLE_SCAN_RANGES + if(gScanRangeStart) { + currentFreq = initialFreq = gScanRangeStart; + for(uint8_t i = 0; i < ARRAY_SIZE(scanStepValues); i++) { + if(scanStepValues[i] >= gTxVfo->StepFrequency) { + settings.scanStepIndex = i; + break; + } + } + settings.stepsCount = STEPS_128; + } + else +#endif + currentFreq = initialFreq = gTxVfo->pRX->Frequency - ((GetStepsCount() / 2) * GetScanStep()); BackupRegisters(); isListening = true; // to turn off RX later redrawStatus = true; - redrawScreen = false; // we will wait until scan done + redrawScreen = true; newScanStart = true; + ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off - RADIO_SetModulation(settings.modulationType = gRxVfo->Modulation); + RADIO_SetModulation(settings.modulationType = gTxVfo->Modulation); BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false); diff --git a/app/spectrum.h b/app/spectrum.h index f9e9d0e..1dcf9e1 100644 --- a/app/spectrum.h +++ b/app/spectrum.h @@ -16,7 +16,7 @@ #ifndef SPECTRUM_H #define SPECTRUM_H -#include "../frequencies.h" + #include "../bitmaps.h" #include "../board.h" #include "../bsp/dp32g030/gpio.h" @@ -29,7 +29,6 @@ #include "../driver/systick.h" #include "../external/printf/printf.h" #include "../font.h" -#include "../frequencies.h" #include "../helper/battery.h" #include "../misc.h" #include "../radio.h" @@ -42,117 +41,118 @@ static const uint8_t DrawingEndY = 40; static const uint8_t U8RssiMap[] = { - 121, 115, 109, 103, 97, 91, 85, 79, 73, 63, + 121, 115, 109, 103, 97, 91, 85, 79, 73, 63, }; static const uint16_t scanStepValues[] = { 1, 10, 50, 100, 250, 500, 625, 833, 1000, 1250, 1500, 2000, 2500, 5000, 10000, }; + static const uint16_t scanStepBWRegValues[] = { - // RX RXw TX BW - // 0b0 000 000 001 01 1000 - // 1 - 0b0000000001011000, // 6.25 - // 10 - 0b0000000001011000, // 6.25 - // 50 - 0b0000000001011000, // 6.25 - // 100 - 0b0000000001011000, // 6.25 - // 250 - 0b0000000001011000, // 6.25 - // 500 - 0b0010010001011000, // 6.25 - // 625 - 0b0100100001011000, // 6.25 - // 833 - 0b0110110001001000, // 6.25 - // 1000 - 0b0110110001001000, // 6.25 - // 1250 - 0b0111111100001000, // 6.25 - // 2500 - 0b0011011000101000, // 25 - // 10000 - 0b0011011000101000, // 25 + // RX RXw TX BW + // 0b0 000 000 001 01 1000 + // 1 + 0b0000000001011000, // 6.25 + // 10 + 0b0000000001011000, // 6.25 + // 50 + 0b0000000001011000, // 6.25 + // 100 + 0b0000000001011000, // 6.25 + // 250 + 0b0000000001011000, // 6.25 + // 500 + 0b0010010001011000, // 6.25 + // 625 + 0b0100100001011000, // 6.25 + // 833 + 0b0110110001001000, // 6.25 + // 1000 + 0b0110110001001000, // 6.25 + // 1250 + 0b0111111100001000, // 6.25 + // 2500 + 0b0011011000101000, // 25 + // 10000 + 0b0011011000101000, // 25 }; static const uint16_t listenBWRegValues[] = { - 0b0011011000101000, // 25 - 0b0111111100001000, // 12.5 - 0b0100100001011000, // 6.25 + 0b0011011000101000, // 25 + 0b0111111100001000, // 12.5 + 0b0100100001011000, // 6.25 }; typedef enum State { - SPECTRUM, - FREQ_INPUT, - STILL, + SPECTRUM, + FREQ_INPUT, + STILL, } State; typedef enum StepsCount { - STEPS_128, - STEPS_64, - STEPS_32, - STEPS_16, + STEPS_128, + STEPS_64, + STEPS_32, + STEPS_16, } StepsCount; typedef enum ScanStep { - S_STEP_0_01kHz, - S_STEP_0_1kHz, - S_STEP_0_5kHz, - S_STEP_1_0kHz, + S_STEP_0_01kHz, + S_STEP_0_1kHz, + S_STEP_0_5kHz, + S_STEP_1_0kHz, - S_STEP_2_5kHz, - S_STEP_5_0kHz, - S_STEP_6_25kHz, - S_STEP_8_33kHz, - S_STEP_10_0kHz, - S_STEP_12_5kHz, + S_STEP_2_5kHz, + S_STEP_5_0kHz, + S_STEP_6_25kHz, + S_STEP_8_33kHz, + S_STEP_10_0kHz, + S_STEP_12_5kHz, S_STEP_15_0kHz, S_STEP_20_0kHz, - S_STEP_25_0kHz, + S_STEP_25_0kHz, S_STEP_50_0kHz, - S_STEP_100_0kHz, + S_STEP_100_0kHz, } ScanStep; typedef struct SpectrumSettings { - uint32_t frequencyChangeStep; - StepsCount stepsCount; - ScanStep scanStepIndex; - uint16_t scanDelay; - uint16_t rssiTriggerLevel; - BK4819_FilterBandwidth_t bw; - BK4819_FilterBandwidth_t listenBw; - int dbMin; - int dbMax; - ModulationMode_t modulationType; - bool backlightState; + uint32_t frequencyChangeStep; + StepsCount stepsCount; + ScanStep scanStepIndex; + uint16_t scanDelay; + uint16_t rssiTriggerLevel; + BK4819_FilterBandwidth_t bw; + BK4819_FilterBandwidth_t listenBw; + int dbMin; + int dbMax; + ModulationMode_t modulationType; + bool backlightState; } SpectrumSettings; typedef struct KeyboardState { - KEY_Code_t current; - KEY_Code_t prev; - uint8_t counter; + KEY_Code_t current; + KEY_Code_t prev; + uint8_t counter; } KeyboardState; typedef struct ScanInfo { - uint16_t rssi, rssiMin, rssiMax; - uint8_t i, iPeak; - uint32_t f, fPeak; - uint16_t scanStep; - uint8_t measurementsCount; + uint16_t rssi, rssiMin, rssiMax; + uint16_t i, iPeak; + uint32_t f, fPeak; + uint16_t scanStep; + uint16_t measurementsCount; } ScanInfo; typedef struct PeakInfo { - uint16_t t; - uint16_t rssi; - uint32_t f; - uint8_t i; + uint16_t t; + uint16_t rssi; + uint32_t f; + uint16_t i; } PeakInfo; void APP_RunSpectrum(void); #endif /* ifndef SPECTRUM_H */ -// vim: ft=c +// vim: ft=c \ No newline at end of file diff --git a/chinese.h b/chinese.h index 5a9a34c..dc9ea7e 100644 --- a/chinese.h +++ b/chinese.h @@ -243,7 +243,7 @@ #define MDC尾音 "\x4D\x44\x43\x84\xE1\x8A\x01" #define MDC首音 "\x4D\x44\x43\x8A\x1E\x8A\x01" #define MDC首尾音 "\x4D\x44\x43\x8A\x1E\x84\xE1\x8A\x01" -#define MDC首音加ROGER "\x4D\x44\x43\x8A\x1E\x8A\x01\x2B+\x52\x4F\x47\x45\x52" +#define MDC首音加ROGER "\x4D\x44\x43\x8A\x1E\x8A\x01\x2B\x52\x4F\x47\x45\x52" #define 除信道参数 "\x8A\xB7\x89\x89\x92\xC8\x87\xB8\x95\x19" #define 全部参数 "\x82\x65\x8D\x11\x87\xB8\x95\x19" #define 禁用全部 "\x93\xCF\x81\x50\x82\x65\x8D\x11" diff --git a/font.c b/font.c index 32d091a..1eeb17b 100644 --- a/font.c +++ b/font.c @@ -15,7 +15,7 @@ */ #include "font.h" - +bool menu_set_flag=false; #if 0 @@ -26,11 +26,6 @@ const uint8_t gFontBigDigits[11][20] = { - - - -// -// {/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x86, 0xC6, 0xE6, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x67, 0x63, 0x61, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, {/*0x00, 0x00,*/ 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, /*0x00*/}, {/*0x00, 0x00,*/ 0x1C, 0x1E, 0x1E, 0x06, 0x06, 0x06, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x60, 0x70, 0x78, 0x7C, 0x6E, 0x67, 0x63, 0x61, 0x60, 0x60, /*0x00*/}, @@ -144,110 +139,6 @@ const uint8_t gFontSmall[95-1][6] = {0x04, 0x02, 0x04, 0x08, 0x04, 0x00} // '->' }; -#ifdef ENABLE_SMALL_BOLD -const uint8_t gFontSmallBold[95 - 1][6] = - { -// {0x7F, 0x7F, 0x1B, 0x3B, 0x7F, 0x66}, -// {0x3F, 0x7F, 0x30, 0x30, 0x7F, 0x3F}, - -// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - - {0x00, 0x00, 0x5E, 0x5E, 0x00, 0x00}, - {0x06, 0x06, 0x00, 0x06, 0x06, 0x00}, - {0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00}, - {0x2E, 0x6B, 0x7F, 0x6B, 0x3A, 0x00}, - {0x63, 0x33, 0x18, 0x0C, 0x66, 0x63}, - {0x30, 0x4B, 0x4D, 0x55, 0x22, 0x50}, - {0x00, 0x00, 0x07, 0x07, 0x00, 0x00}, - {0x00, 0x1C, 0x3E, 0x63, 0x41, 0x00}, - {0x00, 0x41, 0x63, 0x3E, 0x1C, 0x00}, - {0x00, 0x2A, 0x1C, 0x1C, 0x2A, 0x00}, - {0x18, 0x18, 0x7E, 0x7E, 0x18, 0x18}, - {0x00, 0x40, 0x60, 0x20, 0x00, 0x00}, - {0x00, 0x18, 0x18, 0x18, 0x18, 0x00}, - {0x00, 0x00, 0x60, 0x60, 0x00, 0x00}, - {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03}, - {0x3E, 0x7F, 0x63, 0x63, 0x7F, 0x3E}, - {0x64, 0x66, 0x7F, 0x7F, 0x60, 0x60}, - {0x62, 0x73, 0x7B, 0x7B, 0x6F, 0x66}, - {0x63, 0x63, 0x6B, 0x6B, 0x7F, 0x36}, - {0x38, 0x3C, 0x36, 0x7F, 0x7F, 0x30}, - {0x6F, 0x6F, 0x6B, 0x6B, 0x7B, 0x33}, - {0x3E, 0x7F, 0x6B, 0x6B, 0x7B, 0x32}, - {0x03, 0x03, 0x73, 0x7B, 0x0F, 0x07}, - {0x36, 0x7F, 0x6B, 0x6B, 0x7F, 0x36}, - {0x06, 0x6F, 0x6B, 0x6B, 0x7F, 0x3E}, - {0x00, 0x00, 0x6C, 0x6C, 0x00, 0x00}, - {0x00, 0x40, 0x6C, 0x2C, 0x00, 0x00}, - {0x08, 0x14, 0x22, 0x41, 0x00, 0x00}, - {0x36, 0x36, 0x36, 0x36, 0x36, 0x00}, - {0x00, 0x41, 0x22, 0x14, 0x08, 0x00}, - {0x06, 0x07, 0x53, 0x5B, 0x1F, 0x0E}, - {0x30, 0x7B, 0x6B, 0x7B, 0x7F, 0x3E}, - {0x7E, 0x7F, 0x1B, 0x1B, 0x7F, 0x7E}, - {0x7F, 0x7F, 0x6B, 0x6B, 0x7F, 0x36}, - {0x3E, 0x7F, 0x63, 0x63, 0x63, 0x36}, - {0x7F, 0x7F, 0x63, 0x63, 0x7F, 0x3E}, - {0x7F, 0x7F, 0x6B, 0x6B, 0x6B, 0x63}, - {0x7F, 0x7F, 0x1B, 0x1B, 0x1B, 0x03}, - {0x3E, 0x7F, 0x63, 0x6B, 0x7B, 0x3A}, - {0x7F, 0x7F, 0x0C, 0x0C, 0x7F, 0x7F}, - {0x63, 0x63, 0x7F, 0x7F, 0x63, 0x63}, - {0x30, 0x73, 0x63, 0x7F, 0x3F, 0x03}, - {0x7F, 0x7F, 0x1C, 0x36, 0x63, 0x41}, - {0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60}, - {0x7F, 0x7F, 0x06, 0x06, 0x7F, 0x7F}, - {0x7F, 0x7F, 0x0C, 0x18, 0x7F, 0x7F}, - {0x3E, 0x7F, 0x63, 0x63, 0x7F, 0x3E}, - {0x7F, 0x7F, 0x1B, 0x1B, 0x1F, 0x0E}, - {0x3E, 0x7F, 0x63, 0x73, 0x7F, 0x7E}, - {0x7F, 0x7F, 0x1B, 0x3B, 0x7F, 0x66}, - {0x66, 0x6F, 0x6B, 0x6B, 0x7B, 0x33}, - {0x03, 0x03, 0x7F, 0x7F, 0x03, 0x03}, - {0x3F, 0x7F, 0x60, 0x60, 0x7F, 0x3F}, - {0x1F, 0x3F, 0x60, 0x60, 0x3F, 0x1F}, - {0x3F, 0x7F, 0x30, 0x30, 0x7F, 0x3F}, - {0x63, 0x77, 0x1C, 0x1C, 0x77, 0x63}, - {0x07, 0x0F, 0x78, 0x78, 0x0F, 0x07}, - {0x63, 0x73, 0x7B, 0x6F, 0x67, 0x63}, - {0x00, 0x7F, 0x7F, 0x63, 0x63, 0x00}, - {0x01, 0x02, 0x04, 0x08, 0x10, 0x60}, - {0x00, 0x63, 0x63, 0x7F, 0x7F, 0x00}, - {0x0C, 0x0E, 0x03, 0x03, 0x0E, 0x0C}, - {0x60, 0x60, 0x60, 0x60, 0x60, 0x60}, - {0x00, 0x03, 0x07, 0x06, 0x00, 0x00}, - {0x20, 0x76, 0x56, 0x56, 0x7E, 0x3C}, - {0x7F, 0x7F, 0x6C, 0x6C, 0x7C, 0x38}, - {0x38, 0x7C, 0x6C, 0x6C, 0x6C, 0x00}, - {0x38, 0x7C, 0x6C, 0x6C, 0x7F, 0x7F}, - {0x3C, 0x7E, 0x56, 0x56, 0x5E, 0x0C}, - {0x7E, 0x7F, 0x1B, 0x1B, 0x02, 0x00}, - {0x0C, 0x5E, 0x56, 0x56, 0x7E, 0x3C}, - {0x7F, 0x7F, 0x0C, 0x0C, 0x7C, 0x78}, - {0x00, 0x00, 0x7A, 0x7A, 0x00, 0x00}, - {0x30, 0x60, 0x60, 0x7D, 0x3D, 0x00}, - {0x7F, 0x7F, 0x18, 0x3C, 0x7E, 0x66}, - {0x00, 0x3F, 0x7F, 0x40, 0x00, 0x00}, - {0x7C, 0x7C, 0x18, 0x18, 0x7C, 0x7C}, - {0x7C, 0x7C, 0x0C, 0x0C, 0x7C, 0x78}, - {0x3C, 0x7E, 0x66, 0x66, 0x7E, 0x3C}, - {0x7E, 0x7E, 0x36, 0x36, 0x3E, 0x1C}, - {0x1C, 0x3E, 0x36, 0x7E, 0x7E, 0x60}, - {0x7C, 0x7C, 0x0C, 0x0C, 0x18, 0x00}, - {0x4C, 0x5E, 0x56, 0x56, 0x76, 0x20}, - {0x3F, 0x7F, 0x6C, 0x6C, 0x60, 0x00}, - {0x3C, 0x7C, 0x60, 0x60, 0x7C, 0x3C}, - {0x0C, 0x3C, 0x70, 0x70, 0x3C, 0x0C}, - {0x3C, 0x7C, 0x30, 0x30, 0x7C, 0x3C}, - {0x44, 0x6C, 0x38, 0x38, 0x6C, 0x44}, - {0x06, 0x6E, 0x68, 0x68, 0x7E, 0x3E}, - {0x66, 0x76, 0x7E, 0x6E, 0x66, 0x00}, - {0x08, 0x3E, 0x77, 0x41, 0x00, 0x00}, - {0x00, 0x00, 0x7F, 0x00, 0x00, 0x00}, - {0x00, 0x41, 0x77, 0x3E, 0x08, 0x00}, - {0x0C, 0x06, 0x0C, 0x18, 0x0C, 0x00} - }; -#endif #ifdef ENABLE_SPECTRUM const uint8_t gFont3x5[][3] = diff --git a/font.h b/font.h index 4f83cea..d467532 100644 --- a/font.h +++ b/font.h @@ -22,19 +22,18 @@ extern const uint8_t gFontChinese_out[2013]; #define CHN_FONT_WIDTH 11U #define CHN_FONT_HIGH 12U -#define ENABLE_CHINESE_FULL 4 +#define ENABLE_CHINESE_FULL 0 #if ENABLE_CHINESE_FULL ==4 #define MAX_EDIT_INDEX 13 #else #define MAX_EDIT_INDEX 10 #endif +extern bool menu_set_flag; extern const uint8_t gFontBigDigits[11][20/*20*/]; extern const uint8_t gFont3x5[96][3]; extern const uint8_t gFontSmall[95 - 1][6]; -#ifdef ENABLE_SMALL_BOLD -extern const uint8_t gFontSmallBold[95 - 1][6]; -#endif + #if ENABLE_CHINESE_FULL > 0 #if ENABLE_CHINESE_FULL==1 diff --git a/misc.h b/misc.h index 63f3a7c..28b7ee0 100644 --- a/misc.h +++ b/misc.h @@ -36,7 +36,9 @@ #define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) #define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL) #define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST) - +#ifndef SWAP +#define SWAP(a, b) ({ __typeof__ (a) _c = (a); a = b; b = _c; }) +#endif enum { MR_CHANNEL_FIRST = 0, MR_CHANNEL_LAST = 199u, diff --git a/ui/helper.c b/ui/helper.c index b03131e..af46292 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -112,8 +112,13 @@ void UI_PrintCharSmall(char character, uint8_t Start, uint8_t Line) { void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) { uint8_t Length = strlen(pString); - - +#if ENABLE_CHINESE_FULL == 0 + if (menu_set_flag == 1) + { + Length = Length > 7 ? 7 : Length; + menu_set_flag = 0; + } +#endif size_t i; uint8_t sum_pixel = 0; uint16_t true_char[Length]; @@ -225,29 +230,6 @@ true_char[i]=true_char[i]-true_char[i]/256-1; } } -#ifdef ENABLE_SMALL_BOLD -void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) -{ - const size_t Length = strlen(pString); - size_t i; - - if (End > Start) - Start += (((End - Start) - (Length * 8)) + 1) / 2; - - const unsigned int char_width = ARRAY_SIZE(gFontSmallBold[0]); - const unsigned int char_spacing = char_width + 1; - uint8_t *pFb = gFrameBuffer[Line] + Start; - for (i = 0; i < Length; i++) - { - if (pString[i] > ' ') - { - const unsigned int index = (unsigned int)pString[i] - ' ' - 1; - if (index < ARRAY_SIZE(gFontSmallBold)) - memmove(pFb + (i * char_spacing) + 1, &gFontSmallBold[index], char_width); - } - } -} -#endif void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer) { size_t i; diff --git a/ui/helper.h b/ui/helper.h index 6213eea..d10916b 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -28,15 +28,13 @@ uint8_t is_chn(uint8_t num); bool CHINESE_JUDGE(char *name,uint8_t len); -#ifdef ENABLE_SMALL_BOLD - void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); -#endif + void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer); void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center); -#endif void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black); void UI_DisplayPopup(const char *string); +#endif //void UI_DrawPixel(uint8_t x, uint8_t y, bool black); //void UI_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black); diff --git a/ui/main.c b/ui/main.c index 1f9a0a1..a0b15d7 100644 --- a/ui/main.c +++ b/ui/main.c @@ -360,8 +360,7 @@ void UI_DisplayMain(void) { UI_PrintStringSmall("ScnRng", 5, 0, line); sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000); UI_PrintStringSmall(String, 56, 0, line); - uint32_t frq = gEeprom.VfoInfo[vfo_num].pRX->Frequency; - sprintf(String, "%3u.%05u", frq / 100000, frq % 100000); + sprintf(String, "%3u.%05u", gScanRangeStop / 100000, gScanRangeStop % 100000); UI_PrintStringSmall(String, 56, 0, line + 1); continue; } @@ -541,11 +540,12 @@ void UI_DisplayMain(void) { memcpy(gFrameBuffer[line + 2] + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); else memcpy(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); -} - - - #endif + + } + + + if (att.scanlist2) { #if ENABLE_CHINESE_FULL != 4 memcpy(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); @@ -554,10 +554,10 @@ void UI_DisplayMain(void) { memcpy(gFrameBuffer[line + 2] + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); else memcpy(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); +#endif } -#endif // compander symbol #ifndef ENABLE_BIG_FREQ @@ -605,11 +605,9 @@ void UI_DisplayMain(void) { if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { UI_PrintStringSmall(String, 32, 0, line); } 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); #if ENABLE_CHINESE_FULL != 4 @@ -727,7 +725,7 @@ void UI_DisplayMain(void) { if(IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]) &&!(FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num ) &&!( gCurrentFunction == FUNCTION_TRANSMIT&&activeTxVFO == vfo_num) ) - UI_PrintStringSmall(String, LCD_WIDTH + 8, 0, line -1); //中文信道1 + UI_PrintStringSmall(String, LCD_WIDTH + 9, 0, line -1); //中文信道1 else if(!IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]) ) UI_PrintStringSmall(String, LCD_WIDTH + 46, 0, line + 1); //中文信道1 @@ -744,7 +742,7 @@ void UI_DisplayMain(void) { UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1);//中文信道1 #else if(IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]) &&!(FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num ) &&!( gCurrentFunction == FUNCTION_TRANSMIT&&activeTxVFO == vfo_num) ) - UI_PrintStringSmall(String, LCD_WIDTH + 16, 0, line - 1);//中文信道1 + UI_PrintStringSmall(String, LCD_WIDTH + 17, 0, line - 1);//中文信道1 else if(!IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]) ) UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1);//中文信道1 #endif @@ -792,9 +790,10 @@ void UI_DisplayMain(void) { UI_PrintStringSmall("D", LCD_WIDTH + 105, 0, line + 1);//中文信道1 else UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1);//中文信道1 + #endif + } -#endif #endif // show the audio scramble symbol if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0/* && gSetting_ScrambleEnable*/) { @@ -806,10 +805,11 @@ void UI_DisplayMain(void) { UI_PrintStringSmall("E", LCD_WIDTH + 29, 0, line +1);//中文信道1 ok else UI_PrintStringSmall("ENC", LCD_WIDTH + 106, 0, line + 1);//中文信道1 - } - #endif + } + + } #ifdef ENABLE_AGC_SHOW_DATA center_line = CENTER_LINE_IN_USE; @@ -840,11 +840,9 @@ void UI_DisplayMain(void) { //#else // sprintf(String, "MDC1200 ID %04X", mdc1200_unit_id); //#endif -#ifdef ENABLE_SMALL_BOLD - UI_PrintStringSmallBold(String, print_col, 0, 3); -#else + UI_PrintStringSmall(String, print_col, 0, 3); -#endif + } else #endif diff --git a/ui/menu.c b/ui/menu.c index 5195aad..461f27f 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -1189,6 +1189,7 @@ void UI_ShowChineseMenu() { } cnt_char = 0; if (size_menu < 48)cnt_char = (48 - size_menu ) / 2; + menu_set_flag=1; UI_PrintStringSmall(MenuList[gMenuCursor].name, (cnt_char), 0, 0); diff --git a/ui/menu.h b/ui/menu.h index c7de91b..b8d494b 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -27,7 +27,7 @@ typedef struct { VOICE_ID_t voice_id; uint8_t menu_id; #if ENABLE_CHINESE_FULL==4 - const char name[16]; // 使用指针而不是固定长度数组 + const char name[15]; // 使用指针而不是固定长度数组 #else const char name[7]; // 使用指针而不是固定长度数组 #endif diff --git a/uv-k5font/uv-k5font_full/font.xlsx b/uv-k5font/uv-k5font_full/font.xlsx index ee0ea35..dca804e 100644 Binary files a/uv-k5font/uv-k5font_full/font.xlsx and b/uv-k5font/uv-k5font_full/font.xlsx differ diff --git a/version.c b/version.c index 1331f8d..caf7453 100644 --- a/version.c +++ b/version.c @@ -1,10 +1,15 @@ - +#include "font.h" #define ONE_OF_ELEVEN_VER #ifdef GIT_HASH #define VER GIT_HASH #else - #define VER "111TEST2" +#if ENABLE_CHINESE_FULL ==0 + #define VER "111" +#else +#define VER "111K" +#endif + #endif #ifndef ONE_OF_ELEVEN_VER