very small changes, last commit for today

This commit is contained in:
2026-01-16 23:18:31 +01:00
parent 319e4402eb
commit 1626733faf
7 changed files with 71 additions and 52 deletions

View File

@@ -80,6 +80,5 @@ void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq);
void devTEF_Radio_Get_Quality_Status(uint16_t *status, int16_t *level, uint16_t *usn, uint16_t *wam, int16_t *offset, uint16_t *bandwidth, uint16_t *mod, int8_t *snr);
uint8_t devTEF_APPL_Get_Operation_Status();
bool devTEF_Radio_Get_Stereo_Status(uint16_t *status);
void devTEF_Radio_Get_RDS_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);
void devTEF_Radio_Get_RDS_Data(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);

View File

@@ -13,6 +13,9 @@ public:
tft->drawString(data, 0, y, 0);
y += tft->fontHeight(0);
}
void reset() {
y = 0;
}
private:
TFT_eSPI* tft;
int y = 0;

View File

@@ -224,9 +224,13 @@ void TEF6686::setEQ(bool eq) {
}
bool TEF6686::getStereoStatus() {
uint16_t status;
uint16_t status, r;
uint8_t buf[2];
r = devTEF_Get_Cmd(TEF_FM, Cmd_Get_Signal_Status, buf, sizeof(buf));
status = Convert8bto16b(buf);
bool stereo = 0;
if (1 == devTEF_Radio_Get_Stereo_Status(&status)) stereo = ((status >> 15) & 1) ? 1 : 0;
if(r) stereo = ((status >> 15) & 1) ? 1 : 0;
return stereo;
}
@@ -1637,10 +1641,12 @@ void TEF6686::clearRDS(bool fullsearchrds) {
}
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
auto was_muted = mute;
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 2, 0);
devTEF_Radio_Set_Wavegen(1, amplitude, frequency);
delay(time);
devTEF_Radio_Set_Wavegen(0, 0, 0);
if(was_muted) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Mute, 2, 1);
}
void TEF6686::RDScharConverter(const char* input, wchar_t* output, size_t size, bool underscore) {

View File

@@ -73,14 +73,6 @@ void devTEF_Radio_Get_RDS_Data(uint16_t *status, uint16_t *A_block, uint16_t *B_
if(dec_error != NULL) *dec_error = Convert8bto16b(buf + 10);
}
bool devTEF_Radio_Get_Stereo_Status(uint16_t *status) {
uint8_t buf[2];
uint16_t r = devTEF_Get_Cmd(TEF_FM, Cmd_Get_Signal_Status, buf, sizeof(buf));
*status = Convert8bto16b(buf);
return r;
}
void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq) {
devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_Input, 2, mode ? 240 : 0);
if (mode) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 12, 5, 0, amplitude * 10, freq, amplitude * 10, freq);

View File

