Binary
Sets the bars to display the block value in binary over 8 bits. 
#include "cubelet.h"
 
{
 
}
 
{
 
    
 
    
 
    
    for (unsigned int i = 0; i<10; i++){
        if (block_value & (1<<i)){ 
            set_bar(i+1);
        }
        else {
            clear_bar(i+1);
        }
    }
}
 
 
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
Digits
Displays the block value in base 10. First number to be displayed is the hundreds place value, then the tens place value, finally the ones place value. There's a small rest before displaying the next block value. 255 will therefore show one after another: 2, 5, 5, nothing 
#include "cubelet.h"
 
 
{
}
 
{
 
    unsigned int hundreds_digit = block_value/100;
    unsigned int tens_digit = (block_value / 10) % 10;
    unsigned int ones_digit = block_value % 10;
 
 
    for (unsigned int i=0; i<4; i++){ 
        switch (i){
            case 0:
                set_bar_graph(hundreds_digit);
            break;
            case 1:
                set_bar_graph(tens_digit);
            break;
            case 2:
                set_bar_graph(ones_digit);
            break;
            case 3:
                set_bar_graph(0); 
            break;
        }
 
    }
}
 
 
void wait(uint16_t delay)
Function to delay execution for a specified amount of time.
Pong
#include "cubelet.h"
#include <stdbool.h>
 
unsigned int current_bar = 0;
bool direction_positive = true;
 
{
 
}
 
{
 
    if (direction_positive){
        if (current_bar == 9) direction_positive = false; 
        else current_bar++; 
    }
    else { 
        if (current_bar == 0) direction_positive = true; 
        else current_bar--; 
    }
 
    set_bar_graph(0); 
    set_bar(current_bar); 
 
}
 
 
uint8_t inverse(uint8_t bv)
Returns the inverse of the supplied block value.