#include "cubelet.h"
{
}
{
}
{
if (!block_value_override)
{
}
}
{
uint8_t r, g, b, brightness;
static uint8_t last_hue = 0;
static uint8_t blink_led = 0;
uint8_t hue = (uint8_t)(block_value * 2);
for (uint8_t i = 0; i < 4; i++)
{
hueToRGB((hue + i * 64) % 255, 10, &r, &g, &b);
brightness = (uint8_t)((block_value / 2) + (rand() % (block_value / 2 + 1)));
r = (r * brightness) / 255;
g = (g * brightness) / 255;
b = (b * brightness) / 255;
LedSet(i, r, g, b);
LedSet(7 - i, r, g, b);
}
if (rand() % (256 - block_value) < 5)
{
blink_led = rand() % 8;
LedSetHue(blink_led, last_hue, 255);
}
last_hue = (last_hue + 1) % 255;
wait(150 - (block_value / 2));
LedRingUpdate();
}
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 act()
Using to perform an action based on a previously calculated block value.
Definition bargraph.c:19
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
void wait(uint16_t delay)
Function to delay execution for a specified amount of time.