Skip to content

App function reference

Every function your app can call, on one page. Guide links lead to explanations; a dash means there is no guide yet.

Start with the first-app guide.

Reading the signatures

A signature gives the return type, function name, and each parameter type and name. void means no value is returned. A default such as durationMs = 0 can be left out of a call. The smaller Example line shows concrete values; copy that call rather than the signature.

Type or symbol Meaning
uint8_t Whole number from 0 to 255.
int16_t Whole number from -32,768 to 32,767.
uint16_t Whole number from 0 to 65,535.
int32_t, int, long Signed whole number; on the device, -2,147,483,648 to 2,147,483,647.
uint32_t, unsigned long Whole number from 0 to 4,294,967,295 on the device; used for elapsed time.
float Number that can include a fractional part, such as 0.5f; about seven significant digits.
bool Either true or false.
const char*, String Text: a pointer to characters ending with a zero character, or a text object.
const The value cannot be changed through this declaration. After a method signature, the method does not change its object.
& In a parameter type, a reference to an existing object, rather than a copy; before a value, its address.
*, nullptr A pointer holds an address; * in a declaration marks a pointer, and before a pointer reads the object it points to. nullptr means no object.
T A type chosen from your arguments; use matching types, such as three long values for constrain().

These calls are available on both the device and the app emulator. The screen is 128 x 64 pixels with (0, 0) at the top-left; x goes right and y goes down. LEDs are RGBW (red, green, blue, white), with each channel from 0-255.

The calls are written the way they look inside begin(), update() and end() of the studio starter, where display (the screen) and buttonManager (the buttons) are ready to use. In your own functions at the top of the file, write HAL::displayProxy() and HAL::buttonManager() instead.

Examples use your own void onRight(const ButtonEvent& event) callback (a function called when a button changes), sprite image, sheet, animation, and player objects. A button event has buttonIndex, eventType, and duration in ms. Register callbacks in begin() and unregister them in end().

Quick answers

Screen

Call What it does Learn more
DisplayProxy& HAL::displayProxy()
Example: HAL::displayProxy()
The 128 x 64 screen, for code outside your app's functions. Inside begin(), update() and end(), the starter already calls it display. Guide
void display.clear()
Example: display.clear();
Erase the drawing buffer before drawing a frame. Guide
void display.display()
Example: display.display();
Show the drawing buffer on screen. Guide
void display.setColor(OLEDDISPLAY_COLOR color)
Example: display.setColor(WHITE);
Choose white, black, or inverted pixels for drawing. Guide
void display.setPixel(int16_t x, int16_t y)
Example: display.setPixel(64, 32);
Draw one pixel at x, y. Guide
void display.drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1)
Example: display.drawLine(0, 0, 40, 20);
Draw a line between two pixel positions. Guide
void display.drawRect(int16_t x, int16_t y, int16_t w, int16_t h)
Example: display.drawRect(0, 0, 30, 20);
Draw a rectangle outline; width and height are pixels. Guide
void display.fillRect(int16_t x, int16_t y, int16_t w, int16_t h)
Example: display.fillRect(0, 0, 30, 20);
Draw a solid rectangle; width and height are pixels. Guide
void display.drawCircle(int16_t x, int16_t y, int16_t r)
Example: display.drawCircle(64, 32, 10);
Draw a circle outline; radius is pixels. Guide
void display.fillCircle(int16_t x, int16_t y, int16_t r)
Example: display.fillCircle(64, 32, 10);
Draw a solid circle; radius is pixels. Guide
void display.drawHorizontalLine(int16_t x, int16_t y, int16_t len)
Example: display.drawHorizontalLine(0, 0, 20);
Draw a horizontal line of the given pixel length. Guide
void display.drawVerticalLine(int16_t x, int16_t y, int16_t len)
Example: display.drawVerticalLine(0, 0, 20);
Draw a vertical line of the given pixel length. Guide
void display.drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
Example: display.drawTriangle(0, 0, 20, 0, 10, 20);
Join three pixel positions with an outline. Guide
void display.fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
Example: display.fillTriangle(0, 0, 20, 0, 10, 20);
Fill the triangle between three pixel positions. Guide
void display.drawXbm(int16_t x, int16_t y, int16_t w, int16_t h, const unsigned char* data)
Example: display.drawXbm(0, 0, 8, 8, bitmap);
Draw a 1-bit bitmap: one on/off bit per pixel, lowest bit first in each byte. Guide
void display.drawProgressBar(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t progress)
Example: display.drawProgressBar(0, 0, 60, 8, 50);
Draw a progress bar; final argument is 0-100 %. Guide
void HAL::clearDisplay()
Example: HAL::clearDisplay();
Erase the screen drawing buffer. Guide
void HAL::updateDisplay()
Example: HAL::updateDisplay();
Show the drawing buffer on screen. Guide

