Skip to content

Commit 3c8f74f

Browse files
authored
fix esp32 eeprom (ExpressLRS#283)
1 parent bb2ad12 commit 3c8f74f

2 files changed

Lines changed: 14 additions & 17 deletions

File tree

src/lib/EEPROM/elrs_eeprom.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
extEEPROM EEPROM(kbits_2, 1, 1, 0x51);
88
#elif defined(TARGET_R9M_RX)
99
extEEPROM EEPROM(kbits_2, 1, 1, 0x50);
10+
#elif defined(PLATFORM_ESP32)
1011
#else
1112
#define NO_EEPROM 1
1213
#endif

src/src/tx_main.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -449,23 +449,26 @@ void HandleUpdateParameter()
449449
case 1:
450450
if ((ExpressLRS_currAirRate_Modparams->index != enumRatetoIndex((expresslrs_RFrates_e)crsf.ParameterUpdateData[1])))
451451
{
452+
Serial.print("Request AirRate: ");
453+
Serial.println(crsf.ParameterUpdateData[1]);
452454
ExpressLRS_nextAirRateIndex = enumRatetoIndex((expresslrs_RFrates_e)crsf.ParameterUpdateData[1]);
455+
config.SetRate(ExpressLRS_nextAirRateIndex);
453456
}
454457
break;
455458

456459
case 2:
457460
if ((crsf.ParameterUpdateData[1] <= (uint8_t)TLM_RATIO_1_2) && (crsf.ParameterUpdateData[1] >= (uint8_t)TLM_RATIO_NO_TLM))
458461
{
459-
ExpressLRS_currAirRate_Modparams->TLMinterval = (expresslrs_tlm_ratio_e)crsf.ParameterUpdateData[1];
460-
Serial.print("TLM interval: ");
462+
Serial.print("Request TLM interval: ");
461463
Serial.println(ExpressLRS_currAirRate_Modparams->TLMinterval);
464+
config.SetTlm((expresslrs_tlm_ratio_e)crsf.ParameterUpdateData[1]);
462465
}
463466
break;
464467

465468
case 3:
466469
Serial.print("Request Power: ");
467470
Serial.println(crsf.ParameterUpdateData[1]);
468-
POWERMGNT.setPower((PowerLevels_e)crsf.ParameterUpdateData[1]);
471+
config.SetPower((PowerLevels_e)crsf.ParameterUpdateData[1]);
469472
break;
470473

471474
case 4:
@@ -504,15 +507,11 @@ void HandleUpdateParameter()
504507
break;
505508
}
506509
UpdateParamReq = false;
507-
config.SetRate(ExpressLRS_nextAirRateIndex);
508-
config.SetTlm(ExpressLRS_currAirRate_Modparams->TLMinterval);
509-
config.SetPower(POWERMGNT.currPower());
510-
510+
511511
if (config.IsModified())
512512
{
513513
// Stop the timer during eeprom writes
514514
hwTimer.stop();
515-
516515
// Set a flag that will trigger the eeprom commit in the main loop
517516
// NOTE: This is required to ensure we wait long enough for any outstanding IRQ's to fire
518517
WaitEepromCommit = true;
@@ -668,21 +667,18 @@ void loop()
668667
// If there's an outstanding eeprom write, and we've waited long enough for any IRQs to fire...
669668
if (WaitEepromCommit && (micros() - PacketLastSentMicros) > ExpressLRS_currAirRate_Modparams->interval)
670669
{
671-
if (ExpressLRS_currAirRate_Modparams->index != ExpressLRS_nextAirRateIndex)
672-
{
673-
Serial.println("Change Link rate");
674-
SetRFLinkRate(ExpressLRS_nextAirRateIndex);
675-
Serial.println(ExpressLRS_currAirRate_Modparams->enum_rate);
676-
Serial.println(ExpressLRS_currAirRate_Modparams->index);
677-
}
670+
SetRFLinkRate(config.GetRate());
671+
ExpressLRS_currAirRate_Modparams->TLMinterval = (expresslrs_tlm_ratio_e)config.GetTlm();
672+
POWERMGNT.setPower((PowerLevels_e)config.GetPower());
673+
678674
// Write the values, and restart the timer
679675
WaitEepromCommit = false;
680676
// Write the uncommitted eeprom values
681-
config.Commit();
682677
Serial.println("EEPROM COMMIT");
678+
config.Commit();
683679
// Resume the timer
684-
hwTimer.resume();
685680
sendLuaParams();
681+
hwTimer.resume();
686682
}
687683

688684
#ifdef FEATURE_OPENTX_SYNC

0 commit comments

Comments
 (0)