Coder Social home page Coder Social logo

arduino-printf's Introduction

Arduino Printf

This library adds support for the printf() function to Arduino projects. This code leverages the wonderful mpaland/printf library, which is designed for use in embedded systems. For more information about what is available, please refer to the parent library documentation.

What This Library Provides

This library provides a standalone implementation for the following functions:

  • printf()
  • sprintf() and snprintf()
  • vprintf() and vsnprintf()

Project Target

This library aims to offer a complete printf() solution while maintaining low storage and RAM requirements. This is critical for MCUs with limited storage and RAM. This project is ideal for AVR based MCUs like the Arduino Uno and it's siblings.

ESP8266 and ESP32

The Arduino implementations for the ESP8266 and ESP32 already include a printf() implementation as part of the base library. Using this library on those platforms would most likely be redundant.

Using the Library

To use this library in your Arduino project, you need to include the header:

#include <LibPrintf.h>

void setup() {
    serial.begin(115200);
}

By default, the library can be used without any special initialization. Any printf() calls will be output using the Arduino Serial interface.

Advanced Usage

See advanced_usage.md.

Disabling Specific Formats

If memory footprint is critical, floating point, exponential, and 'long long' support and can be turned off via the PRINTF_DISABLE_SUPPORT_FLOAT, PRINTF_DISABLE_SUPPORT_EXPONENTIAL and PRINTF_DISABLE_SUPPORT_LONG_LONG compiler switches. You must define these symbols in the build system.

Examples

Multiple examples are provided with this library in the examples/ folder.

  • Default Usage
    • Without any initialization, Serial will be the default output for printf()
    • This example initializes the Serial class and prints in a loop
  • Specify Print Class
    • Any class derived from the Print base class can be used with the Arduino Printf library
    • This example initializes printf with Serial1 instead of Serial
  • Override Putchar
    • This example overrides _putchar() and adds a space in between every letter
    • You can implement any kind of logic within _putchar() that you like, such as outputting information to multiple ports

arduino-printf's People

Contributors

phillipjohnston avatar scottchiefbaker avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.