![]() |
Cubelets API Documentation 2.0
C API
|
This C file provides a simple program for controlling a Cubelet speaker.
#include "cubelet.h"
Functions | |
void | setup () |
A placeholder for any initialization logic required before the main loop starts. This function is currently empty but can be expanded to include setup tasks such as initializing hardware or variables. | |
void | loop () |
Repeatedly executes the robot's logic in two stages: thinking (think()) and acting (act()). Usage: Called continuously after setup() finishes. Forms the main operational cycle of the Cubelet. | |
void | think () |
Computes the block_value by using the weighted_average() function. Usage: Updates the global variable block_value, which is used in the act() function. | |
void | act () |
Uses the computed block_value to set the Cubelet's speaker output. Usage: Calls set_speaker(), a function likely provided by the cubelet.h library, to control the Cubelet's speaker based on the current block_value. | |
void setup | ( | ) |
void loop | ( | ) |
The loop() function gets called repeatedly while a Cubelet is powered on.
void think | ( | ) |
Used in Action and Think Cubelets to calculate their block value.
void act | ( | ) |
Using to perform an action based on a previously calculated block value.