Hi,
I have a project that I have developed on a Nano V3, but the code and variables required have outgrown the space available on the Nano. I am looking to port the project to the Nano ESP32 (I am aware of the 5V vs 3.3V change) and everything appears to compile except the SparkFun SX1509 library which reports the following two errors:
C:\<PATH>\Arduino\libraries\SX1509_IO_Expander\src/SparkFunSX1509.h:130:70: error: macro "pinMode" passed 3 arguments, but takes just 2
void pinMode(uint8_t pin, uint8_t inOut, uint8_t initialLevel = HIGH);
C:\<PATH>\Arduino\libraries\SX1509_IO_Expander\src/SparkFunSX1509.h:156:43: error: macro "digitalRead" passed 2 arguments, but takes just 1
bool digitalRead(uint8_t pin, bool *value);
Everything compiles correctly if I set the board to be the Nano V3. I have checked in the .h and .cpp files and the number of parameters match for each function.
I have tried Googling for a solution and checking in this forum, but I can't find any resolution.
Any help would be appreciated.
It is telling you what is wrong.
# change this
pinMode(uint8_t pin, uint8_t inOut, uint8_t initialLevel = HIGH);
# to this
pinMode(uint8_t pin, uint8_t inOut);
digitalWrite(uint8_t pin, HIGH);
# and this
digitalRead(uint8_t pin, bool *value);
# to this
value = digitalRead(uint8_t pin);
Thanks for the feedback. So the code in the library needs to be different for the ESP32 version? I need this to work for both AVR and ESP versions, so would you changes work for both ESP32 and AVR or do I need to use an #if defined(ESP32) around the code?
Sorry for the follow up questions, I've never altered the libraries provided by the library manager.
If you are good at "#if defined", then yes, go for it.
I am looking at the code - SparkFun_SX1509_Arduino_Library/src/SparkFunSX1509.h at master · sparkfun/SparkFun_SX1509_Arduino_Library · GitHub
The errors are happening in the .h file, not the .cpp file, so I can't see how I can make the changes you suggest as that just appears to be the definition of the functions, not the functions themselves.
I have spent some more time on this, and if I rename the pinMode function to pinMode2 and the digitalRead to digitalRead2 in the .h and .cpp files it compiles and works, so for some reason why compiling under Nano ESP32 it seems to get confused between the native pinMode and the SX1509.pinMode definitions. Yet it compiles without issues under AVR for a Nano or Nano Every.
Anyone got any ideas what is wrong with the SparkFun_SX1509_Arduino_Library/src/SparkFunSX1509.h at master · sparkfun/SparkFun_SX1509_Arduino_Library · GitHub file that causes the confusion? I would prefer not to have to rename the functions as it will break if the library is ever updated.
My bad. I know what you are doing now. You are setting the Sparkfun board pins.
It's not just pinMode() in the example I saw. This is what I saw:
io.pinMode(uint8_t pin, uint8_t inOut, uint8_t initialLevel = HIGH);
Post your entire code if you have challenges.
The link in the post above is the code. The issue is the SX1509 library code not compiling, not mine.