AceUtils
0.2
Useful Arduino utilties which are too small for separate libraries.
|
Here are some utilities to make printing easier.
Many Arduino platforms (ESP8266, ESP32, TEENSYDUINO) implement a printf()
method on the Print
interface, which allows you to write something like:
Many other Arduino platforms (e.g. UNO or Nano) do not provide a Print.printf()
function. The printfTo()
function in this library provides a workaround.
Usage:
This will print:
An internal buffer of 192 characters is created temporarily on the stack, which limits the output to 191 characters (excluding the terminating ‘’\0' character). The internal compile-time constant
print_utils::BUF_SIZE` can be adjusted smaller or larger if necessary.
Internally, the vsnprintf()
function is used to implement the printf()
functionality, which will cause the program size to grow substantially. You will likely want to use printfTo()
only for debugging purposes.
Print unsigned integers with left padding using the least amount of code. The padding can be user-defined and defaults to a space ' ' character. This can be be a low-memory alternative to using Serial.printf()
or printfTo()
.
Usage:
This is useful for printing fixed point numbers, without having to use the float
type.
Another situation where printfTo()
is useful is printing rows of numbers in a tabular format with fixed-width columns.