mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-14 06:21:41 +02:00
Handle denials of power appropriately
This commit is contained in:
@ -64,10 +64,13 @@ uint32_t LightDetection::getAverageValue(photoTransistors sensor, uint32_t measu
|
||||
};
|
||||
|
||||
void LightDetection::beginInfrared(void){
|
||||
Power::waitForCurrentAllowance(
|
||||
if(!Power::waitForCurrentAllowance(
|
||||
PowerParameters::PowerConsumers::PT_IR,
|
||||
PowerParameters::CurrentConsumptions::CURRENT_PT * 4,
|
||||
LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL);
|
||||
LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)) {
|
||||
ESP_LOGE(TAG,"Could not get power for Infrared Phototransistors");
|
||||
throw "Could not get power for Infrared Phototransistors";
|
||||
}
|
||||
digitalWrite(IR_PT_ENABLE,true);
|
||||
pinMode(IR_PT_ENABLE, OUTPUT);
|
||||
pinMode(IR_PT_FRONT_ADC, INPUT);
|
||||
@ -77,10 +80,13 @@ void LightDetection::beginInfrared(void){
|
||||
};
|
||||
|
||||
void LightDetection::beginDaylight(void){
|
||||
Power::waitForCurrentAllowance(
|
||||
if(!Power::waitForCurrentAllowance(
|
||||
PowerParameters::PowerConsumers::PT_DL,
|
||||
PowerParameters::CurrentConsumptions::CURRENT_PT * 2,
|
||||
LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL);
|
||||
LIGHT_DETECTION_MAX_EXECUTION_DELAY_MS, NULL)) {
|
||||
ESP_LOGE(TAG,"Could not get power for Daylight Phototransistors");
|
||||
throw "Could not get power for Daylight Phototransistors";
|
||||
}
|
||||
digitalWrite(DL_PT_ENABLE,true);
|
||||
pinMode(DL_PT_ENABLE, OUTPUT);
|
||||
pinMode(DL_PT_BOTTOM_ADC, INPUT);
|
||||
|
Reference in New Issue
Block a user