diff --git a/src/lightDetection/LightDetection.cpp b/src/lightDetection/LightDetection.cpp index 8fc22fd..57bbbc4 100644 --- a/src/lightDetection/LightDetection.cpp +++ b/src/lightDetection/LightDetection.cpp @@ -1,4 +1,5 @@ #include "LightDetection.h" +#include void LightDetection::begin(void){ LightDetection::beginInfrared(); @@ -6,7 +7,6 @@ void LightDetection::begin(void){ }; uint16_t LightDetection::getValue(photoTransistors sensor){ - uint16_t result; switch(sensor){ //Fall Through intended case IR_FRONT: @@ -17,6 +17,9 @@ uint16_t LightDetection::getValue(photoTransistors sensor){ case DL_BOTTOM: case DL_FRONT: return readDLPT(sensor); + default: + //currently not reachable, just if enum will be extended in the future + return UINT16_MAX; } }; @@ -26,6 +29,7 @@ photoTransistors LightDetection::getBrightest(ptType type){ uint16_t currentReading = 0; if (type == IR){ + maxSensor = IR_FRONT; for(const auto pt : allIRPTs){ currentReading = LightDetection::getValue(pt); if (currentReading > maxReading){ @@ -34,6 +38,7 @@ photoTransistors LightDetection::getBrightest(ptType type){ } } } else { + maxSensor = DL_FRONT; for(const auto pt : allDLPTs){ currentReading = LightDetection::getValue(pt); if (currentReading > maxReading){ diff --git a/src/lightDetection/LightDetection.h b/src/lightDetection/LightDetection.h index f811515..eed93a5 100644 --- a/src/lightDetection/LightDetection.h +++ b/src/lightDetection/LightDetection.h @@ -62,7 +62,7 @@ public: * Can distingish between IR and Daylight * * @param type select which PTTransistors to compare - * @return photoTransistors which sensor is exposed to the greatest amount of light + * @return photoTransistors which sensor is exposed to the greatest amount of light, if all sensor read 0, the front sensor is returned */ static photoTransistors getBrightest(ptType type);