MW/LW/SW frequency store and AM offset

LW/MW/SW frequency now stored in memory.

Set AM leveloffset to -30dB to have a more accurate readout and working softmute.
This commit is contained in:
Sjef Verhoeven PE5PVB
2023-06-14 21:02:04 +02:00
parent 3ceb3eab99
commit 587445e609
2 changed files with 22 additions and 7 deletions

View File

@@ -168,7 +168,7 @@ TFT_eSprite sprite = TFT_eSprite(&tft);
void setup() { void setup() {
setupmode = true; setupmode = true;
EEPROM.begin(221); EEPROM.begin(234);
if (EEPROM.readByte(43) != 21) { if (EEPROM.readByte(43) != 21) {
EEPROM.writeByte(43, 21); EEPROM.writeByte(43, 21);
EEPROM.writeUInt(0, 10000); EEPROM.writeUInt(0, 10000);
@@ -202,6 +202,9 @@ void setup() {
EEPROM.writeByte(53, 0); EEPROM.writeByte(53, 0);
for (int i = 0; i < 30; i++) EEPROM.writeByte(i + 60, 0); 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); for (int i = 0; i < 30; i++) EEPROM.writeUInt((i * 4) + 100, 8750);
EEPROM.writeUInt(221, 180);
EEPROM.writeUInt(225, 540);
EEPROM.writeUInt(229, 1800);
EEPROM.commit(); EEPROM.commit();
} }
@@ -234,6 +237,9 @@ void setup() {
memorypos = EEPROM.readByte(51); memorypos = EEPROM.readByte(51);
region = EEPROM.readByte(52); region = EEPROM.readByte(52);
radio.rds.underscore = EEPROM.readByte(53); radio.rds.underscore = EEPROM.readByte(53);
frequency_LW = EEPROM.readUInt(221);
frequency_MW = EEPROM.readUInt(225);
frequency_SW = EEPROM.readUInt(229);
for (int i = 0; i < 30; i++) memoryband[i] = EEPROM.readByte(i + 60); 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); for (int i = 0; i < 30; i++) memory[i] = EEPROM.readUInt((i * 4) + 100);
@@ -409,7 +415,7 @@ void setup() {
ShowSignalLevel(); ShowSignalLevel();
ShowBW(); ShowBW();
setupmode = false; setupmode = false;
sprite.createSprite(318, 14); sprite.createSprite(317, 14);
radio.tone(50, -5, 2000); radio.tone(50, -5, 2000);
} }
@@ -542,6 +548,9 @@ void loop() {
EEPROM.writeUInt(0, frequency); EEPROM.writeUInt(0, frequency);
EEPROM.writeUInt(31, frequency_AM); EEPROM.writeUInt(31, frequency_AM);
EEPROM.writeByte(46, band); EEPROM.writeByte(46, band);
EEPROM.writeUInt(221, frequency_LW);
EEPROM.writeUInt(225, frequency_MW);
EEPROM.writeUInt(229, frequency_SW);
EEPROM.commit(); EEPROM.commit();
store = false; store = false;
attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_A), read_encoder, CHANGE); attachInterrupt(digitalPinToInterrupt(ROTARY_PIN_A), read_encoder, CHANGE);
@@ -616,6 +625,9 @@ void StoreFrequency() {
} }
void LimitAMFrequency() { void LimitAMFrequency() {
Serial.println(frequency_LW);
Serial.println(frequency_MW);
Serial.println(frequency_SW);
switch (band) { switch (band) {
case BAND_LW: case BAND_LW:
frequency_AM = frequency_LW; frequency_AM = frequency_LW;
@@ -635,8 +647,6 @@ void LimitAMFrequency() {
frequency_AM = FREQ_SW_START; frequency_AM = FREQ_SW_START;
} }
break; break;
default:
break;
} }
} }
@@ -850,8 +860,12 @@ void ButtonPress() {
if (counter - counterold < 1000) { if (counter - counterold < 1000) {
if (tunemode == 0) { if (tunemode == 0) {
stepsize++; stepsize++;
if (band == BAND_SW || band == BAND_FM) { if (stepsize > 4) stepsize = 0; } if (band == BAND_SW || band == BAND_FM) {
else { if (stepsize > 3) stepsize = 0; } if (stepsize > 4) stepsize = 0;
}
else {
if (stepsize > 3) stepsize = 0;
}
if (screenmute == false) ShowStepSize(); if (screenmute == false) ShowStepSize();

View File

@@ -11,8 +11,9 @@ static const unsigned char tuner_init_tab[] = {
7, 0x20, 0x17, 0x01, 0x00, 0x00, 0x03, 0xE8, 7, 0x20, 0x17, 0x01, 0x00, 0x00, 0x03, 0xE8,
5, 0x20, 0x20, 0x01, 0x00, 0x01, 5, 0x20, 0x20, 0x01, 0x00, 0x01,
5, 0x20, 0x1F, 0x01, 0x01, 0xF4, 5, 0x20, 0x1F, 0x01, 0x01, 0xF4,
5, 0x21, 0x27, 0x01, 0xfe, 0xd4,
9, 0x20, 0x2A, 0x01, 0x00, 0x02, 0x00, 0x96, 0x00, 0xDC, 9, 0x20, 0x2A, 0x01, 0x00, 0x02, 0x00, 0x96, 0x00, 0xDC,
9, 0x21, 0x2A, 0x01, 0x00, 0x02, 0x00, 0x96, 0x00, 0xDC, 9, 0x21, 0x2A, 0x01, 0x00, 0x02, 0x01, 0x18, 0x00, 0xFA,
7, 0x20, 0x2D, 0x01, 0x00, 0x00, 0x00, 0xC8, 7, 0x20, 0x2D, 0x01, 0x00, 0x00, 0x00, 0xC8,
11, 0x20, 0x32, 0x01, 0x00, 0x3C, 0x00, 0x78, 0x00, 0xC8, 0x00, 0xC8, 11, 0x20, 0x32, 0x01, 0x00, 0x3C, 0x00, 0x78, 0x00, 0xC8, 0x00, 0xC8,
11, 0x20, 0x33, 0x01, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x82, 0x01, 0xF4, 11, 0x20, 0x33, 0x01, 0x00, 0x00, 0x00, 0xFA, 0x00, 0x82, 0x01, 0xF4,