All Projects → embeddedartistry → arduino-printf

embeddedartistry / arduino-printf

Licence: MIT license
Add printf support to the Arduino SDK

Programming Languages

c
50402 projects - #5 most used programming language
Makefile
30231 projects
groovy
2714 projects
Meson
512 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to arduino-printf

cakephp-error-email
ErrorEmail Plugin for CakePHP3.x
Stars: ✭ 16 (-75%)
Mutual labels:  debugging
hs-probe-firmware
A CMSIS-DAP implementation in pure Rust.
Stars: ✭ 68 (+6.25%)
Mutual labels:  debugging
stf
Control and manage Android devices from your browser.
Stars: ✭ 1,814 (+2734.38%)
Mutual labels:  debugging
ember-template-inspector
An ember add-on which opens the template file in the code editor while inspecting an element.
Stars: ✭ 15 (-76.56%)
Mutual labels:  debugging
ghc-stack
Hacking GHC's Stack for Fun and Profit (featuring The Glorious Haskell Debugger v0.0.1 Pre-alpha)
Stars: ✭ 69 (+7.81%)
Mutual labels:  debugging
krumo
Krumo: Structured information display solution for PHP
Stars: ✭ 74 (+15.63%)
Mutual labels:  debugging
compile-time-printer
Prints values and types during compilation!
Stars: ✭ 45 (-29.69%)
Mutual labels:  printf
bugsnag-vue
[DEPRECATED] This package now lives within the monorepo for our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 26 (-59.37%)
Mutual labels:  debugging
DbgPkg
Scripts to prepare Windows system for debugging.
Stars: ✭ 30 (-53.12%)
Mutual labels:  debugging
expo-community-flipper
Flipper Support for Expo Apps in React Native
Stars: ✭ 82 (+28.13%)
Mutual labels:  debugging
netlogs
Web extension for debugging your API
Stars: ✭ 16 (-75%)
Mutual labels:  debugging
coc-java-debug
An extension for coc.nvim to enable Java debugging via jdt.ls
Stars: ✭ 92 (+43.75%)
Mutual labels:  debugging
debug-plotter
Rust crate that provides a convenient macro to quickly plot variables.
Stars: ✭ 82 (+28.13%)
Mutual labels:  debugging
SQLCallStackResolver
Utility to resolve SQL Server callstacks to their correct symbolic form using just PDBs and without a dump file
Stars: ✭ 55 (-14.06%)
Mutual labels:  debugging
debug
A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers
Stars: ✭ 10,554 (+16390.63%)
Mutual labels:  debugging
printfTester
Tester for the ft_printf project of 42 school
Stars: ✭ 94 (+46.88%)
Mutual labels:  printf
EVM-Simulator
EVM-Simulator bachelor's thesis.
Stars: ✭ 36 (-43.75%)
Mutual labels:  debugging
emacs-inspector
Inspection tool for Emacs Lisp objects.
Stars: ✭ 71 (+10.94%)
Mutual labels:  debugging
bugsnag-java
Bugsnag error reporting for Java.
Stars: ✭ 51 (-20.31%)
Mutual labels:  debugging
vue-ray
Debug your Vue 2 & 3 code with Ray to fix problems faster
Stars: ✭ 48 (-25%)
Mutual labels:  debugging

Arduino Printf

This library adds support for the printf() function to Arduino projects. This code leverages the embeddedartistry/printf library (a fork of eyalroz/printf, 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. You do not need this library for those platforms.

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. If you need to use a different interface, call printf_init.

If you only want to use s[n]printf, then you do not need to initialize the library.

Advanced Usage

See advanced_usage.md.

Configuration

If memory footprint is critical, you can disable library features using compiler definitions. Available controls are:

  • PRINTF_DISABLE_ALL
    • Remove all printf calls from the program
  • PRINTF_NTOA_BUFFER_SIZE (unsigned integer)
    • 'ntoa' conversion buffer size, this must be big enough to hold one converted numeric number including padded zeros (dynamically created on stack)
    • Default: 32 bytes
  • PRINTF_FTOA_BUFFER_SIZE (unsigned integer)
    • 'ftoa' conversion buffer size, this must be big enough to hold one converted float number including padded zeros (dynamically created on stack)
    • Default: 32 bytes
  • PRINTF_DISABLE_SUPPORT_FLOAT
    • support for the floating point type (%f)
  • PRINTF_DISABLE_SUPPORT_EXPONENTIAL
    • support for exponential floating point notation (%e/%g)
    • Default: active
  • PRINTF_DEFAULT_FLOAT_PRECISION (unsigned integer)
  • PRINTF_MAX_FLOAT (float value)
    • define the largest float suitable to print with %f
    • Default: active
    • 1e9
  • PRINTF_DISABLE_SUPPORT_LONG_LONG
    • support for the long long types (%llu or %p)
    • Default: active
  • PRINTF_DISABLE_SUPPORT_PTRDIFF_T
    • support for the ptrdiff_t type (%t)
    • Default: active

For AVR chips, the library will automatically set PRINTF_DISABLE_SUPPORT_EXPONENTIAL and PRINTF_DISABLE_SUPPORT_LONG_LONG. You can re-enable these settings by defining PRINTF_PREVENT_DEFAULT_AVR_SETTINGS.

Because these settings control behavior in the source file, they cannot be defined in the sketch. You must adjust the compilation commands for your project in order for the changes to take effect.

If you're using a Makefile or other build system, you'd use the -D flag (e.g., -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL) to the library build target. For Arduino IDE, the flags need to be added to the compiler.extra_flags property in platform.txt or platform.local.txt. You would need to restart the IDE for the changes to take effect.

Here are comparisons for a simple test sketch showing the overall sketch size for different configurations:

Type Bytes
No Serial 1606
All options enabled 9476
Disable long long and exponential 6328
Disable long long, float, and exponential 4256

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].