re-export constants from base lib

This commit is contained in:
Vinzenz Schroeter 2025-04-12 12:12:51 +02:00
parent 69014dff38
commit c9be3d87ec
7 changed files with 98 additions and 92 deletions

View file

@ -8,6 +8,35 @@
#include <stdint.h>
#include <stdlib.h>
/**
* pixel count on whole screen
*/
#define PIXEL_COUNT (PIXEL_WIDTH * PIXEL_HEIGHT)
/**
* Display height in pixels
*
* # Examples
*
* ```rust
* # use servicepoint::{PIXEL_HEIGHT, PIXEL_WIDTH, Bitmap};
* let grid = Bitmap::new(PIXEL_WIDTH, PIXEL_HEIGHT);
* ```
*/
#define PIXEL_HEIGHT (TILE_HEIGHT * TILE_SIZE)
/**
* Display width in pixels
*
* # Examples
*
* ```rust
* # use servicepoint::{PIXEL_HEIGHT, PIXEL_WIDTH, Bitmap};
* let grid = Bitmap::new(PIXEL_WIDTH, PIXEL_HEIGHT);
* ```
*/
#define PIXEL_WIDTH (TILE_WIDTH * TILE_SIZE)
/**
* Count of possible brightness values
*/
@ -23,40 +52,60 @@
*/
#define SP_BRIGHTNESS_MIN 0
/**
* pixel count on whole screen
*/
#define SP_PIXEL_COUNT (SP_PIXEL_WIDTH * SP_PIXEL_HEIGHT)
/**
* Display height in pixels
*/
#define SP_PIXEL_HEIGHT (SP_TILE_HEIGHT * SP_TILE_SIZE)
/**
* Display width in pixels
*/
#define SP_PIXEL_WIDTH (SP_TILE_WIDTH * SP_TILE_SIZE)
/**
* Display tile count in the y-direction
*
* # Examples
*
* ```rust
* # use servicepoint::{Cp437Grid, TILE_HEIGHT, TILE_WIDTH};
* let grid = Cp437Grid::new(TILE_WIDTH, TILE_HEIGHT);
* ```
*/
#define SP_TILE_HEIGHT 20
#define TILE_HEIGHT 20
/**
* size of a single tile in one dimension
*/
#define SP_TILE_SIZE 8
#define TILE_SIZE 8
/**
* Display tile count in the x-direction
*
* # Examples
*
* ```rust
* # use servicepoint::{Cp437Grid, TILE_HEIGHT, TILE_WIDTH};
* let grid = Cp437Grid::new(TILE_WIDTH, TILE_HEIGHT);
* ```
*/
#define SP_TILE_WIDTH 56
#define TILE_WIDTH 56
/**
* Specifies the kind of compression to use.
* Specifies the kind of compression to use. Availability depends on features.
*
* # Examples
*
* ```rust
* # use servicepoint::*;
* // create command without payload compression
* # let pixels = Bitmap::max_sized();
* _ = BitmapCommand {
* origin: Origin::ZERO,
* bitmap: pixels,
* compression: CompressionCode::Uncompressed
* };
*
* // create command with payload compressed with lzma and appropriate header flags
* # let pixels = Bitmap::max_sized();
* _ = BitmapCommand {
* origin: Origin::ZERO,
* bitmap: pixels,
* compression: CompressionCode::Lzma
* };
* ```
*/
enum SPCompressionCode
enum CompressionCode
#ifdef __cplusplus
: uint16_t
#endif // __cplusplus
@ -64,26 +113,26 @@ enum SPCompressionCode
/**
* no compression
*/
SP_COMPRESSION_CODE_UNCOMPRESSED = 0,
COMPRESSION_CODE_UNCOMPRESSED = 0,
/**
* compress using flate2 with zlib header
*/
SP_COMPRESSION_CODE_ZLIB = 26490,
COMPRESSION_CODE_ZLIB = 26490,
/**
* compress using bzip2
*/
SP_COMPRESSION_CODE_BZIP2 = 25210,
COMPRESSION_CODE_BZIP2 = 25210,
/**
* compress using lzma
*/
SP_COMPRESSION_CODE_LZMA = 27770,
COMPRESSION_CODE_LZMA = 27770,
/**
* compress using Zstandard
*/
SP_COMPRESSION_CODE_ZSTD = 31347,
COMPRESSION_CODE_ZSTD = 31347,
};
#ifndef __cplusplus
typedef uint16_t SPCompressionCode;
typedef uint16_t CompressionCode;
#endif // __cplusplus
/**
@ -1173,7 +1222,7 @@ size_t sp_char_grid_width(const CharGrid *char_grid);
*/
Command *sp_command_bitmap_linear(size_t offset,
SPBitVec *bit_vec,
SPCompressionCode compression);
CompressionCode compression);
/**
* Set pixel data according to an and-mask starting at the offset.
@ -1204,7 +1253,7 @@ Command *sp_command_bitmap_linear(size_t offset,
*/
Command *sp_command_bitmap_linear_and(size_t offset,
SPBitVec *bit_vec,
SPCompressionCode compression);
CompressionCode compression);
/**
* Set pixel data according to an or-mask starting at the offset.
@ -1235,7 +1284,7 @@ Command *sp_command_bitmap_linear_and(size_t offset,
*/
Command *sp_command_bitmap_linear_or(size_t offset,
SPBitVec *bit_vec,
SPCompressionCode compression);
CompressionCode compression);
/**
* Sets a window of pixels to the specified values.
@ -1262,7 +1311,7 @@ Command *sp_command_bitmap_linear_or(size_t offset,
Command *sp_command_bitmap_linear_win(size_t x,
size_t y,
Bitmap *bitmap,
SPCompressionCode compression);
CompressionCode compression);
/**
* Set pixel data according to a xor-mask starting at the offset.
@ -1293,7 +1342,7 @@ Command *sp_command_bitmap_linear_win(size_t x,
*/
Command *sp_command_bitmap_linear_xor(size_t offset,
SPBitVec *bit_vec,
SPCompressionCode compression);
CompressionCode compression);
/**
* Set the brightness of all tiles to the same value.

View file

@ -6,13 +6,13 @@ int main(void) {
if (connection == NULL)
return 1;
Bitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT);
Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT);
if (pixels == NULL)
return 1;
sp_bitmap_fill(pixels, true);
Command *command = sp_command_bitmap_linear_win(0, 0, pixels, SP_COMPRESSION_CODE_UNCOMPRESSED);
Command *command = sp_command_bitmap_linear_win(0, 0, pixels, COMPRESSION_CODE_UNCOMPRESSED);
if (command == NULL)
return 1;