Arg!! Have spent many hours on seemingly simple problem of displaying to the console. Keep running into this same problem of not being able to print any kind of formatted output to the console when trying to print a String object.
This fails compiling with a “cannot pass objects of non-trivially-copyable type ‘class String’ through ‘…’ …/wiring/inc/sparc_wiring_print.h” error.
The problem is because the parameter to printlnf is a variable argument, the compiler doesn’t know that you want a c-string as the output format of the String object.
Wish it was easier to figure out some of this stuff. Was looking at the https://docs.particle.io/reference/firmware/core/#string-class thinking there was some kind of method (i.e. toString()) that could be called off a C++ String object that would make it the correct type for the printlnf. Looks the c_str() option and the (const char *) options are doing something like that. Either way is converting to the correct type for the various overrides? .
Am going to be using this allot. Am pretty clueless to figure out what is going on with the code unless it’s loaded up with Serial.printlf. This would a topic for another thread but it sure would be nice to have a debugger.
That is a good option too. Was playing around with the Serial.print* commands but could not figure out how they can work together to produce a nicely formatted multi-variable one-line string. So thanks for finally making it make sense. It seems there are soooo many little tricks and quirks to learn when working with C++.