Skip to content

Commit

Permalink
Update solar_radiation_sensor_task.cpp
Browse files Browse the repository at this point in the history
Fix limit check calibrated value
  • Loading branch information
digitecomg committed Oct 24, 2024
1 parent 030d255 commit c8b8c53
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ int32_t SolarRadiationSensorTask::getVrefTemp(void)
/// @param adc_value adc in value
/// @param offset offset adjust value
/// @param gain gain adjust value
/// @return ADC value calibrated
/// @return ADC value calibrated and checked with input area validation limit
float SolarRadiationSensorTask::getAdcCalibratedValue(float adc_value, float offset, float gain)
{
float value = (float)UINT16_MAX;
Expand All @@ -376,6 +376,8 @@ float SolarRadiationSensorTask::getAdcCalibratedValue(float adc_value, float off
value = adc_value;
value += offset;
value *= gain;
if(value <= ADC_MIN) value = ADC_MIN;
if(value >= ADC_MAX) value = ADC_MAX;
}

return value;
Expand Down

0 comments on commit c8b8c53

Please sign in to comment.