Handle denials of power appropriately
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#define IR_LED_MAX_EXECUTION_DELAY_MS 1
|
||||
|
||||
#define TAG "InfraredLight"
|
||||
|
||||
class InfraredLED{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user