gergelytakacs/AutomationShield

AutomationShield compatibitliy with DUE - ADC resolution

KuboJakub opened this issue · 2 comments

Arduino DUE has 12-bit ADC so I have changed the analog reference code. But i did not know that default resolution for DUE is 10-bit, you have to change it in the code with "analogReadResolution(bits)".
My question is, are we gonna use this advantage of DUE and every library will include this code for the case of use DUE or ZERO, or do we use default settings for 10-bit resolution of the ADC for all boards?

#elif ARDUINO_ARCH_SAMD || ARDUINO_ARCH_SAM // Chip uses 12-bit ADC

To see what I added to make 12-bit resolution in Magneto library chack the link:
#elif ARDUINO_ARCH_SAM

There is an issue that if we use 12-bit resolution for DUE, all functions for converting data from analog pins have to be defined for both boards... It means if I read analog position from a sensor and wanna convert it to percents:
data*(100/1023) for UNO
data*(100/4095) for DUE
So library have to have a rework (maybe in .h file) where all 1023 which are used e.g. in mapFloat() function, will be replaced by 4095.... I hope, you know what i mean.

Okay, I understand. However you need to be more specific what do you need to rework there for the rest of the team.

Okay, but that means nobody should hard - code the numbers 1023 or 4095, instead to use AREF.