Compare commits

...
4 Commits
Author SHA1 Message Date
kuba 0ceb8047e8 small refactorings 2026-01-06 19:58:51 +01:00
kuba 70cbed7570 some cleanup and refactoring, nothing functional 2026-01-06 17:29:48 +01:00
kuba 0110291b97 remove airband 2026-01-06 16:27:18 +01:00
kuba 41f0140a22 89.9 flash usage 2026-01-06 13:56:00 +01:00
17 changed files with 378 additions and 926 deletions
+9
View File
@@ -0,0 +1,9 @@
Import("env")
# Apply C++-only flags
env.Append(
CXXFLAGS=[
"-fno-exceptions",
"-fno-rtti"
]
)
+2 -7
View File
@@ -538,10 +538,9 @@ class TEF6686 {
void readRDS(byte showrdserrors);
void SetFreq(uint16_t frequency);
void SetFreqAM(uint16_t frequency);
void SetFreqAIR(uint16_t frequency);
void getProcessing(uint16_t &highcut, uint16_t &stereo, uint16_t &sthiblend, uint8_t &stband_1, uint8_t &stband_2, uint8_t &stband_3, uint8_t &stband_4);
void getStatus(int16_t &level, uint16_t &USN, uint16_t &WAM, int16_t &offset, uint16_t &bandwidth, uint16_t &modulation, int8_t &snr);
void getStatusAM(int16_t &level, uint16_t &noise, uint16_t &cochannel, int16_t &offset, uint16_t &bandwidth, uint16_t &modulation, int8_t &snr);
void getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr);
void getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr);
void getIdentification(uint16_t *device, uint16_t *hw_version, uint16_t *sw_version);
void setSoftmuteFM(uint8_t mode);
void setSoftmuteAM(uint8_t mode);
@@ -580,7 +579,6 @@ class TEF6686 {
void tone(uint16_t time, int16_t amplitude, uint16_t frequency);
void extendBW(bool yesno);
uint16_t getBlockA(void);
String trimTrailingSpaces(String str);
uint8_t af_counter;
uint8_t eon_counter;
uint8_t logbook_counter;
@@ -594,9 +592,6 @@ class TEF6686 {
private:
void RDScharConverter(const char* input, wchar_t* output, size_t size, bool under);
String convertToUTF8(const wchar_t* input);
String extractUTF8Substring(const String& utf8String, size_t start, size_t length, bool under);
String ucs2ToUtf8(const char* ucs2Input);
bool isFixedCallsign(uint16_t stationID, char* stationIDStr);
String PSLongtext;
char ps_buffer[9];
+2 -5
View File
@@ -67,14 +67,11 @@ typedef enum {
void devTEF_Set_Cmd(TEF_MODULE module, uint8_t cmd, uint16_t len, ...);
bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t len);
void devTEF_Radio_Set_Noiseblanker_AM(uint8_t mode, uint16_t start);
void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq);
void devTEF_Radio_Set_GPIO(uint8_t mode);
bool 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);
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);
bool devTEF_Radio_Get_Processing_Status (uint16_t *highcut, uint16_t *stereo, uint16_t *sthiblend, uint8_t *stband_1, uint8_t *stband_2, uint8_t *stband_3, uint8_t *stband_4);
bool devTEF_Radio_Get_Quality_Status_AM (int16_t *level, uint16_t *noise, uint16_t *cochannel, 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);
bool 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_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error);
bool 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);
+7 -37
View File
@@ -36,10 +36,6 @@
#define FREQ_MW_STEP_9K 9
#define FREQ_MW_STEP_10K 10
#define FREQ_SW_STEP_5K 5
#ifdef HAS_AIR_BAND
#define FREQ_AIR_STEP_25K 25
#define FREQ_AIR_STEP_8K33 8.33
#endif
#define FREQ_OIRT_STEP_30K 3
#define FREQ_FM_STEP_50K 5
#define FREQ_FM_STEP_100K 10
@@ -56,11 +52,6 @@
#define FREQ_SW_HIGH_EDGE_MIN (FREQ_SW_11M_END)
#define FREQ_SW_HIGH_EDGE_MAX (FREQ_SW_END)
#ifdef HAS_AIR_BAND
#define FREQ_AIR_LOW_EDGE_MIN 108000
#define FREQ_AIR_HIGH_EDGE_MIN 137000
#endif
#define FREQ_FM_OIRT_START 6500 // use values of 1/10 * kHz
#define FREQ_FM_OIRT_END 7400 // use values of 1/10 * kHz
@@ -225,11 +216,7 @@
#define EE_PRESETS_CNT 99 // When set > 99 change the complete EEPROM adressing!
#define EE_CHECKBYTE_VALUE 20 // 0 ~ 255,add new entry, change for new value
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#ifdef HAS_AIR_BAND
#define EE_TOTAL_CNT 2292 // Total occupied eeprom bytes
#else
#define EE_TOTAL_CNT 2287 // Total occupied eeprom bytes
#endif
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
#define EE_PRESET_BW_START 99 // 99 * 1 byte
@@ -351,10 +338,6 @@
#define EE_BYTE_CLOCKAMPM 2278
#define EE_UINT16_LOGCOUNTER 2279
#define EE_UINT16_PICTLOCK 2283
#ifdef HAS_AIR_BAND
#define EE_BYTE_AIRSTEPSIZE 2287
#define EE_UINT16_FREQUENCY_AIR 2288
#endif
// End of EEPROM index defines
// Memory channel database
@@ -382,33 +365,20 @@ enum SCAN_CANCEL {
};
enum RADIO_BAND {
BAND_OIRT = 0, BAND_FM, BAND_GAP, BAND_LW, BAND_MW, BAND_SW, BAND_AIR
BAND_OIRT = 0, BAND_FM, BAND_GAP, BAND_LW, BAND_MW, BAND_SW, BAND_NONEXISTENT
};
#ifndef HAS_AIR_BAND
enum RADIO_AM_BAND_SELECTION {
AM_BAND_ALL = 0, AM_BAND_LW_MW, AM_BAND_LW_SW, AM_BAND_MW_SW,
AM_BAND_LW, AM_BAND_MW, AM_BAND_SW, AM_BAND_NONE,
AM_BAND_CNT
};
#else
// Toggle: LW -> MW -> SW -> AIR
enum RADIO_AM_BAND_SELECTION {
AM_BAND_ALL = 0,
AM_BAND_LW_MW_SW, AM_BAND_LW_MW_AIR, AM_BAND_LW_SW_AIR, AM_BAND_MW_SW_AIR,
AM_BAND_LW_MW, AM_BAND_LW_SW, AM_BAND_LW_AIR,
AM_BAND_MW_SW, AM_BAND_MW_AIR,
AM_BAND_SW_AIR,
AM_BAND_LW, AM_BAND_MW, AM_BAND_SW, AM_BAND_AIR, AM_BAND_NONE,
AM_BAND_CNT
};
#endif
enum RADIO_FM_BAND_SELECTION {
FM_BAND_ALL = 0, FM_BAND_OIRT, FM_BAND_FM, FM_BAND_NONE,
FM_BAND_CNT
};
enum RADIO_AM_BAND_SELECTION {
AM_BAND_ALL = 0, AM_BAND_LW_MW, AM_BAND_LW_SW, AM_BAND_MW_SW,
AM_BAND_LW, AM_BAND_MW, AM_BAND_SW, AM_BAND_NONE,
AM_BAND_CNT
};
enum RADIO_TUNE_MODE {
TUNE_MAN, TUNE_AUTO, TUNE_MEM, TUNE_MI_BAND
};
+4
View File
@@ -11,3 +11,7 @@ struct HSV {
HSV RGB565toHSV(uint16_t color);
uint16_t HSVtoRGB565(float h, float s, float v);
String convertToUTF8(const wchar_t* input);
String trimTrailingSpaces(String str);
String ucs2ToUtf8(const char* ucs2Input);
String extractUTF8Substring(const String & utf8String, size_t start, size_t length, bool underscore);
+13
View File
@@ -17,3 +17,16 @@ build_flags =
-Wall
-Wextra
-Wno-unknown-pragmas
-Os
-DCORE_DEBUG_LEVEL=0
-DBOARD_HAS_PSRAM=0
-ffunction-sections
-fdata-sections
-Wl,--gc-sections
-DARDUINO_LOOP_STACK_SIZE=4096
build_unflags =
-fexceptions
-frtti
extra_scripts = pre:extra_script.py
+147 -338
View File
@@ -4,20 +4,20 @@
#include <TimeLib.h>
#include "SPIFFS.h"
#include "constants.h"
#include "utils.h"
unsigned long rdstimer = 0;
unsigned long bitStartTime = 0;
bool lastBitState = false;
uint16_t TEF6686::getBlockA(void) {
uint16_t blockA, dummy;
devTEF_Radio_Get_RDS_Status(&dummy, &blockA, &dummy, &dummy, &dummy, &dummy);
uint16_t blockA;
devTEF_Radio_Get_RDS_Status(NULL, &blockA, NULL, NULL, NULL, NULL);
return blockA;
}
void TEF6686::TestAFEON() {
uint16_t status, dummy1, dummy2, afusn, afwam;
int8_t dummy3;
uint16_t status, afusn, afwam;
int16_t aflevel, afoffset;
byte timing;
@@ -27,7 +27,7 @@ void TEF6686::TestAFEON() {
timing = 0;
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 3, af[x].frequency);
while (timing == 0 && !bitRead(timing, 15)) {
devTEF_Radio_Get_Quality_Status(&status, &aflevel, &afusn, &afwam, &afoffset, &dummy1, &dummy2, &dummy3);
devTEF_Radio_Get_Quality_Status(&status, &aflevel, &afusn, &afwam, &afoffset, NULL, NULL, NULL);
timing = lowByte(status);
}
if (afoffset > -125 || afoffset < 125) {
@@ -43,9 +43,7 @@ void TEF6686::TestAFEON() {
af[x].checked = false;
af[x].afvalid = false;
}
} else {
af[x].checked = false;
}
} else af[x].checked = false;
}
}
}
@@ -55,21 +53,18 @@ void TEF6686::TestAFEON() {
uint16_t TEF6686::TestAF() {
if (af_counter != 0) {
uint16_t status, dummy1, dummy2, afusn, afwam, currentusn, currentwam;
int8_t dummy3;
uint16_t status, afusn, afwam, currentusn, currentwam;
int16_t aflevel, afoffset, currentoffset, currentlevel;
byte timing;
devTEF_Radio_Get_Quality_Status(&status, &currentlevel, &currentusn, &currentwam, &currentoffset, &dummy1, &dummy2, &dummy3);
devTEF_Radio_Get_Quality_Status(&status, &currentlevel, &currentusn, &currentwam, &currentoffset, NULL, NULL, NULL);
devTEF_Radio_Get_RDS_Status(&rds.rdsStat, &rds.rdsA, &rds.rdsB, &rds.rdsC, &rds.rdsD, &rds.rdsErr);
for (int x = 0; x < af_counter; x++) {
timing = 0;
devTEF_Set_Cmd(TEF_FM, Cmd_Tune_To, 7, 3, af[x].frequency);
while (timing == 0 && !bitRead(timing, 15)) {
devTEF_Radio_Get_Quality_Status(&status, &aflevel, &afusn, &afwam, &afoffset, &dummy1, &dummy2, &dummy3);
devTEF_Radio_Get_Quality_Status(&status, &aflevel, &afusn, &afwam, &afoffset, NULL, NULL, NULL);
timing = lowByte(status);
}
af[x].score = aflevel - afusn - afwam;
@@ -120,20 +115,11 @@ void TEF6686::init(byte TEF) {
delay(50);
int xtalADC = analogRead(15);
if (xtalADC < XTAL_0V_ADC + XTAL_ADC_TOL) Tuner_Init(tuner_init_tab9216);
else if (xtalADC > XTAL_1V_ADC - XTAL_ADC_TOL && xtalADC < XTAL_1V_ADC + XTAL_ADC_TOL) Tuner_Init(tuner_init_tab12000);
else if (xtalADC > XTAL_2V_ADC - XTAL_ADC_TOL && xtalADC < XTAL_2V_ADC + XTAL_ADC_TOL) Tuner_Init(tuner_init_tab55000);
else Tuner_Init(tuner_init_tab4000);
if (xtalADC < XTAL_0V_ADC + XTAL_ADC_TOL) {
Tuner_Init(tuner_init_tab9216);
log_d("TEF668X XTAL : 9.216M");
} else if (xtalADC > XTAL_1V_ADC - XTAL_ADC_TOL && xtalADC < XTAL_1V_ADC + XTAL_ADC_TOL) {
Tuner_Init(tuner_init_tab12000);
log_d("TEF668X XTAL : 12M");
} else if (xtalADC > XTAL_2V_ADC - XTAL_ADC_TOL && xtalADC < XTAL_2V_ADC + XTAL_ADC_TOL) {
Tuner_Init(tuner_init_tab55000);
log_d("TEF668X XTAL : 55M");
} else {
Tuner_Init(tuner_init_tab4000);
log_d("TEF668X XTAL : 4M");
}
power(1);
Tuner_Init(tuner_init_tab);
}
@@ -167,10 +153,6 @@ void TEF6686::SetFreqAM(uint16_t frequency) {
devTEF_Set_Cmd(TEF_AM, Cmd_Tune_To, 7, 1, frequency);
}
void TEF6686::SetFreqAIR(uint16_t frequency) {
devTEF_Set_Cmd(TEF_AM, Cmd_Tune_To, 7, 1, 10700);
}
void TEF6686::setOffset(int8_t offset) {
devTEF_Set_Cmd(TEF_FM, Cmd_Set_LevelOffset, 5, (offset * 10) - 70);
}
@@ -202,7 +184,8 @@ void TEF6686::setSoftmuteFM(uint8_t mode) {
}
void TEF6686::setAMNoiseBlanker(uint16_t start) {
if (start == 0) devTEF_Radio_Set_Noiseblanker_AM(0, 1000); else devTEF_Radio_Set_Noiseblanker_AM(1, start * 10);
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker, 7, (start == 0) ? 0 : 1, (start == 0) ? 1000 : start * 10);
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker_Audio, 7, (start == 0) ? 0 : 1, 1000);
}
void TEF6686::setAMAttenuation(uint16_t start) {
@@ -335,13 +318,22 @@ void TEF6686::setStHiBlendOffset(uint8_t start) {
}
}
void TEF6686::getStatus(int16_t &level, uint16_t &USN, uint16_t &WAM, int16_t &offset, uint16_t &bandwidth, uint16_t &modulation, int8_t &snr) {
uint16_t status;
devTEF_Radio_Get_Quality_Status(&status, &level, &USN, &WAM, &offset, &bandwidth, &modulation, &snr);
void TEF6686::getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr) {
devTEF_Radio_Get_Quality_Status(NULL, level, USN, WAM, offset, bandwidth, modulation, snr);
}
void TEF6686::getStatusAM(int16_t &level, uint16_t &noise, uint16_t &cochannel, int16_t &offset, uint16_t &bandwidth, uint16_t &modulation, int8_t &snr) {
devTEF_Radio_Get_Quality_Status_AM(&level, &noise, &cochannel, &offset, &bandwidth, &modulation, &snr);
void TEF6686::getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *modulation, int8_t *snr) {
uint8_t buf[14];
devTEF_Get_Cmd(TEF_AM, Cmd_Get_Quality_Data, buf, sizeof(buf));
*level = Convert8bto16b(buf + 2);
*noise = Convert8bto16b(buf + 4);
*cochannel = Convert8bto16b(buf + 6);
*offset = Convert8bto16b(buf + 8);
*bandwidth = Convert8bto16b(buf + 10) / 10;
*modulation = Convert8bto16b(buf + 12) / 10;
if (*level < -200) *level = -200;
if (*level > 1200) *level = 1200;
*snr = int(0.46222375 * (float)(*level) / 10 - 0.082495118 * (float)(*noise / 50) / 10) + 10;
}
void TEF6686::readRDS(byte showrdserrors) {
@@ -365,10 +357,10 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (millis() - bitStartTime >= 87) rds.hasRDS = false;
}
rdsAerrorThreshold = (((rds.rdsErr >> 14) & 0x03) > showrdserrors);
rdsBerrorThreshold = (((rds.rdsErr >> 12) & 0x03) > showrdserrors);
rdsCerrorThreshold = (((rds.rdsErr >> 10) & 0x03) > showrdserrors);
rdsDerrorThreshold = (((rds.rdsErr >> 8) & 0x03) > showrdserrors);
rdsAerrorThreshold = ((rds.rdsErr >> 14) & 0x03) > showrdserrors;
rdsBerrorThreshold = ((rds.rdsErr >> 12) & 0x03) > showrdserrors;
rdsCerrorThreshold = ((rds.rdsErr >> 10) & 0x03) > showrdserrors;
rdsDerrorThreshold = ((rds.rdsErr >> 8) & 0x03) > showrdserrors;
if (bitRead(rds.rdsStat, 9) && (rds.rdsA != previous_rdsA || rds.rdsB != previous_rdsB || rds.rdsC != previous_rdsC || rds.rdsD != previous_rdsD)) {
rds.rdsAerror = (((rds.rdsErr >> 14) & 0x03) > 1);
@@ -411,7 +403,7 @@ void TEF6686::readRDS(byte showrdserrors) {
if (strncmp(rds.picode, "0000", 4) == 0 && rds.rdsB == 0 && rds.stationName.length() == 0) memset(rds.picode, 0, sizeof(rds.picode));
// USA Station callsign decoder
// USA Station callsign decoder GLORY TO TRUMP AND AMERICA RAHHHH (actually hang him and tear up the constititution, not sure what's more of a dictartorship, Venezuela or Trump?)
if ((rds.region == 1 ? ps_process : true) && rds.correctPI != 0 && rds.region > 0 && correctPIold != rds.correctPI) {
bool foundMatch = false;
fs::File file;
@@ -523,7 +515,9 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
if (!rds.rdsBerror || showrdserrors == 3) rdsgroup = rds.rdsB >> 11; else goto end;
if (rds.rdsBerror && showrdserrors != 3) goto end;
rdsgroup = rds.rdsB >> 11; // Includes version bit as LSB, better for the switch statement
rds.TP = (bitRead(rds.rdsB, 10));
rds.PTY = (rds.rdsB >> 5) & 0x1F;
@@ -545,13 +539,13 @@ void TEF6686::readRDS(byte showrdserrors) {
case 3: if (((rds.rdsErr >> 8) & 0x03) > 1) rds.ps78error = true; else rds.ps78error = false; break;
}
ps_buffer2[(segment * 2) + 0] = ps_buffer[(segment * 2) + 0]; // Make a copy of the PS buffer
ps_buffer2[(segment * 2) + 0] = ps_buffer[(segment * 2) + 0];
ps_buffer2[(segment * 2) + 1] = ps_buffer[(segment * 2) + 1];
ps_buffer2[8] = '\0'; // Endmarker
ps_buffer2[8] = '\0';
ps_buffer[(segment * 2) + 0] = rds.rdsD >> 8; // First character of segment
ps_buffer[(segment * 2) + 1] = rds.rdsD & 0xFF; // Second character of segment
ps_buffer[8] = '\0'; // Endmarker
ps_buffer[(segment * 2) + 0] = rds.rdsD >> 8;
ps_buffer[(segment * 2) + 1] = rds.rdsD & 0xFF;
ps_buffer[8] = '\0';
if (ps_process || rds.fastps == 0) {
if (segment == 0) {
@@ -565,12 +559,12 @@ void TEF6686::readRDS(byte showrdserrors) {
if (segment == 3) packet3 = true;
}
if (packet0 && packet1 && packet2 && packet3 && (ps_process || (rds.fastps == 0 && rds.fastps != 2))) { // Last chars are received
if (strcmp(ps_buffer, ps_buffer2) == 0) { // When no difference between current and buffer, let's go...
if (packet0 && packet1 && packet2 && packet3 && (ps_process || (rds.fastps == 0 && rds.fastps != 2))) {
if (strcmp(ps_buffer, ps_buffer2) == 0) {
ps_process = true;
RDScharConverter(ps_buffer2, PStext, sizeof(PStext) / sizeof(wchar_t), (underscore > 0 ? true : false)); // Convert 8 bit ASCII to 16 bit ASCII
String utf8String = convertToUTF8(PStext); // Convert RDS characterset to ASCII
rds.stationName = extractUTF8Substring(utf8String, 0, 8, (underscore > 0 ? true : false)); // Make sure PS does not exceed 8 characters
RDScharConverter(ps_buffer2, PStext, sizeof(PStext) / sizeof(wchar_t), (underscore > 0 ? true : false));
String utf8String = convertToUTF8(PStext);
rds.stationName = extractUTF8Substring(utf8String, 0, 8, (underscore > 0 ? true : false));
for (byte x = 0; x < 8; x++) {
ps_buffer[x] = '\0';
ps_buffer2[x] = '\0';
@@ -578,15 +572,15 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
if ((!ps_process && rds.fastps > 0 && rds.fastps != 2) || rds.fastps == 2) { // Let's get 2 runs of 8 PS characters fast and without refresh
if ((!ps_process && rds.fastps > 0 && rds.fastps != 2) || rds.fastps == 2) {
if (segment == 0) packet0 = true;
if (segment == 1) packet1 = true;
if (segment == 2) packet2 = true;
if (segment == 3) packet3 = true;
RDScharConverter(ps_buffer, PStext, sizeof(PStext) / sizeof(wchar_t), (underscore > 0 ? true : false)); // Convert 8 bit ASCII to 16 bit ASCII
String utf8String = convertToUTF8(PStext); // Convert RDS characterset to ASCII
RDScharConverter(ps_buffer, PStext, sizeof(PStext) / sizeof(wchar_t), (underscore > 0 ? true : false));
String utf8String = convertToUTF8(PStext);
rds.stationName = extractUTF8Substring(utf8String, 0, 8, (underscore > 0 ? true : false));
if (packet0 && packet1 && packet2 && packet3) ps_process = true; // OK, we had one runs, now let's go the idle PS writing
if (packet0 && packet1 && packet2 && packet3) ps_process = true;
}
if(segment == 0) rds.hasDynamicPTY = bitRead(rds.rdsB, 2) & 0x1F;
@@ -598,9 +592,8 @@ void TEF6686::readRDS(byte showrdserrors) {
rds.hasTA = (bitRead(rds.rdsB, 4));
if (!rdsCerrorThreshold && rdsgroup == RDS_GROUP_0A && rds.rdsC != rdsCold) {
//AF decoder
if ((rds.rdsC >> 8) > 224 && (rds.rdsC >> 8) < 250) {
afinit = true; // AF detected
afinit = true;
rds.hasAF = true;
}
@@ -623,9 +616,7 @@ void TEF6686::readRDS(byte showrdserrors) {
doubletestfreq = (rds.rdsC & 0xFF) * 10 + 8750;
}
if (((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) && ((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205)) {
if (afmethodBprobe) af_counterbcheck += 2;
}
if ((((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) && ((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205)) && afmethodBprobe) af_counterbcheck += 2;
if ((rds.rdsB >> 11) == 0 && af_counter < 50) {
uint16_t buffer0;
@@ -635,11 +626,11 @@ void TEF6686::readRDS(byte showrdserrors) {
if ((rds.rdsC & 0xFF) > 0 && (rds.rdsC & 0xFF) < 205) buffer1 = (rds.rdsC & 0xFF) * 10 + 8750; else buffer1 = 0;
if (((rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) && (buffer0 == doubletestfreq || buffer1 == doubletestfreq)) doublecounter++;
if (doublecounter > (af_number / 2)) afmethodB = true; // If signed frequency also appears more than once in the AF list, AF Method B detected
if (doublecounter > (af_number / 2)) afmethodB = true;
if (afmethodBprobe && af_counterbcheck > af_counterb) afmethodBprobe = false; // If more than counter received disable probe flag
if (afmethodBprobe && af_counterbcheck > af_counterb) afmethodBprobe = false;
if (afmethodBprobe) { // Check for Reg. flags
if (afmethodBprobe) {
if (buffer1 == currentfreq && buffer0 > buffer1) {
for (int x = 0; x < af_counter; x++) {
if (af[x].frequency == buffer0 && !af[x].regional) {
@@ -678,7 +669,7 @@ void TEF6686::readRDS(byte showrdserrors) {
}
if (buffer0 != currentfreq && buffer1 != currentfreq && afmethodB && afmethodBprobe) {
afmethodBprobe = false; // Remove faulty Reg. flags
afmethodBprobe = false;
for (int x = 0; x < af_counter; x++) {
if (af[x].frequency == buffer0 || af[x].frequency == buffer1) {
if (af[x].same) {
@@ -695,21 +686,21 @@ void TEF6686::readRDS(byte showrdserrors) {
}
bool isValuePresent = false;
for (int i = 0; i < 50; i++) { // Check if already in list
for (int i = 0; i < 50; i++) {
if ((rds.sortaf && (buffer0 == currentfreq)) || buffer0 == 0 || af[i].frequency == buffer0) {
isValuePresent = true;
break;
}
}
if (!isValuePresent) { // Add frequency to list
if (!isValuePresent) {
af[af_counter].frequency = buffer0;
if (af_counter < 50) af_counter++;
af_updatecounter++;
}
isValuePresent = false;
for (int i = 0; i < 50; i++) { // Check if already in list
for (int i = 0; i < 50; i++) {
if ((rds.sortaf && (buffer1 == currentfreq)) || buffer1 == 0 || af[i].frequency == buffer1) {
isValuePresent = true;
break;
@@ -717,16 +708,15 @@ void TEF6686::readRDS(byte showrdserrors) {
}
if (!isValuePresent) {
af[af_counter].frequency = buffer1; // Add frequency to list
af[af_counter].frequency = buffer1;
if (af_counter < 50) af_counter++;
af_updatecounter++;
}
if (rds.sortaf) { // Sort AF list (low to high)
if (rds.sortaf) {
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 50 - i; j++) {
if (af[j].frequency == 0) continue;
if (af[j].frequency > af[j + 1].frequency && af[j + 1].frequency != 0) {
uint16_t temp = af[j].frequency;
bool temp3 = af[j].afvalid;
@@ -778,7 +768,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF3) rds.ECCtext = ECCtext[200];
break;
}
case '2': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[130];
@@ -798,7 +787,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF3) rds.ECCtext = ECCtext[218];
break;
}
case '3': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[224];
@@ -821,7 +809,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF3) rds.ECCtext = ECCtext[219];
break;
}
case '4': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[148];
@@ -838,7 +825,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[213];
break;
}
case '5': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[133];
@@ -856,7 +842,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[193];
break;
}
case '6': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[134];
@@ -875,7 +860,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[201];
break;
}
case '7': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[139];
@@ -893,7 +877,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[221];
break;
}
case '8': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[142];
@@ -913,7 +896,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF3) rds.ECCtext = ECCtext[190];
break;
}
case '9': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[143];
@@ -934,7 +916,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF4) rds.ECCtext = ECCtext[190];
break;
}
case 'A': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[131];
@@ -955,7 +936,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[214];
break;
}
case 'B': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA1) rds.ECCtext = ECCtext[138];
@@ -978,7 +958,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF4) rds.ECCtext = ECCtext[204];
break;
}
case 'C': {
if (rds.ECC == 0xA1) rds.ECCtext = ECCtext[138];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[223];
@@ -999,7 +978,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[194];
break;
}
case 'D': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA1) rds.ECCtext = ECCtext[138];
@@ -1018,7 +996,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF2) rds.ECCtext = ECCtext[128];
break;
}
case 'E': {
if (rds.ECC == 0xA0) rds.ECCtext = ECCtext[226];
else if (rds.ECC == 0xA1) rds.ECCtext = ECCtext[138];
@@ -1040,7 +1017,6 @@ void TEF6686::readRDS(byte showrdserrors) {
else if (rds.ECC == 0xF3) rds.ECCtext = ECCtext[205];
break;
}
case 'F': {
if (rds.ECC == 0xA1) rds.ECCtext = ECCtext[149];
else if (rds.ECC == 0xA2) rds.ECCtext = ECCtext[222];
@@ -1063,9 +1039,9 @@ void TEF6686::readRDS(byte showrdserrors) {
break;
}
default: {
rds.ECCtext = "";
break;
}
rds.ECCtext = "";
break;
}
}
}
} break;
@@ -1101,11 +1077,11 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
wchar_t RTtext[65] = L""; // Create 16 bit char buffer for Extended ASCII
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), (underscore > 1 ? true : false)); // Convert 8 bit ASCII to 16 bit ASCII
rds.stationText = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText = extractUTF8Substring(rds.stationText, 0, endmarkerRT64, (underscore > 1 ? true : false)); // Make sure RT does not exceed 64 characters
rds.stationText = trimTrailingSpaces(rds.stationText); // Trim empty spaces at the end
wchar_t RTtext[65] = L"";
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), (underscore > 1 ? true : false));
rds.stationText = convertToUTF8(RTtext);
rds.stationText = extractUTF8Substring(rds.stationText, 0, endmarkerRT64, (underscore > 1 ? true : false));
rds.stationText = trimTrailingSpaces(rds.stationText);
}
for (byte i = 0; i < 64; i++) rt_buffer[i] = 0x20;
@@ -1130,11 +1106,11 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
wchar_t RTtext[65] = L""; // Create 16 bit char buffer for Extended ASCII
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), (underscore > 1 ? true : false)); // Convert 8 bit ASCII to 16 bit ASCII
rds.stationText = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText = extractUTF8Substring(rds.stationText, 0, endmarkerRT64, (underscore > 1 ? true : false)); // Make sure RT does not exceed 64 characters
rds.stationText = trimTrailingSpaces(rds.stationText); // Trim empty spaces at the end
wchar_t RTtext[65] = L"";
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), (underscore > 1 ? true : false));
rds.stationText = convertToUTF8(RTtext);
rds.stationText = extractUTF8Substring(rds.stationText, 0, endmarkerRT64, (underscore > 1 ? true : false));
rds.stationText = trimTrailingSpaces(rds.stationText);
}
for (int i = 0; i < 64; i++) rt_buffer2[i] = rt_buffer[i];
@@ -1143,21 +1119,18 @@ void TEF6686::readRDS(byte showrdserrors) {
case RDS_GROUP_2B: {
if (showrdserrors == 3 || (!rdsBerrorThreshold && !rdsDerrorThreshold)) {
// RT decoder (32 characters)
rds.hasRT = true;
rds.rtAB32 = (bitRead(rds.rdsB, 4)); // Get AB flag
rds.rtAB32 = (bitRead(rds.rdsB, 4));
if (rds.rtAB32 != rtAB32old) { // Erase old RT, because of AB change
for (byte i = 0; i < 33; i++) {
rt_buffer32[i] = 0x20;
}
if (rds.rtAB32 != rtAB32old) {
for (byte i = 0; i < 33; i++) rt_buffer32[i] = 0x20;
rt_buffer32[32] = '\0';
rtAB32old = rds.rtAB32;
}
uint16_t segment = (rds.rdsB & 0xf) * 2; // Get RT character segment
rt_buffer32[segment + 0] = rds.rdsD >> 8; // First character of segment
rt_buffer32[segment + 1] = rds.rdsD & 0xff; // Second character of segment
uint16_t segment = (rds.rdsB & 0xf) * 2;
rt_buffer32[segment + 0] = rds.rdsD >> 8;
rt_buffer32[segment + 1] = rds.rdsD & 0xff;
byte endmarkerRT32 = 32;
for (byte i = 0; i < endmarkerRT32; i++) {
@@ -1167,7 +1140,6 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
char rt_buffer_temp[129];
strcpy(rt_buffer_temp, rt_buffer32);
@@ -1178,11 +1150,11 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
wchar_t RTtext[33] = L""; // Create 16 bit char buffer for Extended ASCII
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), (underscore > 1 ? true : false)); // Convert 8 bit ASCII to 16 bit ASCII
rds.stationText32 = convertToUTF8(RTtext); // Convert RDS characterset to ASCII
rds.stationText32 = extractUTF8Substring(rds.stationText32, 0, endmarkerRT32, (underscore > 1 ? true : false));// Make sure RT does not exceed 32 characters
rds.stationText32 = trimTrailingSpaces(rds.stationText32); // Trim empty spaces at the end
wchar_t RTtext[33] = L"";
RDScharConverter(rt_buffer_temp, RTtext, sizeof(RTtext) / sizeof(wchar_t), (underscore > 1 ? true : false));
rds.stationText32 = convertToUTF8(RTtext);
rds.stationText32 = extractUTF8Substring(rds.stationText32, 0, endmarkerRT32, (underscore > 1 ? true : false));
rds.stationText32 = trimTrailingSpaces(rds.stationText32);
}
} break;
@@ -1225,18 +1197,16 @@ void TEF6686::readRDS(byte showrdserrors) {
case RDS_GROUP_4A: {
if (!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold && rds.ctupdate && (rds.PICTlock == rds.rdsA || rds.PICTlock == 0)) {
// CT
uint32_t mjd = (rds.rdsB & 0x03) << 15 | ((rds.rdsC >> 1) & 0x7FFF);;
uint16_t hour, minute, day = 5, month = 1, year = 2026;
int32_t timeoffset;
long J, C, Y, M;
J = mjd + 2400001 + 68569;
C = 4 * J / 146097;
long J = mjd + 2400001 + 68569;
long C = 4 * J / 146097;
J = J - (146097 * C + 3) / 4;
Y = 4000 * (J + 1) / 1461001;
long Y = 4000 * (J + 1) / 1461001;
J = J - 1461 * Y / 4 + 31;
M = 80 * J / 2447;
long M = 80 * J / 2447;
if ((J - 2447 * M / 80) < 32) day = J - 2447 * M / 80;
J = M / 11;
@@ -1278,7 +1248,6 @@ void TEF6686::readRDS(byte showrdserrors) {
case RDS_GROUP_10A: {
if (!rdsCerrorThreshold && !rdsDerrorThreshold) {
// PTYN
uint8_t segment = bitRead(rds.rdsB, 0);
if (rds.rdsC != 0 && rds.rdsD != 0) {
ptyn_buffer[(segment * 4) + 0] = rds.rdsC >> 8;
@@ -1301,7 +1270,6 @@ void TEF6686::readRDS(byte showrdserrors) {
case RDS_GROUP_11A:
case RDS_GROUP_12A:
case RDS_GROUP_13A: {
// RT+ decoding
if ((!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) && rtplusblock == rdsgroup && rds.hasRTplus) {
rds.rdsplusTag1 = ((rds.rdsB & 0x07) << 3) + (rds.rdsC >> 13);
rds.rdsplusTag2 = ((rds.rdsC & 0x01) << 5) + (rds.rdsD >> 11);
@@ -1354,7 +1322,6 @@ void TEF6686::readRDS(byte showrdserrors) {
rds.RTContent2 = extractUTF8Substring(rds.RTContent2, 0, 44, false);
}
// eRT decoding
if ((!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) && eRTblock == rdsgroup && _hasEnhancedRT) {
uint8_t offset = (rds.rdsB & 0x1f) * 4;
eRT_buffer[offset + 0] = rds.rdsC >> 8;
@@ -1380,8 +1347,7 @@ void TEF6686::readRDS(byte showrdserrors) {
}
}
if (!rdsBerrorThreshold && rdsgroup == 16 && (bitRead(rds.rdsB, 15))) rds.hasTMC = true; // TMC flag
if (!rdsBerrorThreshold && rdsgroup == 16 && (bitRead(rds.rdsB, 15))) rds.hasTMC = true;
if ((!rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) && DABAFblock == rdsgroup && rds.hasDABAF) {
rds.dabaffreq = (rds.rdsC * 16);
@@ -1404,7 +1370,6 @@ void TEF6686::readRDS(byte showrdserrors) {
break;
case RDS_GROUP_14A: {
// EON
if (!rdsAerrorThreshold && !rdsBerrorThreshold && !rdsCerrorThreshold && !rdsDerrorThreshold) {
rds.hasEON = true;
@@ -1429,22 +1394,21 @@ void TEF6686::readRDS(byte showrdserrors) {
else eon[eon_counter].picode[j] += 'A' - 10;
}
eon[eon_counter].pi = rds.rdsD; // Store PI on next array
eon[eon_counter].pi = rds.rdsD;
if (eon_counter < 20) eon_counter++;
eonIndex = eon_counter - 1;
} else eonIndex = i;
uint8_t offset = rds.rdsB & 0x0F; // Read offset
uint8_t offset = rds.rdsB & 0x0F;
if (offset < 4 && eon[eonIndex].pi == rds.rdsD) {
eon_buffer[eonIndex][(offset * 2) + 0] = rds.rdsC >> 8; // First character of segment
eon_buffer[eonIndex][(offset * 2) + 1] = rds.rdsC & 0xFF; // Second character of segment
eon_buffer[eonIndex][(offset * 2) + 0] = rds.rdsC >> 8;
eon_buffer[eonIndex][(offset * 2) + 1] = rds.rdsC & 0xFF;
}
if (eon[eonIndex].pi == rds.rdsD) { // Last chars are received
RDScharConverter(eon_buffer[eonIndex], EONPStext[eonIndex], sizeof(EONPStext[eonIndex]) / sizeof(wchar_t), false); // Convert 8 bit ASCII to 16 bit ASCII
String utf8String = convertToUTF8(EONPStext[eonIndex]); // Convert RDS characterset to ASCII
eon[eonIndex].ps = extractUTF8Substring(utf8String, 0, 8, false); // Make sure PS does not exceed 8 characters
if (eon[eonIndex].pi == rds.rdsD) {
RDScharConverter(eon_buffer[eonIndex], EONPStext[eonIndex], sizeof(EONPStext[eonIndex]) / sizeof(wchar_t), false);
eon[eonIndex].ps = extractUTF8Substring(convertToUTF8(EONPStext[eonIndex]), 0, 8, false);
}
if (offset == 13 && eon[eonIndex].pi == rds.rdsD) {
@@ -1456,11 +1420,10 @@ void TEF6686::readRDS(byte showrdserrors) {
if (bitRead(rds.rdsB, 4) && eon[eonIndex].pi == rds.rdsD) eon[eonIndex].tp = true;
if (offset > 4 && offset < 9 && eon[eonIndex].pi == rds.rdsD) { // Check if mapped frequency belongs to current frequency
if (offset > 4 && offset < 9 && eon[eonIndex].pi == rds.rdsD) {
if (((rds.rdsC >> 8) * 10 + 8750) == currentfreq && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
if (eon[eonIndex].mappedfreq == 0) {
eon[eonIndex].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array
} else if (eon[eonIndex].mappedfreq2 == 0 && eon[eonIndex].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
if (eon[eonIndex].mappedfreq == 0) eon[eonIndex].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750);
else if (eon[eonIndex].mappedfreq2 == 0 && eon[eonIndex].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
eon[eonIndex].mappedfreq2 = ((rds.rdsC & 0xFF) * 10 + 8750);
} else if (eon[eonIndex].mappedfreq3 == 0 && eon[eonIndex].mappedfreq2 != ((rds.rdsC & 0xFF) * 10 + 8750) && eon[eonIndex].mappedfreq != ((rds.rdsC & 0xFF) * 10 + 8750) && (rds.rdsC >> 8) > 0 && (rds.rdsC >> 8) < 205) {
eon[eonIndex].mappedfreq3 = ((rds.rdsC & 0xFF) * 10 + 8750);
@@ -1543,7 +1506,7 @@ void TEF6686::readRDS(byte showrdserrors) {
PSLongtext = pslong_buffer;
rds.stationNameLong = extractUTF8Substring(pslong_buffer, 0, endmarkerLPS, true);
rds.stationNameLong = trimTrailingSpaces(rds.stationNameLong);
if ((packet0long && packet1long && packet2long && packet3long) || foundendmarker) pslong_process = true; // OK, we had one runs, now let's go the idle PS Long writing
if ((packet0long && packet1long && packet2long && packet3long) || foundendmarker) pslong_process = true;
}
}
}
@@ -1560,161 +1523,87 @@ void TEF6686::readRDS(byte showrdserrors) {
void TEF6686::clearRDS(bool fullsearchrds) {
devTEF_Set_Cmd(TEF_FM, Cmd_Set_RDS, 9, fullsearchrds ? 3 : 1, 1, 0);
rds.piBuffer.clear();
rds.stationName = "";
rds.stationText = "";
rds.stationNameLong = "";
rds.stationText32 = "";
rds.RTContent1 = "";
rds.RTContent2 = "";
rds.PTYN = "";
rds.ECCtext = "";
rds.stationIDtext = "";
rds.stationStatetext = "";
rds.enhancedRTtext = "";
PSLongtext = "";
rds.stationName = rds.stationText = rds.stationNameLong = "";
rds.stationText32 = rds.RTContent1 = rds.RTContent2 = "";
rds.PTYN = rds.ECCtext = rds.stationIDtext = "";
rds.stationStatetext = rds.enhancedRTtext = PSLongtext = "";
uint8_t i;
for (i = 0; i < 8; i++) {
ps_buffer[i] = 0x20;
PStext[i] = 0;
ptyn_buffer[i] = 0x20;
PTYNtext[i] = 0;
for (uint8_t i = 0; i < 8; i++) {
ps_buffer[i] = ptyn_buffer[i] = 0x20;
PStext[i] = PTYNtext[i] = 0;
}
ps_buffer[8] = 0;
ptyn_buffer[8] = 0;
PStext[8] = 0;
PTYNtext[8] = 0;
ps_buffer[8] = ptyn_buffer[8] = PStext[8] = PTYNtext[8] = 0;
for (i = 0; i < 64; i++) rt_buffer[i] = 0x20;
for (uint8_t i = 0; i < 64; i++) rt_buffer[i] = 0x20;
rt_buffer[64] = 0;
for (i = 0; i < 128; i++) eRT_buffer[i] = 0x20;
for (uint8_t i = 0; i < 128; i++) eRT_buffer[i] = 0x20;
eRT_buffer[128] = 0;
for (i = 0; i < 32; i++) {
rt_buffer32[i] = 0x20;
pslong_buffer[i] = 0x20;
pslong_buffer2[i] = 0x20;
// PSLongtext[i] = L'\0';
}
for (uint8_t i = 0; i < 32; i++) rt_buffer32[i] = pslong_buffer[i] = pslong_buffer2[i] = 0x20;
rt_buffer32[32] = 0;
pslong_buffer[32] = 0;
// PSLongtext[32] = L'\0';
for (i = 0; i < 6; i++) rds.picode[i] = 0x20;
for (uint8_t i = 0; i < 6; i++) rds.picode[i] = 0x20;
rds.picode[6] = 0;
for (i = 0; i < 4; i++) rds.dabafeid[i] = 0x20;
for (uint8_t i = 0; i < 4; i++) rds.dabafeid[i] = 0x20;
rds.dabafeid[4] = 0;
for (i = 0; i < 3; i++) rds.dabafchannel[i] = 0x20;
for (uint8_t i = 0; i < 3; i++) rds.dabafchannel[i] = 0x20;
rds.dabafchannel[3] = 0;
for (i = 0; i < 8; i++) rds.stationID[i] = 0x20;
for (uint8_t i = 0; i < 8; i++) rds.stationID[i] = 0x20;
rds.stationID[8] = 0;
for (i = 0; i < 2; i++) rds.stationState[i] = 0x20;
for (uint8_t i = 0; i < 2; i++) rds.stationState[i] = 0x20;
rds.stationState[2] = 0;
for (i = 0; i < 50; i++) {
for (uint8_t i = 0; i < 50; i++) {
af[i].frequency = 0;
af[i].score = -32767;
af[i].afvalid = true;
af[i].checked = false;
af[i].regional = false;
af[i].same = false;
af[i].checked = af[i].regional = af[i].same = false;
}
for (i = 0; i < 20; i++) {
for (uint8_t i = 0; i < 20; i++) {
eon[i].pty = 254;
eon[i].pi = 0;
eon[i].ps = "";
eon[i].mappedfreq = 0;
eon[i].mappedfreq2 = 0;
eon[i].mappedfreq3 = 0;
eon[i].ta = false;
eon[i].tp = false;
eon[i].taset = false;
eon[i].ptyset = false;
eon[i].pi = eon[i].mappedfreq = eon[i].mappedfreq2 = eon[i].mappedfreq3 = 0;
eon[i].ta = eon[i].tp = eon[i].taset = eon[i].ptyset = false;
for (int y = 0; y < 5; y++) eon[i].picode[y] = 0;
for (int j = 0; j < 9; j++) {
EONPStext[i][j] = 0;
eon_buffer[i][j] = 0;
}
for (int j = 0; j < 9; j++) EONPStext[i][j] = eon_buffer[i][j] = 0;
}
for (i = 0; i < 45; i++) {
RDSplus1[i] = 0;
RDSplus2[i] = 0;
}
for (uint8_t i = 0; i < 45; i++) RDSplus1[i] = RDSplus2[i] = 0;
for (i = 0; i < 33; i++) rds.blockcounter[i] = 0;
for (uint8_t i = 0; i < 33; i++) rds.blockcounter[i] = 0;
for (i = 0; i < 10; i++) rds.aid[i] = 0;
for (uint8_t i = 0; i < 10; i++) rds.aid[i] = 0;
rdsgroup = 254;
processed_rdsblocks = 0;
piold = 0;
rds.correctPI = 0;
rds.ECC = 254;
rdsgroup = rds.ECC = 254;
rds.dabaffreq = rds.correctPI = correctPIold = processed_rdsblocks = piold = 0;
rds.PTY = 32;
rds.dabaffreq = 0;
rds.hasECC = false;
rds.hasRT = false;
rds.hasRDS = false;
rds.TP = false;
rds.hasAF = false;
rds.hasTA = false;
rds.hasEON = false;
rds.hasCT = false;
rds.hasTMC = false;
rds.hasAID = false;
rds.hasPTYN = false;
rds.hasLongPS = false;
rds.hasRTplus = false;
rds.hasDABAF = false;
rds.hasEnhancedRT = false;
rt_process = false;
ps_process = false;
pslong_process = false;
rds.hasECC = rds.hasRT = rds.hasRDS = false;
rds.TP = rds.hasAF = rds.hasTA = false;
rds.hasEON = rds.hasCT = rds.hasTMC = false;
rds.hasAID = rds.hasPTYN = rds.hasLongPS = false;
rds.hasRTplus = rds.hasDABAF = rds.hasEnhancedRT = false;
rt_process = ps_process = pslong_process = false;
rds.rdsreset = true;
rds.hasArtificialhead = false;
rds.hasCompressed = false;
rds.hasDynamicPTY = false;
rds.hasStereo = false;
af_counter = 0;
af_updatecounter = 0;
eon_counter = 0;
afreset = true;
rds.rdsAerror = true;
rds.rdsBerror = true;
rds.rdsCerror = true;
rds.rdsDerror = true;
initrt = true;
initab = true;
rds.hasArtificialhead = rds.hasCompressed = false;
rds.hasDynamicPTY = rds.hasStereo = false;
af_counter = af_updatecounter = eon_counter = 0;
afreset = rds.rdsAerror = rds.rdsBerror = rds.rdsCerror = rds.rdsDerror = true;
initrt = initab = true;
rds.rdsplusTag1 = 169;
rds.rdsplusTag2 = 169;
afinit = false;
errorfreepi = false;
afmethodB = false;
packet0 = false;
packet1 = false;
packet2 = false;
packet3 = false;
packet0long = false;
packet1long = false;
packet2long = false;
packet3long = false;
rds.aid_counter = 0;
afmethodBprobe = false;
afmethodBtrigger = false;
correctPIold = 0;
af_number = 0;
_hasEnhancedRT = false;
rds.ps12error = true;
rds.ps34error = true;
rds.ps56error = true;
rds.ps78error = true;
afinit = afmethodB = errorfreepi = false;
packet0 = packet1 = packet2 = packet3 = false;
packet0long = packet1long = packet2long = packet3long = false;
rds.aid_counter = af_number = 0;
afmethodBprobe = afmethodBtrigger = _hasEnhancedRT = false;
rds.ps12error = rds.ps34error = rds.ps56error = rds.ps78error = true;
}
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
@@ -1724,58 +1613,6 @@ void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
devTEF_Radio_Set_Wavegen(0, 0, 0);
}
String TEF6686::convertToUTF8(const wchar_t* input) {
String output;
while (*input) {
uint32_t unicode = *input;
if (unicode < 0x80) output += (char)unicode;
else if (unicode < 0x800) {
output += (char)(0xC0 | (unicode >> 6));
output += (char)(0x80 | (unicode & 0x3F));
} else if (unicode < 0x10000) {
output += (char)(0xE0 | (unicode >> 12));
output += (char)(0x80 | ((unicode >> 6) & 0x3F));
output += (char)(0x80 | (unicode & 0x3F));
} else {
output += (char)(0xF0 | (unicode >> 18));
output += (char)(0x80 | ((unicode >> 12) & 0x3F));
output += (char)(0x80 | ((unicode >> 6) & 0x3F));
output += (char)(0x80 | (unicode & 0x3F));
}
input++;
}
return output;
}
String TEF6686::extractUTF8Substring(const String & utf8String, size_t start, size_t length, bool underscore) {
String substring;
size_t utf8Length = utf8String.length();
size_t utf8Index = 0;
size_t charIndex = 0;
while (utf8Index < utf8Length && charIndex < start + length) {
uint8_t currentByte = utf8String.charAt(utf8Index);
uint8_t numBytes = 0;
if (currentByte < 0x80) numBytes = 1;
else if ((currentByte >> 5) == 0x6) numBytes = 2;
else if ((currentByte >> 4) == 0xE) numBytes = 3;
else if ((currentByte >> 3) == 0x1E) numBytes = 4;
if (charIndex >= start) substring += utf8String.substring(utf8Index, utf8Index + numBytes);
utf8Index += numBytes;
charIndex++;
}
if (underscore) {
while (substring.length() < length) substring += '_';
}
return substring;
}
void TEF6686::RDScharConverter(const char* input, wchar_t* output, size_t size, bool underscore) {
for (size_t i = 0; i < size - 1; i++) {
char currentChar = input[i];
@@ -1919,35 +1756,7 @@ void TEF6686::RDScharConverter(const char* input, wchar_t* output, size_t size,
case 0xFF: output[i] = L' '; break;
}
}
output[size - 1] = L'\0';
}
String TEF6686::trimTrailingSpaces(String str) {
int end = str.length() - 1;
while (end >= 0 && isspace(str[end])) end--;
return str.substring(0, end + 1);
}
String TEF6686::ucs2ToUtf8(const char* ucs2Input) {
String utf8Output;
size_t length = 0;
while (ucs2Input[length] != '\0' || ucs2Input[length + 1] != '\0') length += 2;
for (size_t i = 0; i < length; i += 2) {
uint16_t ucs2Char = ((uint8_t)ucs2Input[i] << 8) | (uint8_t)ucs2Input[i + 1];
if (ucs2Char <= 0x7F) utf8Output += (char)ucs2Char;
else if (ucs2Char <= 0x7FF) {
utf8Output += (char)(0xC0 | (ucs2Char >> 6));
utf8Output += (char)(0x80 | (ucs2Char & 0x3F));
} else {
utf8Output += (char)(0xE0 | (ucs2Char >> 12));
utf8Output += (char)(0x80 | ((ucs2Char >> 6) & 0x3F));
utf8Output += (char)(0x80 | (ucs2Char & 0x3F));
}
}
return utf8Output;
output[size - 1] = 0;
}
static const char* fixedCalls[] = {"CBLA", "CBFM", "CBOT"};
+20 -51
View File
@@ -30,18 +30,13 @@ bool devTEF_Get_Cmd(TEF_MODULE module, uint8_t cmd, uint8_t *receive, uint16_t l
return Tuner_ReadBuffer(receive, len);
}
void devTEF_Radio_Set_Noiseblanker_AM(uint8_t mode, uint16_t start) {
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker, 7, mode, start);
devTEF_Set_Cmd(TEF_AM, Cmd_Set_NoiseBlanker_Audio, 7, mode, 1000);
}
uint8_t devTEF_APPL_Get_Operation_Status() {
uint8_t buf[2];
devTEF_Get_Cmd(TEF_APPL, Cmd_Get_Operation_Status, buf, sizeof(buf));
return Convert8bto16b(buf);
}
bool devTEF_Radio_Get_Processing_Status (uint16_t *highcut, uint16_t *stereo, uint16_t *sthiblend, uint8_t *stband_1, uint8_t *stband_2, uint8_t *stband_3, uint8_t *stband_4) {
bool devTEF_Radio_Get_Processing_Status(uint16_t *highcut, uint16_t *stereo, uint16_t *sthiblend, uint8_t *stband_1, uint8_t *stband_2, uint8_t *stband_3, uint8_t *stband_4) {
uint8_t buf[12];
uint16_t r = devTEF_Get_Cmd(TEF_FM, Cmd_Get_Processing_Status, buf, sizeof(buf));
*highcut = Convert8bto16b(buf + 2) / 10;
@@ -56,52 +51,33 @@ bool devTEF_Radio_Get_Processing_Status (uint16_t *highcut, uint16_t *stereo, ui
return r;
}
bool 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) {
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 buf[14];
uint16_t r = devTEF_Get_Cmd(TEF_FM, Cmd_Get_Quality_Data, buf, sizeof(buf));
*status = Convert8bto16b(buf);
*level = Convert8bto16b(buf + 2);
*usn = Convert8bto16b(buf + 4);
*wam = Convert8bto16b(buf + 6);
*offset = Convert8bto16b(buf + 8);
*bandwidth = Convert8bto16b(buf + 10) / 10;
*mod = Convert8bto16b(buf + 12) / 10;
devTEF_Get_Cmd(TEF_FM, Cmd_Get_Quality_Data, buf, sizeof(buf));
if(status != NULL) *status = Convert8bto16b(buf);
if(level != NULL) *level = Convert8bto16b(buf + 2);
if(usn != NULL) *usn = Convert8bto16b(buf + 4);
if(wam != NULL) *wam = Convert8bto16b(buf + 6);
if(offset != NULL) *offset = Convert8bto16b(buf + 8);
if(bandwidth != NULL) *bandwidth = Convert8bto16b(buf + 10) / 10;
if(mod != NULL) *mod = Convert8bto16b(buf + 12) / 10;
if (*level < -200) *level = -200;
if (*level > 1200) *level = 1200;
*snr = int(0.46222375 * (float)(*level) / 10 - 0.082495118 * (float)(*usn) / 10) + 10;
return r;
if(snr != NULL) *snr = int(0.46222375 * (float)(*level) / 10 - 0.082495118 * (float)(*usn) / 10) + 10;
}
bool devTEF_Radio_Get_Quality_Status_AM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *mod, int8_t *snr) {
uint8_t buf[14];
uint16_t r = devTEF_Get_Cmd(TEF_AM, Cmd_Get_Quality_Data, buf, sizeof(buf));
*level = Convert8bto16b(buf + 2);
*noise = Convert8bto16b(buf + 4);
*cochannel = Convert8bto16b(buf + 6);
*offset = Convert8bto16b(buf + 8);
*bandwidth = Convert8bto16b(buf + 10) / 10;
*mod = Convert8bto16b(buf + 12) / 10;
if (*level < -200) *level = -200;
if (*level > 1200) *level = 1200;
*snr = int(0.46222375 * (float)(*level) / 10 - 0.082495118 * (float)(*noise / 50) / 10) + 10;
return r;
}
bool 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_Status(uint16_t *status, uint16_t *A_block, uint16_t *B_block, uint16_t *C_block, uint16_t *D_block, uint16_t *dec_error) {
uint8_t buf[12];
uint8_t r = devTEF_Get_Cmd(TEF_FM, Cmd_Get_RDS_Status, buf, sizeof(buf));
*status = Convert8bto16b(buf);
*A_block = Convert8bto16b(buf + 2);
*B_block = Convert8bto16b(buf + 4);
*C_block = Convert8bto16b(buf + 6);
*D_block = Convert8bto16b(buf + 8);
*dec_error = Convert8bto16b(buf + 10);
return r;
devTEF_Get_Cmd(TEF_FM, Cmd_Get_RDS_Status, buf, sizeof(buf));
if(status != NULL) *status = Convert8bto16b(buf);
if(A_block != NULL) *A_block = Convert8bto16b(buf + 2);
if(B_block != NULL) *B_block = Convert8bto16b(buf + 4);
if(C_block != NULL) *C_block = Convert8bto16b(buf + 6);
if(D_block != NULL) *D_block = Convert8bto16b(buf + 8);
if(dec_error != NULL) *dec_error = Convert8bto16b(buf + 10);
}
bool 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) {
bool 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) {
uint8_t buf[12];
uint8_t r = devTEF_Get_Cmd(TEF_FM, Cmd_Get_RDS_Data, buf, sizeof(buf));
*status = Convert8bto16b(buf);
@@ -126,10 +102,3 @@ void devTEF_Radio_Set_Wavegen(bool mode, int16_t amplitude, uint16_t freq) {
if (mode) devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 15, 5, 0, amplitude * 10, freq, amplitude * 10, freq);
else devTEF_Set_Cmd(TEF_AUDIO, Cmd_Set_WaveGen, 15, 0);
}
void devTEF_Radio_Set_GPIO(uint8_t mode) {
if (mode == 0) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 33, 2);
if (mode == 1) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 33, 3);
if (mode == 2) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 32, 2);
if (mode == 3) devTEF_Set_Cmd(TEF_APPL, Cmd_Set_GPIO, 9, 0, 32, 3);
}
+14 -16
View File
@@ -9,9 +9,9 @@ void Communication() {
if (wifi) {
int packetSize = Udp.parsePacket();
if (packetSize > 0) {
char packetBuffer[packetSize + 1]; // +1 for null getStatus
char packetBuffer[packetSize + 1];
Udp.read(packetBuffer, packetSize);
packetBuffer[packetSize] = '\0'; // Ensure valid string
packetBuffer[packetSize] = '\0';
Udp.endPacket();
String packet = String(packetBuffer);
@@ -28,23 +28,24 @@ void Communication() {
char command = packet.charAt(1);
switch (command) {
case 'U':
case 'D':
case 'D': {
tunemode = TUNE_MAN;
ShowTuneMode();
if (command == 'U') TuneUp(); else TuneDown();
ShowFreq(0);
break;
}
case '>':
case '<':
case '<': {
if (command == '>') direction = true; else direction = false;
Seek(direction);
ShowFreq(0);
break;
}
case 'T':
uint16_t freqtemp;
freqtemp = packet.substring(2).toInt();
case 'T': {
uint16_t freqtemp = packet.substring(2).toInt();
if (BAND_FM) freqtemp -= ConverterSet * 1000;
if (seek) seek = false;
radio.clearRDS(fullsearchrds);
@@ -74,11 +75,12 @@ void Communication() {
}
ShowFreq(0);
break;
}
case 'S': if (!scandxmode) startFMDXScan(); break;
case 'E': if (scandxmode) cancelDXScan(); break;
case 'S': {if (!scandxmode) startFMDXScan(); break;}
case 'E': {if (scandxmode) cancelDXScan(); break;}
case 'R': radio.clearRDS(fullsearchrds); break;
case 'R': {radio.clearRDS(fullsearchrds); break;}
}
return;
}
@@ -168,8 +170,6 @@ void Communication() {
passwordcrypt();
RemoteClient.print(saltkey + "\n");
}
} else {
if (Server.hasClient()) Server.available().stop();
}
if (wificonnected && !RemoteClient.connected()) {
@@ -195,9 +195,7 @@ void Communication() {
RemoteClient.print("o1,0\n");
RemoteClient.print("G" + String(!EQset) + String(!iMSset) + "\n");
store = true;
} else {
RemoteClient.print("a0\n");
}
} else RemoteClient.print("a0\n");
}
}
@@ -815,7 +813,7 @@ void XDRGTKRoutine() {
delay(5);
DataPrint(String(freq_scan * 10, DEC));
DataPrint(" = ");
if (band < BAND_GAP) radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN); else radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
if (band < BAND_GAP) radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN); else radio.getStatusAM(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
DataPrint(String((SStatus / 10) + 10, DEC));
DataPrint(", ");
}
-90
View File
@@ -1448,27 +1448,6 @@ void ShowOneLine(byte position, byte item, bool selected) {
FullLineSprite.setTextDatum(TR_DATUM);
FullLineSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
#ifdef HAS_AIR_BAND
switch (bandAM) {
case AM_BAND_ALL: FullLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_LW_MW_SW: FullLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 298, 2); break;
case AM_BAND_LW_MW_AIR: FullLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_LW_SW_AIR: FullLineSprite.drawString(textUI(102) + String(",") + textUI(104) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_MW_SW_AIR: FullLineSprite.drawString(textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_LW_MW: FullLineSprite.drawString(textUI(102) + String(",") + textUI(103), 298, 2); break;
case AM_BAND_LW_SW: FullLineSprite.drawString(textUI(102) + String(",") + textUI(104), 298, 2); break;
case AM_BAND_LW_AIR: FullLineSprite.drawString(textUI(102) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_MW_SW: FullLineSprite.drawString(textUI(103) + String(",") + textUI(104), 298, 2); break;
case AM_BAND_MW_AIR: FullLineSprite.drawString(textUI(103) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_SW_AIR: FullLineSprite.drawString(textUI(104) + String(",") + textUI(223), 298, 2); break;
case AM_BAND_LW: FullLineSprite.drawString(textUI(102), 298, 2); break;
case AM_BAND_MW: FullLineSprite.drawString(textUI(103), 298, 2); break;
case AM_BAND_SW: FullLineSprite.drawString(textUI(104), 298, 2); break;
case AM_BAND_AIR: FullLineSprite.drawString(textUI(223), 298, 2); break;
case AM_BAND_NONE: FullLineSprite.drawString(textUI(83), 298, 2); break;
}
break;
#else
switch (bandAM) {
case AM_BAND_ALL: FullLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 298, 2); break;
case AM_BAND_LW_MW: FullLineSprite.drawString(textUI(102) + String(",") + textUI(103), 298, 2); break;
@@ -1480,8 +1459,6 @@ void ShowOneLine(byte position, byte item, bool selected) {
case AM_BAND_NONE: FullLineSprite.drawString(textUI(83), 298, 2); break;
}
break;
#endif
case DISPLAYSETTINGS:
FullLineSprite.setTextDatum(TL_DATUM);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
@@ -2569,27 +2546,6 @@ void ShowOneButton(byte position, byte item, bool selected) {
PSSprite.drawString(shortLine(removeNewline(textUI(101))), 75, 1);
PSSprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
#ifdef HAS_AIR_BAND
switch (bandAM) {
case AM_BAND_ALL: PSSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_LW_MW_SW: PSSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 75, 15); break;
case AM_BAND_LW_MW_AIR: PSSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_LW_SW_AIR: PSSprite.drawString(textUI(102) + String(",") + textUI(104) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_MW_SW_AIR: PSSprite.drawString(textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_LW_MW: PSSprite.drawString(textUI(102) + String(",") + textUI(103), 75, 15); break;
case AM_BAND_LW_SW: PSSprite.drawString(textUI(102) + String(",") + textUI(104), 75, 15); break;
case AM_BAND_LW_AIR: PSSprite.drawString(textUI(102) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_MW_SW: PSSprite.drawString(textUI(103) + String(",") + textUI(104), 75, 15); break;
case AM_BAND_MW_AIR: PSSprite.drawString(textUI(103) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_SW_AIR: PSSprite.drawString(textUI(104) + String(",") + textUI(223), 75, 15); break;
case AM_BAND_LW: PSSprite.drawString(textUI(102), 75, 15); break;
case AM_BAND_MW: PSSprite.drawString(textUI(103), 75, 15); break;
case AM_BAND_SW: PSSprite.drawString(textUI(104), 75, 15); break;
case AM_BAND_AIR: PSSprite.drawString(textUI(223), 75, 15); break;
case AM_BAND_NONE: PSSprite.drawString(textUI(83), 75, 15); break;
}
break;
#else
switch (bandAM) {
case AM_BAND_ALL: PSSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 75, 15); break;
case AM_BAND_LW_MW: PSSprite.drawString(textUI(102) + String(",") + textUI(103), 75, 15); break;
@@ -2601,8 +2557,6 @@ void ShowOneButton(byte position, byte item, bool selected) {
case AM_BAND_NONE: PSSprite.drawString(textUI(83), 75, 15); break;
}
break;
#endif
case DISPLAYSETTINGS:
PSSprite.setTextDatum(TC_DATUM);
PSSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
@@ -3374,27 +3328,6 @@ void MenuUpDown(bool dir) {
bandAM--;
if (bandAM > AM_BAND_CNT) bandAM = AM_BAND_NONE;
}
#ifdef HAS_AIR_BAND
switch (bandAM) {
case AM_BAND_ALL: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW_MW_SW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_LW_MW_AIR: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW_SW_AIR: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_MW_SW_AIR: OneBigLineSprite.drawString(textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW_MW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103), 135, 0); break;
case AM_BAND_LW_SW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_LW_AIR: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_MW_SW: OneBigLineSprite.drawString(textUI(103) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_MW_AIR: OneBigLineSprite.drawString(textUI(103) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_SW_AIR: OneBigLineSprite.drawString(textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW: OneBigLineSprite.drawString(textUI(102), 135, 0); break;
case AM_BAND_MW: OneBigLineSprite.drawString(textUI(103), 135, 0); break;
case AM_BAND_SW: OneBigLineSprite.drawString(textUI(104), 135, 0); break;
case AM_BAND_AIR: OneBigLineSprite.drawString(textUI(223), 135, 0); break;
case AM_BAND_NONE: OneBigLineSprite.drawString(textUI(83), 135, 0); break;
}
#else
switch (bandAM) {
case AM_BAND_ALL: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_LW_MW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103), 135, 0); break;
@@ -3405,7 +3338,6 @@ void MenuUpDown(bool dir) {
case AM_BAND_SW: OneBigLineSprite.drawString(textUI(104), 135, 0); break;
case AM_BAND_NONE: OneBigLineSprite.drawString(textUI(83), 135, 0); break;
}
#endif
OneBigLineSprite.pushSprite(24, 118);
break;
@@ -4749,27 +4681,6 @@ void DoMenu() {
case ITEM8:
Infoboxprint(textUI(101));
#ifdef HAS_AIR_BAND
switch (bandAM) {
case AM_BAND_ALL: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW_MW_SW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_LW_MW_AIR: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW_SW_AIR: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_MW_SW_AIR: OneBigLineSprite.drawString(textUI(103) + String(",") + textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW_MW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103), 135, 0); break;
case AM_BAND_LW_SW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_LW_AIR: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_MW_SW: OneBigLineSprite.drawString(textUI(103) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_MW_AIR: OneBigLineSprite.drawString(textUI(103) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_SW_AIR: OneBigLineSprite.drawString(textUI(104) + String(",") + textUI(223), 135, 0); break;
case AM_BAND_LW: OneBigLineSprite.drawString(textUI(102), 135, 0); break;
case AM_BAND_MW: OneBigLineSprite.drawString(textUI(103), 135, 0); break;
case AM_BAND_SW: OneBigLineSprite.drawString(textUI(104), 135, 0); break;
case AM_BAND_AIR: OneBigLineSprite.drawString(textUI(223), 135, 0); break;
case AM_BAND_NONE: OneBigLineSprite.drawString(textUI(83), 135, 0); break;
}
#else
switch (bandAM) {
case AM_BAND_ALL: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103) + String(",") + textUI(104), 135, 0); break;
case AM_BAND_LW_MW: OneBigLineSprite.drawString(textUI(102) + String(",") + textUI(103), 135, 0); break;
@@ -4780,7 +4691,6 @@ void DoMenu() {
case AM_BAND_SW: OneBigLineSprite.drawString(textUI(104), 135, 0); break;
case AM_BAND_NONE: OneBigLineSprite.drawString(textUI(83), 135, 0); break;
}
#endif
OneBigLineSprite.pushSprite(24, 118);
break;
+7 -22
View File
@@ -320,7 +320,6 @@ bool isDST(time_t t) {
}
if (month > 3 && month < 10) return true;
return false;
}
@@ -390,9 +389,7 @@ void sendUDPlog() {
String AF = "";
if (radio.rds.hasAF && radio.af_counter > 0) {
for (byte i = 0; i < radio.af_counter; i++) {
AF += String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10) + (i == radio.af_counter - 1 ? "" : ";");
}
for (byte i = 0; i < radio.af_counter; i++) AF += String(radio.af[i].frequency / 100) + "." + String((radio.af[i].frequency % 100) / 10) + (i == radio.af_counter - 1 ? "" : ";");
}
String EON = "";
@@ -419,24 +416,12 @@ void sendUDPlog() {
if (radio.rds.hasRTplus) RTPLUS += radio.rds.RTContent1 + ";" + radio.rds.RTContent2;
// Construct the data row to send via UDP
String row = CHIP + "," +
VERSION + "," +
String(scandxmode) + "," +
currentDateTime + "," +
frequencyFormatted + "," +
String(radio.rds.picode).substring(0, 4) + "," +
signal + "," +
String(radio.getStereoStatus()) + "," +
String(radio.rds.hasTA) + "," +
String(radio.rds.TP) + "," +
String(radio.rds.hasTMC) + "," +
String(radio.rds.PTY) + "," +
ECC + "," +
stationName + "," +
radioTextModified + "," +
AF + "," +
EON + "," +
RTPLUS + "\n";
String row = CHIP + "," + VERSION + "," + String(scandxmode) + "," +
currentDateTime + "," + frequencyFormatted + "," + String(radio.rds.picode).substring(0, 4) + "," +
signal + "," + String(radio.getStereoStatus()) + "," + String(radio.rds.hasTA) + "," +
String(radio.rds.TP) + "," + String(radio.rds.hasTMC) + "," + String(radio.rds.PTY) + "," +
ECC + "," + stationName + "," + radioTextModified + "," +
AF + "," + EON + "," + RTPLUS + "\n";
// Send the data via UDP if it's new
if (UDPlogold != row) {
+52 -328
View File
@@ -44,7 +44,6 @@ using fs::FS;
#define EXT_IRQ 14
#define DYNAMIC_SPI_SPEED
//#define HAS_AIR_BAND
#ifdef ARS
TFT_eSPI tft = TFT_eSPI(320, 240);
@@ -78,9 +77,6 @@ bool memorystore;
bool memreset, memtune;
bool menu, menuopen;
bool mwstepsize;
#ifdef HAS_AIR_BAND
bool airstepsize;
#endif
bool nobattery;
bool NTPupdated;
bool optenc;
@@ -355,11 +351,6 @@ unsigned int frequency_MIBand_75M;
unsigned int frequency_MIBand_90M;
unsigned int frequency_MW;
unsigned int frequency_SW;
#ifdef HAS_AIR_BAND
unsigned int frequency_AIR;
unsigned int AIRHighEdgeSet;
unsigned int AIRLowEdgeSet;
#endif
unsigned int frequencyold;
unsigned int HighEdgeOIRTSet;
unsigned int HighEdgeSet;
@@ -435,29 +426,19 @@ WebServer webserver(80);
#pragma region helpers
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);
}
if (freq % FREQ_OIRT_STEP_30K == 1) frequency_OIRT = (freq + 1);
else if (freq % FREQ_OIRT_STEP_30K == 0) frequency_OIRT = (freq - 1);
}
void Round50K(unsigned int freq) {
if (freq % 10 < 3) {
frequency = (freq - freq % 10);
} else if (freq % 10 > 2 && freq % 10 < 8) {
frequency = (freq - (freq % 10 - 5));
} else if (freq % 10 > 7) {
frequency = (freq - (freq % 10) + 10);
}
if (freq % 10 < 3) frequency = (freq - freq % 10);
else if (freq % 10 > 2 && freq % 10 < 8) frequency = (freq - (freq % 10 - 5));
else if (freq % 10 > 7) frequency = (freq - (freq % 10) + 10);
}
void Round100K(unsigned int freq) {
if (freq % 10 < 5) {
frequency = (freq - freq % 10);
} else {
frequency = (freq - (freq % 10) + 10);
}
if (freq % 10 < 5) frequency = (freq - freq % 10);
else frequency = (freq - (freq % 10) + 10);
}
void Round200K(unsigned int freq) {
@@ -470,13 +451,9 @@ void Round200K(unsigned int freq) {
}
void Round5K(unsigned int freqAM) {
if (freqAM % 10 < 3) {
frequency_AM = (freqAM - freqAM % 10);
} else if (freqAM % 10 > 2 && freqAM % 10 < 8) {
frequency_AM = (freqAM - (freqAM % 10 - 5));
} else if (freqAM % 10 > 7) {
frequency_AM = (freqAM - (freqAM % 10) + 10);
}
if (freqAM % 10 < 3) frequency_AM = (freqAM - freqAM % 10);
else if (freqAM % 10 > 2 && freqAM % 10 < 8) frequency_AM = (freqAM - (freqAM % 10 - 5));
else if (freqAM % 10 > 7) frequency_AM = (freqAM - (freqAM % 10) + 10);
}
void Touch_IRQ_Handler() {
@@ -488,9 +465,6 @@ void StoreFrequency() {
case BAND_LW: freqold = frequency_LW; frequency_AM = frequency_LW; break;
case BAND_MW: freqold = frequency_MW; frequency_AM = frequency_MW; break;
case BAND_SW: freqold = frequency_SW; frequency_AM = frequency_SW; break;
#ifdef HAS_AIR_BAND
case BAND_AIR: freqold = frequency_AIR; frequency_AM = frequency_AIR; break;
#endif
}
EEPROM.writeUInt(EE_UINT16_FREQUENCY_FM, frequency);
EEPROM.writeUInt(EE_UINT16_FREQUENCY_OIRT, frequency_OIRT);
@@ -499,9 +473,6 @@ void StoreFrequency() {
EEPROM.writeUInt(EE_UINT16_FREQUENCY_LW, frequency_LW);
EEPROM.writeUInt(EE_UINT16_FREQUENCY_MW, frequency_MW);
EEPROM.writeUInt(EE_UINT16_FREQUENCY_SW, frequency_SW);
#ifdef HAS_AIR_BAND
EEPROM.writeUInt(EE_UINT16_FREQUENCY_AIR, frequency_AIR);
#endif
EEPROM.commit();
}
@@ -672,7 +643,7 @@ void updateSWMIBand() {
}
void updateCodetect() {
if (band > BAND_GAP && band != BAND_AIR) {
if (band > BAND_GAP) {
if (WAM) tftPrint(ALEFT, "CO", 50, 61, PrimaryColor, PrimaryColorSmooth, 16);
else tftPrint(ALEFT, "CO", 50, 61, BackgroundColor, BackgroundColor, 16);
}
@@ -758,9 +729,6 @@ void setup() {
frequency_LW = EEPROM.readUInt(EE_UINT16_FREQUENCY_LW);
frequency_MW = EEPROM.readUInt(EE_UINT16_FREQUENCY_MW);
frequency_SW = EEPROM.readUInt(EE_UINT16_FREQUENCY_SW);
#ifdef HAS_AIR_BAND
frequency_AIR = EEPROM.readUInt(EE_UINT16_FREQUENCY_AIR);
#endif
XDRGTK_key = EEPROM.readString(EE_STRING_XDRGTK_KEY);
usesquelch = EEPROM.readByte(EE_BYTE_USESQUELCH);
showmodulation = EEPROM.readByte(EE_BYTE_SHOWMODULATION);
@@ -791,9 +759,6 @@ void setup() {
radio.rds.fastps = EEPROM.readByte(EE_BYTE_FASTPS);
tot = EEPROM.readByte(EE_BYTE_TOT);
mwstepsize = EEPROM.readByte(EE_BYTE_MWREGION);
#ifdef HAS_AIR_BAND
airstepsize = EEPROM.readByte(EE_BYTE_AIRSTEPSIZE);
#endif
spispeed = EEPROM.readByte(EE_BYTE_SPISPEED);
amscansens = EEPROM.readByte(EE_BYTE_AMSCANSENS);
fmscansens = EEPROM.readByte(EE_BYTE_FMSCANSENS);
@@ -854,12 +819,8 @@ void setup() {
for (int i = 0; i < EE_PRESETS_CNT; i++) presets[i].ms = EEPROM.readByte(i + EE_PRESET_MS_START);
for (int i = 0; i < EE_PRESETS_CNT; i++) {
for (int y = 0; y < 9; y++) {
presets[i].RDSPS[y] = EEPROM.readByte((i * 9) + y + EE_PRESETS_RDSPS_START);
}
for (int y = 0; y < 5; y++) {
presets[i].RDSPI[y] = EEPROM.readByte((i * 5) + y + EE_PRESETS_RDSPI_START);
}
for (int y = 0; y < 9; y++) presets[i].RDSPS[y] = EEPROM.readByte((i * 9) + y + EE_PRESETS_RDSPS_START);
for (int y = 0; y < 5; y++) presets[i].RDSPI[y] = EEPROM.readByte((i * 5) + y + EE_PRESETS_RDSPI_START);
}
if (USBmode) Serial.begin(19200); else Serial.begin(115200);
@@ -1074,8 +1035,8 @@ void setup() {
if (TEF != 102 && TEF != 205) SetTunerPatch();
radio.init(TEF);
uint16_t device, hw, sw;
uint16_t device, hw, sw;
radio.getIdentification(&device, &hw, &sw);
if (TEF != (highByte(hw) * 100 + highByte(sw))) SetTunerPatch();
@@ -1127,12 +1088,12 @@ void setup() {
Udp.stop();
tft.fillRect(184, 230, 16, 6, SignificantColor);
}
delay(1500);
delay(1000);
radio.setVolume(VolSet);
radio.setOffset(LevelOffset);
radio.setAMOffset(AMLevelOffset);
if (band > BAND_GAP && band != BAND_AIR) {
if (band > BAND_GAP) {
radio.setAMCoChannel(amcodect, amcodectcount);
radio.setAMAttenuation(amgain);
}
@@ -1205,9 +1166,7 @@ void loop() {
doTouchEvent(x, y);
firstTouchHandled = true;
lastTouchTime = millis();
} else if (touchrepeat) {
if (millis() - lastTouchTime >= 500) doTouchEvent(x, y);
}
} else if (touchrepeat && millis() - lastTouchTime >= 500) doTouchEvent(x, y);
}
} else {
firstTouchHandled = false;
@@ -1285,7 +1244,7 @@ void loop() {
}
if (!scanholdflag) delay(100);
radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
if (!initdxscan) {
switch (scancancel) {
@@ -1357,9 +1316,7 @@ void loop() {
tft.drawBitmap(249, 4, Speaker, 28, 24, GreyoutColor);
}
findMemoryAF = false;
} else {
frequency = radio.TestAF();
}
} else frequency = radio.TestAF();
if (freqold != frequency) {
ShowFreq(0);
dropout = true;
@@ -1432,16 +1389,12 @@ void loop() {
tftPrint(ALEFT, "100", 160, 144, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ACENTER, "A", 7, 128, ActiveColor, ActiveColorSmooth, 16);
for (byte segments = 0; segments < 94; segments++) {
if (segments > 54) {
if (((segments - 53) % 10) == 0) tft.fillRect(16 + (2 * segments), 141, 2, 2, BarSignificantColor);
} else {
if (((segments + 1) % 6) == 0) tft.fillRect(16 + (2 * segments), 141, 2, 2, ModBarInsignificantColor);
}
if (segments > 54 && (((segments - 53) % 10) == 0)) tft.fillRect(16 + (2 * segments), 141, 2, 2, BarSignificantColor);
else if(((segments + 1) % 6) == 0) tft.fillRect(16 + (2 * segments), 141, 2, 2, ModBarInsignificantColor);
}
}
if (radio.rds.region == 0) {
tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
} else {
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, ActiveColor, ActiveColorSmooth, 16);
else {
tftPrint(ALEFT, "PI", 212, 184, ActiveColor, ActiveColorSmooth, 16);
tftPrint(ALEFT, "ID", 212, 201, ActiveColor, ActiveColorSmooth, 16);
}
@@ -1472,9 +1425,8 @@ void loop() {
tftPrint(ACENTER, "A", 7, 128, GreyoutColor, BackgroundColor, 16);
tft.fillRect(16, 133, 187, 6, GreyoutColor);
}
if (radio.rds.region == 0) {
tftPrint(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor, 16);
} else {
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor, 16);
else {
tftPrint(ALEFT, "PI", 212, 184, GreyoutColor, BackgroundColor, 16);
tftPrint(ALEFT, "ID", 212, 201, GreyoutColor, BackgroundColor, 16);
}
@@ -1491,11 +1443,8 @@ void loop() {
if (millis() >= lowsignaltimer + 300) {
lowsignaltimer = millis();
if (af || (!screenmute || (screenmute && (XDRGTKTCP || XDRGTKUSB)))) {
if (band < BAND_GAP) {
radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
} else {
radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
}
if (band < BAND_GAP) radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
else radio.getStatusAM(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
}
if (!BWtune && !menu) {
doSquelch();
@@ -1505,8 +1454,8 @@ void loop() {
} else {
if (af || (!screenmute || (screenmute && (XDRGTKTCP || XDRGTKUSB)))) {
if (band < BAND_GAP) radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
else radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
if (band < BAND_GAP) radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
else radio.getStatusAM(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
}
if (!BWtune && !menu) {
doSquelch();
@@ -1716,34 +1665,6 @@ void doBandSelectionFM() {
}
void CheckBandForbiddenAM() {
#ifdef HAS_AIR_BAND
switch (band) {
case BAND_LW:
if (bandAM == AM_BAND_MW_SW_AIR || bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_MW_AIR || bandAM == AM_BAND_SW_AIR || bandAM == AM_BAND_MW || bandAM == AM_BAND_SW || bandAM == AM_BAND_AIR)
bandforbidden = 1;
else
bandforbidden = 0;
break;
case BAND_MW:
if (bandAM == AM_BAND_LW_SW_AIR || bandAM == AM_BAND_LW_SW || bandAM == AM_BAND_LW_AIR || bandAM == AM_BAND_SW_AIR || bandAM == AM_BAND_LW || bandAM == AM_BAND_SW || bandAM == AM_BAND_AIR)
bandforbidden = 1;
else
bandforbidden = 0;
break;
case BAND_SW:
if (bandAM == AM_BAND_LW_MW_AIR || bandAM == AM_BAND_LW_MW || bandAM == AM_BAND_LW_AIR || bandAM == AM_BAND_MW_AIR || bandAM == AM_BAND_LW || bandAM == AM_BAND_MW || bandAM == AM_BAND_AIR)
bandforbidden = 1;
else
bandforbidden = 0;
break;
case BAND_AIR:
if (bandAM == AM_BAND_LW_MW_SW || bandAM == AM_BAND_LW_MW || bandAM == AM_BAND_LW_SW || bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_LW || bandAM == AM_BAND_MW || bandAM == AM_BAND_SW)
bandforbidden = 1;
else
bandforbidden = 0;
break;
}
#else
switch (band) {
case BAND_LW:
if (bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_MW || bandAM == AM_BAND_SW) bandforbidden = 1;
@@ -1758,102 +1679,11 @@ void CheckBandForbiddenAM() {
else bandforbidden = 0;
break;
}
#endif
}
void doBandSelectionAM() {
if (band < BAND_GAP) return;
#ifdef HAS_AIR_BAND // has air band
switch (bandAM) {
case AM_BAND_ALL:
break;
case AM_BAND_LW_MW_SW:
if (band == BAND_AIR) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_LW_MW_AIR:
if (band == BAND_SW) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_LW_SW_AIR:
if (band == BAND_MW) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_MW_SW_AIR:
if (band == BAND_LW) {
band = BAND_MW;
SelectBand();
}
break;
case AM_BAND_LW_MW:
if (band == BAND_SW || band == BAND_AIR) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_LW_SW:
if (band == BAND_MW || band == BAND_AIR) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_LW_AIR:
if (band == BAND_MW || band == BAND_SW) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_MW_SW:
if (band == BAND_LW || band == BAND_AIR) {
band = BAND_MW;
SelectBand();
}
break;
case AM_BAND_MW_AIR:
if (band == BAND_LW || band == BAND_SW) {
band = BAND_MW;
SelectBand();
}
break;
case AM_BAND_SW_AIR:
if (band == BAND_LW || band == BAND_MW) {
band = BAND_SW;
SelectBand();
}
break;
case AM_BAND_LW:
if (band != BAND_LW) {
band = BAND_LW;
SelectBand();
}
break;
case AM_BAND_MW:
if (band != BAND_MW) {
band = BAND_MW;
SelectBand();
}
break;
case AM_BAND_SW:
if (band != BAND_SW) {
band = BAND_SW;
SelectBand();
}
break;
case AM_BAND_AIR:
if (band != BAND_AIR) {
band = BAND_AIR;
SelectBand();
}
break;
}
#else // has no air band
switch (bandAM) {
case AM_BAND_ALL:
break;
@@ -1898,31 +1728,14 @@ void doBandSelectionAM() {
SelectBand();
break;
}
#endif
}
void FMjumptoAM() {
#ifdef HAS_AIR_BAND
if (bandAM == AM_BAND_ALL || bandAM == AM_BAND_LW_MW_AIR || bandAM == AM_BAND_LW_SW_AIR || bandAM == AM_BAND_LW_MW || bandAM == AM_BAND_LW_SW || bandAM == AM_BAND_LW_AIR || bandAM == AM_BAND_LW) {
band = BAND_LW;
if (stepsize > 3) stepsize = 3;
} else if (bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_MW_AIR || bandAM == AM_BAND_MW) {
band = BAND_MW;
} else if (bandAM == AM_BAND_SW_AIR || bandAM == AM_BAND_SW) {
band = BAND_SW;
} else if (bandAM == AM_BAND_AIR) {
band = BAND_AIR;
}
#else
if (bandAM == AM_BAND_ALL || bandAM == AM_BAND_LW_MW || bandAM == AM_BAND_LW_SW || bandAM == AM_BAND_LW) {
band = BAND_LW;
if (stepsize > 3) stepsize = 3;
} else if (bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_MW) {
band = BAND_MW;
} else if (bandAM == AM_BAND_SW) {
band = BAND_SW;
}
#endif
} else if (bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_MW) band = BAND_MW;
else if (bandAM == AM_BAND_SW) band = BAND_SW;
}
void AMjumptoFM() {
@@ -1933,26 +1746,6 @@ void AMjumptoFM() {
void ToggleBand(byte nowBand) {
switch (nowBand) {
#ifdef HAS_AIR_BAND
case BAND_LW:
if (bandAM == AM_BAND_LW_MW_SW || bandAM == AM_BAND_LW_MW_AIR || bandAM == AM_BAND_LW_MW || bandAM == AM_BAND_ALL) band = BAND_MW;
else if (bandAM == AM_BAND_LW_SW_AIR || bandAM == AM_BAND_LW_SW) band = BAND_SW;
else if (bandAM == AM_BAND_LW_MW_AIR || bandAM == AM_BAND_LW_SW_AIR || bandAM == AM_BAND_LW_AIR) band = BAND_AIR;
else if (bandAM == AM_BAND_LW || bandAM == AM_BAND_NONE) AMjumptoFM();
break;
case BAND_MW:
if (bandAM == AM_BAND_LW_MW_SW || bandAM == AM_BAND_MW_SW_AIR || bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_ALL) band = BAND_SW;
else if (bandAM == AM_BAND_LW_MW_AIR || bandAM == AM_BAND_MW_AIR) band = BAND_AIR;
else if (bandAM == AM_BAND_MW || bandAM == AM_BAND_NONE) AMjumptoFM();
break;
case BAND_SW:
if (bandAM == AM_BAND_LW_SW_AIR || bandAM == AM_BAND_MW_SW_AIR || bandAM == AM_BAND_SW_AIR || bandAM == AM_BAND_ALL) band = BAND_AIR;
else if (bandAM == AM_BAND_LW_MW_SW || bandAM == AM_BAND_LW_SW || bandAM == AM_BAND_MW_SW || bandAM == AM_BAND_SW || bandAM == AM_BAND_NONE) AMjumptoFM();
break;
case BAND_AIR:
AMjumptoFM();
break;
#else // has no air band
case BAND_LW:
if (bandAM == AM_BAND_LW_MW || bandAM == AM_BAND_ALL) band = BAND_MW;
else if (bandAM == AM_BAND_LW_SW) band = BAND_SW;
@@ -1977,7 +1770,6 @@ void ToggleBand(byte nowBand) {
else if (bandAM == AM_BAND_SW || bandAM == AM_BAND_NONE) AMjumptoFM();
}
break;
#endif
case BAND_OIRT:
if(bandFM == FM_BAND_ALL || bandFM == FM_BAND_FM) band = BAND_FM;
else if(bandFM == FM_BAND_OIRT && bandAM != AM_BAND_NONE) FMjumptoAM();
@@ -2433,28 +2225,16 @@ void SelectBand() {
case BAND_LW: freqold = frequency_LW; frequency_AM = frequency_LW; break;
case BAND_MW: freqold = frequency_MW; frequency_AM = frequency_MW; break;
case BAND_SW: freqold = frequency_SW; frequency_AM = frequency_SW; break;
#ifdef HAS_AIR_BAND
case BAND_AIR: freqold = frequency_AIR; frequency_AM = frequency_AIR; break;
#endif
}
LimitAMFrequency();
if (!externaltune && tunemode != TUNE_MEM) CheckBandForbiddenAM();
#ifdef HAS_AIR_BAND
if (band == BAND_AIR) {
radio.SetFreqAIR(10700);
} else {
radio.SetFreqAM(frequency_AM);
}
#else
radio.SetFreqAM(frequency_AM);
#endif
radio.setAMAttenuation(amgain);
radio.setAMCoChannel(amcodect, amcodectcount);
doBW();
if (!screenmute) {
if (radio.rds.region == 0) {
tftPrint(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor, 16);
} else {
if (radio.rds.region == 0) tftPrint(ALEFT, "PI", 212, 193, GreyoutColor, BackgroundColor, 16);
else {
tftPrint(ALEFT, "PI", 212, 184, GreyoutColor, BackgroundColor, 16);
tftPrint(ALEFT, "ID", 212, 201, GreyoutColor, BackgroundColor, 16);
}
@@ -2468,9 +2248,6 @@ void SelectBand() {
tft.fillRoundRect(287, 57, 30, 18, 2, GreyoutColor);
tftPrint(ACENTER, "EQ", 301, 59, BackgroundColor, GreyoutColor, 16);
tftReplace(ALEFT, "MHz", "kHz", 258, 76, ActiveColor, ActiveColorSmooth, BackgroundColor, 28);
// todo
// if (band == AM_BAND_AIR) tftPrint(ALEFT, "MHz", 258, 76, ActiveColor, ActiveColorSmooth, 28);
// else tftPrint(ALEFT, "KHz", 258, 76, ActiveColor, ActiveColorSmooth, 28);
}
} else {
if (tunemode == TUNE_MI_BAND) tunemode = TUNE_MAN;
@@ -2520,20 +2297,12 @@ void SelectBand() {
tftPrint(ALEFT, textUI(105), 70, 32, BackgroundColor, BackgroundColor, 16);
tftPrint(ALEFT, textUI(106), 70, 32, BackgroundColor, BackgroundColor, 16);
#ifdef HAS_AIR_BAND
tftPrint(ALEFT, textUI(223), 70, 32, BackgroundColor, BackgroundColor, 16);
#endif
switch (band) {
case BAND_LW: tftPrint(ALEFT, textUI(102), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_MW: tftPrint(ALEFT, textUI(103), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_SW: tftPrint(ALEFT, textUI(104), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_FM: tftPrint(ALEFT, textUI(105), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
case BAND_OIRT: tftPrint(ALEFT, textUI(106), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
#ifdef HAS_AIR_BAND
case BAND_AIR: tftPrint(ALEFT, textUI(223), 70, 32, (bandforbidden ? GreyoutColor : PrimaryColor), (bandforbidden ? BackgroundColor : PrimaryColorSmooth), 16); break;
#endif
}
}
leave = false;
@@ -2718,7 +2487,7 @@ void ShowStepSize() {
}
}
void RoundStep() {//todo air
void RoundStep() {
if (band == BAND_FM) {
unsigned int freq = frequency;
switch (fmdefaultstepsize) {
@@ -2882,14 +2651,12 @@ void KeyUp() {
case TUNE_MAN:
TuneUp();
break;
case TUNE_AUTO:
direction = true;
seek = true;
seekinit = true;
Seek(direction);
break;
case TUNE_MEM:
memorypos++;
if (memorypos > EE_PRESETS_CNT - 1) memorypos = 0;
@@ -3044,7 +2811,6 @@ void DoMemoryPosTune() {
#endif
radio.clearRDS(fullsearchrds);
// Process empty stations
if (IsStationEmpty()) {
memoryposstatus = MEM_DARK;
return;
@@ -3076,13 +2842,6 @@ void DoMemoryPosTune() {
frequency_SW = presets[memorypos].frequency;
radio.SetFreqAM(frequency_SW);
break;
#ifdef HAS_AIR_BAND
case BAND_AIR:
frequency_AIR = presets[memorypos].frequency;
// radio.SetFreq(frequency_AIR); // todo
radio.SetFreqAM(10700); // todo
break;
#endif
}
if (band == BAND_FM || band == BAND_OIRT) {
@@ -3141,9 +2900,6 @@ void ShowFreq(int mode) {
case BAND_LW: frequency_AM = frequency_LW; break;
case BAND_MW: frequency_AM = frequency_MW; break;
case BAND_SW: frequency_AM = frequency_SW; break;
#ifdef HAS_AIR_BAND
case BAND_AIR: frequency_AM = frequency_AIR; break; // todo air
#endif
}
if (!screenmute) {
@@ -3159,8 +2915,7 @@ void ShowFreq(int mode) {
FrequencySprite.setTextDatum(TR_DATUM);
FrequencySprite.setTextColor(FreqColor, FreqColorSmooth, false);
if (band == BAND_AIR) FrequencySprite.drawString(String(frequency_AM / 1000) + "." + String(frequency_AM % 1000) + " ", 218, -6);
else FrequencySprite.drawString(String(frequency_AM) + " ", 218, -6);
FrequencySprite.drawString(String(frequency_AM) + " ", 218, -6);
FrequencySprite.unloadFont();
FrequencySprite.setTextColor(PrimaryColor, PrimaryColorSmooth, false);
FrequencySprite.setTextDatum(TL_DATUM);
@@ -3952,13 +3707,6 @@ void TuneUp() {
temp = FREQ_SW_STEP_5K;
frequency_AM = (frequency_AM / FREQ_SW_STEP_5K) * FREQ_SW_STEP_5K;
}
#ifdef HAS_AIR_BAND
else if (frequency_AM < AIRHighEdgeSet && frequency_AM > AIRLowEdgeSet) {
if (airstepsize == 0) temp = FREQ_AIR_STEP_25K;
else temp = FREQ_AIR_STEP_8K33;
}
#endif
} else {
if (band == BAND_OIRT) temp = FREQ_OIRT_STEP_30K;
else {
@@ -3971,9 +3719,9 @@ void TuneUp() {
}
}
if (stepsize == 1) temp = 1;
if (stepsize == 2) temp = 10;
if (stepsize == 3) temp = 100;
if (stepsize == 4) temp = 1000;
else if (stepsize == 2) temp = 10;
else if (stepsize == 3) temp = 100;
else if (stepsize == 4) temp = 1000;
if (rotaryaccelerate && rotarycounter > 2) temp *= 2;
if (band == BAND_FM) {
@@ -4025,17 +3773,6 @@ void TuneUp() {
radio.SetFreqAM(frequency_AM);
frequency_SW = frequency_AM;
}
#ifdef HAS_AIR_BAND
else if (band == BAND_AIR) {
frequency_AM += temp;
if (frequency_AIR > AIRHighEdgeSet) {
frequency_AM = AIRLowEdgeSet;
EdgeBeeper();
}
radio.SetFreqAM(frequency_AM);
frequency_AIR = frequency_AM;
}
#endif
radio.clearRDS(fullsearchrds);
if (RDSSPYUSB) Serial.print("G:\r\nRESET-------\r\n\r\n");
if (RDSSPYTCP) RemoteClient.print("G:\r\nRESET-------\r\n\r\n");
@@ -4074,9 +3811,9 @@ void TuneDown() {
}
}
if (stepsize == 1) temp = 1;
if (stepsize == 2) temp = 10;
if (stepsize == 3) temp = 100;
if (stepsize == 4) temp = 1000;
else if (stepsize == 2) temp = 10;
else if (stepsize == 3) temp = 100;
else if (stepsize == 4) temp = 1000;
if (rotaryaccelerate && rotarycounter > 2) temp *= 2;
if (band == BAND_FM) {
@@ -4149,7 +3886,7 @@ void Seek(bool mode) {
}
if (band < BAND_GAP) {
radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
if ((USN < fmscansens * 30) && (WAM < 230) && (OStatus < 80 && OStatus > -80) && (!usesquelch || (Squelch < SStatus || Squelch == 920))) {
seek = false;
radio.setUnMute();
@@ -4161,7 +3898,7 @@ void Seek(bool mode) {
if (RDSSPYTCP) RemoteClient.print("G:\r\nRESET-------\r\n\r\n");
}
} else {
radio.getStatusAM(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
radio.getStatusAM(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
if ((USN < amscansens * 30) && (OStatus < 2 && OStatus > -2) && (!usesquelch || (Squelch < SStatus || Squelch == 920))) {
seek = false;
radio.setUnMute();
@@ -4176,12 +3913,10 @@ void read_encoder() {
if (millis() - rotarytimer >= 15) {
rotarycounteraccelerator = 2; // Steady fast
rotarycounter = 0;
}
if (millis() - rotarytimer >= 30) {
} else if (millis() - rotarytimer >= 30) {
rotarycounteraccelerator = 4;
rotarycounter = 0;
}
if (millis() - rotarytimer >= 45) {
} else if (millis() - rotarytimer >= 45) {
rotarycounteraccelerator = 6; // Quick flicks
rotarycounter = 0;
}
@@ -4256,7 +3991,7 @@ void MuteScreen(bool setting) {
void DefaultSettings() {
EEPROM.writeByte(EE_BYTE_CHECKBYTE, EE_CHECKBYTE_VALUE);
EEPROM.writeUInt(EE_UINT16_FREQUENCY_FM, 10000);
EEPROM.writeUInt(EE_UINT16_FREQUENCY_FM, 9500);
EEPROM.writeUInt(EE_UINT16_FREQUENCY_OIRT, FREQ_FM_OIRT_START);
EEPROM.writeByte(EE_BYTE_VOLSET, 0);
EEPROM.writeUInt(EE_UINT16_CONVERTERSET, 0);
@@ -4362,11 +4097,6 @@ void DefaultSettings() {
EEPROM.writeByte(EE_BYTE_CLOCKAMPM, 0);
EEPROM.writeUInt(EE_UINT16_PICTLOCK, 0);
#ifdef HAS_AIR_BAND
EEPROM.writeUInt(EE_UINT16_FREQUENCY_AIR, 135350);
EEPROM.writeByte(EE_BYTE_AIRSTEPSIZE, 0);
#endif
#ifdef DYNAMIC_SPI_SPEED
EEPROM.writeByte(EE_BYTE_SPISPEED, 7);
#else
@@ -4405,10 +4135,10 @@ void tftReplace(int8_t offset, const String & textold, const String & text, int1
const uint8_t *selectedFont = nullptr;
if (language == LANGUAGE_CHS) {
if (fontsize == 16) selectedFont = FONT16_CHS;
if (fontsize == 28) selectedFont = FONT28_CHS;
else if (fontsize == 28) selectedFont = FONT28_CHS;
} else {
if (fontsize == 16) selectedFont = FONT16;
if (fontsize == 28) selectedFont = FONT28;
else if (fontsize == 28) selectedFont = FONT28;
}
if (fontsize == 48) selectedFont = FONT48;
@@ -4441,10 +4171,10 @@ void tftPrint(int8_t offset, const String & text, int16_t x, int16_t y, int colo
const uint8_t *selectedFont = nullptr;
if (language == LANGUAGE_CHS) {
if (fontsize == 16) selectedFont = FONT16_CHS;
if (fontsize == 28) selectedFont = FONT28_CHS;
else if (fontsize == 28) selectedFont = FONT28_CHS;
} else {
if (fontsize == 16) selectedFont = FONT16;
if (fontsize == 28) selectedFont = FONT28;
else if (fontsize == 28) selectedFont = FONT28;
}
if (fontsize == 48) selectedFont = FONT48;
@@ -4486,7 +4216,6 @@ void UpdateFonts(byte mode) {
OneBigLineSprite.loadFont(FONT28);
}
break;
case 1:
FullLineSprite.unloadFont();
OneBigLineSprite.unloadFont();
@@ -4572,9 +4301,6 @@ void saveData() {
EEPROM.writeByte(EE_BYTE_FASTPS, radio.rds.fastps);
EEPROM.writeByte(EE_BYTE_TOT, tot);
EEPROM.writeByte(EE_BYTE_MWREGION, mwstepsize);
#ifdef HAS_AIR_BAND
EEPROM.writeByte(EE_BYTE_AIRSTEPSIZE, airstepsize);
#endif
EEPROM.writeByte(EE_BYTE_SPISPEED, spispeed);
EEPROM.writeByte(EE_BYTE_AMSCANSENS, amscansens);
EEPROM.writeByte(EE_BYTE_FMSCANSENS, fmscansens);
@@ -4747,9 +4473,7 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
tftPrint(ARIGHT, textUI(272), 120, 155, ActiveColor, ActiveColorSmooth, 16);
for (frequency = startfreq * 10; frequency <= stopfreq * 10; frequency += 10) {
if (stopScanning) {
break;
}
if (stopScanning) break;
currentIteration++;
percent = (currentIteration * 100) / totalIterations;
@@ -4757,7 +4481,7 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
radio.SetFreq(frequency);
radio.clearRDS(fullsearchrds);
delay(50);
radio.getStatus(SStatus, USN, WAM, OStatus, BW, MStatus, CN);
radio.getStatus(&SStatus, &USN, &WAM, &OStatus, &BW, &MStatus, &CN);
if ((USN < fmscansens * 30) && (WAM < 230) && (OStatus < 80 && OStatus > -80)) {
for (byte y = 0; y < 20; y++) {
delay(50);
+4 -3
View File
@@ -1,6 +1,7 @@
#include "rds.h"
#include "constants.h"
#include <TimeLib.h>
#include "utils.h"
String HexStringold;
float smoothBER = 0;
@@ -551,7 +552,7 @@ void showPS() {
}
// Handle scrolling logic for long PS
if (PSSprite.textWidth(radio.trimTrailingSpaces(radio.rds.stationNameLong)) < 150) {
if (PSSprite.textWidth(trimTrailingSpaces(radio.rds.stationNameLong)) < 150) {
xPos5 = 0;
PSSprite.fillSprite(BackgroundColor);
PSSprite.setTextColor(RDSstatus ? RDSColor : RDSDropoutColor, RDSstatus ? RDSColorSmooth : RDSDropoutColorSmooth, false);
@@ -703,7 +704,7 @@ void showRadioText() {
if (radio.rds.hasRT &&
(radio.rds.stationText.length() > 0 || radio.rds.stationText32.length() > 0)) {
if (RDSSprite.textWidth(radio.trimTrailingSpaces(RTString)) < 270) {
if (RDSSprite.textWidth(trimTrailingSpaces(RTString)) < 270) {
xPos = 0;
FullLineSprite.fillSprite(BackgroundColor);
FullLineSprite.setTextDatum(TL_DATUM);
@@ -958,7 +959,7 @@ void ShowAFEON() {
}
}
if (FullLineSprite.textWidth(radio.trimTrailingSpaces(AIDString)) < 270) {
if (FullLineSprite.textWidth(trimTrailingSpaces(AIDString)) < 270) {
xPos = 0;
FullLineSprite.fillSprite(BackgroundColor);
FullLineSprite.setTextColor(ActiveColor, ActiveColorSmooth, false);
+16 -16
View File
@@ -14,8 +14,8 @@ void doTouchEvent(uint16_t x, uint16_t y) {
ModeButtonPress();
return;
}
if (menuopen) { // Menu navigation
if (x > 18 && x < 78 && y > 150 && y < 190) KeyDown(); // ---------------
if (menuopen) {
if (x > 18 && x < 78 && y > 150 && y < 190) KeyDown();
if (x > 240 && x < 300 && y > 150 && y < 190) KeyUp();
if ((x > 240 && x < 300 && y > 40 && y < 80) || (x > 130 && x < 190 && y > 150 && y < 190)) {
touchrepeat = false;
@@ -93,18 +93,18 @@ void doTouchEvent(uint16_t x, uint16_t y) {
}
}
if (!menu && !BWtune) { // All pages except menu
if (x > 30 && x < 65 && y > 0 && y < 30 && band < BAND_GAP) { // ---------------------
doStereoToggle(); // Stereo toggle
if (!menu && !BWtune) {
if (x > 30 && x < 65 && y > 0 && y < 30 && band < BAND_GAP) {
doStereoToggle();
return;
} else if (x > 155 && x < 250 && y > 0 && y < 30) {
BuildBWSelector(); // Set bandwidth
BuildBWSelector();
BWtune = true;
return;
}
}
if (BWtune) { // BW menu
if (BWtune) {
if (y > 35 && y < 65) {
if (x > 7 && x < 77) BWtemp = 1;
if (x > 87 && x < 157) BWtemp = 2;
@@ -177,26 +177,26 @@ void doTouchEvent(uint16_t x, uint16_t y) {
return;
}
if (!BWtune && !menu && !advancedRDS && !seek && !afscreen) { // Normal radio mode
if (x > 0 && x < 320 && y > 180 && y < 240 && band < BAND_GAP) { // -----------------
if (!BWtune && !menu && !advancedRDS && !seek && !afscreen) {
if (x > 0 && x < 320 && y > 180 && y < 240 && band < BAND_GAP) {
leave = true;
BuildAdvancedRDS(); // Switch to Advanced RDS View
BuildAdvancedRDS();
return;
} else if (x > 60 && x < 240 && y > 40 && y < 100) {
doBandToggle(); // Toggle bands
doBandToggle();
return;
} else if (x > 0 && x < 30 && y > 25 && y < 90) {
doTuneMode(); // Toggle tune mode
doTuneMode();
return;
} else if (x > 250 && x < 320 && y > 50 && y < 80) {
toggleiMSEQ(); // Toggle iMQ/EQ
toggleiMSEQ();
}
}
if (!BWtune && !menu && advancedRDS && !seek && !afscreen) { // Advanced RDS mode
if (x > 0 && x < 320 && y > 120 && y < 170) { // -----------------
if (!BWtune && !menu && advancedRDS && !seek && !afscreen) {
if (x > 0 && x < 320 && y > 120 && y < 170) {
leave = true;
BuildDisplay(); // Switch to normal radio view
BuildDisplay();
SelectBand();
return;
} else if (x > 0 && x < 320 && y > 180 && y < 240) {
+79
View File
@@ -48,3 +48,82 @@ uint16_t HSVtoRGB565(float h, float s, float v) {
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
}
String convertToUTF8(const wchar_t* input) {
String output;
while (*input) {
uint32_t unicode = *input;
if (unicode < 0x80) output += (char)unicode;
else if (unicode < 0x800) {
output += (char)(0xC0 | (unicode >> 6));
output += (char)(0x80 | (unicode & 0x3F));
} else if (unicode < 0x10000) {
output += (char)(0xE0 | (unicode >> 12));
output += (char)(0x80 | ((unicode >> 6) & 0x3F));
output += (char)(0x80 | (unicode & 0x3F));
} else {
output += (char)(0xF0 | (unicode >> 18));
output += (char)(0x80 | ((unicode >> 12) & 0x3F));
output += (char)(0x80 | ((unicode >> 6) & 0x3F));
output += (char)(0x80 | (unicode & 0x3F));
}
input++;
}
return output;
}
String trimTrailingSpaces(String str) {
int end = str.length() - 1;
while (end >= 0 && isspace(str[end])) end--;
return str.substring(0, end + 1);
}
String ucs2ToUtf8(const char* ucs2Input) {
String utf8Output;
size_t length = 0;
while (ucs2Input[length] != '\0' || ucs2Input[length + 1] != '\0') length += 2;
for (size_t i = 0; i < length; i += 2) {
uint16_t ucs2Char = ((uint8_t)ucs2Input[i] << 8) | (uint8_t)ucs2Input[i + 1];
if (ucs2Char <= 0x7F) utf8Output += (char)ucs2Char;
else if (ucs2Char <= 0x7FF) {
utf8Output += (char)(0xC0 | (ucs2Char >> 6));
utf8Output += (char)(0x80 | (ucs2Char & 0x3F));
} else {
utf8Output += (char)(0xE0 | (ucs2Char >> 12));
utf8Output += (char)(0x80 | ((ucs2Char >> 6) & 0x3F));
utf8Output += (char)(0x80 | (ucs2Char & 0x3F));
}
}
return utf8Output;
}
String extractUTF8Substring(const String & utf8String, size_t start, size_t length, bool underscore) {
String substring;
size_t utf8Length = utf8String.length();
size_t utf8Index = 0;
size_t charIndex = 0;
while (utf8Index < utf8Length && charIndex < start + length) {
uint8_t currentByte = utf8String.charAt(utf8Index);
uint8_t numBytes = 0;
if (currentByte < 0x80) numBytes = 1;
else if ((currentByte >> 5) == 0x6) numBytes = 2;
else if ((currentByte >> 4) == 0xE) numBytes = 3;
else if ((currentByte >> 3) == 0x1E) numBytes = 4;
if (charIndex >= start) substring += utf8String.substring(utf8Index, utf8Index + numBytes);
utf8Index += numBytes;
charIndex++;
}
if (underscore) {
while (substring.length() < length) substring += '_';
}
return substring;
}
-11
View File
@@ -1,11 +0,0 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html