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

@@ -1,8 +1,15 @@
#include "ColorDetection.h"
void ColorDetection::begin(void){
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::RGBW_SENSOR, PowerParameters::CurrentConsumptions::CURRENT_SENSOR_RGBW, COLOR_DETECTION_MAX_EXECUTION_DELAY_MS, NULL);
ColorDetection::configure(VEML_CONFIG{.mode = AUTO,.enabled = true,.exposureTime=MS40});
if(!Power::waitForCurrentAllowance(
PowerParameters::PowerConsumers::RGBW_SENSOR,
PowerParameters::CurrentConsumptions::CURRENT_SENSOR_RGBW,
COLOR_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)){
ESP_LOGE(TAG,"Could not get power for ColorDetection");
throw "Could not get power for ColorDetection";
}
ColorDetection::configure(
VEML_CONFIG{.mode = AUTO, .enabled = true, .exposureTime = MS40});
};
void ColorDetection::configure(VEML_CONFIG config){
uint8_t configRegister = 0;

View File

@@ -31,6 +31,7 @@
#define COLOR_DETECTION_MAX_EXECUTION_DELAY_MS 1
#define TAG "ColorDetection"
enum duration{
MS40,