Some changes

This commit is contained in:
2026-02-18 18:39:50 +01:00
parent 015079b151
commit ebeb452ded
12 changed files with 641 additions and 377 deletions
+261
View File
@@ -0,0 +1,261 @@
# PC Control Interface
The PC Control Interface of the firmware allows the PC to do useful things with the radio directly.
## Invoking
Any time, ever, the PC ("Serial device") can send a "~/" on the data line, once the radio is ready for command (or already is), a response will get received: [0x01 0xFF].
That means, we can send commands to the radio now.
## Packet
Every single packet starts with its length, example: [0x02 0xAA 0x55] [0x03 0x00 0x01 0x02]
The byte after the lenght is expected to be the command, which will be defined below
### Commands
#### 0 - Set clock
This sets the I2C clock.
4 bytes after command should represent the clock to set as commanded.
##### Example
Set clock to 400 kHz
[0x05] - Length
[0x00] - Command
[0x00] - MSB Byte of clock value
[0x06]
[0x1A]
[0x80] - LSB Byte of the clock value
##### Response
[0x01] - Length
[0x00] - Response to command 0
#### 1 - Send I2C data
This command sends out the provided data to a provided address over I2C
First byte after the command should be the address, and the rest until the end of the command shall be the data itself
##### Structure
[0x03] - Length
[0x01] - Command
[X] - Device address
[X] - Address to set on the device (data)
[X] - Address contents on the device (data)
##### Response
[0x02] - Length
[0x01] - Response to command 0
[X] - Arbitrary status value which matches the value of Arduino's endTransmission function
#### 2 - Send + Receive I2C data
This command sends out the provided data to a provided address over I2C, but then sends a repeated start and requests a number of bytes which is provided by the command
First byte after the command should be the address, the following byte should be the lenght of the data to send before reading, the message that is to be send should be sent now, and the last byte should be the number of bytes to receive from the device
##### Example
[0x03] - Length
[0x02] - Command
[X] - Device address
[X] - Length of data to send
[X] - Actual data
[n] - Request two bytes from the device
##### Response
[0x02+n] - Length
[0x02] - Response to command 2
[X] - Arbitrary status value which matches the value of Arduino's endTransmission function
n*[X] - Data received from the device
#### 3 - Quit
This commands quits the control interface.
It will also reset the baud rate to 115200
##### Example
[0x01] - Length
[0x03] - Command
##### Response
[0x01] - Length
[0x03] - Response to command 3
#### 4 - Protocol version
Returns the current protocol version
##### Example
[0x01] - Length
[0x04] - Command
##### Response
[0x02] - Length
[0x04] - Response to command 4
[0x02] - Current protocol version
#### 5 - Reboot
This command will reset the ESP32
##### Example
[0x01] - Length
[0x05] - Command
##### Response
[0x01] - Length
[0x05] - Response to command 5
#### 6 - Change baud rate
This will change the baud rate. Response of this command is still in the prev baud rate.
##### Example
Set baud rate to 921600
[0x05] - Length
[0x06] - Command
[0x00] - MSB byte of baud rate
[0x0E]
[0x10]
[0x00] - LSB byte of baud rate
##### Response
[0x01] - Length
[0x06] - Response to command 6
#### 7 - Write to EEPROM
This command will write to the NVS of the ESP32
This command is only available on versions 2+
##### Example
Store 0xff at address 0x10
[0x04] - Length
[0x07] - Command
[0x00] - MSB byte of address
[0x10] - LSB byte of address
[0xff]
Store 0xffaa at address 0x5555
[0x04] - Length
[0x07] - Command
[0x55] - MSB byte of address
[0x55] - LSB byte of address
[0xff]
[0xaa]
##### Response
[0x01] - Length
[0x07] - Response to command 7
#### 8 - Read from EEPROM
This command will read from the NVS of the ESP32
This command is only available on versions 2+
##### Structure
[0x04] - Length
[0x08] - Command
[X] - MSB byte of address
[X] - LSB byte of address
[n] - Length to read
##### Response
[0x01 + n] - Length
[0x08] - Response to command 8
n*[X] - Data read from EEPROM
#### 255 - Ping / Wake
This command is only available on versions 2+
##### Structure
[0x01] - Length
[0xFF] - Command
##### Response
[0x01] - Length
[0xFF] - Response to command 255
+3 -140
View File
@@ -2,7 +2,7 @@
#include <Arduino.h>
#define VERSION "v2.20.6b"
#define VERSION "v2.20.6c"
#define ROTARY_PIN_A 34
#define ROTARY_PIN_B 36
@@ -22,18 +22,10 @@
#define RX8010SJ_ADDRESS 0x32 // Address of the RTC chip in the DP666 receivers
#define REVERSE false
#define ALEFT -1
#define ACENTER 0
#define ARIGHT 1
#define MAX(x, y) (x) < (y) ? (y) : (x)
#define MIN(X, Y) {\
typeof (X) x_ = (X);\
typeof (Y) y_ = (Y);\
(x_ < y_) ? x_ : y_; }
#define TIMER_OFFSET_TIMER 250
#define TIMER_BW_TIMER 300
#define TIMER_SNR_TIMER 30
@@ -71,15 +63,14 @@
#define SPEAKER_ICON_HEIGHT 24
// Touch thresholds
#define TOUCH_RAW_Z_THRESHOLD 250
#define TOUCH_RAW_Z_THRESHOLD 235
// Battery detection
#define BATTERY_DETECT_THRESHOLD 200
#define BATTERY_DETECT_THRESHOLD 200 // About 0.161V
// Squelch values
#define SQUELCH_MAX_VALUE 920
#define BAT_LEVEL_STAGE 8
#define BATTERY_LOW_VALUE 3.2
#define BATTERY_FULL_VALUE 4.12
@@ -264,134 +255,6 @@
#define ITEM9 190
#define ITEM10 210
// EEPROM index defines
#define EE_PRESETS_CNT 99 // When set > 99 change the complete EEPROM adressing!
#define EE_CHECKBYTE_VALUE 20 // 0 ~ 255,add new entry, change for new value
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#define EE_TOTAL_CNT 2287 // Total occupied eeprom bytes
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
#define EE_PRESET_BW_START 99 // 99 * 1 byte
#define EE_PRESET_MS_START 198 // 99 * 1 byte
#define EE_PRESETS_FREQUENCY_START 297 // 99 * 4 bytes
#define EE_PRESETS_RDSPI_START 693 // 99 * 5 bytes
#define EE_PRESETS_RDSPS_START 1188 // 99 * 9 bytes
#define EE_UINT16_FREQUENCY_FM 2079
#define EE_BYTE_VOLSET 2083
#define EE_BYTE_STEREO 2084
#define EE_BYTE_BANDFM 2085
#define EE_BYTE_BANDAM 2086
#define EE_UINT16_CONVERTERSET 2087
#define EE_UINT16_FMLOWEDGESET 2091
#define EE_UINT16_FMHIGHEDGESET 2095
#define EE_BYTE_CONTRASTSET 2099
#define EE_BYTE_STEREOLEVEL 2100
#define EE_BYTE_HIGHCUTLEVEL 2101
#define EE_BYTE_HIGHCUTOFFSET 2102
#define EE_BYTE_LEVELOFFSET 2103
#define EE_BYTE_RTBUFFER 2104
#define EE_BYTE_SORTAF 2105
#define EE_BYTE_STATIONLISTID 2106
#define EE_BYTE_EDGEBEEP 2107
#define EE_BYTE_SOFTMUTEAM 2108
#define EE_BYTE_SOFTMUTEFM 2109
#define EE_UINT16_FREQUENCY_AM 2110
#define EE_BYTE_LANGUAGE 2114
#define EE_BYTE_SHOWRDSERRORS 2115
#define EE_BYTE_TEF 2116
#define EE_BYTE_DISPLAYFLIP 2117
#define EE_BYTE_ROTARYMODE 2118
#define EE_BYTE_STEPSIZE 2119
#define EE_BYTE_TUNEMODE 2120
// empty byte
#define EE_BYTE_CHECKBYTE 2122
#define EE_BYTE_IMSSET 2123
#define EE_BYTE_EQSET 2124
#define EE_BYTE_BAND 2125
#define EE_BYTE_LOWLEVELSET 2126
#define EE_BYTE_BWSET_FM 2127
#define EE_BYTE_BWSET_AM 2128
#define EE_BYTE_BANDAUTOSW 2129
#define EE_BYTE_MEMORYPOS 2130
#define EE_BYTE_REGION 2131
#define EE_BYTE_RDS_UNDERSCORE 2132
#define EE_BYTE_USBMODE 2133
#define EE_BYTE_WIFI 2134
#define EE_BYTE_SUBNETCLIENT 2135
#define EE_BYTE_SHOWSWMIBAND 2136
#define EE_BYTE_RDS_FILTER 2137
#define EE_BYTE_RDS_PIERRORS 2138
#define EE_BYTE_USESQUELCH 2139
#define EE_BYTE_SHOWAUDIO 2140
#define EE_BYTE_AM_NB 2141
#define EE_BYTE_FM_NB 2142
#define EE_BYTE_AUDIOMODE 2143
#define EE_BYTE_TOUCH_ROTATING 2144
#define EE_BYTE_HARDWARE_MODEL 2145
#define EE_BYTE_POWEROPTIONS 2146
#define EE_BYTE_CURRENTTHEME 2147
#define EE_BYTE_FMDEFAULTSTEPSIZE 2148
#define EE_BYTE_SCREENSAVERSET 2149
#define EE_BYTE_UNIT 2150
#define EE_BYTE_AF 2151
#define EE_BYTE_BATTERY_OPTIONS 2152
#define EE_BYTE_AM_CO_DECT 2153
#define EE_BYTE_AM_CO_DECT_COUNT 2154
#define EE_BYTE_AM_RF_GAIN 2155
#define EE_BYTE_FM_DEEMPHASIS 2156
#define EE_UINT16_FREQUENCY_LW 2157
#define EE_UINT16_FREQUENCY_MW 2161
#define EE_UINT16_FREQUENCY_SW 2165
#define EE_UINT16_LOWEDGEOIRTSET 2169
#define EE_UINT16_HIGHEDGEOIRTSET 2173
#define EE_INT16_AMLEVELOFFSET 2177
#define EE_UINT16_FREQUENCY_OIRT 2181
#define EE_STRING_XDRGTK_KEY 2185 // 11 byte
#define EE_BYTE_FASTPS 2196
#define EE_BYTE_TOT 2197
#define EE_BYTE_MWREGION 2198
#define EE_BYTE_SPISPEED 2199
#define EE_BYTE_AMSCANSENS 2200
#define EE_BYTE_FMSCANSENS 2201
#define EE_BYTE_FREQFONT 2202
// Empty space, this was not used
#define EE_BYTE_XDRGTKMUTE 2204
#define EE_BYTE_FMAGC 2205
#define EE_BYTE_AMAGC 2206
#define EE_BYTE_FMSI 2207
#define EE_BYTE_SCANSTART 2208
#define EE_BYTE_SCANSTOP 2209
#define EE_BYTE_SCANHOLD 2210
#define EE_BYTE_SCANMEM 2211
#define EE_BYTE_SCANCANCEL 2212
#define EE_BYTE_SCANMUTE 2213
#define EE_BYTE_AUTOSQUELCH 2214
#define EE_BYTE_LONGBANDPRESS 2215
#define EE_BYTE_SHOWCLOCK 2216
#define EE_BYTE_SHOWLONGPS 2217
#define EE_UINT16_MEMSTARTFREQ 2218
#define EE_UINT16_MEMSTOPFREQ 2222
#define EE_BYTE_MEMSTARTPOS 2226
#define EE_BYTE_MEMSTOPPOS 2227
#define EE_BYTE_MEMPIONLY 2228
#define EE_BYTE_MEMDOUBLEPI 2229
// blank space
#define EE_BYTE_WAITONLYONSIGNAL 2253
#define EE_UINT16_CALTOUCH1 2254
#define EE_UINT16_CALTOUCH2 2258
#define EE_UINT16_CALTOUCH3 2262
#define EE_UINT16_CALTOUCH4 2266
#define EE_UINT16_CALTOUCH5 2270
#define EE_BYTE_INVERTDISPLAY 2274
#define EE_BYTE_TIMEZONE 2275
#define EE_BYTE_AUTOLOG 2276
#define EE_BYTE_AUTODST 2277
#define EE_BYTE_CLOCKAMPM 2278
#define EE_UINT16_LOGCOUNTER 2279
#define EE_UINT16_PICTLOCK 2283
// End of EEPROM index defines
// Memory channel database
typedef struct {
byte bw;
+2
View File
@@ -5,6 +5,7 @@
#include "TEF6686.h"
#include "constants.h"
#include "change_detector.h"
#include "nonvolatile.h"
#include "language.h"
#include <WiFi.h>
#include <WiFiUdp.h>
@@ -261,6 +262,7 @@ extern String XDRGTK_key;
extern Detector<String, 1> XDRGTKRDS;
extern uint16_t BW;
extern uint16_t MStatus;
extern bool modLevelForceRedraw;
extern uint16_t SWMIBandPos;
extern uint16_t SWMIBandPosold;
extern uint16_t TouchCalData[5];
+128 -2
View File
@@ -1,7 +1,133 @@
#pragma once
#include <EEPROM.h>
#include "globals.h"
#include "logbook.h"
// EEPROM index defines
#define EE_PRESETS_CNT 99 // When set > 99 change the complete EEPROM adressing!
#define EE_CHECKBYTE_VALUE 20 // 0 ~ 255,add new entry, change for new value
#define EE_PRESETS_FREQUENCY 0 // Default value when memory channel should be skipped!
#define EE_TOTAL_CNT 2287 // Total occupied eeprom bytes, we can take 20K
#define EE_PRESETS_BAND_START 0 // 99 * 1 byte
#define EE_PRESET_BW_START 99 // 99 * 1 byte
#define EE_PRESET_MS_START 198 // 99 * 1 byte
#define EE_PRESETS_FREQUENCY_START 297 // 99 * 4 bytes
#define EE_PRESETS_RDSPI_START 693 // 99 * 5 bytes
#define EE_PRESETS_RDSPS_START 1188 // 99 * 9 bytes
#define EE_UINT16_FREQUENCY_FM 2079
#define EE_BYTE_VOLSET 2083
#define EE_BYTE_STEREO 2084
#define EE_BYTE_BANDFM 2085
#define EE_BYTE_BANDAM 2086
#define EE_UINT16_CONVERTERSET 2087
#define EE_UINT16_FMLOWEDGESET 2091
#define EE_UINT16_FMHIGHEDGESET 2095
#define EE_BYTE_CONTRASTSET 2099
#define EE_BYTE_STEREOLEVEL 2100
#define EE_BYTE_HIGHCUTLEVEL 2101
#define EE_BYTE_HIGHCUTOFFSET 2102
#define EE_BYTE_LEVELOFFSET 2103
#define EE_BYTE_RTBUFFER 2104
#define EE_BYTE_SORTAF 2105
#define EE_BYTE_STATIONLISTID 2106
#define EE_BYTE_EDGEBEEP 2107
#define EE_BYTE_SOFTMUTEAM 2108
#define EE_BYTE_SOFTMUTEFM 2109
#define EE_UINT16_FREQUENCY_AM 2110
#define EE_BYTE_LANGUAGE 2114
#define EE_BYTE_SHOWRDSERRORS 2115
#define EE_BYTE_TEF 2116
#define EE_BYTE_DISPLAYFLIP 2117
#define EE_BYTE_ROTARYMODE 2118
#define EE_BYTE_STEPSIZE 2119
#define EE_BYTE_TUNEMODE 2120
// empty byte
#define EE_BYTE_CHECKBYTE 2122
#define EE_BYTE_IMSSET 2123
#define EE_BYTE_EQSET 2124
#define EE_BYTE_BAND 2125
#define EE_BYTE_LOWLEVELSET 2126
#define EE_BYTE_BWSET_FM 2127
#define EE_BYTE_BWSET_AM 2128
#define EE_BYTE_BANDAUTOSW 2129
#define EE_BYTE_MEMORYPOS 2130
#define EE_BYTE_REGION 2131
#define EE_BYTE_RDS_UNDERSCORE 2132
#define EE_BYTE_USBMODE 2133
#define EE_BYTE_WIFI 2134
#define EE_BYTE_SUBNETCLIENT 2135
#define EE_BYTE_SHOWSWMIBAND 2136
#define EE_BYTE_RDS_FILTER 2137
#define EE_BYTE_RDS_PIERRORS 2138
#define EE_BYTE_USESQUELCH 2139
#define EE_BYTE_SHOWAUDIO 2140
#define EE_BYTE_AM_NB 2141
#define EE_BYTE_FM_NB 2142
#define EE_BYTE_AUDIOMODE 2143
#define EE_BYTE_TOUCH_ROTATING 2144
#define EE_BYTE_HARDWARE_MODEL 2145
#define EE_BYTE_POWEROPTIONS 2146
#define EE_BYTE_CURRENTTHEME 2147
#define EE_BYTE_FMDEFAULTSTEPSIZE 2148
#define EE_BYTE_SCREENSAVERSET 2149
#define EE_BYTE_UNIT 2150
#define EE_BYTE_AF 2151
#define EE_BYTE_BATTERY_OPTIONS 2152
#define EE_BYTE_AM_CO_DECT 2153
#define EE_BYTE_AM_CO_DECT_COUNT 2154
#define EE_BYTE_AM_RF_GAIN 2155
#define EE_BYTE_FM_DEEMPHASIS 2156
#define EE_UINT16_FREQUENCY_LW 2157
#define EE_UINT16_FREQUENCY_MW 2161
#define EE_UINT16_FREQUENCY_SW 2165
#define EE_UINT16_LOWEDGEOIRTSET 2169
#define EE_UINT16_HIGHEDGEOIRTSET 2173
#define EE_INT16_AMLEVELOFFSET 2177
#define EE_UINT16_FREQUENCY_OIRT 2181
#define EE_STRING_XDRGTK_KEY 2185 // 11 byte
#define EE_BYTE_FASTPS 2196
#define EE_BYTE_TOT 2197
#define EE_BYTE_MWREGION 2198
#define EE_BYTE_SPISPEED 2199
#define EE_BYTE_AMSCANSENS 2200
#define EE_BYTE_FMSCANSENS 2201
#define EE_BYTE_FREQFONT 2202
// Empty space, this was not used
#define EE_BYTE_XDRGTKMUTE 2204
#define EE_BYTE_FMAGC 2205
#define EE_BYTE_AMAGC 2206
#define EE_BYTE_FMSI 2207
#define EE_BYTE_SCANSTART 2208
#define EE_BYTE_SCANSTOP 2209
#define EE_BYTE_SCANHOLD 2210
#define EE_BYTE_SCANMEM 2211
#define EE_BYTE_SCANCANCEL 2212
#define EE_BYTE_SCANMUTE 2213
#define EE_BYTE_AUTOSQUELCH 2214
#define EE_BYTE_LONGBANDPRESS 2215
#define EE_BYTE_SHOWCLOCK 2216
#define EE_BYTE_SHOWLONGPS 2217
#define EE_UINT16_MEMSTARTFREQ 2218
#define EE_UINT16_MEMSTOPFREQ 2222
#define EE_BYTE_MEMSTARTPOS 2226
#define EE_BYTE_MEMSTOPPOS 2227
#define EE_BYTE_MEMPIONLY 2228
#define EE_BYTE_MEMDOUBLEPI 2229
// blank space
#define EE_BYTE_WAITONLYONSIGNAL 2253
#define EE_UINT16_CALTOUCH1 2254
#define EE_UINT16_CALTOUCH2 2258
#define EE_UINT16_CALTOUCH3 2262
#define EE_UINT16_CALTOUCH4 2266
#define EE_UINT16_CALTOUCH5 2270
#define EE_BYTE_INVERTDISPLAY 2274
#define EE_BYTE_TIMEZONE 2275
#define EE_BYTE_AUTOLOG 2276
#define EE_BYTE_AUTODST 2277
#define EE_BYTE_CLOCKAMPM 2278
#define EE_UINT16_LOGCOUNTER 2279
#define EE_UINT16_PICTLOCK 2283
// End of EEPROM index defines
void StoreFrequency();
void ClearMemoryRange(uint8_t start, uint8_t stop);
+1 -1
View File
@@ -356,7 +356,7 @@ void TEF6686::getStatus(int16_t *level, uint16_t *USN, uint16_t *WAM, int16_t *o
void TEF6686::getStatusAM(int16_t *level, uint16_t *noise, uint16_t *cochannel, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel, int8_t *snr) {
uint8_t buf[14];
devTEF_Get_Cmd(TEF_AM, Cmd_Get_Quality_Data, buf, sizeof(buf));
devTEF_Get_Cmd(TEF_AM, Cmd_Get_Quality_Status, buf, sizeof(buf));
if(level != NULL) *level = Convert8bto16b(buf + 2);
if(noise != NULL) *noise = Convert8bto16b(buf + 4);
if(cochannel != NULL) *cochannel = Convert8bto16b(buf + 6);
+1 -1
View File
@@ -35,7 +35,7 @@ uint8_t devTEF_APPL_Get_Operation_Status() {
void devTEF_Radio_Get_Quality_Status(uint16_t *status, int16_t *level, uint16_t *usn, uint16_t *wam, int16_t *offset, uint16_t *bandwidth, uint16_t *audiolevel, int8_t *snr) {
uint8_t buf[14];
devTEF_Get_Cmd(TEF_FM, Cmd_Get_Quality_Data, buf, sizeof(buf));
devTEF_Get_Cmd(TEF_FM, Cmd_Get_Quality_Status, buf, sizeof(buf));
if(status != NULL) *status = Convert8bto16b(buf);
if(level != NULL) *level = Convert8bto16b(buf + 2);
if(usn != NULL) *usn = Convert8bto16b(buf + 4);
+3 -2
View File
@@ -15,6 +15,7 @@ using fs::FS;
#include "system_console.h"
#include "core.h"
#include "main.h"
#include "logbook.h"
Console console(&tft);
RTC_DATA_ATTR bool gpio_chip = false;
@@ -1646,7 +1647,7 @@ void KeyUp() {
case TUNE_MI_BAND:
if (showSWMIBand) {
if (displayflip) ToggleSWMIBand(true);
else ToggleSWMIBand(REVERSE);
else ToggleSWMIBand(false);
}
break;
}
@@ -1704,7 +1705,7 @@ void KeyDown() {
break;
case TUNE_MI_BAND:
if (showSWMIBand) {
if (displayflip) ToggleSWMIBand(REVERSE);
if (displayflip) ToggleSWMIBand(false);
else ToggleSWMIBand(true);
} break;
}
+1
View File
@@ -249,6 +249,7 @@ String XDRGTK_key;
Detector<String, 1> XDRGTKRDS{""};
uint16_t BW;
uint16_t MStatus;
bool modLevelForceRedraw = true;
uint16_t SWMIBandPos;
uint16_t SWMIBandPosold;
uint16_t TouchCalData[5];
+3 -2
View File
@@ -2996,6 +2996,7 @@ void BuildDisplay() {
rdsstatscreen = false;
advancedRDS = false;
BWtune = false;
modLevelForceRedraw = true;
tft.fillScreen(BackgroundColor);
tft.drawRect(0, 0, 320, 240, FrameColor);
@@ -3116,8 +3117,8 @@ void BuildDisplay() {
radio.rds.hasTMC.call();
radio.rds.hasCT.call();
radio.rds.hasRTplus.call();
MPold = 99;
USold = 99;
MPold = 100;
USold = 100;
}
void MenuUpDown(bool dir) {
+44 -35
View File
@@ -11,12 +11,15 @@
#include "FREQFONT.h"
#include "touch.h"
#include "rds.h"
#include "logbook.h"
#include "comms.h"
void Touch_IRQ_Handler() {
touch_detect = true;
}
void read_encoder() {
if(i2c_pc_control) return;
if (!digitalRead(ROTARY_PIN_A) || !digitalRead(ROTARY_PIN_B)) {
uint32_t dt = millis() - rotarytimer;
if (dt >= 45) {
@@ -182,16 +185,8 @@ void later_setup_periph() {
void setup() {
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
gpio_set_drive_capability((gpio_num_t)5, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)16, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)17, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)18, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)19, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)21, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)22, GPIO_DRIVE_CAP_0);
gpio_set_drive_capability((gpio_num_t)23, GPIO_DRIVE_CAP_0);
analogWriteFrequency(5000);
analogWriteFrequency(6700); // six seven
EEPROM.begin(EE_TOTAL_CNT);
@@ -452,8 +447,6 @@ void setup() {
console.reset();
}
#include "comms.h"
void handleWiFi() {
if (wifi && !menu) {
webserver.handleClient();
@@ -530,26 +523,39 @@ void ShowAudioLevel() {
peakholdold = constrain(peakholdold, 0, 86);
// Skip redraw when nothing changed
static int prevDisplayedSegments = -1;
static int prevPeakhold = -1;
if (!modLevelForceRedraw && DisplayedSegments == prevDisplayedSegments && peakholdold == prevPeakhold) return;
modLevelForceRedraw = false;
// Pre-computed gradient color lookup table (cached, recomputed only on theme change)
static uint16_t modGradient[87];
static uint16_t cachedInsigColor = 0;
static uint16_t cachedSigColor = 0;
static bool gradientReady = false;
if (!gradientReady || cachedInsigColor != ModBarInsignificantColor || cachedSigColor != ModBarSignificantColor) {
HSV hsv1 = RGB565toHSV(ModBarInsignificantColor);
HSV hsv2 = RGB565toHSV(ModBarSignificantColor);
int gradientStart = (86 * 25) / 100;
int gradientEnd = (86 * 60) / 100;
for (int i = 0; i < min(DisplayedSegments, gradientStart); i++) tft.fillRect(16 + 2 * i, 133, 2, 6, ModBarInsignificantColor);
if (DisplayedSegments > gradientStart) {
for (int i = gradientStart; i < min(DisplayedSegments, gradientEnd); i++) {
float h = map(i, gradientStart, gradientEnd, hsv1.h, hsv2.h);
float s = map(i, gradientStart, gradientEnd, hsv1.s * 100, hsv2.s * 100) / 100.0;
float v = map(i, gradientStart, gradientEnd, hsv1.v * 100, hsv2.v * 100) / 100.0;
tft.fillRect(16 + 2 * i, 133, 2, 6, HSVtoRGB565(h, s, v));
int gStart = (86 * 25) / 100;
int gEnd = (86 * 60) / 100;
for (int i = 0; i < 87; i++) {
if (i < gStart) modGradient[i] = ModBarInsignificantColor;
else if (i < gEnd) {
float h = map(i, gStart, gEnd, hsv1.h, hsv2.h);
float s = map(i, gStart, gEnd, hsv1.s * 100, hsv2.s * 100) / 100.0;
float v = map(i, gStart, gEnd, hsv1.v * 100, hsv2.v * 100) / 100.0;
modGradient[i] = HSVtoRGB565(h, s, v);
} else modGradient[i] = ModBarSignificantColor;
}
cachedInsigColor = ModBarInsignificantColor;
cachedSigColor = ModBarSignificantColor;
gradientReady = true;
}
if (DisplayedSegments > gradientEnd) {
for (int i = gradientEnd; i < DisplayedSegments; i++) tft.fillRect(16 + 2 * i, 133, 2, 6, ModBarSignificantColor);
}
// Draw bar segments using cached gradient colors
for (int i = 0; i < DisplayedSegments; i++) tft.fillRect(16 + 2 * i, 133, 2, 6, modGradient[i]);
int greyStart = 16 + 2 * DisplayedSegments;
int greyWidth = 2 * (87 - DisplayedSegments);
@@ -559,6 +565,9 @@ void ShowAudioLevel() {
tft.fillRect(peakHoldPosition, 133, 2, 6, (MStatus > 80) ? ModBarSignificantColor : PrimaryColor);
if (millis() - peakholdmillis >= 1000 && (peakholdold <= DisplayedSegments || peakholdold >= 86)) tft.fillRect(peakHoldPosition, 133, 2, 6, GreyoutColor);
prevDisplayedSegments = DisplayedSegments;
prevPeakhold = peakholdold;
}
}
@@ -948,7 +957,7 @@ void ShowBattery() {
else return;
float v = analogReadMilliVolts(BATTERY_PIN) * 0.002; // 0.002 converts to volts plus corrects the /2 voltage divider
byte battery = map(constrain(v, BATTERY_LOW_VALUE, BATTERY_FULL_VALUE), BATTERY_LOW_VALUE, BATTERY_FULL_VALUE, 0, BAT_LEVEL_STAGE);
byte battery = map(constrain(v, BATTERY_LOW_VALUE, BATTERY_FULL_VALUE), BATTERY_LOW_VALUE, BATTERY_FULL_VALUE, 0, 32);
byte batteryprobe = map(constrain(v, BATTERY_LOW_VALUE, BATTERY_FULL_VALUE), BATTERY_LOW_VALUE, BATTERY_FULL_VALUE, 0, 50);
if (batteryold != batteryprobe) {
if (batterydetect) {
@@ -962,7 +971,7 @@ void ShowBattery() {
if (batteryoptions != BATTERY_VALUE && batteryoptions != BATTERY_PERCENT && battery != 0) {
if(v > BATTERY_FULL_VALUE) tft.fillRoundRect(279, 8, 32, 16, 2, ActiveColor);
else tft.fillRoundRect(279, 8, battery * 8, 16, 2, SecondaryColor);
else tft.fillRoundRect(279, 8, battery, 16, 2, SecondaryColor);
} else tft.fillRoundRect(279, 8, 32, 16, 2, BackgroundColor);
}
batteryold = batteryprobe;
@@ -1359,7 +1368,7 @@ void loop() {
if (screensavertriggered) {
if (!touchrotating) {
rotary = 0;
WakeToSleep(REVERSE);
WakeToSleep(false);
} else {
if (BWtune) doBWtuneUp(); else KeyUp();
}
@@ -1378,7 +1387,7 @@ void loop() {
if (screensavertriggered) {
if (!touchrotating) {
rotary = 0;
WakeToSleep(REVERSE);
WakeToSleep(false);
} else {
if (BWtune) doBWtuneDown(); else KeyDown();
}
@@ -1395,7 +1404,7 @@ void loop() {
if (digitalRead(BANDBUTTON) == LOW) {
tottimer = millis();
if (screensavertriggered) {
WakeToSleep(REVERSE);
WakeToSleep(false);
while (digitalRead(BANDBUTTON) == LOW);
} else BANDBUTTONPress();
}
@@ -1403,7 +1412,7 @@ void loop() {
if (digitalRead(ROTARY_BUTTON) == LOW) {
tottimer = millis();
if (screensavertriggered) {
WakeToSleep(REVERSE);
WakeToSleep(false);
while (digitalRead(ROTARY_BUTTON) == LOW);
} else if (!afscreen && !rdsstatscreen) ButtonPress();
}
@@ -1411,7 +1420,7 @@ void loop() {
if (digitalRead(MODEBUTTON) == LOW) {
tottimer = millis();
if (screensavertriggered) {
WakeToSleep(REVERSE);
WakeToSleep(false);
while (digitalRead(MODEBUTTON) == LOW);
} else if(!screenmute) ModeButtonPress();
}
@@ -1419,13 +1428,13 @@ void loop() {
if (digitalRead(BWBUTTON) == LOW && !BWtune) {
tottimer = millis();
if (screensavertriggered) {
WakeToSleep(REVERSE);
WakeToSleep(false);
while (digitalRead(BWBUTTON) == LOW);
} else if(!screenmute) BWButtonPress();
}
if (digitalRead(EXT_IRQ) == LOW) {
if (screensavertriggered) WakeToSleep(REVERSE);
if (screensavertriggered) WakeToSleep(false);
int num = GetNum();
if (!screenmute && !BWtune && !menu && !advancedRDS && !rdsstatscreen && !afscreen && num != -1) NumpadProcess(num);
}
+2
View File
@@ -1,4 +1,6 @@
#include "nonvolatile.h"
#include "globals.h"
#include "logbook.h"
void StoreFrequency() {
switch (band) {
-2
View File
@@ -491,9 +491,7 @@ void showCT() {
time_t t = rtc.getEpoch();
t += Timezone * 3600; // Convert offset from hours to seconds
if (NTPupdated) {
if (autoDST && isDST(t)) t += 3600;
}
auto localtm = localtime(&t);