Code cleanup

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-02-25 12:49:42 +01:00
parent 310277fb5c
commit b9de9d473c
5 changed files with 41 additions and 20 deletions
+1 -4
View File
@@ -3310,7 +3310,6 @@ void ShowSignalLevel() {
float sval = 0;
int16_t smeter = 0;
int16_t segments;
if (SStatus > 0) {
if (SStatus < 1000) {
@@ -3367,7 +3366,6 @@ void ShowSignalLevel() {
if (unit == 2) SStatusprint = round((float(SStatus) / 10.0 - 10.0 * log10(75) - 90.0) * 10.0);
static int DisplayedSignalSegments = 0;
static unsigned long SignalPreviousMillis = 0;
if (SStatusprint > (SStatusold + 3) || SStatusprint < (SStatusold - 3)) {
if (advancedRDS) {
@@ -3493,7 +3491,6 @@ void ShowOffset() {
int leftArrowBaseX = centerX - arrowWidth - arrowGap; // Shift left arrow further left
int rightArrowBaseX = centerX + arrowWidth + arrowGap; // Shift right arrow further right
int arrowHeight = height - 2; // Arrow height
int arrowBaseYTop = baseY + 1; // Adjusted top Y position
int arrowBaseYBottom = baseY + height - 1;
@@ -3583,7 +3580,7 @@ void ShowModLevel() {
int segments;
// Ensure MStatus does not exceed 120
MStatus = constrain(MStatus, 0, 120);
MStatus = (MStatus > 120) ? 120 : MStatus;
// If seeking or squelch is active, reset modulation level
if (seek || SQ) {
+4 -2
View File
@@ -1,7 +1,7 @@
#include "TEF6686.h"
#include <map>
#include <Arduino.h>
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
#include <TimeLib.h>
#include "SPIFFS.h"
#include "constants.h"
@@ -1360,7 +1360,7 @@ void TEF6686::readRDS(byte showrdserrors) {
mjd = (rds.rdsB & 0x03);
mjd <<= 15;
mjd += ((rds.rdsC >> 1) & 0x7FFF);
uint16_t hour, minute, day, month, year;
uint16_t hour, minute, day = 1, month = 1, year = 2020; // Set default values for day, month, and year
int32_t timeoffset;
long J, C, Y, M;
@@ -1383,6 +1383,7 @@ void TEF6686::readRDS(byte showrdserrors) {
if (bitRead(rds.rdsD, 5)) timeoffset *= -1;
timeoffset *= 1800;
minute = (rds.rdsD & 0x0fc0) >> 6;
if (year < 2024 || hour > 23 || minute > 59 || timeoffset > 55800 || timeoffset < -55800) break;
struct tm tm;
@@ -1394,6 +1395,7 @@ void TEF6686::readRDS(byte showrdserrors) {
tm.tm_sec = 0;
tm.tm_isdst = -1;
time_t rdstime = mktime(&tm);
if (lastrdstime == 0) {
lastrdstime = rdstime;
lasttimeoffset = timeoffset;
+9 -4
View File
@@ -12,6 +12,9 @@ extern const unsigned char tuner_init_tab4000[] PROGMEM;
extern const unsigned char tuner_init_tab12000[] PROGMEM;
extern const unsigned char tuner_init_tab55000[] PROGMEM;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
enum RDS_GROUPS {
RDS_GROUP_0A, RDS_GROUP_0B, RDS_GROUP_1A, RDS_GROUP_1B, RDS_GROUP_2A, RDS_GROUP_2B, RDS_GROUP_3A, RDS_GROUP_3B,
RDS_GROUP_4A, RDS_GROUP_4B, RDS_GROUP_5A, RDS_GROUP_5B, RDS_GROUP_6A, RDS_GROUP_6B, RDS_GROUP_7A, RDS_GROUP_7B,
@@ -19,6 +22,10 @@ enum RDS_GROUPS {
RDS_GROUP_12A, RDS_GROUP_12B, RDS_GROUP_13A, RDS_GROUP_13B, RDS_GROUP_14A, RDS_GROUP_14B, RDS_GROUP_15A, RDS_GROUP_15B
};
// Fixed PI/callsign combinations for Canada
static const uint16_t fixedPI[] = {0x4C10, 0x4C11, 0x4C12};
static const char* fixedCalls[] = {"CBLA", "CBFM", "CBOT"};
static const char* const PTY_EU[] {
"None",
"News",
@@ -91,10 +98,6 @@ static const char* const PTY_USA[] {
" "
};
// Fixed PI/callsign combinations for Canada
inline const uint16_t fixedPI[] = {0x4C10, 0x4C11, 0x4C12};
inline const char* fixedCalls[] = {"CBLA", "CBFM", "CBOT"};
static const uint16_t oda_app_ids[] {
0x0000, 0x0093, 0x0BCB, 0x0C24, 0x0CC1, 0x0D45, 0x0D8B, 0x0E2C, 0x0E31, 0x0F87,
0x125F, 0x1BDA, 0x1C5E, 0x1C68, 0x1CB1, 0x1D47, 0x1DC2, 0x1DC5, 0x1E8F, 0x4400,
@@ -564,6 +567,8 @@ const DABFrequencyLabel DABfrequencyTable[] = {
{1490624, "LW"}
};
#pragma GCC diagnostic pop
typedef struct _rds_ {
byte region;
byte stationTypeCode;
+6 -1
View File
@@ -1,3 +1,6 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#include "config.h"
#define ON 1
@@ -787,4 +790,6 @@ static const uint16_t openradiologo[] PROGMEM = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xbdf7, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffdf, 0x39c7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x42e6, 0x76ef, 0xa6cf, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x7ecf, 0x5be9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xce59, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xef5d, 0x3186, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x9492, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5367, 0x76ef, 0x9e6e, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x1962, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x31a6, 0xef7d, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xef5d, 0x4228, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xad75, 0xf7be, 0xffff, 0xffff, 0xffff, 0xffff, 0xef7d, 0x94b2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2183, 0x5be8, 0x76ef, 0x95ed, 0x9e8f, 0xa6ef, 0xa730, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0x76ef, 0xa730, 0xa6f0, 0x9e8f, 0x962e, 0x76ef, 0x76ef, 0x3aa5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0xd6ba, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xd6ba, 0x2965, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};
};
#pragma GCC diagnostic pop
+21 -9
View File
@@ -764,8 +764,8 @@ void showPS() {
void showCT() {
// Temporary string buffers for time and date formatting
char timeStr[6]; // HH:MM
char dateStr[9]; // DD-MM-YY
char timeStr[16]; // Increased buffer size to 16
char dateStr[9]; // DD-MM-YY
time_t t;
// Determine the current time source
@@ -793,15 +793,27 @@ void showCT() {
// Format the time based on region
if (clockampm) { // USA region: 12-hour AM/PM format
int hour = localtime(&t)->tm_hour;
String ampm = (hour >= 12) ? "PM" : "AM";
if (hour == 0) {
hour = 12; // Midnight case
} else if (hour > 12) {
hour -= 12; // Convert PM hours
// Ensure the hour is valid (between 1-12)
if (hour < 1 || hour > 12) {
if (hour == 0) {
hour = 12; // Midnight case
} else if (hour > 12) {
hour -= 12; // Convert PM hours
}
}
sprintf(timeStr, "%d:%02d %s", hour, localtime(&t)->tm_min, ampm.c_str());
String ampm = (localtime(&t)->tm_hour >= 12) ? "PM" : "AM";
snprintf(timeStr, sizeof(timeStr), "%d:%02d %s", hour, localtime(&t)->tm_min, ampm.c_str());
} else { // Other regions: 24-hour format
strftime(timeStr, sizeof(timeStr), "%H:%M", localtime(&t));
int hour = localtime(&t)->tm_hour;
// Ensure the hour is valid (between 0-23)
if (hour < 0 || hour > 23) {
hour = 0; // Invalid hour, reset to 0
}
snprintf(timeStr, sizeof(timeStr), "%02d:%02d", hour, localtime(&t)->tm_min);
}
// Store formatted time in rds_clock