Moved memory channels to struct
This commit is contained in:
+29
-28
@@ -76,7 +76,7 @@ bool haseonold;
|
|||||||
bool hasrtplusold;
|
bool hasrtplusold;
|
||||||
bool hastmcold;
|
bool hastmcold;
|
||||||
bool LowLevelInit;
|
bool LowLevelInit;
|
||||||
bool memoryms[EE_PRESETS_CNT];
|
//bool memoryms[EE_PRESETS_CNT];
|
||||||
bool memorystore;
|
bool memorystore;
|
||||||
bool menu;
|
bool menu;
|
||||||
bool menuopen;
|
bool menuopen;
|
||||||
@@ -161,8 +161,8 @@ byte iMSEQ;
|
|||||||
byte iMSset;
|
byte iMSset;
|
||||||
byte language;
|
byte language;
|
||||||
byte licold;
|
byte licold;
|
||||||
byte memoryband[EE_PRESETS_CNT];
|
//byte memoryband[EE_PRESETS_CNT];
|
||||||
byte memorybw[EE_PRESETS_CNT];
|
//byte memorybw[EE_PRESETS_CNT];
|
||||||
byte memorypos;
|
byte memorypos;
|
||||||
byte memoryposold;
|
byte memoryposold;
|
||||||
byte memoryposstatus;
|
byte memoryposstatus;
|
||||||
@@ -338,7 +338,7 @@ unsigned int LWLowEdgeSet;
|
|||||||
unsigned int mappedfreqold[20];
|
unsigned int mappedfreqold[20];
|
||||||
unsigned int mappedfreqold2[20];
|
unsigned int mappedfreqold2[20];
|
||||||
unsigned int mappedfreqold3[20];
|
unsigned int mappedfreqold3[20];
|
||||||
unsigned int memory[EE_PRESETS_CNT];
|
//unsigned int memory[EE_PRESETS_CNT];
|
||||||
unsigned int MWHighEdgeSet;
|
unsigned int MWHighEdgeSet;
|
||||||
unsigned int MWLowEdgeSet;
|
unsigned int MWLowEdgeSet;
|
||||||
unsigned int scanner_end;
|
unsigned int scanner_end;
|
||||||
@@ -362,6 +362,7 @@ unsigned long tottimer;
|
|||||||
unsigned long tuningtimer;
|
unsigned long tuningtimer;
|
||||||
unsigned long udptimer;
|
unsigned long udptimer;
|
||||||
|
|
||||||
|
mem presets[EE_PRESETS_CNT];
|
||||||
TEF6686 radio;
|
TEF6686 radio;
|
||||||
ESP32Time rtc(0);
|
ESP32Time rtc(0);
|
||||||
|
|
||||||
@@ -491,10 +492,10 @@ void setup() {
|
|||||||
LowEdgeOIRTSet = LowEdgeOIRTSet;
|
LowEdgeOIRTSet = LowEdgeOIRTSet;
|
||||||
HighEdgeOIRTSet = FREQ_FM_OIRT_END;
|
HighEdgeOIRTSet = FREQ_FM_OIRT_END;
|
||||||
|
|
||||||
for (int i = 0; i < EE_PRESETS_CNT; i++) memoryband[i] = EEPROM.readByte(i + EE_PRESETS_BAND_START);
|
for (int i = 0; i < EE_PRESETS_CNT; i++) presets[i].memoryband = EEPROM.readByte(i + EE_PRESETS_BAND_START);
|
||||||
for (int i = 0; i < EE_PRESETS_CNT; i++) memory[i] = EEPROM.readUInt((i * 4) + EE_PRESETS_START);
|
for (int i = 0; i < EE_PRESETS_CNT; i++) presets[i].frequency = EEPROM.readUInt((i * 4) + EE_PRESETS_START);
|
||||||
for (int i = 0; i < EE_PRESETS_CNT; i++) memorybw[i] = EEPROM.readByte(i + EE_PRESET_BW_START);
|
for (int i = 0; i < EE_PRESETS_CNT; i++) presets[i].memorybw = EEPROM.readByte(i + EE_PRESET_BW_START);
|
||||||
for (int i = 0; i < EE_PRESETS_CNT; i++) memoryms[i] = EEPROM.readByte(i + EE_PRESET_MS_START);
|
for (int i = 0; i < EE_PRESETS_CNT; i++) presets[i].memoryms = EEPROM.readByte(i + EE_PRESET_MS_START);
|
||||||
|
|
||||||
btStop();
|
btStop();
|
||||||
|
|
||||||
@@ -1344,7 +1345,7 @@ void BANDBUTTONPress() {
|
|||||||
if (memorystore) {
|
if (memorystore) {
|
||||||
EEPROM.writeUInt((memorypos * 4) + EE_PRESETS_START, EE_PRESETS_FREQUENCY);
|
EEPROM.writeUInt((memorypos * 4) + EE_PRESETS_START, EE_PRESETS_FREQUENCY);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
memory[memorypos] = EE_PRESETS_FREQUENCY;
|
presets[memorypos].frequency = EE_PRESETS_FREQUENCY;
|
||||||
memorystore = false;
|
memorystore = false;
|
||||||
ShowTuneMode();
|
ShowTuneMode();
|
||||||
if (memoryposstatus == MEM_DARK || memoryposstatus == MEM_EXIST) {
|
if (memoryposstatus == MEM_DARK || memoryposstatus == MEM_EXIST) {
|
||||||
@@ -2231,19 +2232,19 @@ void ButtonPress() {
|
|||||||
EEPROM.writeUInt((memorypos * 4) + EE_PRESETS_START, frequency_SW);
|
EEPROM.writeUInt((memorypos * 4) + EE_PRESETS_START, frequency_SW);
|
||||||
}
|
}
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
memoryband[memorypos] = band;
|
presets[memorypos].memoryband = band;
|
||||||
memorybw[memorypos] = BWset;
|
presets[memorypos].memorybw = BWset;
|
||||||
memoryms[memorypos] = StereoToggle;
|
presets[memorypos].memoryms = StereoToggle;
|
||||||
if (band == BAND_FM) {
|
if (band == BAND_FM) {
|
||||||
memory[memorypos] = frequency;
|
presets[memorypos].frequency = frequency;
|
||||||
} else if (band == BAND_OIRT) {
|
} else if (band == BAND_OIRT) {
|
||||||
memory[memorypos] = frequency_OIRT;
|
presets[memorypos].frequency = frequency_OIRT;
|
||||||
} else if (band == BAND_LW) {
|
} else if (band == BAND_LW) {
|
||||||
memory[memorypos] = frequency_LW;
|
presets[memorypos].frequency = frequency_LW;
|
||||||
} else if (band == BAND_MW) {
|
} else if (band == BAND_MW) {
|
||||||
memory[memorypos] = frequency_MW;
|
presets[memorypos].frequency = frequency_MW;
|
||||||
} else {
|
} else {
|
||||||
memory[memorypos] = frequency_SW;
|
presets[memorypos].frequency = frequency_SW;
|
||||||
}
|
}
|
||||||
ShowTuneMode();
|
ShowTuneMode();
|
||||||
if (memoryposstatus == MEM_DARK || memoryposstatus == MEM_EXIST) {
|
if (memoryposstatus == MEM_DARK || memoryposstatus == MEM_EXIST) {
|
||||||
@@ -2466,7 +2467,7 @@ void KeyDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsStationEmpty() {
|
bool IsStationEmpty() {
|
||||||
if (memoryband[memorypos] == BAND_FM && memory[memorypos] == EE_PRESETS_FREQUENCY) {
|
if (presets[memorypos].memoryband == BAND_FM && presets[memorypos].frequency == EE_PRESETS_FREQUENCY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -2516,33 +2517,33 @@ void DoMemoryPosTune() {
|
|||||||
memoryposstatus = MEM_NORMAL;
|
memoryposstatus = MEM_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (band != memoryband[memorypos]) {
|
if (band != presets[memorypos].memoryband) {
|
||||||
band = memoryband[memorypos];
|
band = presets[memorypos].memoryband;
|
||||||
SelectBand();
|
SelectBand();
|
||||||
} else {
|
} else {
|
||||||
band = memoryband[memorypos];
|
band = presets[memorypos].memoryband;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (band == BAND_FM) {
|
if (band == BAND_FM) {
|
||||||
frequency = memory[memorypos];
|
frequency = presets[memorypos].frequency;
|
||||||
radio.SetFreq(frequency);
|
radio.SetFreq(frequency);
|
||||||
} else if (band == BAND_OIRT) {
|
} else if (band == BAND_OIRT) {
|
||||||
frequency_OIRT = memory[memorypos];
|
frequency_OIRT = presets[memorypos].frequency;
|
||||||
radio.SetFreq(frequency_OIRT);
|
radio.SetFreq(frequency_OIRT);
|
||||||
} else if (band == BAND_LW) {
|
} else if (band == BAND_LW) {
|
||||||
frequency_LW = memory[memorypos];
|
frequency_LW = presets[memorypos].frequency;
|
||||||
radio.SetFreqAM(frequency_LW);
|
radio.SetFreqAM(frequency_LW);
|
||||||
} else if (band == BAND_MW) {
|
} else if (band == BAND_MW) {
|
||||||
frequency_MW = memory[memorypos];
|
frequency_MW = presets[memorypos].frequency;
|
||||||
radio.SetFreqAM(frequency_MW);
|
radio.SetFreqAM(frequency_MW);
|
||||||
} else if (band == BAND_SW) {
|
} else if (band == BAND_SW) {
|
||||||
frequency_SW = memory[memorypos];
|
frequency_SW = presets[memorypos].frequency;
|
||||||
radio.SetFreqAM(frequency_SW);
|
radio.SetFreqAM(frequency_SW);
|
||||||
}
|
}
|
||||||
ShowFreq(0);
|
ShowFreq(0);
|
||||||
|
|
||||||
if (band == BAND_FM || band == BAND_OIRT) {
|
if (band == BAND_FM || band == BAND_OIRT) {
|
||||||
StereoToggle = memoryms[memorypos];
|
StereoToggle = presets[memorypos].memoryms;
|
||||||
if (!StereoToggle) {
|
if (!StereoToggle) {
|
||||||
Stereostatusold = false;
|
Stereostatusold = false;
|
||||||
if (CurrentSkin == 1 && !advancedRDS && !afscreen) {
|
if (CurrentSkin == 1 && !advancedRDS && !afscreen) {
|
||||||
@@ -2570,7 +2571,7 @@ void DoMemoryPosTune() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BWset = memorybw[memorypos];
|
BWset = presets[memorypos].memorybw;
|
||||||
doBW();
|
doBW();
|
||||||
BWtune = true;
|
BWtune = true;
|
||||||
|
|
||||||
|
|||||||
+10
-8
@@ -3,6 +3,8 @@
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|
||||||
|
extern mem presets[];
|
||||||
|
|
||||||
void Communication() {
|
void Communication() {
|
||||||
if (!menu) {
|
if (!menu) {
|
||||||
if (wifi) {
|
if (wifi) {
|
||||||
@@ -173,12 +175,12 @@ void Communication() {
|
|||||||
for (byte x = 0; x < EE_PRESETS_CNT; x++) {
|
for (byte x = 0; x < EE_PRESETS_CNT; x++) {
|
||||||
Serial.print(x + 1);
|
Serial.print(x + 1);
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
Serial.print(memory[x]);
|
Serial.print(presets[x].frequency);
|
||||||
if (memoryband[x] == BAND_FM || memoryband[x] == BAND_OIRT) Serial.print("0");
|
if (presets[x].memoryband == BAND_FM || presets[x].memoryband == BAND_OIRT) Serial.print("0");
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
Serial.print(memorybw[x]);
|
Serial.print(presets[x].memorybw);
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
Serial.print(memoryms[x]);
|
Serial.print(presets[x].memoryms);
|
||||||
Serial.print("\n");
|
Serial.print("\n");
|
||||||
}
|
}
|
||||||
} else if (data_str.startsWith("S")) {
|
} else if (data_str.startsWith("S")) {
|
||||||
@@ -241,10 +243,10 @@ void Communication() {
|
|||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
error |= (1 << 7);
|
error |= (1 << 7);
|
||||||
memorypos = mempos;
|
memorypos = mempos;
|
||||||
memoryband[mempos] = memband;
|
presets[mempos].memoryband = memband;
|
||||||
memory[mempos] = memfreq;
|
presets[mempos].frequency = memfreq;
|
||||||
memorybw[mempos] = membw;
|
presets[mempos].memorybw = membw;
|
||||||
memoryms[mempos] = memms;
|
presets[mempos].memoryms = memms;
|
||||||
|
|
||||||
EEPROM.writeByte(mempos + EE_PRESETS_BAND_START, memband);
|
EEPROM.writeByte(mempos + EE_PRESETS_BAND_START, memband);
|
||||||
EEPROM.writeByte(mempos + EE_PRESET_BW_START, membw);
|
EEPROM.writeByte(mempos + EE_PRESET_BW_START, membw);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ extern bool BWreset;
|
|||||||
extern bool direction;
|
extern bool direction;
|
||||||
extern bool externaltune;
|
extern bool externaltune;
|
||||||
extern bool fullsearchrds;
|
extern bool fullsearchrds;
|
||||||
extern bool memoryms[];
|
|
||||||
extern bool menu;
|
extern bool menu;
|
||||||
extern bool RDSSPYTCP;
|
extern bool RDSSPYTCP;
|
||||||
extern bool RDSSPYUSB;
|
extern bool RDSSPYUSB;
|
||||||
@@ -44,8 +43,6 @@ extern byte EQset;
|
|||||||
extern byte iMSEQ;
|
extern byte iMSEQ;
|
||||||
extern byte iMSset;
|
extern byte iMSset;
|
||||||
extern byte language;
|
extern byte language;
|
||||||
extern byte memoryband[];
|
|
||||||
extern byte memorybw[];
|
|
||||||
extern byte memorypos;
|
extern byte memorypos;
|
||||||
extern byte subnetclient;
|
extern byte subnetclient;
|
||||||
extern char buff[16];
|
extern char buff[16];
|
||||||
@@ -99,7 +96,6 @@ extern unsigned int frequency_SW;
|
|||||||
extern unsigned int frequencyold;
|
extern unsigned int frequencyold;
|
||||||
extern unsigned int LWHighEdgeSet;
|
extern unsigned int LWHighEdgeSet;
|
||||||
extern unsigned int LWLowEdgeSet;
|
extern unsigned int LWLowEdgeSet;
|
||||||
extern unsigned int memory[];
|
|
||||||
extern unsigned int MWHighEdgeSet;
|
extern unsigned int MWHighEdgeSet;
|
||||||
extern unsigned int MWLowEdgeSet;
|
extern unsigned int MWLowEdgeSet;
|
||||||
extern unsigned int scanner_end;
|
extern unsigned int scanner_end;
|
||||||
|
|||||||
@@ -295,6 +295,16 @@ static const char* const FreqFont[] = {"Classic", "Roubenstil", "Motoya", "Aura2
|
|||||||
static const char* const Theme[] = {"Essence", "Cyan", "Crimson", "Monochrome", "Volcano", "Dendro", "Sakura", "Whiteout", "Tangerine", "Ocean", "Indigo", "Maroon", "GoldBrite"};
|
static const char* const Theme[] = {"Essence", "Cyan", "Crimson", "Monochrome", "Volcano", "Dendro", "Sakura", "Whiteout", "Tangerine", "Ocean", "Indigo", "Maroon", "GoldBrite"};
|
||||||
static const char* const Skin[] = {"Essential", "NightSky"};
|
static const char* const Skin[] = {"Essential", "NightSky"};
|
||||||
|
|
||||||
|
// Memory channel database
|
||||||
|
typedef struct {
|
||||||
|
byte memorybw;
|
||||||
|
byte memoryband;
|
||||||
|
bool memoryms;
|
||||||
|
unsigned int frequency;
|
||||||
|
char RDSPI[5];
|
||||||
|
char RDSPS[9];
|
||||||
|
} mem;
|
||||||
|
|
||||||
// FM band: before BAND_GAP; AM band: after BAND_GAP
|
// FM band: before BAND_GAP; AM band: after BAND_GAP
|
||||||
enum RADIO_BAND {
|
enum RADIO_BAND {
|
||||||
BAND_OIRT = 0, BAND_FM, BAND_GAP, BAND_LW, BAND_MW, BAND_SW
|
BAND_OIRT = 0, BAND_FM, BAND_GAP, BAND_LW, BAND_MW, BAND_SW
|
||||||
|
|||||||
Reference in New Issue
Block a user