Cubelets API Documentation 2.0
C API
Loading...
Searching...
No Matches
bv_utils.h File Reference

Definitions for functions to manipulate and calculate block values.

#include <stdint.h>
#include "routing_table.h"

Go to the source code of this file.

Functions

uint8_t weighted_average (void)
 Calculates a block value based on the on the weighted average of neighbors block values.
 
uint8_t inverse (uint8_t bv)
 Returns the inverse of the supplied block value.
 
uint8_t minimum (void)
 Returns the smallest block value from neighboring blocks.
 
uint8_t maximum (void)
 Returns the largest block value from neighboring blocks.
 
void set_block_value (uint32_t id, uint8_t bv)
 Manually override the block value of a specific block in the construction.
 
uint8_t get_block_value (uint32_t id)
 Get the block value of a remote Cubelet.
 

Function Documentation

◆ weighted_average()

uint8_t weighted_average ( void )

Calculates the average of the block values from surrounding neighbors. With closer neighbors being weighted heavier than neighbors far away.

Returns
The weighed average of neighbor block values. 0-255.

◆ inverse()

uint8_t inverse ( uint8_t bv)

Returns the inverse of the supplied block value. 255->0 0->255.

Parameters
bvThe block value to invert
Returns
The inverse of the supplied block value. Unsigned byte 0-255.

◆ minimum()

uint8_t minimum ( void )

Returns the smallest block value from neighboring blocks with a valid block value.

Returns
The minimum block value of neighboring blocks. 0-255

◆ maximum()

uint8_t maximum ( void )

Returns the largest block value from neighboring blocks with a valid block value.

Returns
The largest block value of neighboring blocks. 0-255

◆ set_block_value()

void set_block_value ( uint32_t id,
uint8_t bv )

Manually override the block value of a specific block in the construction.

Parameters
idThe ID of the Cubelet to override
bvThe block value to set for the remote Cubelet

◆ get_block_value()

uint8_t get_block_value ( uint32_t id)

Get the blov value of a Cubelet from it's ID

Parameters
idThe ID of block you wish to retrieve the block value for
Returns
The block value of the Cubelet that hss the specified ID