DwarfOS (dOS) is a lightweight "OS" designed for microcontrollers such as Arduino. It aims to minimize dependency on large libraries, providing essential functionalities tailored for resource-constrained environments. This README provides an overview of the features and components included in dOS.
DwarfOS includes its own time management module (mcu_clock.h
) for precise timekeeping. It supports real-time clock (
RTC) functionality when using a watch quartz.
Communication with external devices or host systems is facilitated through serial ports using the UART helper
module (uart_helper.h
).
The input_queue.h
contains a circular buffer that dynamically adjusts its size. This buffer facilitates a stdin
interface, enabling the utilization of standard functions such as printf
and fgets
. An illustrative example of its usage
is provided in the Dwarf-Example
repository.
Strings stored in flash memory can be lazily loaded into dynamic memory using the string repository
module (string_repository.h
).
DwarfOS provides support for generating timestamp strings in Coordinated Universal Time (UTC), Central European Time (CET), and Central European Summer Time (CEST).
A helper function is included for converting integers to ASCII strings, facilitating data conversion and output.
The puts_PF
function is a new addition to our standard input/output library as addition to avr's puts_P
. It reads a null-terminated string from the "far" program memory beyond 64kB and writes it to the standard output. This function is only available on AVR microcontrollers that support the ELPM instruction.
We've introduced a feature to generate text files in program memory. This is useful for storing large amounts of static text data, consuming only 2 bytes of RAM for each array. The convertStringsToPGMTextFile
function is used to convert an array of strings into a format that can be stored in program memory.
The flash_helper.c
file now includes functions for reading data from flash memory. These functions are particularly useful for retrieving data that has been stored in flash memory, such as the text files generated by convertStringsToPGMTextFile
. The createFileString_P
and putFileString_P
functions can load strings from these text files stored in flash memory or directly put them to stdout without RAM consumption. Using the addressOf
macro enables writing code that is independent of whether the files are in near or far program memory. The only distinction the user will notice is the volume of data that can be uploaded.
One of the notable features of dOS is its modular architecture, allowing for separate loading and unloading of modules.
Modules such as the string repository, UART helper, and time management are loaded into the heap memory, enabling flexible memory management.
This approach allows users to load only the necessary modules, conserving memory resources on the microcontroller. Additionally, it facilitates easy modification; users can utilize function pointers to redirect to custom implementations, making it possible to mock individual functions in unit tests.
The description of usage is provided in main.c
and setup.c
with an ample number of comments aimed at aiding beginners.
An additional example demonstrating how to include dOS into a project as a Git submodule, utilizing its own CMakeLists with
library build options, is provided in the Dwarf-Example
repository.
Contributions to improve or expand this library are welcome! If you find any issues or have suggestions for enhancements, feel free to open an issue or submit a pull request.
This library is licensed under the MIT License. See the LICENSE
file for details.