From af0e177c7d0a4aba1f1cdfc9052e5e74fdf0a1d3 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Tue, 17 Feb 2026 09:43:26 +0100 Subject: [PATCH] copy some stuff from upstream --- include/Tuner_Drv_Lithio.h | 2 ++ include/constants.h | 2 +- src/TEF6686.cpp | 3 ++- src/Tuner_Interface.cpp | 4 +-- src/comms.cpp | 2 +- src/main.cpp | 55 ++++++++++++++++++++++++++++++++------ 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/include/Tuner_Drv_Lithio.h b/include/Tuner_Drv_Lithio.h index f46a1f5..f0fbc68 100644 --- a/include/Tuner_Drv_Lithio.h +++ b/include/Tuner_Drv_Lithio.h @@ -24,6 +24,7 @@ typedef enum { Cmd_Set_NoiseBlanker_Audio = 24, Cmd_Set_Deemphasis = 31, Cmd_Set_StereoImprovement = 32, + Cmd_Set_LevelStep = 38, Cmd_Set_LevelOffset = 39, Cmd_Set_Softmute_Max = 45, Cmd_Set_Highcut_Level = 52, @@ -31,6 +32,7 @@ typedef enum { Cmd_Set_Highcut_Mph = 54, Cmd_Set_Highcut_Max = 55, Cmd_Set_LowCut_Max = 57, + Cmd_Set_LowCut_Min = 58, Cmd_Set_Stereo_Time = 60, Cmd_Set_Stereo_Level = 62, Cmd_Set_Stereo_Noise = 63, diff --git a/include/constants.h b/include/constants.h index 49c343f..48e8b56 100644 --- a/include/constants.h +++ b/include/constants.h @@ -2,7 +2,7 @@ #include -#define VERSION "v2.20.5e" +#define VERSION "v2.20.6b" #define ROTARY_PIN_A 34 #define ROTARY_PIN_B 36 diff --git a/src/TEF6686.cpp b/src/TEF6686.cpp index 88150a8..ba466dd 100644 --- a/src/TEF6686.cpp +++ b/src/TEF6686.cpp @@ -136,9 +136,10 @@ void TEF6686::init(byte TEF) { while(devTEF_APPL_Get_Operation_Status() != 2) delay(1); // Wait for it to start Wire.setClock(old_clock); + devTEF_Set_Cmd(TEF_FM, Cmd_Set_LevelStep, 7, 0xffff, 0xffff, 0xffff, 0xffff, 0xfffc, 0xfff8, 0x0); devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Mph, 3, 0, 360, 300); devTEF_Set_Cmd(TEF_FM, Cmd_Set_Highcut_Max, 2, 0, 4000); - devTEF_Set_Cmd(TEF_FM, Cmd_Set_LowCut_Max, 2, 0, 100); + devTEF_Set_Cmd(TEF_FM, Cmd_Set_LowCut_Max, 2, 1, 60); devTEF_Set_Cmd(TEF_FM, Cmd_Set_Stereo_Time, 4, 60, 120, 100, 200); devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Time, 4, 500, 2000, 200, 200); devTEF_Set_Cmd(TEF_FM, Cmd_Set_StHiBlend_Level, 3, 0, 600, 240); diff --git a/src/Tuner_Interface.cpp b/src/Tuner_Interface.cpp index de78a5d..10cbd97 100644 --- a/src/Tuner_Interface.cpp +++ b/src/Tuner_Interface.cpp @@ -5,7 +5,7 @@ bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) { Wire.beginTransmission(TEF668X_ADDRESS); - for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]); + Wire.write(buf, len); uint8_t r = Wire.endTransmission(); if (!Data_Accelerator) delay(1); return (r == 0) ? true : false; @@ -33,7 +33,7 @@ static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) { for (i = 0; i < len; i++) buf[1 + i] = pgm_read_byte(&pLutBytes[i]); pLutBytes += len; - if (1 != (r = Tuner_WriteBuffer(buf, len + 1))) break; + if(!Tuner_WriteBuffer(buf, len + 1)) break; } } diff --git a/src/comms.cpp b/src/comms.cpp index eec9ba0..7b725f3 100644 --- a/src/comms.cpp +++ b/src/comms.cpp @@ -959,7 +959,7 @@ void total_pc_control() { case 1: { // Send data if(len < 3) break; Wire.beginTransmission(data[1]); - for(int i = 0; i < (len-2); i++) Wire.write(data[2+i]); + Wire.write(data + 2, len - 2); auto out = Wire.endTransmission(); Serial.write(2); Serial.write(1); diff --git a/src/main.cpp b/src/main.cpp index 310dafd..a478e15 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1036,6 +1036,44 @@ void NumpadProcess(int num) { ShowFreq(5); ShowFreq(0); } + } else if (tunemode == TUNE_MEM) { + if (num == 127) { + freq_in = 0; + menuoption = ITEM1; + menupage = DXMODE; + menuitem = 0; + submenu = true; + menu = true; + if (language == LANGUAGE_CHS) PSSprite.setTextFont(1); else PSSprite.setTextFont(0); + BuildMenu(); + } else if (num == 13) { + if (freq_in > 0 && freq_in <= EE_PRESETS_CNT) { + byte oldmemorypos = memorypos; + memorypos = freq_in - 1; + if (IsStationEmpty()) { + // Flash red and revert + FrequencySprite.setTextDatum(TR_DATUM); + FrequencySprite.fillSprite(BackgroundColor); + FrequencySprite.setTextColor(SignificantColor, SignificantColorSmooth, false); + FrequencySprite.drawString(String(freq_in) + " ", 218, -6); + FrequencySprite.pushSprite(46, 46); + delay(500); + memorypos = oldmemorypos; + ShowFreq(0); + ShowMemoryPos(); + } else { + DoMemoryPosTune(); + ShowMemoryPos(); + } + } else ShowFreq(0); + freq_in = 0; + } else { + if (freq_in / 100 == 0) { + int temp = freq_in * 10 + num; + if (temp <= EE_PRESETS_CNT) freq_in = temp; + } + ShowNum(freq_in); + } } else { if (num == 127) { freq_in = 0; @@ -1353,10 +1391,10 @@ void setup() { if (USBmode) Serial.updateBaudRate(19200); else Serial.updateBaudRate(115200); - if (iMSset && EQset) iMSEQ = 2; - if (!iMSset && EQset) iMSEQ = 3; - if (iMSset && !EQset) iMSEQ = 4; - if (!iMSset && !EQset) iMSEQ = 1; + if(iMSset && EQset) iMSEQ = 2; + else if(!iMSset && EQset) iMSEQ = 3; + else if(iMSset && !EQset) iMSEQ = 4; + else iMSEQ = 1; switch (band) { case BAND_LW: @@ -1625,6 +1663,7 @@ void handleTimers() { if (freq_in != 0 && millis() >= keypadtimer + DELAY_KEYPAD_TIMEOUT_MS) { freq_in = 0; ShowFreq(0); + if (tunemode == TUNE_MEM) ShowMemoryPos(); } } @@ -2648,10 +2687,10 @@ void ButtonPress() { if (BWsettemp == 18 || BWsettemp == 19) { if (BWsettemp == 18) iMSset = !iMSset; if (BWsettemp == 19) EQset = !EQset; - if (!iMSset && !EQset) iMSEQ = 0; - if (iMSset && EQset) iMSEQ = 2; - if (!iMSset && EQset) iMSEQ = 3; - if (iMSset && !EQset) iMSEQ = 4; + if(!iMSset && !EQset) iMSEQ = 0; + else if(iMSset && EQset) iMSEQ = 2; + else if(!iMSset && EQset) iMSEQ = 3; + else iMSEQ = 4; EEPROM.writeByte(EE_BYTE_IMSSET, iMSset); EEPROM.writeByte(EE_BYTE_EQSET, EQset); EEPROM.commit();