Chapter 3

API Reference

A comprehensive API reference for the CODAL C/C++ micro:bit v2 APIs.

This API reference is still a work in progress. You may find articles that are still stubs, or that have missing content. If you feel like contributing a piece of missing content to the API reference, please feel free to create a pull request in the documentation repository.

    codal-core


    Accelerometer

    CODAL’s accelerometer abstraction class. Allows for reading of the micro:bit’s built in accelerometer data, as well as the configuration of the sample rate and range.

    Button

    Represents a single hardware button. Allows for button press event tracking.

    Compass

    A compass abstraction. Reads the magnetometer to determine the orientation of the device, applying tilt compensation from data provided by the accelerometer.

    CoordinateSpace

    Representation of a coordinate space, for easy transformations in 3D space related abstractions.

    KeyValueStorage

    A simple key-value storage medium implemented with flash as the backing store. Utilises an in-memory scratch buffer.

    LEDMatrix

    A software representation of an LED matrix, also used to represent the micro:bit’s LED display.

    ManagedBuffer

    A mutable reference counted byte buffer, for general purpose use.

    ManagedString

    A copy assignable, immutable string class implemented using basic reference counting.

    MessageBus

    A lightweight message bus implementation, with asynchronous event handling using the fiber scheduler.

    MultiButton

    Represents a multi-button group, which can then be detected as a single press event.

    NVMController

    A generic interface to represent non volatile memory controllers.

    Pin

    Abstraction for a simple generic pin, with ability for handling both digital and analogue I/O.

    Sample3D

    A three dimensional vector representing sample data retrieved from a 3D abstraction.

    Timer

    A low level timer abstraction, adding integration with the CODAL message bus event system.

    TouchButton

    Represents a button triggered by capacitive touch. Can be hooked for press events.

    License & Attribution

    Licensing and attribution information for the ‘codal-core’ documentation.

    codal-microbit-v2


    MicroBit

    Represents the micro:bit v2 in its entirety. Allows for convenient access to device drivers to control the micro:bit’s various hardware elements.

    MicroBitAudio

    The audio API for micro:bit v2. Allows for multi-stream audio playback with a basic mixer, in addition to synthesiser support for small sound bytes.

    MicroBitBLEManager

    Bluetooth low energy stack manager for the micro:bit’s BLE. Must be enabled at compile to be included in CODAL builds.

    MicroBitCompassCalibrator

    A compass calibration class for CODAL’s compass abstraction on the micro:bit.

    MicroBitDisplay

    An abstraction layer over the micro:bit’s ‘display’ (LED matrix), allowing for string display and animated images.

    MicroBitI2C

    I2C protocol wrapper for the micro:bit. Allows for creating I2C channels over provided NRF52 pins.

    MicroBitIO

    Container for representations of all the micro:bit’s pins as NRF52 pin instances.

    MicroBitLog

    A simple logging API for the micro:bit, which enables generated results to be viewed easily from an external PC.

    MicroBitPowerManager

    Power management interface for the micro:bit. Holds information on power usage, as well as functions for working with deep sleep modes.

    MicroBitRadio

    A radio abstraction for the micro:bit. Contains functions for sending and receiving data over a set of radio bands, with buffering support.

    MicroBitThermometer

    A pseudo-thermometer for the micro:bit v2. Infers the ambient temperature based on the surface temperature readings of various chips on the micro:bit.

    MicroBitUSBFlashManager

    An abstraction for managing the micro:bit’s USB interface and corresponding flash.

    License & Attribution

    Licensing and attribution information for the ‘codal-microbit-v2’ documentation.

    codal-nrf52


    NRF52ADC

    A DMA-enabled analogue to digital converter abstraction, supporting the use of multiplexed DMA/ADC channels.

    NRF52FlashManager

    Interface which provides functions for reading and writing arbitrary portions of attached flash memory. Also provides page and size information.

    NRF52Pin

    Software abstraction of a single pin available to an NRF52 processor. Supports digital and analogue read/write.

    NRF52Serial

    An interface for performing serial over pins on the NRF52, integrated with the CODAL event system.

    NRF52TouchSensor

    A capacitive touch sensor watch class, driven by a low level NRF52 timer. Allows for touch capacitive pins being driven high when pressed.

    NRFLowLevelTimer

    CODAL abstraction for hardware timers available to NRF52 processors.

    License & Attribution

    Licensing and attribution information for the ‘codal-nrf52’ documentation.