C++ platform to build Arduino and AVR projects. Rationale is size and speed optimization.
FastArduino v1.10 has been released on 16th May 2023. The implemented enhancements are listed here. Mainly this release brings generic support for display devices and concrete implementation for Nokia 5110 LCD display. More details are provided in the release notes.
FastArduino is a C++ object-oriented library for Arduino boards based on AVR MCU and also for bare AVR MCU.
FastArduino API is fully documented here and documentation also includes a complete tutorial.
FastArduino C++ code is also analyzed by SonarQube and results of this analysis are published from time to time here.
FastArduino benefits are:
From my viewpoint, the main issues with other third-party Arduino libraries are essentially heavy usage of virtual
methods, which quickly increases code size when you start to define deep classes hierarchies; this also can have a slight impact on speed due to additional indirection when calling methods. Calling virtual
methods from an ISR also has a big impact on code size as the generated code for ISR will push all registers to the stack, then call your ISR code, and finally pop all registers back from the stack; of course, this also has a dramatic impact on ISR execution speed. Avoiding virtual
methods calls from an ISR ensures the compiler generates only the strict minimum of push and pop necessary.
FastArduino tries to favour C++ templates rather than virtual methods whenever possible; in the very rare locations where virtual methods are used, their number is reduced to the minimum needed (abstract virtual methods only, typically used for event handlers, generally limited to hierarchy of 2 levels only, one abstract parent and direct children).
Also, no ISR gets automatically declared by FastArduino: every program declares the ISR it needs by using pre-defined FastArduino ISR-registration macros (note that ISR registration is the only feature for which FastArduino uses macros). FastArduino does not use virtual
methods for ISR callbacks, thus permitting optimization of ISR code size, which would not have been possible with virtual
methods as callbacks.
Note that, if you consider using FastArduino for your projects, you should be aware that FastArduino does not support Arduino API and does not intend to do so some day. That means you will have to first learn FastArduino API (you can use the complete tutorial and the numerous examples provided for that) in order to reap its benefits. FastArduino is definitely not for newcomers to C++ programming as it makes heavy use of C++ specificities. FastArduino currently uses C++17 standard.
Since the initial drafts, I decided not to be compliant with Arduino IDE as I find it is a real pain. All my projects (including FastArduino itself) are now built with Visual Studio Code along with a small extension I developed specifically for FastArduino. Once properly setup, I find VS Code environment very easy and friendly to use.
FastArduino is also buildable from the command line (on a linux system) through the standard make
. Its make system can also be used for projects using the FastArduino library.
Making FastArduino buildable on Arduino IDE is not on the roadmap.
My complete setup is described in ArduinoDevSetup.docx. This document also describes how I setup Visual Studio Code for my projects.
One easy way to start a new project using FastArduino is to checkout this project template.
Since version 1.9, FastArduino prevents usage of dynamic allocation (new
and delete
) because it is bad for AVR MCU with such limited amount of SRAM, as it may lead to heap fragmentation and ultimately program crash.
FastArduino has always encouraged static allocation only, throughout its API and implementation.
Allowing dynamic allocation would have undesirable effects on classes with virtual methods: they should also define a virtual destructor, which has an impact on generated code and data (vtable) size. Hence, we have decided to not define virtual destructors in such FastArduino classes, and prevent overall dynamic allocation to avoid virtual destructors.
Latest FastArduino release v1.10 has been published on 16.05.2023.
In the current version, the project covers almost all features; a few missing, less important, features will be released in future versions (see roadmap below); the API of current features is deemed stable and should not change in the future.
What the library has:
In addition, FastArduino brings support for the following devices:
As of now, the following platforms are supported (and tested):
I intend to probably add support some day for:
A step-by-step tutorial is available for those who want to learn FastArduino API; it covers the whole FastArduino core API. In addition to that, the FastArduino API is fully documented through doxygen.
The project is organized according to the following structure:
/
: root project directory
cores/fastarduino
: FastArduino platform C++ source code
tools
: Provide simple tools to edit fonts and bitmaps, to be used with FastArduino Display class
make
: utility makefiles and scripts to build FastArduino library, generate docs, and prepare releases
examples
: source code of basic examples of all FastArduino features, gathered by categories
.vscode
: project settings for Visual Studio Code
docs
: created by doxygen, contains all docs generated in HTML format, published here
basedoc
: other various project documentation
dox
: doxygen documentation source files and settings
tuto-samples
: source code of samples used in tutorial; samples are often present in 2 flavours, Arduino API and FastArduino, in order to compare their respective sizes
example-boards
: contains schemas (produced with LochMaster software) of stripboards that I use for FastArduino runtime tests
refs
: contains datasheets for AVR MCU and external devices supported by FastArduino
build
: created at build time, contains object files
deps
: created at build time, contains all source code dependencies
dist
: created at build time, contains FastArduino library for various targets
apidocs
: created by doxygen, contains docs generated in LATEX format
The roadmap of next activities and new supported features is the following:
Milestones dates are "best effort" and may change based on contributors' availability.
The following features are not in FastArduino roadmap currently (but may be in the future):