GY-63_MS5611/libraries/PrintSize
2022-08-03 21:56:07 +02:00
..
.github add funding.yml 2022-08-03 21:56:07 +02:00
examples 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00
test 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00
.arduino-ci.yml 0.3.1 PrintSize 2021-11-13 22:52:33 +01:00
keywords.txt 0.3.1 PrintSize 2021-11-13 22:52:33 +01:00
library.json 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00
library.properties 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00
LICENSE 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00
PrintSize.h 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00
readme.md 0.3.2 PrintSize 2021-12-24 13:42:31 +01:00

Arduino CI Arduino-lint JSON check License: MIT GitHub release

PrintSize

Arduino library to determine the length of print statements.

Description

PrintSize is a minimal library to determine the length of a variable when printed. This includes printing of floats, integers in decimal or hex notation.

Works for print(), println() and if supported printf() e.g. ESP32.

Finally since 0.2.0 it has a total counter to add up the characters "printed" since the last reset() call. (see example)

This library relates to https://github.com/RobTillaart/PrintCharArray which holds the printed data in a buffer for later processing.

Operational

Example shows the right alignment of 10 random numbers.

Example shows (elementary) line fitting.

Applications

Can be used to calculate the needed space.

  • to properly do a right alignment e.g. for numbers or variable text.
  • do left alignment and overwrite previous output with just enough spaces.
  • centring of numbers.
  • see if output will fit into a line / display.
  • see if a string fits in EEPROM or any other storage medium.
  • see if a string fits in a communication buffer.

Future

  • add examples
  • add a function to handle tab char correctly e.g. could add more than one char. Interferes with the write(str, length).