use brightness type from base crate

This commit is contained in:
Vinzenz Schroeter 2025-04-12 13:12:50 +02:00
parent 40fed5ba04
commit 597614bc95
3 changed files with 43 additions and 34 deletions

View file

@ -266,6 +266,31 @@ typedef struct {
*/
typedef ValueGrid_Brightness BrightnessGrid;
/**
* A display brightness value, checked for correct value range
*
* # Examples
*
* ```
* # use servicepoint::*;
* let b = Brightness::MAX;
* let val: u8 = b.into();
*
* let b = Brightness::try_from(7).unwrap();
* # let connection = FakeConnection;
* let result = connection.send(GlobalBrightnessCommand::from(b));
* ```
*/
typedef uint8_t Brightness;
/**
* highest possible brightness value, 11
*/
#define Brightness_MAX 11
/**
* lowest possible brightness value, 0
*/
#define Brightness_MIN 0
/**
* A grid containing UTF-8 characters.
*
@ -819,7 +844,7 @@ BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/
* - `brightness_grid` is not written to or read from concurrently
*/
void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ brightness_grid,
uint8_t value);
Brightness value);
/**
* Deallocates a [SPBrightnessGrid].
@ -866,9 +891,9 @@ void sp_brightness_grid_free(BrightnessGrid */*notnull*/ brightness_grid);
* - `brightness_grid` points to a valid [SPBrightnessGrid]
* - `brightness_grid` is not written to concurrently
*/
uint8_t sp_brightness_grid_get(BrightnessGrid */*notnull*/ brightness_grid,
size_t x,
size_t y);
Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ brightness_grid,
size_t x,
size_t y);
/**
* Gets the height of the [SPBrightnessGrid] instance.
@ -956,7 +981,7 @@ BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width,
void sp_brightness_grid_set(BrightnessGrid */*notnull*/ brightness_grid,
size_t x,
size_t y,
uint8_t value);
Brightness value);
/**
* Gets an unsafe reference to the data of the [SPBrightnessGrid] instance.
@ -1358,7 +1383,7 @@ Command *sp_command_bitmap_linear_xor(size_t offset,
* - the returned [SPCommand] instance is freed in some way, either by using a consuming function or
* by explicitly calling `sp_command_free`.
*/
Command */*notnull*/ sp_command_brightness(uint8_t brightness);
Command */*notnull*/ sp_command_brightness(Brightness brightness);
/**
* Set the brightness of individual tiles in a rectangular area of the display.