@@ -29,8 +29,8 @@ using fs::FS;
Console console(&tft);
bool gpio_chip = false;
#pragma region to move
void Round30K(unsigned int freq) {
#pragma region helpers
inline void Round30K(unsigned int freq) {
if (freq % FREQ_OIRT_STEP_30K == 1) frequency_OIRT = (freq + 1);
else if (freq % FREQ_OIRT_STEP_30K == 0) frequency_OIRT = (freq - 1);
}
@@ -41,7 +41,7 @@ void Round50K(unsigned int freq) {
else if (freq % 10 > 7) frequency = (freq - (freq % 10) + 10);
}
void Round100K(unsigned int freq) {
inline void Round100K(unsigned int freq) {
if (freq % 10 < 5) frequency = (freq - freq % 10);
else frequency = (freq - (freq % 10) + 10);
}
@@ -61,19 +61,19 @@ void Round5K(unsigned int freqAM) {
else if (freqAM % 10 > 7) frequency_AM = (freqAM - (freqAM % 10) + 10);
}
void Touch_IRQ_Handler() {
inline void Touch_IRQ_Handler() {
touch_detect = true;
}
void deepSleep() {
inline void deepSleep() {
MuteScreen(1);
StoreFrequency();
radio.power(1);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_34, LOW);
esp_sleep_enable_ext0_wakeup((gpio_num_t)ROTARY_BUTTON, LOW);
esp_deep_sleep_start();
}
bool IsStationEmpty() {
inline bool IsStationEmpty() {
return presets[memorypos].band == BAND_FM && presets[memorypos].frequency == EE_PRESETS_FREQUENCY;
}
@@ -94,19 +94,12 @@ void doLog() {
}
}
void EdgeBeeper() {
inline void EdgeBeeper() {
if(!edgebeep) return;
radio.tone(50, -5, 2000);
if (radio.mute) {
radio.setMute();
if (!screenmute) tft.drawBitmap(249, 4, Speaker, 28, 24, PrimaryColor);
} else {
radio.setUnMute();
if (!screenmute) tft.drawBitmap(249, 4, Speaker, 28, 24, GreyoutColor);
}
}
const char* textUI(uint16_t number) {
inline const char* textUI(uint16_t number) {
if (number >= language_entrynumber) return "Overflow";
else return (const char*)pgm_read_ptr(&(myLanguage[language][number]));
}
@@ -223,7 +216,7 @@ void updateSWMIBand() {
}
}
void updateCodetect() {
inline void updateCodetect() {
if (band > BAND_GAP) {
if (WAM) tftPrint(ALEFT, "CO", 50, 61, PrimaryColor, PrimaryColorSmooth, 16);
else tftPrint(ALEFT, "CO", 50, 61, BackgroundColor, BackgroundColor, 16);
@@ -775,38 +768,64 @@ void toggleiMSEQ() {
}
void TuneFreq(int temp) {
aftest = true;
aftimer = millis();
int newfreq = temp;
if (band == BAND_FM) {
while (temp < (LowEdgeSet * 10)) temp = temp * 10;
if (temp > (HighEdgeSet * 10)) EdgeBeeper();
else frequency = temp;
radio.SetFreq(frequency);
} else if (band == BAND_OIRT) {
while (temp < (LowEdgeOIRTSet * 10)) temp = temp * 10;
if (temp > HighEdgeOIRTSet) EdgeBeeper();
else frequency_OIRT = temp;
radio.SetFreq(frequency_OIRT);
} else if (band == BAND_LW) {
while (temp < LWLowEdgeSet) temp = temp * 10;
if (temp > LWHighEdgeSet) EdgeBeeper();
else frequency_AM = temp;
radio.SetFreqAM(frequency_AM);
frequency_LW = frequency_AM;
} else if (band == BAND_MW) {
while (temp < MWLowEdgeSet) temp = temp * 10;
if (temp > MWHighEdgeSet) EdgeBeeper();
else frequency_AM = temp;
radio.SetFreqAM(frequency_AM);
frequency_MW = frequency_AM;
} else if (band == BAND_SW) {
while (temp < SWLowEdgeSet) temp = temp * 10;
if (temp > SWHighEdgeSet) EdgeBeeper();
else frequency_AM = temp;
radio.SetFreqAM(frequency_AM);
frequency_SW = frequency_AM;
while (newfreq < (LowEdgeSet * 10)) newfreq *= 10;
if (newfreq > (HighEdgeSet * 10)) {
EdgeBeeper();
return;
}
if (newfreq == frequency) return;
frequency = newfreq;
radio.SetFreq(frequency);
} else if (band == BAND_OIRT) {
while (newfreq < (LowEdgeOIRTSet * 10)) newfreq *= 10;
if (newfreq > HighEdgeOIRTSet) {
EdgeBeeper();
return;
}
if (newfreq == frequency_OIRT) return;
frequency_OIRT = newfreq;
radio.SetFreq(frequency_OIRT);
} else if (band == BAND_LW) {
while (newfreq < LWLowEdgeSet) newfreq *= 10;
if (newfreq > LWHighEdgeSet) {
EdgeBeeper();
return;
}
if (newfreq == frequency_LW) return;
frequency_AM = newfreq;
frequency_LW = newfreq;
radio.SetFreqAM(frequency_AM);
} else if (band == BAND_MW) {
while (newfreq < MWLowEdgeSet) newfreq *= 10;
if (newfreq > MWHighEdgeSet) {
EdgeBeeper();
return;
}
if (newfreq == frequency_MW) return;
frequency_AM = newfreq;
frequency_MW = newfreq;
radio.SetFreqAM(frequency_AM);
} else if (band == BAND_SW) {
while (newfreq < SWLowEdgeSet) newfreq *= 10;
if (newfreq > SWHighEdgeSet) {
EdgeBeeper();
return;
}
if (newfreq == frequency_SW) return;
frequency_AM = newfreq;
frequency_SW = newfreq;
radio.SetFreqAM(frequency_AM);
}
aftest = true;
aftimer = millis();
radio.clearRDS(fullsearchrds);
if (RDSSPYUSB) Serial.print("G:\r\nRESET-------\r\n\r\n");
@@ -1384,7 +1403,7 @@ void setup() {
for (int x = 0; x <= ContrastSet; x++) {
analogWrite(CONTRASTPIN, map(x, 0, 100, 15, 255));
delay(10);
delay(9);
}
console.print("Firmware " + String(VERSION));
@@ -1445,7 +1464,7 @@ void setup() {
console.print("Detected a TEF6689 Lithio FMSI DR");
#endif
}
console.print("Chip Patch: v" + String(TEF) + " HW " + String(hw >> 8) + "." + String(hw & 0xff) + " SW " + String(sw >> 8) + "." + String(sw & 0xff));
console.print("Chip Patch: v" + String(TEF));
if(analogRead(BATTERY_PIN) < 200) batterydetect = false;
else console.print("Battery detected.");
@@ -1515,6 +1534,7 @@ void setup() {
screensavertimer = millis();
tottimer = millis();
console.reset();
}
void ShowModLevel();

View File

@@ -404,7 +404,7 @@ void showPI() {
void showPTY() {
if(radio.rds.PTY.changed(0)) {
String PTYString = String(radio.rds.PTY) + "/" + (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(227 + radio.rds.PTY));
String PTYString = (radio.rds.region != 0 ? (radio.rds.region == 0 ? PTY_EU[radio.rds.PTY] : PTY_USA[radio.rds.PTY]) : textUI(227 + radio.rds.PTY));
GeneralTextSprite.fillSprite(TFT_TRANSPARENT);
GeneralTextSprite.fillRect(0, 0, 160, 19, BackgroundColor);
if(RDSstatus) GeneralTextSprite.setTextColor(RDSColor, RDSColorSmooth, false);

View File

@@ -105,7 +105,6 @@ bool init_rtc() {
Wire.write(toBCD(26));
Wire.endTransmission();
writeToModule(0x1F, 0); // Unset stop bit
sync_from_rx_rtc();
return true;
}
sync_from_rx_rtc();