move examples into package (include them in published crate)

This commit is contained in:
Vinzenz Schroeter 2024-05-26 13:55:19 +02:00
parent 5514f60c28
commit c92493fad1
22 changed files with 26 additions and 165 deletions

78
Cargo.lock generated
View file

@ -17,15 +17,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "announce"
version = "0.1.0"
dependencies = [
"clap 4.5.4",
"env_logger",
"servicepoint",
]
[[package]]
name = "anstream"
version = "0.6.14"
@ -250,29 +241,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "env_filter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9"
dependencies = [
"anstream",
"anstyle",
"env_filter",
"humantime",
"log",
]
[[package]]
name = "errno"
version = "0.3.9"
@ -299,16 +267,6 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "game_of_life"
version = "0.1.0"
dependencies = [
"clap 4.5.4",
"env_logger",
"rand",
"servicepoint",
]
[[package]]
name = "getrandom"
version = "0.2.15"
@ -347,12 +305,6 @@ dependencies = [
"libc",
]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "indexmap"
version = "1.9.3"
@ -425,15 +377,6 @@ dependencies = [
"adler",
]
[[package]]
name = "moving_line"
version = "0.1.0"
dependencies = [
"clap 4.5.4",
"env_logger",
"servicepoint",
]
[[package]]
name = "once_cell"
version = "1.19.0"
@ -506,16 +449,6 @@ dependencies = [
"getrandom",
]
[[package]]
name = "random_brightness"
version = "0.1.0"
dependencies = [
"clap 4.5.4",
"env_logger",
"rand",
"servicepoint",
]
[[package]]
name = "regex"
version = "1.10.4"
@ -610,8 +543,10 @@ name = "servicepoint"
version = "0.4.2"
dependencies = [
"bzip2",
"clap 4.5.4",
"flate2",
"log",
"rand",
"rust-lzma",
"zstd",
]
@ -831,15 +766,6 @@ version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]]
name = "wiping_clear"
version = "0.1.0"
dependencies = [
"clap 4.5.4",
"env_logger",
"servicepoint",
]
[[package]]
name = "zstd"
version = "0.13.1"

View file

@ -4,10 +4,5 @@ members = [
"crates/servicepoint",
"crates/servicepoint_binding_c",
"crates/servicepoint_binding_cs",
"examples/announce",
"examples/game_of_life",
"examples/moving_line",
"examples/wiping_clear",
"examples/random_brightness",
"examples/lang_c"
"crates/servicepoint_binding_c/examples/lang_c"
]

View file

@ -26,3 +26,8 @@ compression_bzip2 = ["dep:bzip2"]
compression_lzma = ["dep:rust-lzma"]
compression_zstd = ["dep:zstd"]
all_compressions = ["compression_zlib", "compression_bzip2", "compression_lzma", "compression_zstd"]
[dev-dependencies]
# for examples
clap = { version = "4.5", features = ["derive"] }
rand = "0.8"

View file

@ -14,10 +14,11 @@ struct Cli {
/// example: `cargo run -- --text "Hallo,
/// CCCB"`
fn main() {
env_logger::init();
let cli = Cli::parse();
let mut cli = Cli::parse();
if cli.text.is_empty() {
cli.text.push("Hello, CCCB!".to_string());
}
let connection = Connection::open(&cli.destination).unwrap();
if cli.clear {

View file

@ -14,7 +14,6 @@ struct Cli {
}
fn main() {
env_logger::init();
let cli = Cli::parse();
let connection = Connection::open(&cli.destination).unwrap();
@ -22,13 +21,11 @@ fn main() {
loop {
connection
.send(
Command::BitmapLinearWin(
.send(Command::BitmapLinearWin(
Origin(0, 0),
field.clone(),
CompressionCode::Lzma,
)
)
))
.expect("could not send");
thread::sleep(FRAME_PACING);
field = iteration(field);

View file

@ -11,8 +11,6 @@ struct Cli {
}
fn main() {
env_logger::init();
let connection = Connection::open(Cli::parse().destination).unwrap();
let mut pixels = PixelGrid::max_sized();
@ -23,13 +21,11 @@ fn main() {
pixels.set((y + x_offset) % PIXEL_WIDTH, y, true);
}
connection
.send(
Command::BitmapLinearWin(
.send(Command::BitmapLinearWin(
Origin(0, 0),
pixels.clone(),
CompressionCode::Lzma,
)
)
))
.unwrap();
thread::sleep(FRAME_PACING);
}

View file

@ -17,7 +17,6 @@ struct Cli {
}
fn main() {
env_logger::init();
let cli = Cli::parse();
let connection = Connection::open(cli.destination).unwrap();
@ -55,9 +54,7 @@ fn main() {
}
}
connection
.send(CharBrightness(origin, luma))
.unwrap();
connection.send(CharBrightness(origin, luma)).unwrap();
std::thread::sleep(wait_duration);
}
}

View file

@ -14,7 +14,6 @@ struct Cli {
}
fn main() {
env_logger::init();
let cli = Cli::parse();
let sleep_duration = Duration::max(
@ -37,9 +36,7 @@ fn main() {
let bit_vec = BitVec::from(&*pixel_data);
connection
.send(
Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma)
)
.send(Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma))
.unwrap();
thread::sleep(sleep_duration);
}

View file

@ -11,4 +11,4 @@ test = false
cc = "1.0"
[dependencies]
servicepoint_binding_c = { path = "../../crates/servicepoint_binding_c" }
servicepoint_binding_c = { path = "../.." }

View file

@ -0,0 +1 @@

View file

@ -1,10 +0,0 @@
[package]
name = "announce"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
servicepoint = { path = "../../crates/servicepoint" }
clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11"

View file

@ -1,12 +0,0 @@
[package]
name = "game_of_life"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
servicepoint = { path = "../../crates/servicepoint" }
clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11"
rand = "0.8.5"

View file

@ -1,10 +0,0 @@
[package]
name = "moving_line"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
servicepoint = { path = "../../crates/servicepoint" }
clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11"

View file

@ -1,12 +0,0 @@
[package]
name = "random_brightness"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
servicepoint = { path = "../../crates/servicepoint" }
clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11"
rand = "0.8"

View file

@ -1,10 +0,0 @@
[package]
name = "wiping_clear"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
servicepoint = { path = "../../crates/servicepoint" }
clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11"