Added database with USA callsigns and states
This commit is contained in:
@@ -180,6 +180,8 @@ char buff[16];
|
||||
char eonpicodeold[20][6];
|
||||
char programTypePrevious[18];
|
||||
char radioIdPrevious[7];
|
||||
char stationIDPrevious[8];
|
||||
char stationStatePrevious[3];
|
||||
const uint8_t* currentFont = nullptr;
|
||||
float vPerold;
|
||||
int ActiveColor;
|
||||
@@ -274,6 +276,7 @@ String rtplusstringold;
|
||||
String salt;
|
||||
String saltkey = " ";
|
||||
String stationIDold;
|
||||
String stationStateold;
|
||||
String SWMIBandstring = String();
|
||||
String SWMIBandstringold = String();
|
||||
String XDRGTK_key;
|
||||
|
||||
+21938
File diff suppressed because it is too large
Load Diff
+71
-9
@@ -2,7 +2,8 @@
|
||||
#include <map>
|
||||
#include <Arduino.h>
|
||||
#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 bitStartTime = 0;
|
||||
@@ -441,6 +442,61 @@ void TEF6686::readRDS(byte showrdserrors)
|
||||
}
|
||||
|
||||
// USA Station callsign decoder
|
||||
if (ps_process && rds.correctPI != 0 && rds.region == 1 && correctPIold != rds.correctPI) {
|
||||
bool foundMatch = false;
|
||||
|
||||
if (SPIFFS.begin(true)) {
|
||||
File file = SPIFFS.open("/USA_callsigns.csv");
|
||||
if (file) {
|
||||
int i = 0;
|
||||
while (file.available() && !isprint(file.peek())) {
|
||||
file.read();
|
||||
i++;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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
|
||||
@@ -456,17 +512,19 @@ void TEF6686::readRDS(byte showrdserrors)
|
||||
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';
|
||||
}
|
||||
}
|
||||
rds.stationID[6] = '\0';
|
||||
rds.stationID[7] = '?';
|
||||
rds.stationID[8] = '\0';
|
||||
}
|
||||
correctPIold = rds.correctPI;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
rds.stationType[17] = 0;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
rds.picode[i] = 0x20;
|
||||
rds.stationID[i] = 0x20;
|
||||
for (i = 0; i < 6; i++) rds.picode[i] = 0x20;
|
||||
rds.picode[6] = 0;
|
||||
rds.stationID[6] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 8; i++) rds.stationID[i] = 0x20;
|
||||
rds.stationID[8] = 0;
|
||||
|
||||
|
||||
for (i = 0; i < 3; i++) rds.stationState[i] = 0x20;
|
||||
rds.stationState[3] = 0;
|
||||
|
||||
for (i = 0; i < 50; i++) {
|
||||
af[i].frequency = 0;
|
||||
@@ -1435,6 +1496,7 @@ void TEF6686::clearRDS (bool fullsearchrds)
|
||||
rds.aid_counter = 0;
|
||||
afmethodBprobe = false;
|
||||
afmethodBtrigger = false;
|
||||
correctPIold = 0;
|
||||
}
|
||||
|
||||
void TEF6686::tone(uint16_t time, int16_t amplitude, uint16_t frequency) {
|
||||
|
||||
+3
-1
@@ -538,7 +538,8 @@ typedef struct _rds_ {
|
||||
String LICtext;
|
||||
char stationType[18];
|
||||
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 aid[10];
|
||||
byte aid_counter;
|
||||
@@ -713,5 +714,6 @@ class TEF6686 {
|
||||
uint8_t af_counterb;
|
||||
uint8_t af_counterbcheck;
|
||||
bool afmethodBtrigger;
|
||||
uint16_t correctPIold;
|
||||
};
|
||||
#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 (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, 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);
|
||||
@@ -393,7 +394,7 @@ void readRds() {
|
||||
}
|
||||
|
||||
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 (!screenmute) {
|
||||
if (advancedRDS) {
|
||||
@@ -401,6 +402,7 @@ void showPI() {
|
||||
if (region == REGION_US) {
|
||||
tftReplace(-1, PIold, radio.rds.picode, 240, 72, 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) {
|
||||
tftReplace(-1, PIold, radio.rds.picode, 30, 201, BWAutoColor, BWAutoColorSmooth, 16);
|
||||
@@ -409,16 +411,20 @@ void showPI() {
|
||||
if (region == REGION_US) {
|
||||
tftReplace(-1, PIold, radio.rds.picode, 240, 184, 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;
|
||||
stationIDold = radio.rds.stationID;
|
||||
stationStateold = radio.rds.stationState;
|
||||
if (wifi) {
|
||||
Udp.beginPacket(remoteip, 9030);
|
||||
Udp.print("from=TEF_tuner " + String(stationlistid, DEC) + ";PI=" + String(radio.rds.picode, 4));
|
||||
Udp.endPacket();
|
||||
}
|
||||
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 char eonpicodeold[20][6];
|
||||
extern char programTypePrevious[18];
|
||||
extern char stationIDPrevious[8];
|
||||
extern char stationStatePrevious[3];
|
||||
extern char radioIdPrevious[7];
|
||||
extern int ActiveColor;
|
||||
extern int ActiveColorSmooth;
|
||||
@@ -91,6 +93,7 @@ extern String RDSSPYRDSold;
|
||||
extern String RTold;
|
||||
extern String rtplusstringold;
|
||||
extern String stationIDold;
|
||||
extern String stationStateold;
|
||||
extern String XDRGTKRDS;
|
||||
extern String XDRGTKRDSold;
|
||||
extern unsigned int mappedfreqold[20];
|
||||
|
||||
Reference in New Issue
Block a user