![]() |
Cubelets API Documentation 2.0
C API
|
Lowers the sensitivity of the Brightness Cubelet/Hat by half. More...
#include "cubelet.h"
Functions | |
void | setup () |
Initialization function called once at the start. The first line includes the header required for all cubelets The setup() Function runs once when the program starts. Here, it’s empty because we don't have any initialization. | |
void | loop () |
Continuously checks and adjusts the brightness level. | |
We want to change the Brightness cubelet/hat so that it becomes less sensitive to lower illumination while providing a bit more sensitivity to higher illuminations.
setup()
function initializes the system (empty in this case).loop()
function continuously calculates the new value.void setup | ( | ) |
void loop | ( | ) |
The loop() function gets called repeatedly while a Cubelet is powered on.
This function reads the current brightness using the get_brightness()
function and modifies the value based on a sensitivity adjustment.
The value is obtained from the get_brightness()
function and later adjusted based on the current brightness level. tmp_block_value is a temporary variable for storing the brightness value while we do calculations on it.
Let's split the value handling into two parts.
If the brightness is 128 or greater, the value is adjusted by:
The mapping is as follows:
[0-128] -> 0
[128-255] -> [0,255]