fix brightness, rest of the update to servicepoint 0.7

This commit is contained in:
Vinzenz Schroeter 2024-06-27 19:49:27 +02:00
parent 0fff7a20d0
commit feacd6c01e
4 changed files with 83 additions and 17 deletions

View file

@ -18,5 +18,3 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build - name: Build
run: cargo build --verbose run: cargo build --verbose
# - name: Run tests
# run: cargo test --verbose

76
Cargo.lock generated
View file

@ -278,6 +278,27 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
[[package]]
name = "bzip2"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8"
dependencies = [
"bzip2-sys",
"libc",
]
[[package]]
name = "bzip2-sys"
version = "0.1.11+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]] [[package]]
name = "calloop" name = "calloop"
version = "0.12.4" version = "0.12.4"
@ -466,6 +487,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "crc32fast"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.19" version = "0.8.19"
@ -598,6 +628,16 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "flate2"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]] [[package]]
name = "float-ord" name = "float-ord"
version = "0.3.2" version = "0.3.2"
@ -1606,12 +1646,16 @@ dependencies = [
[[package]] [[package]]
name = "servicepoint" name = "servicepoint"
version = "0.6.0" version = "0.7.0"
source = "git+https://github.com/cccb/servicepoint.git?branch=fix-brightness#fc0705b826cd8b3c458fbb4d512307891486dcc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a65a19c938a6b227fd9360ecfbfd5a5891543f446bcc2077342a5641c9a0b1"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"bzip2",
"flate2",
"log", "log",
"rust-lzma", "rust-lzma",
"zstd",
] ]
[[package]] [[package]]
@ -2590,3 +2634,31 @@ dependencies = [
"quote", "quote",
"syn", "syn",
] ]
[[package]]
name = "zstd"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a"
dependencies = [
"zstd-safe",
]
[[package]]
name = "zstd-safe"
version = "7.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a"
dependencies = [
"zstd-sys",
]
[[package]]
name = "zstd-sys"
version = "2.0.11+zstd.1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4"
dependencies = [
"cc",
"pkg-config",
]

View file

@ -7,7 +7,7 @@ license = "GPL-3.0-or-later"
[dependencies] [dependencies]
# packet parsing # packet parsing
servicepoint = { git = "https://github.com/cccb/servicepoint.git", branch = "fix-brightness" } servicepoint = { version = "0.7.0", features = ["all_compressions"] }
# gui # gui
winit = { version = "0.30", features = ["rwh_05"] } # for creating a window winit = { version = "0.30", features = ["rwh_05"] } # for creating a window

View file

@ -67,21 +67,17 @@ impl<'t> App<'t> {
for x in 0..PIXEL_WIDTH { for x in 0..PIXEL_WIDTH {
let is_set = display.get(x, y); let is_set = display.get(x, y);
let brightness = luma.get(x / TILE_SIZE, y / TILE_SIZE); let brightness: u8 = luma.get(x / TILE_SIZE, y / TILE_SIZE).into();
let max_brightness: u8 = Brightness::MAX.into();
let scale: f32 = (u8::MAX as f32) / (max_brightness as f32);
let brightness = (scale * brightness as f32) as u8;
let color = if is_set { let color = if is_set {
[ [
if self.cli.red { brightness.into() } else { 0u8 }, if self.cli.red { brightness } else { 0u8 },
if self.cli.green { if self.cli.green { brightness } else { 0u8 },
brightness.into() if self.cli.blue { brightness } else { 0u8 },
} else {
0u8
},
if self.cli.blue {
brightness.into()
} else {
0u8
},
255, 255,
] ]
} else { } else {