separate types for c api

This commit is contained in:
Vinzenz Schroeter 2024-06-23 15:42:15 +02:00
parent c554fbd800
commit 555d917d96
11 changed files with 648 additions and 162 deletions

View file

@ -2,7 +2,7 @@
use clap::Parser;
use servicepoint::{Command, Connection, Cp473Grid, Grid, Origin};
use servicepoint::{Command, Connection, Cp437Grid, Grid, Origin};
#[derive(Parser, Debug)]
struct Cli {
@ -33,7 +33,7 @@ fn main() {
let max_width = cli.text.iter().map(|t| t.len()).max().unwrap();
let mut chars = Cp473Grid::new(max_width, cli.text.len());
let mut chars = Cp437Grid::new(max_width, cli.text.len());
for y in 0..cli.text.len() {
let row = &cli.text[y];

View file

@ -13,7 +13,7 @@ pub type Offset = usize;
/// A grid containing codepage 437 characters.
///
/// The encoding is currently not enforced.
pub type Cp473Grid = PrimitiveGrid<u8>;
pub type Cp437Grid = PrimitiveGrid<u8>;
/// A command to send to the display.
#[derive(Debug, Clone, PartialEq)]
@ -27,7 +27,7 @@ pub enum Command {
/// The library does not currently convert between UTF-8 and CP-437.
/// Because Rust expects UTF-8 strings, it might be necessary to only send ASCII for now.
/// </div>
Cp437Data(Origin<Tiles>, Cp473Grid),
Cp437Data(Origin<Tiles>, Cp437Grid),
/// Sets a window of pixels to the specified values
BitmapLinearWin(Origin<Pixels>, PixelGrid, CompressionCode),
@ -276,7 +276,7 @@ impl TryFrom<Packet> for Command {
let Packet(_, payload) = packet;
Ok(Command::Cp437Data(
Origin::new(a as usize, b as usize),
Cp473Grid::load(c as usize, d as usize, &payload),
Cp437Grid::load(c as usize, d as usize, &payload),
))
}
CommandCode::CharBrightness => {

View file

@ -6,7 +6,7 @@ pub use bitvec;
use bitvec::prelude::{BitVec, Msb0};
pub use crate::brightness::{Brightness, BrightnessGrid};
pub use crate::command::{Command, Cp473Grid, Offset};
pub use crate::command::{Command, Cp437Grid, Offset};
pub use crate::compression_code::CompressionCode;
pub use crate::connection::Connection;
pub use crate::data_ref::DataRef;