Text

Call What it does Learn more
uint16_t display.drawString(int16_t x, int16_t y, const String& text)
Example: display.drawString(0, 0, "Hi");
Draw text using the current font and alignment. Studio apps return 0 on the device and in the browser emulator. Guide
uint16_t display.drawStringMaxWidth(int16_t x, int16_t y, uint16_t maxLineWidth, const String& text)
Example: display.drawStringMaxWidth(0, 0, 80, "Hi");
Draw one unwrapped line in studio apps, on the device and in the browser emulator; the width argument is ignored. Guide
uint16_t display.getStringWidth(const String& text)
uint16_t display.getStringWidth(const char* text, uint16_t length, bool = false)
Example: display.getStringWidth("Hi");
Measure text width in pixels; also accepts text and length. Guide
void display.setFont(const uint8_t* fontData)
Example: display.setFont(ArialMT_Plain_16);
Select a 10, 16, or 24 pixel font handle. Guide
void display.setTextAlignment(OLEDDISPLAY_TEXT_ALIGNMENT alignment)
Example: display.setTextAlignment(TEXT_ALIGN_LEFT);
Place text left, right, or centered on x; CENTER_BOTH also centers on y. Guide
void HAL::drawString(int16_t x, int16_t y, const String& text)
Example: HAL::drawString(0, 0, "Hi");
Draw text at x, y with the current font and alignment. Guide

Buttons

Call What it does Learn more
ButtonManager& HAL::buttonManager()
Example: HAL::buttonManager()
The buttons, for code outside your app's functions. Inside begin(), update() and end(), the starter already calls it buttonManager. Guide
void buttonManager.registerCallback(int buttonIndex, ButtonCallback callback)
Example: buttonManager.registerCallback(button_RightIndex, onRight);
Call onRight for press, release, and hold events; replaces that button's callback. Guide
void buttonManager.unregisterCallback(int buttonIndex)
Example: buttonManager.unregisterCallback(button_RightIndex);
Remove the button callback when leaving the app. Guide
bool buttonManager.isPressed(int buttonIndex) const
Example: buttonManager.isPressed(button_RightIndex);
Read whether the button is down right now. Guide
bool buttonManager.hasCallback(int buttonIndex) const
Example: buttonManager.hasCallback(button_RightIndex);
Check whether a button has a registered callback. Guide
ButtonCallback buttonManager.getCallback(int buttonIndex) const
Example: buttonManager.getCallback(button_RightIndex);
Read the registered callback, or nullptr if none. Guide

LEDs

Pixel map: 0 Back, 1 Front Top, 2 Front Middle, 3 Front Bottom.

