GY-63_MS5611/libraries/PrintCharArray
2023-11-16 10:36:39 +01:00
..
.github 0.3.3 PrintCharArray + github actions 2023-02-22 12:59:02 +01:00
examples 0.3.2 PrintCharArray 2021-12-24 13:08:51 +01:00
test 0.3.2 PrintCharArray 2021-12-24 13:08:51 +01:00
.arduino-ci.yml 0.3.3 PrintCharArray 2022-11-22 15:51:21 +01:00
CHANGELOG.md 0.3.4 PrintCharArray 2023-11-16 10:36:39 +01:00
keywords.txt 0.3.1 PrintCharArray 2021-11-13 16:35:33 +01:00
library.json 0.3.4 PrintCharArray 2023-11-16 10:36:39 +01:00
library.properties 0.3.4 PrintCharArray 2023-11-16 10:36:39 +01:00
LICENSE 0.3.3 PrintCharArray + github actions 2023-02-22 12:59:02 +01:00
PrintCharArray.h 0.3.4 PrintCharArray 2023-11-16 10:36:39 +01:00
readme.md 0.3.4 PrintCharArray 2023-11-16 10:36:39 +01:00

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

PrintCharArray

Arduino library to print to a char array.

Description

PrintCharArray is a class that implements the Print interface and an internal char array. It will effectively buffer a number of print statements and allows it to be printed or processed (for real) later. The internal buffer can be set in the constructor and has a minimum of 20 bytes and a maximum of 250 bytes. Default size is 100 bytes.

Applications

  • Buffer slowly generated data, and send it with minimum time between bytes. Use it e.g. for faster printing to SD card or Ethernet which can handle larger buffers.
  • print to buffer to see how many chars the output will be.
    • use to prevent "display line overflow" (e.g. floats).
    • use to right align output (see examples).

Interface

#include "PrintCharArray.h"
  • PrintCharArray(uint8_t size = 100) constructor, default size of 100 bytes.
  • size_t write(uint8_t c) workhorse I of Print interface.
  • size_t write(uint8_t * str, uint8_t length) workhorse II of Print interface.
  • void clear() wipes the internal buffer.
  • int available() shows how much space is left in the internal buffer. Replaces free().
  • int size() current usage of the buffer.
  • int bufSize() size of the whole buffer. Recall that a char array must have a '\0' delimiter.
  • char * getBuffer() to access the buffer.

Operation

See examples.

Future

Must

  • documentation

Should

  • move code to .cpp file
  • testing

Could

  • examples
    • inject spaces in "middle align" example? possible?
    • rename some
    • add real live examples.
  • add functions like repeat(char c) to inject e.g. 7 spaces etc.
  • add error flag
  • PRINTCHARARRAY_LIB_VERSION

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,