From 11282a12562858fc78223f7acc906703575df570 Mon Sep 17 00:00:00 2001 From: Sjef Verhoeven PE5PVB Date: Mon, 6 Jan 2025 19:25:03 +0100 Subject: [PATCH] Small update in PS positioning --- src/rds.cpp | 60 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/src/rds.cpp b/src/rds.cpp index 06a3e85..6e9fbce 100644 --- a/src/rds.cpp +++ b/src/rds.cpp @@ -12,9 +12,7 @@ int AIDWidth; int afstringWidth; int eonstringWidth; int rtplusstringWidth; -int length12; -int length34; -int length56; +int length1, length2, length3, length4, length5, length6, length7; String afstringold; String eonstringold; @@ -352,10 +350,14 @@ void readRds() { if (!radio.rds.hasLongPS) { PSSprite.fillSprite(BackgroundColor); PSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); - PSSprite.drawString(PSold.substring(0, 2), 0, 2); - PSSprite.drawString(PSold.substring(2, 4), length12, 2); - PSSprite.drawString(PSold.substring(4, 6), length34, 2); - PSSprite.drawString(PSold.substring(6, 8), length56, 2); + PSSprite.drawString(PSold.substring(0, 1), 0, 2); + PSSprite.drawString(PSold.substring(1, 2), length1, 2); + PSSprite.drawString(PSold.substring(2, 3), length2, 2); + PSSprite.drawString(PSold.substring(3, 4), length3, 2); + PSSprite.drawString(PSold.substring(4, 5), length4, 2); + PSSprite.drawString(PSold.substring(5, 6), length5, 2); + PSSprite.drawString(PSold.substring(6, 7), length6, 2); + PSSprite.drawString(PSold.substring(7, 8), length7, 2); if (advancedRDS) { PSSprite.pushSprite(36, 72); @@ -411,13 +413,17 @@ void readRds() { if (!radio.rds.hasLongPS) { PSSprite.fillSprite(BackgroundColor); PSSprite.setTextColor((ps12errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(PSold.substring(0, 2), 0, 2); + PSSprite.drawString(PSold.substring(0, 1), 0, 1); + PSSprite.drawString(PSold.substring(1, 2), length1, 2); PSSprite.setTextColor((ps34errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(PSold.substring(2, 4), length12, 2); + PSSprite.drawString(PSold.substring(2, 3), length2, 2); + PSSprite.drawString(PSold.substring(3, 4), length3, 2); PSSprite.setTextColor((ps56errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(PSold.substring(4, 6), length34, 2); + PSSprite.drawString(PSold.substring(4, 5), length4, 2); + PSSprite.drawString(PSold.substring(5, 6), length5, 2); PSSprite.setTextColor((ps78errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(PSold.substring(6, 8), length56, 2); + PSSprite.drawString(PSold.substring(6, 7), length6, 2); + PSSprite.drawString(PSold.substring(7, 8), length7, 2); if (advancedRDS) { PSSprite.pushSprite(36, 72); @@ -685,7 +691,7 @@ void showPTY() { } void showPS() { - if (radio.rds.stationName != PSold || (RDSstatus && (!radio.rds.hasLongPS && showlongps) && (ps12errorold != radio.rds.ps12error || ps34errorold != radio.rds.ps34error || ps56errorold != radio.rds.ps56error || ps78errorold != radio.rds.ps78error)) || (radio.rds.hasLongPS && showlongps)) { + if (radio.rds.stationName != PSold || (RDSstatus && (!radio.rds.hasLongPS && showlongps) && !(ps12errorold == radio.rds.ps12error || ps34errorold == radio.rds.ps34error || ps56errorold == radio.rds.ps56error || ps78errorold == radio.rds.ps78error)) || (radio.rds.hasLongPS && showlongps)) { if (afscreen) { if (!screenmute) tftReplace(0, PSold, radio.rds.stationName, 160, 201, BWAutoColor, BWAutoColorSmooth, BackgroundColor, 16); } else { @@ -723,14 +729,18 @@ void showPS() { } else { xPos5 = 0; PSSprite.fillSprite(BackgroundColor); - length12 = PSSprite.textWidth(radio.rds.stationName.substring(0, 2)); - length34 = PSSprite.textWidth(radio.rds.stationName.substring(2, 4)) + length12; - length56 = PSSprite.textWidth(radio.rds.stationName.substring(4, 6)) + length34; + length1 = PSSprite.textWidth(radio.rds.stationName.substring(0, 1)); + length2 = PSSprite.textWidth(radio.rds.stationName.substring(1, 2)) + length1; + length3 = PSSprite.textWidth(radio.rds.stationName.substring(2, 3)) + length2; + length4 = PSSprite.textWidth(radio.rds.stationName.substring(3, 4)) + length3; + length5 = PSSprite.textWidth(radio.rds.stationName.substring(4, 5)) + length4; + length6 = PSSprite.textWidth(radio.rds.stationName.substring(5, 6)) + length5; + length7 = PSSprite.textWidth(radio.rds.stationName.substring(6, 7)) + length6; - if (PSold.substring(0, 2) != radio.rds.stationName.substring(0, 2)) ps12errorold = true; - if (PSold.substring(2, 4) != radio.rds.stationName.substring(2, 4)) ps34errorold = true; - if (PSold.substring(4, 6) != radio.rds.stationName.substring(4, 6)) ps56errorold = true; - if (PSold.substring(6, 8) != radio.rds.stationName.substring(6, 8)) ps78errorold = true; + if (PSold.substring(0, 2) != radio.rds.stationName.substring(0, 2)) ps12errorold = true; + if (PSold.substring(2, 4) != radio.rds.stationName.substring(2, 4)) ps34errorold = true; + if (PSold.substring(4, 6) != radio.rds.stationName.substring(4, 6)) ps56errorold = true; + if (PSold.substring(6, 8) != radio.rds.stationName.substring(6, 8)) ps78errorold = true; if (ps12errorold && PSold.substring(0, 2) != radio.rds.stationName.substring(0, 2)) ps12errorold = radio.rds.ps12error; if (ps34errorold && PSold.substring(2, 4) != radio.rds.stationName.substring(2, 4)) ps34errorold = radio.rds.ps34error; if (ps56errorold && PSold.substring(4, 6) != radio.rds.stationName.substring(4, 6)) ps56errorold = radio.rds.ps56error; @@ -740,13 +750,17 @@ void showPS() { PSSprite.setTextColor(RDSDropoutColor, RDSDropoutColorSmooth, false); } else { PSSprite.setTextColor((ps12errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(radio.rds.stationName.substring(0, 2), 0, 2); + PSSprite.drawString(radio.rds.stationName.substring(0, 1), 0, 2); + PSSprite.drawString(radio.rds.stationName.substring(1, 2), length1, 2); PSSprite.setTextColor((ps34errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(radio.rds.stationName.substring(2, 4), length12, 2); + PSSprite.drawString(radio.rds.stationName.substring(2, 3), length2, 2); + PSSprite.drawString(radio.rds.stationName.substring(3, 4), length3, 2); PSSprite.setTextColor((ps56errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(radio.rds.stationName.substring(4, 6), length34, 2); + PSSprite.drawString(radio.rds.stationName.substring(4, 5), length4, 2); + PSSprite.drawString(radio.rds.stationName.substring(5, 6), length5, 2); PSSprite.setTextColor((ps78errorold ? RDSDropoutColor : RDSColor), (radio.rds.ps12error ? RDSDropoutColorSmooth : RDSColorSmooth), false); - PSSprite.drawString(radio.rds.stationName.substring(6, 8), length56, 2); + PSSprite.drawString(radio.rds.stationName.substring(6, 7), length6, 2); + PSSprite.drawString(radio.rds.stationName.substring(7, 8), length7, 2); } } if (!screenmute) {