Call What it does Learn more
void HAL::setRgbLed(int index, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
Example: HAL::setRgbLed(pixel_Front_Middle, 0, 0, 255, 0);
Set one RGBW LED; red, green, blue, white channels each use 0-255. Guide
void HAL::setRgbLedsOff()
Example: HAL::setRgbLedsOff();
Turn all four RGBW LEDs off. Guide
void setColorsOff()
Example: setColorsOff();
Turn all four LEDs off; call in begin() and end(). Guide
void setDeterminedColorsFront(uint8_t r, uint8_t g, uint8_t b, uint8_t w)
Example: setDeterminedColorsFront(0, 0, 255, 0);
Set the three front LEDs; RGBW channels each use 0-255. Guide
void setDeterminedColorsAll(uint8_t r, uint8_t g, uint8_t b, uint8_t w)
Example: setDeterminedColorsAll(0, 0, 255, 0);
Set all four LEDs; RGBW channels each use 0-255. Guide
void setRandomColors()
Example: setRandomColors();
Give the three front LEDs random red/green/blue channels from 0-9, with white off; back LED is unchanged. Guide
void mapToRainbow(int input, uint8_t dim, uint8_t &red, uint8_t &green, uint8_t &blue)
Example: mapToRainbow(1024, 64, r, g, b);
Convert hue 0-4095 to red, green, blue output variables; dim scales brightness from 0-255. Guide

Sound

Call What it does Learn more
AudioManager& HAL::audioManager()
Example: AudioManager& audio = HAL::audioManager();
Get the sound manager for tones, notes, and microphone readings. Guide
void HAL::audioManager().playTone(float frequency, int durationMs = 0)
Example: HAL::audioManager().playTone(880, 100);
Play a tone at 880 Hz for 100 ms; duration 0 plays until stopped. Guide
void HAL::audioManager().stopTone()
Example: HAL::audioManager().stopTone();
Stop the tone; call when leaving an app that uses tones. Guide
int HAL::audioManager().playNote(float frequency, int durationMs = 0)
Example: HAL::audioManager().playNote(440, 100);
Play a note alongside others (a chord); duration 0 holds it until stopNote(). Returns a handle, or -1 if the note could not start. Guide
void HAL::audioManager().stopNote(int handle)
Example: HAL::audioManager().stopNote(handle);
Stop the note identified by the handle returned from playNote(). Guide
void HAL::audioManager().stopNotes()
Example: HAL::audioManager().stopNotes();
Stop all additional notes. Guide
void HAL::audioManager().playSequence(const ToneStep* steps, int count)
Example: HAL::audioManager().playSequence(steps, count);
Play up to 64 copied ToneStep entries in studio apps, on the device and in the browser emulator: freq in Hz (0 is rest), durationMs and gapAfterMs in ms. Guide
void HAL::audioManager().stopSequence()
Example: HAL::audioManager().stopSequence();
Stop the tone sequence. Guide
bool HAL::audioManager().isSequencePlaying() const
Example: HAL::audioManager().isSequencePlaying();
Always false in studio apps, on the device and in the browser emulator. Time your app logic with millis() instead. Guide
void HAL::audioManager().setVolume(float)
Example: HAL::audioManager().setVolume(0.5f);
Does nothing in studio apps, on the device and in the browser emulator. Use the emulator controls for browser volume. Guide
void HAL::audioManager().enableMic(bool on)
Example: HAL::audioManager().enableMic(true);
Enable device microphone readings; false disables them; emulator has no microphone. Guide
float HAL::audioManager().getMicVolumeLinear() const
Example: HAL::audioManager().getMicVolumeLinear();
Read microphone level 0.0-1.0; emulator stays at 0.0 (silent). Guide
float HAL::audioManager().getMicVolumeDb() const
Example: HAL::audioManager().getMicVolumeDb();
Read microphone dBFS; 0 is full scale, quieter is negative; emulator returns -60. Guide

Slider

Call What it does Learn more
float sliderPosition_12Bits_Filtered
Example: sliderPosition_12Bits_Filtered
Slider 0-4095. Smoothed on device. Guide
float sliderPosition_12Bits_Inverted_Filtered
Example: sliderPosition_12Bits_Inverted_Filtered
Slider 0-4095. Direction reversed. Emulator leaves this at 0. Guide
int sliderPosition_8Bits_Filtered
Example: sliderPosition_8Bits_Filtered
Slider 0-255. Smoothed on device. Guide
int sliderPosition_8Bits_Inverted_Filtered
Example: sliderPosition_8Bits_Inverted_Filtered
Slider 0-255. Direction reversed. Guide
float sliderPosition_Percentage_Filtered
Example: sliderPosition_Percentage_Filtered
Slider 0-100 %. Smoothed on device. Guide
float sliderPosition_Percentage_Inverted_Filtered
Example: sliderPosition_Percentage_Inverted_Filtered
Slider 0-100 %. Direction reversed. Guide

Motion

Call What it does Learn more
float accelX
Example: accelX
X acceleration, roughly 1000 units per g (gravity); emulator uses supplied tilt. Guide
float accelY
Example: accelY
Y acceleration, roughly 1000 units per g (gravity); emulator uses supplied tilt. Guide
float accelZ
Example: accelZ
Z acceleration, roughly 1000 units per g (gravity); emulator uses supplied tilt. Guide
float tempC
Example: tempC
Temperature placeholder in degrees Celsius; both app targets leave it at 0. Guide

Time and math

Call What it does Learn more
unsigned long millis()
Example: unsigned long now = millis();
Read elapsed time in ms; use unsigned subtraction to time actions across clock wraparound. Guide
unsigned long micros()
Example: unsigned long nowUs = micros();
Read elapsed microseconds; both targets have only 1000-microsecond resolution. Guide
void delay(unsigned long)
Example: delay(10);
Does nothing on the device or in the app emulator - use millis() timing. Guide
void delayMicroseconds(unsigned int)
Example: delayMicroseconds(100);
Does nothing on the device or in the app emulator - use millis() timing. Guide
long random(long maxExclusive)
long random(long minInclusive, long maxExclusive)
Example: int roll = random(1, 7);
Choose an integer from the first bound inclusive to the second exclusive; one argument starts at 0. Guide
void randomSeed(unsigned long)
Example: randomSeed(42);
Does nothing in studio apps, on the device and in the browser emulator. Guide
long map(long x, long in_min, long in_max, long out_min, long out_max)
Example: long brightness = map(value, 0, 100, 0, 255);
Rescale an integer range; does not clamp values outside the range. Guide
template <typename T> T constrain(T x, T lo, T hi)
Example: long bounded = constrain(value, 0L, 100L);
Clamp a value between inclusive bounds; use long integers on both targets. Guide
template <typename T> T min(T a, T b)
Example: int smaller = min(a, b);
Choose the smaller of two values of the same type. Guide
template <typename T> T max(T a, T b)
Example: int larger = max(a, b);
Choose the larger of two values of the same type. Guide
float radians(float deg)
Example: float angle = radians(90.0f);
Convert degrees to radians (one full turn is about 6.283 radians). Guide
float degrees(float rad)
Example: float angle = degrees(1.0f);
Convert radians to degrees (360 degrees is one full turn). Guide
unsigned long millis_NOW
Example: millis_NOW
The time in ms when this frame started; read it instead of calling millis() repeatedly. Guide

Sprites and animation

Studio apps already have cf_gfx.h and their generated project art available. You do not need to add those #include lines. Add using namespace cf::gfx; at the top of the file, below the #include lines, to use these short names.

When building an app into the firmware by hand, add #include "cf_gfx.h" and your generated asset header (if your project has art) at the top of the file. Then put using namespace cf::gfx; below the #include lines.

Examples use Actor player, AnimationPlayer clock, MeshActor model, and RigActor figure. A pivot is the point on a sprite placed at its screen position.

Call What it does Learn more
void drawSprite(DisplayProxy& d, const Sprite& s, int16_t x, int16_t y)
Example: drawSprite(display, sprite, 0, 0);
Draw a sprite with its top-left at x, y; ignores its pivot. Guide
void drawSpritePivoted(DisplayProxy& d, const Sprite& s, int16_t x, int16_t y)
Example: drawSpritePivoted(display, sprite, 64, 32);
Draw a sprite with its pivot at x, y. Guide
const Animation* findAnimation(const SpriteSheet& sheet, const char* name)
Example: findAnimation(sheet, "run");
Find a named animation in a sheet; returns nullptr if missing. Guide
bool sampleSprite(const Sprite& s, int16_t x, int16_t y)
Example: sampleSprite(sprite, 0, 0);
Read one on/off pixel in sprite-local coordinates; outside is false. Guide
bool pixelCollides(const Sprite& a, int16_t ax, int16_t ay, const Sprite& b, int16_t bx, int16_t by)
bool pixelCollides(const Actor& a, const Actor& b)
Example: pixelCollides(player, enemy);
Check overlapping lit pixels; Actor form applies pivots, Sprite form takes top-left positions. Guide
Actor()
Example: Actor player;
Create an actor with a position and an animation player. Guide
void player.setSheet(const SpriteSheet* sheet)
Example: player.setSheet(&sheet);
Bind a sprite sheet for looking up animations by name. Guide
const SpriteSheet* player.sheet() const
Example: player.sheet();
Read the bound sheet pointer, or nullptr if none. Guide
bool player.play(const char* animName, uint32_t nowMs)
bool player.play(const Animation* anim, uint32_t nowMs)
Example: player.play("run", millis());
Play by name or animation pointer; same animation keeps running; false if missing. Guide
bool player.update(uint32_t nowMs)
Example: player.update(millis());
Advance animation using time in ms; true if the visible sprite changed. Guide
void player.draw(DisplayProxy& d) const
Example: player.draw(display);
Draw the current sprite with its pivot at the actor's position. Guide
void player.setPos(int16_t x, int16_t y)
Example: player.setPos(64, 32);
Place the actor's pivot at x, y in screen pixels. Guide
void player.setPosQ8(int32_t xQ8, int32_t yQ8)
Example: player.setPosQ8(64 * 256, 32 * 256);
Place the pivot in fractional pixels; 256 units equal one pixel. Guide
int16_t player.x() const
Example: player.x();
Read horizontal position in pixels, rounded down. Guide
int16_t player.y() const
Example: player.y();
Read vertical position in pixels, rounded down. Guide
int32_t player.xQ8() const
Example: player.xQ8();
Read horizontal position in units of 1/256 pixel. Guide
int32_t player.yQ8() const
Example: player.yQ8();
Read vertical position in units of 1/256 pixel. Guide
const Sprite* player.sprite() const
Example: player.sprite();
Read the current sprite pointer; nullptr means nothing to draw. Guide
const Animation* player.animation() const
Example: player.animation();
Read the selected animation pointer, or nullptr if none. Guide
bool player.finished() const
Example: player.finished();
Check whether playback has finished or stopped. Guide
AnimationPlayer()
Example: AnimationPlayer clock;
Create an animation clock without a screen position. Guide
void clock.play(const Animation* anim, uint32_t nowMs)
Example: clock.play(&animation, millis());
Start or restart at frame 0 using time in ms; nullptr stops. Guide
void clock.setIfChanged(const Animation* anim, uint32_t nowMs)
Example: clock.setIfChanged(&animation, millis());
Start only if the animation pointer differs; safe every update. Guide
bool clock.update(uint32_t nowMs)
Example: clock.update(millis());
Advance by elapsed ms; true if the sprite changed; 0 ms frames hold indefinitely. Guide
void clock.stop()
Example: clock.stop();
Clear playback; sprite and animation pointers become nullptr. Guide
const Sprite* clock.sprite() const
Example: clock.sprite();
Read the current sprite pointer; nullptr means nothing to draw. Guide
const Animation* clock.animation() const
Example: clock.animation();
Read the selected animation pointer, including after it finishes. Guide
uint8_t clock.frameIndex() const
Example: clock.frameIndex();
Read the current frame number, starting at 0. Guide
bool clock.finished() const
Example: clock.finished();
Check whether playback has finished or stopped. Guide
MeshActor()
Example: MeshActor model;
Create a wireframe model actor with default depth 48 and scale 256. Guide
void model.setMesh(const Mesh* m)
Example: model.setMesh(&mesh);
Bind the model's points and connecting lines. Guide
const Mesh* model.mesh() const
Example: model.mesh();
Read the bound model pointer, or nullptr if none. Guide
void model.setPos(int16_t sx, int16_t sy)
Example: model.setPos(64, 32);
Place the model's anchor in screen pixels. Guide
int16_t model.x() const
Example: model.x();
Read the anchor's horizontal screen position in pixels. Guide
int16_t model.y() const
Example: model.y();
Read the anchor's vertical screen position in pixels. Guide
void model.setScaleQ8(uint16_t s)
Example: model.setScaleQ8(256);
Set model size; 256 is normal size and 512 is double. Guide
uint16_t model.scaleQ8() const
Example: model.scaleQ8();
Read size in units where 256 is normal size. Guide
void model.setRotation(uint8_t yaw, uint8_t pitch, uint8_t roll)
Example: model.setRotation(0, 64, 0);
Rotate about vertical, horizontal, and depth axes; 256 units equal one turn. Guide
void model.spin(int8_t dYaw, int8_t dPitch, int8_t dRoll)
Example: model.spin(1, 0, 0);
Add yaw, pitch, roll steps; 256 steps equal one turn. Guide
uint8_t model.yaw() const
Example: model.yaw();
Read rotation about the model's vertical axis; 0-255 is one turn. Guide
uint8_t model.pitch() const
Example: model.pitch();
Read rotation about the model's horizontal axis; 0-255 is one turn. Guide
uint8_t model.roll() const
Example: model.roll();
Read rotation about the model's depth axis; 0-255 is one turn. Guide
void model.setPerspective(uint8_t depth)
Example: model.setPerspective(48);
Set viewing depth; 0 disables perspective size changes with distance. Guide
uint8_t model.perspective() const
Example: model.perspective();
Read the viewing depth; 0 means no perspective. Guide
void model.draw(DisplayProxy& d) const
Example: model.draw(display);
Draw model lines; skip lines with either end behind the near viewing plane. Guide
bool model.projectPoint(int32_t mx, int32_t my, int32_t mz, int16_t& outX, int16_t& outY) const
Example: model.projectPoint(0, 0, 0, x, y);
Convert a model point to screen x/y; keep coordinates within about +/-8192; false if hidden. Guide
RigActor()
Example: RigActor figure;
Create an actor for connected bones, poses, and falling-body motion. -
void figure.setRig(const Rig* rig)
Example: figure.setRig(&rig);
Bind bones and poses, clearing playback and physics state. -
const Rig* figure.rig() const
Example: figure.rig();
Read the bound rig pointer, or nullptr if none. -
void figure.setPos(int16_t x, int16_t y)
Example: figure.setPos(64, 32);
Place the rig's origin in screen pixels. -
int16_t figure.x() const
Example: figure.x();
Read the horizontal screen position in pixels. -
int16_t figure.y() const
Example: figure.y();
Read the vertical screen position in pixels. -
State figure.state() const
Example: figure.state();
Read whether the figure is posing, animating, falling, or standing up. -
bool figure.isRagdoll() const
Example: figure.isRagdoll();
True during falling-body motion or standing up. -
bool figure.play(const char* name)
bool figure.play(const RigAnimation* animation)
bool figure.play(const RigAnimation& animation)
Example: figure.play("walk");
Play a named animation or pose; also accepts an animation pointer or reference; false if missing. -
bool figure.blend(const char* poseA, const char* poseB, uint8_t amount)
bool figure.blend(const RigPose* poseA, const RigPose* poseB, uint8_t amount)
bool figure.blend(const RigPose& poseA, const RigPose& poseB, uint8_t amount)
Example: figure.blend("idle", "reach", 128);
Blend two poses; amount 0-255 moves smoothly from the first to the second. -
bool figure.ragdoll(float impulseX = 0.0f, float impulseY = 0.0f)
Example: figure.ragdoll(1.0f, -2.0f);
Start falling-body physics with x/y impulse; false without a valid rig of at most 11 bones. -
bool figure.pin(const char* bone, float x, float y)
bool figure.pin(uint8_t bone, float x, float y)
Example: figure.pin("head", 64, 16);
Hold one bone at screen x/y during falling-body motion; also accepts a bone index. -
void figure.unpin()
Example: figure.unpin();
Release the held bone. -
void figure.standUp()
Example: figure.standUp();
Start standing up from a falling-body pose. -
void figure.update(uint32_t nowMs)
Example: figure.update(millis());
Advance animation by ms or physics by one step; call each update. -
void figure.draw(DisplayProxy& display) const
Example: figure.draw(display);
Draw the current connected-bone figure. -
uint8_t figure.boneCount() const
Example: figure.boneCount();
Read the number of bones in the bound rig. -
const RigBoneTransform& figure.boneTransform(uint8_t index) const
Example: figure.boneTransform(0);
Read a valid bone index's calculated start, end, and angle; no bounds check. -
uint8_t figure.particleCount() const
Example: figure.particleCount();
Read the number of physics points used by falling-body motion. -
RigParticle figure.particle(uint8_t index) const
Example: figure.particle(0);
Read a physics point's x/y; invalid index returns (0, 0). -
float figure.maxHardConstraintError() const
Example: figure.maxHardConstraintError();
Read the largest length error in pixels for rigid physics connections. -
int16_t sinQ14(uint8_t a)
Example: sinQ14(64);
Read sine scaled by 16384; 256 angle units equal one turn. Guide
int16_t cosQ14(uint8_t a)
Example: cosQ14(0);
Read cosine scaled by 16384; 256 angle units equal one turn. Guide
uint8_t degreesToBinaryAngle(int32_t degrees)
Example: degreesToBinaryAngle(90);
Convert degrees to a wrapped 0-255 angle; 256 units equal one turn. -
uint8_t blendBinaryAngle(uint8_t from, uint8_t to, uint8_t amount)
Example: blendBinaryAngle(0, 64, 128);
Blend angles by the shorter turn; amount 0-255 selects first to second. -
int32_t interpolateRigInteger(int32_t from, int32_t to, uint8_t amount)
Example: interpolateRigInteger(0, 100, 128);
Blend integers; amount 0-255 selects first to second, rounding halfway away from zero. -
void rotateRigOffset(int32_t x, int32_t y, uint8_t angle, int32_t& outX, int32_t& outY)
Example: rotateRigOffset(10, 0, 64, x, y);
Rotate a pixel offset into output x/y; 256 angle units equal one turn. -
int16_t rigPoseDegrees(const RigPose* pose, uint8_t bone)
Example: rigPoseDegrees(&pose, 0);
Read a valid bone index's pose angle in degrees; null pose data returns 0. -
int32_t rigPoseRootDy(const RigPose* pose)
Example: rigPoseRootDy(&pose);
Read a pose's vertical origin offset in pixels; null pose returns 0. -
int32_t rigRoundRatioHalfAwayFromZero(int64_t numerator, int64_t denominator)
Example: rigRoundRatioHalfAwayFromZero(5, 2);
Divide with halfway values rounded away from zero; denominator must be positive. -
bool solveRigPose(const Rig& rig, const RigPose* poseA, const RigPose* poseB, uint8_t blendAmount, RigBoneTransform* out, uint8_t outCapacity)
bool solveRigPose(const Rig& rig, const RigPose* pose, RigBoneTransform* out, uint8_t outCapacity)
Example: solveRigPose(rig, &pose, transforms, 16);
Calculate bone positions; also accepts two poses and a 0-255 blend; false for invalid capacity or bone order. -
const RigPose* findRigPose(const Rig& rig, const char* name)
Example: findRigPose(rig, "idle");
Look up a pose by name; nullptr if missing. -
const RigAnimation* findRigAnimation(const Rig& rig, const char* name)
Example: findRigAnimation(rig, "walk");
Look up a bone animation by name; nullptr if missing. -
uint8_t smoothstepRigAmount(uint8_t amount)
Example: smoothstepRigAmount(128);
Ease a 0-255 blend amount so its start and finish are gradual. -

Leaving the app / app control

Call What it does Learn more
MenuManager& MenuManager::instance().instance()
Example: MenuManager& menu = MenuManager::instance();
Get the shared menu controller. Guide
void MenuManager::instance().returnToMenu()
Example: MenuManager::instance().returnToMenu();
Go back to the menu. Your app closes once the function that called this (for example a button callback) finishes. Guide
unsigned long millis_APP_LASTINTERACTION
Example: millis_APP_LASTINTERACTION = millis();
Set this to millis() to count as activity, so the device does not go to sleep while your app runs. Guide

Button names

Name Value What it does Learn more
const int button_BottomLeftIndex = 4
Example: button_BottomLeftIndex
4 BottomLeft button; aliases refer to the same physical button. Guide
const int button_BottomRightIndex = 5
Example: button_BottomRightIndex
5 BottomRight button; aliases refer to the same physical button. Guide
const int button_DownIndex = button_TopRightIndex
Example: button_DownIndex
1 Down button; aliases refer to the same physical button. Guide
const int button_EnterIndex = button_BottomRightIndex
Example: button_EnterIndex
5 Enter button; aliases refer to the same physical button. Guide
const int button_LeftIndex = button_MiddleLeftIndex
Example: button_LeftIndex
2 Left button; aliases refer to the same physical button. Guide
const int button_MiddleLeftIndex = 2
Example: button_MiddleLeftIndex
2 MiddleLeft button; aliases refer to the same physical button. Guide
const int button_MiddleRightIndex = 3
Example: button_MiddleRightIndex
3 MiddleRight button; aliases refer to the same physical button. Guide
const int button_RightIndex = button_MiddleRightIndex
Example: button_RightIndex
3 Right button; aliases refer to the same physical button. Guide
const int button_SelectIndex = button_BottomLeftIndex
Example: button_SelectIndex
4 Select button; aliases refer to the same physical button. Guide
const int button_TopLeftIndex = 0
Example: button_TopLeftIndex
0 TopLeft button; aliases refer to the same physical button. Guide
const int button_TopRightIndex = 1
Example: button_TopRightIndex
1 TopRight button; aliases refer to the same physical button. Guide
const int button_UpIndex = button_TopLeftIndex
Example: button_UpIndex
0 Up button; aliases refer to the same physical button. Guide

LED names

Name Value What it does Learn more
const uint16_t pixel_Back = 0
Example: pixel_Back
0 Back RGBW LED. Guide
const uint16_t pixel_Front_Bottom = 3
Example: pixel_Front_Bottom
3 Front Bottom RGBW LED. Guide
const uint16_t pixel_Front_Middle = 2
Example: pixel_Front_Middle
2 Front Middle RGBW LED. Guide
const uint16_t pixel_Front_Top = 1
Example: pixel_Front_Top
1 Front Top RGBW LED. Guide

Colors

Name Value What it does Learn more
OLEDDISPLAY_COLOR BLACK = 0
Example: BLACK
0 Draw pixels off. Guide
OLEDDISPLAY_COLOR WHITE = 1
Example: WHITE
1 Draw pixels on. Guide
OLEDDISPLAY_COLOR INVERSE = 2
Example: INVERSE
2 Toggle drawn pixels on/off. Guide

Fonts

Name Value What it does Learn more
const uint8_t ArialMT_Plain_10[]
Example: ArialMT_Plain_10
font handle 10 pixel font; pass to setFont(). Guide
const uint8_t ArialMT_Plain_16[]
Example: ArialMT_Plain_16
font handle 16 pixel font; pass to setFont(). Guide
const uint8_t ArialMT_Plain_24[]
Example: ArialMT_Plain_24
font handle 24 pixel font; pass to setFont(). Guide

Text alignment

Name Value What it does Learn more
OLEDDISPLAY_TEXT_ALIGNMENT TEXT_ALIGN_LEFT = 0
Example: TEXT_ALIGN_LEFT
0 Text starts at x. Guide
OLEDDISPLAY_TEXT_ALIGNMENT TEXT_ALIGN_RIGHT = 1
Example: TEXT_ALIGN_RIGHT
1 Text ends at x. Guide
OLEDDISPLAY_TEXT_ALIGNMENT TEXT_ALIGN_CENTER = 2
Example: TEXT_ALIGN_CENTER
2 Text is centered on x. Guide
OLEDDISPLAY_TEXT_ALIGNMENT TEXT_ALIGN_CENTER_BOTH = 3
Example: TEXT_ALIGN_CENTER_BOTH
3 Text is centered on x and y. Guide

Button event types

Name Value What it does Learn more
ButtonEventType ButtonEvent_None
Example: ButtonEvent_None
0 No button event. Guide
ButtonEventType ButtonEvent_Pressed
Example: ButtonEvent_Pressed
1 Button went down. Guide
ButtonEventType ButtonEvent_Released
Example: ButtonEvent_Released
2 Button went up; duration is time held in ms. Guide
ButtonEventType ButtonEvent_Held
Example: ButtonEvent_Held
3 Button passed the 1500 ms hold threshold; duration is time held in ms. Guide

Animation constants

Name Value What it does Learn more
LoopMode LOOP_ONCE = 0
Example: LOOP_ONCE
0 Play once then draw nothing. Guide
LoopMode LOOP_ONCE_HOLD = 1
Example: LOOP_ONCE_HOLD
1 Play once and keep the last frame. Guide
LoopMode LOOP_LOOP = 2
Example: LOOP_LOOP
2 Repeat from the first frame. Guide
LoopMode LOOP_PINGPONG = 3
Example: LOOP_PINGPONG
3 Play forward then backward, repeating. Guide
BitOrder BO_LSB_FIRST = 0
Example: BO_LSB_FIRST
0 Lowest bit first per byte; required for drawing sprites correctly. Guide
BitOrder BO_MSB_FIRST = 1
Example: BO_MSB_FIRST
1 Highest bit first; collision can read it but drawing mirrors each byte. Guide
RigRenderMode RIG_RENDER_BAKED16 = 0
Example: RIG_RENDER_BAKED16
0 Use one of 16 image angles; fall back to lines when images are absent. -
RigRenderMode RIG_RENDER_LINE = 1
Example: RIG_RENDER_LINE
1 Draw bones as lines. -
RigRenderMode RIG_RENDER_FLAT = 2
Example: RIG_RENDER_FLAT
2 Draw bones as lines, matching LINE mode. -
State STATE_POSE
Example: RigActor::STATE_POSE
0 Holding a pose. -
State STATE_ANIMATION
Example: RigActor::STATE_ANIMATION
1 Playing bone animation. -
State STATE_RAGDOLL
Example: RigActor::STATE_RAGDOLL
2 Falling-body physics is active. -
State STATE_STANDING
Example: RigActor::STATE_STANDING
3 Returning from physics to standing. -
constexpr int32_t kFocal = 110
Example: kFocal
110 Perspective projection focal length in pixels. Guide
constexpr int32_t kNearZ = 8
Example: kNearZ
8 Minimum visible model depth. Guide
constexpr uint8_t kDefaultDepth = 48
Example: kDefaultDepth
48 Initial model viewing depth. Guide
constexpr uint16_t kScaleBaseQ8 = 256
Example: kScaleBaseQ8
256 Normal model size; 256 means 1x. Guide
constexpr uint8_t kMaxRigBones = 16
Example: kMaxRigBones
16 Maximum bones for pose calculation. -
constexpr uint8_t kMaxRigParticles = 11
Example: kMaxRigParticles
11 Maximum physics points for falling-body motion. -
constexpr uint8_t kMaxRigConstraints = 11
Example: kMaxRigConstraints
11 Maximum physics connections. -

Readable globals

Call What it does Learn more
float sliderPosition_12Bits_Filtered
Example: sliderPosition_12Bits_Filtered
Slider 0-4095. Smoothed on device. Guide
float sliderPosition_12Bits_Inverted_Filtered
Example: sliderPosition_12Bits_Inverted_Filtered
Slider 0-4095. Direction reversed. Emulator leaves this at 0. Guide
int sliderPosition_8Bits_Filtered
Example: sliderPosition_8Bits_Filtered
Slider 0-255. Smoothed on device. Guide
int sliderPosition_8Bits_Inverted_Filtered
Example: sliderPosition_8Bits_Inverted_Filtered
Slider 0-255. Direction reversed. Guide
float sliderPosition_Percentage_Filtered
Example: sliderPosition_Percentage_Filtered
Slider 0-100 %. Smoothed on device. Guide
float sliderPosition_Percentage_Inverted_Filtered
Example: sliderPosition_Percentage_Inverted_Filtered
Slider 0-100 %. Direction reversed. Guide
float accelX
Example: accelX
X acceleration, roughly 1000 units per g (gravity); emulator uses supplied tilt. Guide
float accelY
Example: accelY
Y acceleration, roughly 1000 units per g (gravity); emulator uses supplied tilt. Guide
float accelZ
Example: accelZ
Z acceleration, roughly 1000 units per g (gravity); emulator uses supplied tilt. Guide
float tempC
Example: tempC
Temperature placeholder in degrees Celsius; both app targets leave it at 0. Guide
unsigned long millis_NOW
Example: millis_NOW
The time in ms when this frame started; read it instead of calling millis() repeatedly. Guide