Closed rei-vilo closed 8 years ago
Similarly, with a 12-bit DAC, vADC * ADC_MAXIMUM_uV
throws an overflow.
Change line 114 of S5813A.cpp for
long S5813A_Class::readVoltage(void)
{
long vADC = analogRead(this->temperature_pin);
return REV_PD(((uint32_t)vADC * ADC_MAXIMUM_uV) / ADC_COUNTS);
}
One solution is to add a scale factor, defined based on platform.
// Divide by scale to prevent overflow, then multiply to restore range return REV_PD(((vADC * (ADC_MAXIMUM_uV/SCALE)) / ADC_COUNTS)*SCALE);
Define SCALE appropriately depending on the ADC width (1 for arduino)
For Tiva:
// Tiva LaunchPads / TI TM4C123x, TM4C129x run at 3.3V
// pin A8 on Connected LP upper, A6 on Connected LP lower
// Energia does not define an analog reference name for Tiva
// ADC maximum voltage at counts
// Scale factor, to prevent overflow
I have done a port to get gratis running on the Tiva/Stellaris launchpads, which includes this fix, but looks like I didn't push it to my account yet. Will try to get it up soon.
I think this is fixed
Change lines 36 and 38 of EPD_GFX.h for
Report log