Open ste2425 opened 2 years ago
Just want to add this is a super cool Lib that will save me a ton of time. I'll be using in my PSP project here: https://github.com/ste2425/PSP-Bluetooth-Controller
Thanks for making it 👍
Thank you for reporting the issue and suggesting appropriate changes. and also for your kind appreciation to my work. I'm glad you are finding it useful...
Regarding the error, I think the issue arises because I have used unsigned int at https://github.com/kulbhushanchand/MCP4251/blob/30573564483181dffe4dd87d77d44fde87c72fc2/src/MCP4251.cpp#L64
Using unsigned int makes code machine/compiler dependent, because of the bits allocated to int varies as per the micro controller (e.g. arduino uno vs due). Therefore, uint16_t is preferred, which always allocate same number of bits irrespective of the machine.
Your solution is also correct 👍
However, can you also test another future-proof solution by not making any change in MCP4251.h
and instead replacing unsigned int
by uint16_t
in the MCP4251.cpp
at https://github.com/kulbhushanchand/MCP4251/blob/30573564483181dffe4dd87d77d44fde87c72fc2/src/MCP4251.cpp#L64
After making the changes defined in #1 and trying to recompile i get the following error:
To fix it i modified line
43
inMCP4251.h
from:void DigitalPotSetWiperPosition(bool potNum, uint16_t value); // Need confirmation if it is working
to
void DigitalPotSetWiperPosition(bool potNum, unsigned int value); // Need confirmation if it is working
With that change it now compiles. I'm unable to test if it actually works just yet but figured i would report this.
This is using Arduino IDE version: 1.8.16 and targeting an Arduino Nano 33 IOT.
I will report back about it physically working or not once ive got everything hooked up.