Add memorychannels

- Added 30 memorychannels
- EEPROM database cleanup
- Lowlevelthreshold range -10 - +40
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-06-04 21:39:12 +02:00
parent 34a47744fb
commit ea410e46da
4 changed files with 249 additions and 67738 deletions

View File

@@ -33,13 +33,14 @@ bool cleanup;
bool direction; bool direction;
bool dropout; bool dropout;
bool fullsearchrds; bool fullsearchrds;
bool showrdserrors = true; bool showrdserrors;
bool LowLevelInit = false; bool LowLevelInit;
bool memorystore;
bool menu; bool menu;
bool menuopen = false; bool menuopen;
bool power = true; bool power = true;
bool RDSstatusold; bool RDSstatusold;
bool screenmute = false; bool screenmute;
bool seek; bool seek;
bool setupmode; bool setupmode;
bool SQ; bool SQ;
@@ -47,8 +48,10 @@ bool Stereostatusold;
bool StereoToggle = true; bool StereoToggle = true;
bool store; bool store;
bool tuned; bool tuned;
bool tunemode = false; byte tunemode;
bool USBstatus = false; byte memorypos;
byte memoryposold;
bool USBstatus;
bool XDRMute; bool XDRMute;
byte band; byte band;
byte BWset; byte BWset;
@@ -58,7 +61,7 @@ byte EQset;
byte freqoldcount; byte freqoldcount;
byte iMSEQ; byte iMSEQ;
byte iMSset; byte iMSset;
byte LowLevelSet; byte memoryband[30];
byte optenc; byte optenc;
byte rotarymode; byte rotarymode;
byte SNR; byte SNR;
@@ -83,6 +86,7 @@ int HighCutOffset;
int HighEdgeSet; int HighEdgeSet;
int LevelOffset; int LevelOffset;
int LowEdgeSet; int LowEdgeSet;
int LowLevelSet;
int lowsignaltimer; int lowsignaltimer;
int menuoption = 30; int menuoption = 30;
int MStatusold; int MStatusold;
@@ -129,13 +133,14 @@ uint16_t BW;
uint16_t MStatus; uint16_t MStatus;
uint16_t USN; uint16_t USN;
uint16_t WAM; uint16_t WAM;
uint8_t buff_pos = 0; uint8_t buff_pos;
uint8_t RDSstatus; uint8_t RDSstatus;
unsigned int change; unsigned int change;
unsigned int freq_scan; unsigned int freq_scan;
unsigned int frequency; unsigned int frequency;
unsigned int frequency_AM; unsigned int frequency_AM;
unsigned int frequencyold; unsigned int frequencyold;
unsigned int memory[30];
unsigned int scanner_end; unsigned int scanner_end;
unsigned int scanner_start; unsigned int scanner_start;
unsigned int scanner_step; unsigned int scanner_step;
@@ -147,10 +152,9 @@ TFT_eSprite sprite = TFT_eSprite(&tft);
void setup() { void setup() {
setupmode = true; setupmode = true;
EEPROM.begin(56); EEPROM.begin(221);
if (EEPROM.readByte(41) != 15) { if (EEPROM.readByte(43) != 16) {
EEPROM.writeByte(2, 0); EEPROM.writeByte(43, 16);
EEPROM.writeByte(3, 0);
EEPROM.writeUInt(0, 10000); EEPROM.writeUInt(0, 10000);
EEPROM.writeInt(4, 0); EEPROM.writeInt(4, 0);
EEPROM.writeInt(8, 0); EEPROM.writeInt(8, 0);
@@ -161,19 +165,24 @@ void setup() {
EEPROM.writeInt(28, 0); EEPROM.writeInt(28, 0);
EEPROM.writeInt(32, 70); EEPROM.writeInt(32, 70);
EEPROM.writeInt(36, 0); EEPROM.writeInt(36, 0);
EEPROM.writeByte(41, 15); EEPROM.writeByte(40, 0);
EEPROM.writeByte(41, 0);
EEPROM.writeByte(42, 0); EEPROM.writeByte(42, 0);
EEPROM.writeByte(43, 20);
EEPROM.writeByte(44, 1); EEPROM.writeByte(44, 1);
EEPROM.writeByte(45, 1); EEPROM.writeByte(45, 1);
EEPROM.writeByte(46, 0); EEPROM.writeByte(46, 0);
EEPROM.writeUInt(47, 828); EEPROM.writeUInt(47, 828);
EEPROM.writeByte(51, 0);
EEPROM.writeByte(52, 0); EEPROM.writeByte(52, 0);
EEPROM.writeByte(53, 0); EEPROM.writeByte(53, 0);
EEPROM.writeByte(54, 0); EEPROM.writeByte(54, 0);
EEPROM.writeByte(55, 0); EEPROM.writeInt(55, 20);
EEPROM.writeByte(59, 1);
for (int i = 0; i < 30; i++) EEPROM.writeByte(i + 60, 0);
for (int i = 0; i < 30; i++) EEPROM.writeUInt((i * 4) + 100, 8750);
EEPROM.commit(); EEPROM.commit();
} }
frequency = EEPROM.readUInt(0); frequency = EEPROM.readUInt(0);
VolSet = EEPROM.readInt(4); VolSet = EEPROM.readInt(4);
ConverterSet = EEPROM.readInt(8); ConverterSet = EEPROM.readInt(8);
@@ -184,17 +193,21 @@ void setup() {
StereoLevel = EEPROM.readInt(28); StereoLevel = EEPROM.readInt(28);
HighCutLevel = EEPROM.readInt(32); HighCutLevel = EEPROM.readInt(32);
HighCutOffset = EEPROM.readInt(36); HighCutOffset = EEPROM.readInt(36);
stepsize = EEPROM.readByte(42); stepsize = EEPROM.readByte(40);
LowLevelSet = EEPROM.readByte(43); tunemode = EEPROM.readByte(41);
optenc = EEPROM.readByte(42);
iMSset = EEPROM.readByte(44); iMSset = EEPROM.readByte(44);
EQset = EEPROM.readByte(45); EQset = EEPROM.readByte(45);
band = EEPROM.readByte(46); band = EEPROM.readByte(46);
frequency_AM = EEPROM.readUInt(47); frequency_AM = EEPROM.readUInt(47);
memorypos = EEPROM.readByte(51);
rotarymode = EEPROM.readByte(52); rotarymode = EEPROM.readByte(52);
displayflip = EEPROM.readByte(53); displayflip = EEPROM.readByte(53);
TEF = EEPROM.readByte(54); TEF = EEPROM.readByte(54);
optenc = EEPROM.readByte(55); LowLevelSet = EEPROM.readInt(55);
EEPROM.commit(); showrdserrors = EEPROM.readByte(59);
for (int i = 0; i < 30; i++) memoryband[i] = EEPROM.readByte(i + 60);
for (int i = 0; i < 30; i++) memory[i] = EEPROM.readUInt((i * 4) + 100);
btStop(); btStop();
Serial.begin(115200); Serial.begin(115200);
@@ -292,7 +305,7 @@ void setup() {
optenc = 0; optenc = 0;
tft.drawCentreString("encoder set to standard", 150, 70, 4); tft.drawCentreString("encoder set to standard", 150, 70, 4);
} }
EEPROM.writeByte(55, optenc); EEPROM.writeByte(42, optenc);
EEPROM.commit(); EEPROM.commit();
tft.drawCentreString("Please release button", 150, 100, 4); tft.drawCentreString("Please release button", 150, 100, 4);
while (digitalRead(ROTARY_BUTTON) == LOW) delay(50); while (digitalRead(ROTARY_BUTTON) == LOW) delay(50);
@@ -539,10 +552,12 @@ void PWRButtonPress() {
if (power == false) { if (power == false) {
ESP.restart(); ESP.restart();
} else { } else {
if (tunemode != 2) {
if (band == 0) band = 1; else band = 0; if (band == 0) band = 1; else band = 0;
StoreFrequency(); StoreFrequency();
SelectBand(); SelectBand();
} }
}
} else { } else {
if (power == false) { if (power == false) {
ESP.restart(); ESP.restart();
@@ -571,7 +586,7 @@ void StoreFrequency() {
void SelectBand() { void SelectBand() {
if (band == 1) { if (band == 1) {
seek = false; seek = false;
tunemode = false; if (tunemode == 1) tunemode = 0;
BWreset = true; BWreset = true;
BWset = 2; BWset = 2;
radio.SetFreqAM(frequency_AM); radio.SetFreqAM(frequency_AM);
@@ -696,7 +711,7 @@ void ModeButtonPress() {
EEPROM.writeInt(28, StereoLevel); EEPROM.writeInt(28, StereoLevel);
EEPROM.writeInt(32, HighCutLevel); EEPROM.writeInt(32, HighCutLevel);
EEPROM.writeInt(36, HighCutOffset); EEPROM.writeInt(36, HighCutOffset);
EEPROM.writeByte(43, LowLevelSet); EEPROM.writeInt(55, LowLevelSet);
EEPROM.commit(); EEPROM.commit();
} }
while (digitalRead(MODEBUTTON) == LOW) delay(50); while (digitalRead(MODEBUTTON) == LOW) delay(50);
@@ -745,19 +760,33 @@ void RoundStep() {
void ButtonPress() { void ButtonPress() {
if (menu == false) { if (menu == false) {
if (tunemode == 2) {
if (memorystore == false) {
memorystore = true;
ShowTuneMode();
} else {
memorystore = false;
EEPROM.writeByte(memorypos + 60, band);
if (band == 0) EEPROM.writeUInt((memorypos * 4) + 100, frequency); else EEPROM.writeUInt((memorypos * 4) + 100, frequency_AM);
EEPROM.commit();
memoryband[memorypos] = band;
if (band == 0) memory[memorypos] = frequency; else memory[memorypos] = frequency_AM;
ShowTuneMode();
}
} else {
seek = false; seek = false;
unsigned long counterold = millis(); unsigned long counterold = millis();
unsigned long counter = millis(); unsigned long counter = millis();
while (digitalRead(ROTARY_BUTTON) == LOW && counter - counterold <= 1000) counter = millis(); while (digitalRead(ROTARY_BUTTON) == LOW && counter - counterold <= 1000) counter = millis();
if (counter - counterold < 1000) { if (counter - counterold < 1000) {
if (tunemode == false) { if (tunemode == 0) {
stepsize++; stepsize++;
if (stepsize > 4) stepsize = 0; if (stepsize > 4) stepsize = 0;
if (screenmute == false) ShowStepSize(); if (screenmute == false) ShowStepSize();
EEPROM.writeByte(42, stepsize); EEPROM.writeByte(40, stepsize);
EEPROM.commit(); EEPROM.commit();
if (stepsize == 0) { if (stepsize == 0) {
RoundStep(); RoundStep();
@@ -799,6 +828,7 @@ void ButtonPress() {
EEPROM.writeByte(45, EQset); EEPROM.writeByte(45, EQset);
EEPROM.commit(); EEPROM.commit();
} }
}
} else { } else {
if (menuopen == false) { if (menuopen == false) {
menuopen = true; menuopen = true;
@@ -901,12 +931,25 @@ void ButtonPress() {
void KeyUp() { void KeyUp() {
rotary = 0; rotary = 0;
if (menu == false) { if (menu == false) {
if (tunemode == true) { switch (tunemode) {
case 0:
TuneUp();
break;
case 1:
direction = true; direction = true;
seek = true; seek = true;
Seek(direction); Seek(direction);
} else { break;
TuneUp();
case 2:
memorypos++;
if (memorypos > 29) memorypos = 0;
ShowMemoryPos();
if (memorystore == false) DoMemoryPosTune();
EEPROM.writeByte(51, memorypos);
EEPROM.commit();
break;
} }
if (USBstatus == true) if (band == 0) Serial.println("T" + String(frequency * 10)); else Serial.println("T" + String(frequency_AM)); if (USBstatus == true) if (band == 0) Serial.println("T" + String(frequency * 10)); else Serial.println("T" + String(frequency_AM));
radio.clearRDS(fullsearchrds); radio.clearRDS(fullsearchrds);
@@ -1018,7 +1061,7 @@ void KeyUp() {
tft.setTextColor(TFT_BLACK); tft.setTextColor(TFT_BLACK);
tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4); tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4);
LowLevelSet++; LowLevelSet++;
if (LowLevelSet > 40 || LowLevelSet <= 0) LowLevelSet = 0; if (LowLevelSet > 40) LowLevelSet = -10;
tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4); tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4);
break; break;
@@ -1040,12 +1083,25 @@ void KeyUp() {
void KeyDown() { void KeyDown() {
rotary = 0; rotary = 0;
if (menu == false) { if (menu == false) {
if (tunemode == true) { switch (tunemode) {
case 0:
TuneDown();
break;
case 1:
direction = false; direction = false;
seek = true; seek = true;
Seek(direction); Seek(direction);
} else { break;
TuneDown();
case 2:
memorypos--;
if (memorypos > 29) memorypos = 29;
ShowMemoryPos();
if (memorystore == false) DoMemoryPosTune();
EEPROM.writeByte(51, memorypos);
EEPROM.commit();
break;
} }
if (USBstatus == true) if (band == 0) Serial.println("T" + String(frequency * 10)); else Serial.println("T" + String(frequency_AM)); if (USBstatus == true) if (band == 0) Serial.println("T" + String(frequency * 10)); else Serial.println("T" + String(frequency_AM));
radio.clearRDS(fullsearchrds); radio.clearRDS(fullsearchrds);
@@ -1160,7 +1216,7 @@ void KeyDown() {
tft.setTextColor(TFT_BLACK); tft.setTextColor(TFT_BLACK);
tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4); tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4);
LowLevelSet--; LowLevelSet--;
if (LowLevelSet > 40) LowLevelSet = 40; if (LowLevelSet < -10) LowLevelSet = 40;
tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4); tft.drawRightString(String(LowLevelSet, DEC), 145, 110, 4);
break; break;
@@ -1180,6 +1236,32 @@ void KeyDown() {
} }
} }
void ShowMemoryPos() {
tft.setTextColor(TFT_BLACK);
tft.drawString(String(memoryposold + 1), 80, 30, 2);
tft.setTextColor(TFT_SKYBLUE);
tft.drawString(String(memorypos + 1), 80, 30, 2);
memoryposold = memorypos;
}
void DoMemoryPosTune() {
if (band != memoryband[memorypos]) {
band = memoryband[memorypos];
SelectBand();
} else {
band = memoryband[memorypos];
}
if (band == 0) {
frequency = memory[memorypos];
radio.SetFreq(frequency);
} else {
frequency_AM = memory[memorypos];
radio.SetFreqAM(frequency_AM);
}
ShowFreq(0);
}
void readRds() { void readRds() {
if (band == 0) { if (band == 0) {
RDSstatus = radio.readRDS(showrdserrors); RDSstatus = radio.readRDS(showrdserrors);
@@ -1423,10 +1505,11 @@ void BuildDisplay() {
RDSstatusold = false; RDSstatusold = false;
Stereostatusold = false; Stereostatusold = false;
ShowFreq(0); ShowFreq(0);
updateTuneMode(); ShowTuneMode();
updateBW(); updateBW();
ShowUSBstatus(); ShowUSBstatus();
ShowStepSize(); ShowStepSize();
ShowMemoryPos();
updateiMS(); updateiMS();
updateEQ(); updateEQ();
Squelchold = -2; Squelchold = -2;
@@ -1847,24 +1930,8 @@ void doSquelch() {
} }
} }
} }
ShowSquelch();
} }
void ShowSquelch() {
if (menu == false) {
if (SQ == false) {
tft.drawRoundRect(3, 79, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("MUTE", 24, 81, 2);
} else {
tft.drawRoundRect(3, 79, 40, 20, 5, TFT_WHITE);
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("MUTE", 24, 81, 2);
}
}
}
void updateBW() { void updateBW() {
if (BWset == 0) { if (BWset == 0) {
if (screenmute == false) { if (screenmute == false) {
@@ -2017,28 +2084,37 @@ void doBW() {
} }
void doTuneMode() { void doTuneMode() {
switch (tunemode) {
case 0:
if (band == 0) { if (band == 0) {
if (tunemode == true) tunemode = false; else tunemode = true; tunemode = 1;
updateTuneMode();
if (stepsize != 0) { if (stepsize != 0) {
stepsize = 0; stepsize = 0;
RoundStep(); RoundStep();
ShowStepSize(); ShowStepSize();
}
} else {
tunemode = 2;
}
break;
case 1:
tunemode = 2;
break;
case 2:
tunemode = 0;
break;
}
ShowTuneMode();
ShowFreq(0); ShowFreq(0);
} EEPROM.writeByte(41, tunemode);
} EEPROM.commit();
} }
void updateTuneMode() { void ShowTuneMode() {
if (tunemode == true) { switch (tunemode) {
tft.drawRoundRect(3, 57, 40, 20, 5, TFT_WHITE); case 0:
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("AUTO", 24, 59, 2);
tft.drawRoundRect(3, 35, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("MAN", 24, 37, 2);
} else {
tft.drawRoundRect(3, 57, 40, 20, 5, TFT_GREYOUT); tft.drawRoundRect(3, 57, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT); tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("AUTO", 24, 59, 2); tft.drawCentreString("AUTO", 24, 59, 2);
@@ -2046,8 +2122,47 @@ void updateTuneMode() {
tft.drawRoundRect(3, 35, 40, 20, 5, TFT_WHITE); tft.drawRoundRect(3, 35, 40, 20, 5, TFT_WHITE);
tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);
tft.drawCentreString("MAN", 24, 37, 2); tft.drawCentreString("MAN", 24, 37, 2);
tft.drawRoundRect(3, 79, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("MEM", 24, 81, 2);
break;
case 1:
tft.drawRoundRect(3, 57, 40, 20, 5, TFT_WHITE);
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("AUTO", 24, 59, 2);
tft.drawRoundRect(3, 35, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("MAN", 24, 37, 2);
tft.drawRoundRect(3, 79, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("MEM", 24, 81, 2);
break;
case 2:
tft.drawRoundRect(3, 57, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("AUTO", 24, 59, 2);
tft.drawRoundRect(3, 35, 40, 20, 5, TFT_GREYOUT);
tft.setTextColor(TFT_GREYOUT);
tft.drawCentreString("MAN", 24, 37, 2);
if (memorystore == true) {
tft.drawRoundRect(3, 79, 40, 20, 5, TFT_RED);
tft.setTextColor(TFT_RED);
} else {
tft.drawRoundRect(3, 79, 40, 20, 5, TFT_WHITE);
tft.setTextColor(TFT_WHITE);
}
tft.drawCentreString("MEM", 24, 81, 2);
break;
} }
} }
void ShowUSBstatus() { void ShowUSBstatus() {
if (USBstatus == true) tft.drawBitmap(272, 6, USBLogo, 43, 21, TFT_SKYBLUE); else tft.drawBitmap(272, 6, USBLogo, 43, 21, TFT_GREYOUT); if (USBstatus == true) tft.drawBitmap(272, 6, USBLogo, 43, 21, TFT_SKYBLUE); else tft.drawBitmap(272, 6, USBLogo, 43, 21, TFT_GREYOUT);
} }
@@ -2136,14 +2251,12 @@ void XDRGTKRoutine() {
LevelOffset = atol(buff + 1); LevelOffset = atol(buff + 1);
if (LevelOffset == 0) { if (LevelOffset == 0) {
MuteScreen(0); MuteScreen(0);
LowLevelSet = EEPROM.readByte(43); LowLevelSet = EEPROM.readInt(55);
EEPROM.commit();
Serial.print("G00\n"); Serial.print("G00\n");
} }
if (LevelOffset == 10) { if (LevelOffset == 10) {
MuteScreen(1); MuteScreen(1);
LowLevelSet = EEPROM.readByte(43); LowLevelSet = EEPROM.readInt(55);
EEPROM.commit();
Serial.print("G10\n"); Serial.print("G10\n");
} }
if (LevelOffset == 1) { if (LevelOffset == 1) {

View File

@@ -1,14 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Example OpenOCD configuration file for ESP32-S3 connected via builtin USB-JTAG adapter.
#
# For example, OpenOCD can be started for ESP32-S3 debugging on
#
# openocd -f board/esp32s3-builtin.cfg
#
# Source the JTAG interface configuration file
source [find interface/esp_usb_jtag.cfg]
# Source the ESP32-S3 configuration file
source [find target/esp32s3.cfg]

67571
debug.svd

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +0,0 @@
{
"name":"Arduino on ESP32-S3",
"toolchainPrefix":"xtensa-esp32s3-elf",
"svdFile":"debug.svd",
"request":"attach",
"overrideAttachCommands":[
"set remote hardware-watchpoint-limit 2",
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
],
"overrideRestartCommands":[
"monitor reset halt",
"monitor gdb_sync"
]
}