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

Detailed Description

Strobe

#include "cubelet.h"
unsigned int last_flash_counter = 0;
void setup()
{
}
void loop()
{
block_value = weighted_average();
if (block_value != 0){ //no strobe should occur when block value is zero.
if (last_flash_counter > 5+(255-block_value)) { //wait between 5 and 260 ~10ms intervals. Theoretically 20-0.4 flashes per second.
last_flash_counter = 0;
set_flashlight(255);
wait(10);
set_flashlight(0);
}
else {
last_flash_counter++;
wait(10);
}
}
}
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 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.