Handle denials of power appropriately

This commit is contained in:
2025-02-12 22:59:13 +01:00
parent 21f7d9ae8a
commit c130026f00
19 changed files with 126 additions and 47 deletions

View File

@@ -46,15 +46,23 @@ void InfraredLED::setState(bool state){
ledc_set_freq(pwmSpeedMode,timer,1);
if (state) {
if (this->ledPin == IR_BOTTOM_PIN) {
Power::waitForCurrentAllowance(
PowerParameters::PowerConsumers::LED_IR_BOTTOM,
PowerParameters::CurrentConsumptions::CURRENT_LED_IR_BOTTOM,
IR_LED_MAX_EXECUTION_DELAY_MS, NULL);
if (!Power::waitForCurrentAllowance(
PowerParameters::PowerConsumers::LED_IR_BOTTOM,
PowerParameters::CurrentConsumptions::CURRENT_LED_IR_BOTTOM,
IR_LED_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG,
"Could not get power for Bottom IR LED. Not turning on.");
return;
}
} else if (this->ledPin == IR_FRONT_PIN) {
Power::waitForCurrentAllowance(
PowerParameters::PowerConsumers::LED_IR_FRONT,
PowerParameters::CurrentConsumptions::CURRENT_LED_IR_FRONT,
IR_LED_MAX_EXECUTION_DELAY_MS, NULL);
if (!Power::waitForCurrentAllowance(
PowerParameters::PowerConsumers::LED_IR_FRONT,
PowerParameters::CurrentConsumptions::CURRENT_LED_IR_FRONT,
IR_LED_MAX_EXECUTION_DELAY_MS, NULL)) {
ESP_LOGE(TAG,
"Could not get power for Front IR LED. Not turning on.");
return;
}
}
ledc_set_duty(pwmSpeedMode,channel,1023);
} else {

View File

@@ -17,6 +17,7 @@
#define IR_LED_MAX_EXECUTION_DELAY_MS 1
#define TAG "InfraredLight"
class InfraredLED{
public: