Introduction
Welcome to the Cubelets C API. This API can be used with Console. To flash new code onto your cubelets, they must be running OS4.
Code Structure
The basic structure of your custom program should start with:
#include "cubelet.h"
{
}
{
}
void setup()
Function ran just a single time. Used for setting up variables or timers.
Definition bargraph.c:3
void loop()
The loop() function gets called repeatedly while a Cubelet is powered on.
Definition bargraph.c:8
Example Cubelet Program
An example using some of the most useful API calls:
#include "cubelet.h"
#define TOGGLE_DELAY_MS 500
void toggle_block_value(void)
{
block_value =
inverse(block_value);
}
{
block_value = 0;
}
{
set_flashlight(block_value);
}
uint8_t inverse(uint8_t bv)
Returns the inverse of the supplied block value.
void set_interval(uint16_t delay, timer_callback_t callback)
Allows a function callback to be fired continuously after the specified amount of time.
List All Cubelets
Where to find the API calls you're looking for
You can always browse the full API to find what you need, but here are some starting points: