mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-18 22:13:45 +02:00
Fixed PR comments
This commit is contained in:
@@ -152,6 +152,15 @@ void LEDManager::displayCurrentPattern()
|
||||
|
||||
void LEDManager::updateState(const LEDStates_e newState)
|
||||
{
|
||||
// If we've got an error state - that's it, keep repeating it indefinitely
|
||||
if (ledStateMap[this->currentState].isError)
|
||||
return;
|
||||
|
||||
// Alternative (recoverable error states):
|
||||
// Allow recovery from error states by only blocking transitions when both, current and new states are error. Uncomment to enable recovery.
|
||||
// if (ledStateMap[this->currentState].isError && ledStateMap[newState].isError)
|
||||
// return;
|
||||
|
||||
// Only update when new state differs and is known.
|
||||
if (!ledStateMap.contains(newState))
|
||||
return;
|
||||
@@ -159,11 +168,6 @@ void LEDManager::updateState(const LEDStates_e newState)
|
||||
if (newState == this->currentState)
|
||||
return;
|
||||
|
||||
// Allow recovery from error states: if both current and new are error, ignore.
|
||||
// Otherwise permit transitioning out of error when a non-error state arrives.
|
||||
if (ledStateMap[this->currentState].isError && ledStateMap[newState].isError)
|
||||
return;
|
||||
|
||||
this->currentState = newState;
|
||||
this->currentPatternIndex = 0;
|
||||
this->finishedPattern = false;
|
||||
@@ -181,12 +185,6 @@ void LEDManager::setExternalLEDDutyCycle(uint8_t dutyPercent)
|
||||
const uint32_t dutyCycle = (static_cast<uint32_t>(dutyPercent) * 255) / 100;
|
||||
ESP_LOGI(LED_MANAGER_TAG, "Updating external LED duty to %u%% (raw %lu)", dutyPercent, dutyCycle);
|
||||
|
||||
// Persist into config immediately so it survives reboot
|
||||
if (this->deviceConfig)
|
||||
{
|
||||
this->deviceConfig->setLEDDUtyCycleConfig(dutyPercent);
|
||||
}
|
||||
|
||||
// Apply to LEDC hardware live
|
||||
// We configured channel 0 in setup with LEDC_LOW_SPEED_MODE
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, dutyCycle));
|
||||
|
||||
Reference in New Issue
Block a user