Cubelets API Documentation 2.0
C API
Loading...
Searching...
No Matches
inverse.c File Reference

Detailed Description

#include "cubelet.h"
void setup()
{
}
void loop()
{
think();
}
void think()
{
if(!block_value_override)
{
/*
* Don't bother calculating the weighted average if there aren't any
* Cubelets with a valid block value (sensors/min/max/threshold/inverse).
*/
if(valid_entry_count > 0)
{
block_value = weighted_average();
block_value = inverse(block_value);
}
else
{
block_value = 0;
}
}
}
uint8_t inverse(uint8_t bv)
Returns the inverse of the supplied block value.
uint8_t weighted_average(void)
Calculates a block value based on the on the weighted average of neighbors block values.
void setup()
Function ran just a single time. Used for setting up variables or timers.
Definition bargraph.c:3
void think()
Used in Action and Think Cubelets to calculate their block value.
Definition bargraph.c:14
void loop()
The loop() function gets called repeatedly while a Cubelet is powered on.
Definition bargraph.c:8