I have some sprintf commands that were working in the Arduino IDE, but after moving my program over to PlatformIO, they don’t seem to put anything into the char array. I am using an Adafruit ItsyBitsy M4, which is a Atmel SAMD 54.
It’s supposed to go to a TFT, but this shows the same issue - I get “Ping: (s)”
I did some searching on this forum, and I see a couple of posts about STM32 and setting a build flag, but they didn’t work, and I couldn’t see any flags for SAMD boards. The posts said that the sprintf was disabled on that architecture because of memory constraints. Is it disabled for SAMD boards too?
@maxgerhardt oops. Should be float seconds = 10.1 on one line, the sprintf on the next…. I was reusing seconds a few times in my clode and botched my example.
i found this method to be the one that works on all platforms meaning SAMD, STM, ESP, Pico. with the correct compiler flags it even works on AVR.
i like to get a String from my sprint func instead of creating a char buffer. its just easier and the code is cleaner. you can do Serial.print(s_printf(...)); in on line even if the Serial does not offer sprintf itself.
Thanks @maxgerhardt I must have not done the build_flags correctly. I think I had a different one or two that I tried, but that worked. That was very frustrating. Very glad to have that solved.