Added database with USA callsigns and states
This commit is contained in:
@@ -180,6 +180,8 @@ char buff[16];
|
|||||||
char eonpicodeold[20][6];
|
char eonpicodeold[20][6];
|
||||||
char programTypePrevious[18];
|
char programTypePrevious[18];
|
||||||
char radioIdPrevious[7];
|
char radioIdPrevious[7];
|
||||||
|
char stationIDPrevious[8];
|
||||||
|
char stationStatePrevious[3];
|
||||||
const uint8_t* currentFont = nullptr;
|
const uint8_t* currentFont = nullptr;
|
||||||
float vPerold;
|
float vPerold;
|
||||||
int ActiveColor;
|
int ActiveColor;
|
||||||
@@ -274,6 +276,7 @@ String rtplusstringold;
|
|||||||
String salt;
|
String salt;
|
||||||
String saltkey = " ";
|
String saltkey = " ";
|
||||||
String stationIDold;
|
String stationIDold;
|
||||||
|
String stationStateold;
|
||||||
String SWMIBandstring = String();
|
String SWMIBandstring = String();
|
||||||
String SWMIBandstringold = String();
|
String SWMIBandstringold = String();
|
||||||
String XDRGTK_key;
|
String XDRGTK_key;
|
||||||
|
|||||||
+21938
File diff suppressed because it is too large
Load Diff
+92
-30
@@ -2,7 +2,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
||||||
#include "callsigns_usa.h"
|
#include "SPIFFS.h"
|
||||||
|
//#include "callsigns_usa.h"
|
||||||
|
|
||||||
unsigned long rdstimer = 0;
|
unsigned long rdstimer = 0;
|
||||||
unsigned long bitStartTime = 0;
|
unsigned long bitStartTime = 0;
|
||||||
@@ -441,32 +442,89 @@ void TEF6686::readRDS(byte showrdserrors)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// USA Station callsign decoder
|
// USA Station callsign decoder
|
||||||
uint16_t stationID = rds.rdsA;
|
if (ps_process && rds.correctPI != 0 && rds.region == 1 && correctPIold != rds.correctPI) {
|
||||||
if (stationID > 4096) {
|
bool foundMatch = false;
|
||||||
if (stationID > 21671 && (stationID & 0xF00U) >> 8 == 0) stationID = ((uint16_t)uint8_t(0xA0 + ((stationID & 0xF000U) >> 12)) << 8) + lowByte(stationID); // C0DE -> ACDE
|
|
||||||
if (stationID > 21671 && lowByte(stationID) == 0) stationID = 0xAF00 + uint8_t(highByte(stationID)); // CD00 -> AFCD
|
if (SPIFFS.begin(true)) {
|
||||||
if (stationID < 39247) {
|
File file = SPIFFS.open("/USA_callsigns.csv");
|
||||||
if (stationID > 21671) {
|
if (file) {
|
||||||
rds.stationID[0] = 'W';
|
int i = 0;
|
||||||
stationID -= 21672;
|
while (file.available() && !isprint(file.peek())) {
|
||||||
} else {
|
file.read();
|
||||||
rds.stationID[0] = 'K';
|
i++;
|
||||||
stationID -= 4096;
|
}
|
||||||
|
|
||||||
|
char buffer[64];
|
||||||
|
while (file.available()) {
|
||||||
|
int bytesRead = file.readBytesUntil('\n', buffer, sizeof(buffer) - 1);
|
||||||
|
buffer[bytesRead] = '\0';
|
||||||
|
|
||||||
|
char *token = strtok(buffer, ";");
|
||||||
|
|
||||||
|
int firstColumnValue;
|
||||||
|
uint16_t frequencyValue;
|
||||||
|
char stationID[8];
|
||||||
|
char stationState[8];
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
firstColumnValue = atoi(token);
|
||||||
|
token = strtok(NULL, ";");
|
||||||
|
frequencyValue = atoi(token);
|
||||||
|
token = strtok(NULL, ";");
|
||||||
|
strncpy(stationID, token, sizeof(stationID) - 1);
|
||||||
|
stationID[sizeof(stationID) - 1] = '\0';
|
||||||
|
token = strtok(NULL, ";");
|
||||||
|
strncpy(stationState, token, sizeof(stationState) - 1);
|
||||||
|
stationState[sizeof(stationState) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frequencyValue == currentfreq && static_cast<uint16_t>(firstColumnValue) == rds.correctPI) {
|
||||||
|
strncpy(rds.stationID, stationID, 7);
|
||||||
|
strncpy(rds.stationState, stationState, 2);
|
||||||
|
foundMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rds.stationID[1] = char(stationID / 676 + 65);
|
|
||||||
rds.stationID[2] = char((stationID - 676 * int(stationID / 676)) / 26 + 65);
|
|
||||||
rds.stationID[3] = char(((stationID - 676 * int(stationID / 676)) % 26) + 65);
|
|
||||||
rds.stationID[5] = '\0';
|
|
||||||
} else {
|
|
||||||
stationID -= 4835;
|
|
||||||
rds.stationID[0] = 'K';
|
|
||||||
rds.stationID[1] = char(stationID / 676 + 65);
|
|
||||||
rds.stationID[2] = char((stationID - 676 * int(stationID / 676)) / 26 + 65);
|
|
||||||
rds.stationID[3] = char(((stationID - 676 * int(stationID / 676)) % 26) + 65);
|
|
||||||
rds.stationID[5] = '\0';
|
|
||||||
}
|
}
|
||||||
|
/* for (int i = 0; i < sizeof(callsign_USA) / sizeof(callsign_USA[0]); i++) {
|
||||||
|
if (callsign_USA[i][0].csusa_pi == rds.correctPI && callsign_USA[i][0].csusa_freq == currentfreq / 10) {
|
||||||
|
strncpy(rds.stationID, callsign_USA[i][0].csusa_callsign, 7);
|
||||||
|
foundMatch = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!foundMatch) {
|
||||||
|
uint16_t stationID = rds.rdsA;
|
||||||
|
if (stationID > 4096) {
|
||||||
|
if (stationID > 21671 && (stationID & 0xF00U) >> 8 == 0) stationID = ((uint16_t)uint8_t(0xA0 + ((stationID & 0xF000U) >> 12)) << 8) + lowByte(stationID); // C0DE -> ACDE
|
||||||
|
if (stationID > 21671 && lowByte(stationID) == 0) stationID = 0xAF00 + uint8_t(highByte(stationID)); // CD00 -> AFCD
|
||||||
|
if (stationID < 39247) {
|
||||||
|
if (stationID > 21671) {
|
||||||
|
rds.stationID[0] = 'W';
|
||||||
|
stationID -= 21672;
|
||||||
|
} else {
|
||||||
|
rds.stationID[0] = 'K';
|
||||||
|
stationID -= 4096;
|
||||||
|
}
|
||||||
|
rds.stationID[1] = char(stationID / 676 + 65);
|
||||||
|
rds.stationID[2] = char((stationID - 676 * int(stationID / 676)) / 26 + 65);
|
||||||
|
rds.stationID[3] = char(((stationID - 676 * int(stationID / 676)) % 26) + 65);
|
||||||
|
} else {
|
||||||
|
stationID -= 4835;
|
||||||
|
rds.stationID[0] = 'K';
|
||||||
|
rds.stationID[1] = char(stationID / 676 + 65);
|
||||||
|
rds.stationID[2] = char((stationID - 676 * int(stationID / 676)) / 26 + 65);
|
||||||
|
rds.stationID[3] = char(((stationID - 676 * int(stationID / 676)) % 26) + 65);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rds.stationID[7] = '?';
|
||||||
|
rds.stationID[8] = '\0';
|
||||||
|
}
|
||||||
|
correctPIold = rds.correctPI;
|
||||||
}
|
}
|
||||||
rds.stationID[6] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rds.rdsBerror || showrdserrors == 3) rdsblock = rds.rdsB >> 11; else return;
|
if (!rds.rdsBerror || showrdserrors == 3) rdsblock = rds.rdsB >> 11; else return;
|
||||||
@@ -1344,12 +1402,15 @@ void TEF6686::clearRDS (bool fullsearchrds)
|
|||||||
for (i = 0; i < 17; i++) rds.stationType[i] = 0x20;
|
for (i = 0; i < 17; i++) rds.stationType[i] = 0x20;
|
||||||
rds.stationType[17] = 0;
|
rds.stationType[17] = 0;
|
||||||
|
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) rds.picode[i] = 0x20;
|
||||||
rds.picode[i] = 0x20;
|
rds.picode[6] = 0;
|
||||||
rds.stationID[i] = 0x20;
|
|
||||||
rds.picode[6] = 0;
|
for (i = 0; i < 8; i++) rds.stationID[i] = 0x20;
|
||||||
rds.stationID[6] = 0;
|
rds.stationID[8] = 0;
|
||||||
}
|
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) rds.stationState[i] = 0x20;
|
||||||
|
rds.stationState[3] = 0;
|
||||||
|
|
||||||
for (i = 0; i < 50; i++) {
|
for (i = 0; i < 50; i++) {
|
||||||
af[i].frequency = 0;
|
af[i].frequency = 0;
|
||||||
@@ -1435,6 +1496,7 @@ void TEF6686::clearRDS (bool fullsearchrds)
|
|||||||
rds.aid_counter = 0;
|
rds.aid_counter = 0;
|
||||||
afmethodBprobe = false;
|
afmethodBprobe = false;
|
||||||
afmethodBtrigger = false;
|
afmethodBtrigger = false;
|
||||||
|
correctPIold = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
||||||
|
|||||||
+3
-1
@@ -538,7 +538,8 @@ typedef struct _rds_ {
|
|||||||
String LICtext;
|
String LICtext;
|
||||||
char stationType[18];
|
char stationType[18];
|
||||||
char picode[7];
|
char picode[7];
|
||||||
char stationID[7];
|
char stationID[8];
|
||||||
|
char stationState[3];
|
||||||
uint16_t hour, minute, day, month, year, rdsA, rdsB, rdsC, rdsD, rdsErr, rdsStat, correctPI, rdsplusTag1, rdsplusTag2;
|
uint16_t hour, minute, day, month, year, rdsA, rdsB, rdsC, rdsD, rdsErr, rdsStat, correctPI, rdsplusTag1, rdsplusTag2;
|
||||||
uint16_t aid[10];
|
uint16_t aid[10];
|
||||||
byte aid_counter;
|
byte aid_counter;
|
||||||
@@ -713,5 +714,6 @@ class TEF6686 {
|
|||||||
uint8_t af_counterb;
|
uint8_t af_counterb;
|
||||||
uint8_t af_counterbcheck;
|
uint8_t af_counterbcheck;
|
||||||
bool afmethodBtrigger;
|
bool afmethodBtrigger;
|
||||||
|
uint16_t correctPIold;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
+21538
-21539
File diff suppressed because it is too large
Load Diff
+7
-1
@@ -288,6 +288,7 @@ void readRds() {
|
|||||||
if (region == REGION_US) {
|
if (region == REGION_US) {
|
||||||
if (advancedRDS) tftPrint(-1, PIold, 240, 72, SecondaryColor, SecondaryColorSmooth, 16); else tftPrint(-1, PIold, 240, 184, SecondaryColor, SecondaryColorSmooth, 16);
|
if (advancedRDS) tftPrint(-1, PIold, 240, 72, SecondaryColor, SecondaryColorSmooth, 16); else tftPrint(-1, PIold, 240, 184, SecondaryColor, SecondaryColorSmooth, 16);
|
||||||
if (advancedRDS) tftPrint(-1, stationIDold, 240, 89, SecondaryColor, SecondaryColorSmooth, 16); else tftPrint(-1, stationIDold, 240, 201, SecondaryColor, SecondaryColorSmooth, 16);
|
if (advancedRDS) tftPrint(-1, stationIDold, 240, 89, SecondaryColor, SecondaryColorSmooth, 16); else tftPrint(-1, stationIDold, 240, 201, SecondaryColor, SecondaryColorSmooth, 16);
|
||||||
|
if (advancedRDS) tftPrint(1, stationStateold, 318, 89, SecondaryColor, SecondaryColorSmooth, 16); else tftPrint(1, stationStateold, 318, 201, SecondaryColor, SecondaryColorSmooth, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (advancedRDS) tftPrint(-1, PSold, 38, 75, SecondaryColor, SecondaryColorSmooth, 28); else tftPrint(-1, PSold, 38, 187, SecondaryColor, SecondaryColorSmooth, 28);
|
if (advancedRDS) tftPrint(-1, PSold, 38, 75, SecondaryColor, SecondaryColorSmooth, 28); else tftPrint(-1, PSold, 38, 187, SecondaryColor, SecondaryColorSmooth, 28);
|
||||||
@@ -393,7 +394,7 @@ void readRds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showPI() {
|
void showPI() {
|
||||||
if (strcmp(radio.rds.picode, radioIdPrevious)) {
|
if (strcmp(radio.rds.picode, radioIdPrevious) && strcmp(radio.rds.stationID, stationIDPrevious) && strcmp(radio.rds.stationState, stationStatePrevious)) {
|
||||||
if (!afscreen && !radio.rds.rdsAerror && !radio.rds.rdsBerror && !radio.rds.rdsCerror && !radio.rds.rdsDerror && radio.rds.rdsA != radio.rds.correctPI && PIold.length() > 1) radio.clearRDS(fullsearchrds);
|
if (!afscreen && !radio.rds.rdsAerror && !radio.rds.rdsBerror && !radio.rds.rdsCerror && !radio.rds.rdsDerror && radio.rds.rdsA != radio.rds.correctPI && PIold.length() > 1) radio.clearRDS(fullsearchrds);
|
||||||
if (!screenmute) {
|
if (!screenmute) {
|
||||||
if (advancedRDS) {
|
if (advancedRDS) {
|
||||||
@@ -401,6 +402,7 @@ void showPI() {
|
|||||||
if (region == REGION_US) {
|
if (region == REGION_US) {
|
||||||
tftReplace(-1, PIold, radio.rds.picode, 240, 72, PrimaryColor, PrimaryColorSmooth, 16);
|
tftReplace(-1, PIold, radio.rds.picode, 240, 72, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
tftReplace(-1, stationIDold, radio.rds.stationID, 240, 89, PrimaryColor, PrimaryColorSmooth, 16);
|
tftReplace(-1, stationIDold, radio.rds.stationID, 240, 89, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
|
tftReplace(1, stationStateold, radio.rds.stationState, 318, 89, SecondaryColor, SecondaryColorSmooth, 16);
|
||||||
}
|
}
|
||||||
} else if (afscreen) {
|
} else if (afscreen) {
|
||||||
tftReplace(-1, PIold, radio.rds.picode, 30, 201, BWAutoColor, BWAutoColorSmooth, 16);
|
tftReplace(-1, PIold, radio.rds.picode, 30, 201, BWAutoColor, BWAutoColorSmooth, 16);
|
||||||
@@ -409,16 +411,20 @@ void showPI() {
|
|||||||
if (region == REGION_US) {
|
if (region == REGION_US) {
|
||||||
tftReplace(-1, PIold, radio.rds.picode, 240, 184, PrimaryColor, PrimaryColorSmooth, 16);
|
tftReplace(-1, PIold, radio.rds.picode, 240, 184, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
tftReplace(-1, stationIDold, radio.rds.stationID, 240, 201, PrimaryColor, PrimaryColorSmooth, 16);
|
tftReplace(-1, stationIDold, radio.rds.stationID, 240, 201, PrimaryColor, PrimaryColorSmooth, 16);
|
||||||
|
tftReplace(1, stationStateold, radio.rds.stationState, 318, 201, SecondaryColor, SecondaryColorSmooth, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PIold = radio.rds.picode;
|
PIold = radio.rds.picode;
|
||||||
stationIDold = radio.rds.stationID;
|
stationIDold = radio.rds.stationID;
|
||||||
|
stationStateold = radio.rds.stationState;
|
||||||
if (wifi) {
|
if (wifi) {
|
||||||
Udp.beginPacket(remoteip, 9030);
|
Udp.beginPacket(remoteip, 9030);
|
||||||
Udp.print("from=TEF_tuner " + String(stationlistid, DEC) + ";PI=" + String(radio.rds.picode, 4));
|
Udp.print("from=TEF_tuner " + String(stationlistid, DEC) + ";PI=" + String(radio.rds.picode, 4));
|
||||||
Udp.endPacket();
|
Udp.endPacket();
|
||||||
}
|
}
|
||||||
strcpy(radioIdPrevious, radio.rds.picode);
|
strcpy(radioIdPrevious, radio.rds.picode);
|
||||||
|
strcpy(stationIDPrevious, radio.rds.stationID);
|
||||||
|
strcpy(stationStatePrevious, radio.rds.stationState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ extern byte region;
|
|||||||
extern byte stationlistid;
|
extern byte stationlistid;
|
||||||
extern char eonpicodeold[20][6];
|
extern char eonpicodeold[20][6];
|
||||||
extern char programTypePrevious[18];
|
extern char programTypePrevious[18];
|
||||||
|
extern char stationIDPrevious[8];
|
||||||
|
extern char stationStatePrevious[3];
|
||||||
extern char radioIdPrevious[7];
|
extern char radioIdPrevious[7];
|
||||||
extern int ActiveColor;
|
extern int ActiveColor;
|
||||||
extern int ActiveColorSmooth;
|
extern int ActiveColorSmooth;
|
||||||
@@ -91,6 +93,7 @@ extern String RDSSPYRDSold;
|
|||||||
extern String RTold;
|
extern String RTold;
|
||||||
extern String rtplusstringold;
|
extern String rtplusstringold;
|
||||||
extern String stationIDold;
|
extern String stationIDold;
|
||||||
|
extern String stationStateold;
|
||||||
extern String XDRGTKRDS;
|
extern String XDRGTKRDS;
|
||||||
extern String XDRGTKRDSold;
|
extern String XDRGTKRDSold;
|
||||||
extern unsigned int mappedfreqold[20];
|
extern unsigned int mappedfreqold[20];
|
||||||
|
|||||||
Reference in New Issue
Block a user