From b821f6459e3ba0b5265ad918371bc11d50355c08 Mon Sep 17 00:00:00 2001 From: Sjef Verhoeven PE5PVB Date: Thu, 6 Jul 2023 23:19:10 +0200 Subject: [PATCH] Added PIN, extended EON to 20 positions --- src/TEF6686.cpp | 24 ++++++++++++++++-------- src/TEF6686.h | 8 ++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/TEF6686.cpp b/src/TEF6686.cpp index 56dd3aa..e73d67c 100644 --- a/src/TEF6686.cpp +++ b/src/TEF6686.cpp @@ -394,11 +394,9 @@ void TEF6686::readRDS(bool showrdserrors) for (int i = 0; i < 50; i++) { for (int j = 0; j < 50 - i; j++) { - // Ignore elements with value 0 if (af[j].frequency == 0) continue; if (af[j].frequency > af[j + 1].frequency && af[j + 1].frequency != 0) { - // Swap the elements uint16_t temp = af[j].frequency; bool temp2 = af[j].filler; af[j].frequency = af[j + 1].frequency; @@ -414,15 +412,22 @@ void TEF6686::readRDS(bool showrdserrors) case RDS_GROUP_1A: { if (rds.correct) { - if (rds.rdsC >> 12 == 0) { // ECC code readout + if (rds.rdsC >> 12 == 0) { // ECC code readout rds.ECC = rds.rdsC & 0xff; rds.hasECC = true; } - if (rds.rdsC >> 12 == 3) { // ECC code readout + if (rds.rdsC >> 12 == 3) { // ECC code readout rds.LIC = rds.rdsC & 0xff; rds.hasLIC = true; } + + if (rds.rdsD != 0) { // PIN decoder + rds.hasPIN = true; + rds.pinMin = rds.rdsD & 0x3f; + rds.pinHour = rds.rdsD >> 6 & 0x1f; + rds.pinDay = rds.rdsD >> 11 & 0x1f; + } } } break; @@ -601,7 +606,7 @@ void TEF6686::readRDS(bool showrdserrors) rds.hasEON = true; // Group is there, so we have EON bool isValuePresent = false; - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 20; i++) { if (eon[i].pi == rds.rdsD) { // Check if EON is already in array isValuePresent = true; break; @@ -610,14 +615,14 @@ void TEF6686::readRDS(bool showrdserrors) if (!isValuePresent) { eon[eon_counter].pi = rds.rdsD; // Store PI on next array - if (eon_counter < 5) eon_counter++; + if (eon_counter < 20) eon_counter++; } offset = rds.rdsB & 0x0F; // Read offset if (offset < 4) { byte position; - for (position = 0; position < 5; position++) { + for (position = 0; position < 20; position++) { if (eon[position].pi == rds.rdsD) { // Find position in array break; } @@ -643,7 +648,6 @@ void TEF6686::readRDS(bool showrdserrors) eon[position].mappedfreq = ((rds.rdsC & 0xFF) * 10 + 8750); // Add mapped frequency to array } } - } } } @@ -699,7 +703,11 @@ void TEF6686::clearRDS (bool fullsearchrds) rds.ECC = 0; rds.LIC = 0; + rds.pinHour = 0; + rds.pinMin = 0; + rds.pinDay = 0; rds.stationTypeCode = 32; + rds.hasPIN = false; rds.hasECC = false; rds.hasLIC = false; rds.hasRT = false; diff --git a/src/TEF6686.h b/src/TEF6686.h index ba1166b..2168fd9 100644 --- a/src/TEF6686.h +++ b/src/TEF6686.h @@ -108,6 +108,9 @@ typedef struct _rds_ { int8_t offset; unsigned int ECC; unsigned int LIC; + byte pinMin; + byte pinHour; + byte pinDay; bool rdsAerror; bool rdsBerror; bool rdsCerror; @@ -117,6 +120,7 @@ typedef struct _rds_ { bool hasDynamicPTY; bool hasStereo; bool hasRDS; + bool hasPIN; bool hasECC; bool hasLIC; bool hasRT; @@ -153,7 +157,7 @@ typedef struct _eon_ { class TEF6686 { public: af_ af[50]; - eon_ eon[5]; + eon_ eon[20]; rds_ rds; void readRDS(bool showrdserrors); void SetFreq(uint16_t frequency); @@ -196,6 +200,7 @@ class TEF6686 { void setVolume(int8_t volume); void tone(uint16_t time, int16_t amplitude, uint16_t frequency); uint8_t af_counter; + uint8_t eon_counter; bool mute; private: @@ -212,7 +217,6 @@ class TEF6686 { char rt_buffer[65]; char rt_buffer2[65]; bool useRTPlus = true; - byte eon_counter; bool ABold; char stationTextBuffer[65]; uint64_t doublecheck;