From 88409faa02705112d0b5c746d8739ed0e866d0fb Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 10 May 2024 19:56:37 +0200 Subject: [PATCH] update shared lib --- Cargo.lock | 2 +- src/protocol.rs | 11 +++++------ src/upd_loop.rs | 10 +++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a87e00..58fc241 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2151,7 +2151,7 @@ dependencies = [ [[package]] name = "servicepoint2" version = "0.1.0" -source = "git+https://github.com/kaesaecracker/servicepoint.git#06d3a99659dc32060c7a302fa8d7147c5227dda6" +source = "git+https://github.com/kaesaecracker/servicepoint.git#9eaa7462bccee02f698779b0fb4b9c1e9676bc60" dependencies = [ "num", "num-derive", diff --git a/src/protocol.rs b/src/protocol.rs index 9bbbc90..5c4df7c 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -1,11 +1,11 @@ use num_derive::{FromPrimitive, ToPrimitive}; -use servicepoint2::DisplayCommandCode; +use servicepoint2::CommandCode; use std::mem::size_of; #[repr(C)] #[derive(Debug)] pub struct HdrWindow { - pub command: DisplayCommandCode, + pub command: CommandCode, pub x: u16, pub y: u16, pub w: u16, @@ -36,7 +36,7 @@ pub enum DisplaySubcommand { #[derive(Debug)] pub enum ReadHeaderError { BufferTooSmall, - WrongCommandEndianness(u16, DisplayCommandCode), + WrongCommandEndianness(u16, CommandCode), InvalidCommand(u16), } @@ -49,7 +49,7 @@ impl HdrWindow { } let command_u16 = Self::read_beu16(&buffer[0..=1]); - return match DisplayCommandCode::from_primitive(command_u16) { + return match CommandCode::from_primitive(command_u16) { Some(command) => Ok(HdrWindow { command, x: Self::read_beu16(&buffer[2..=3]), @@ -58,8 +58,7 @@ impl HdrWindow { h: Self::read_beu16(&buffer[8..=9]), }), None => { - let maybe_command = - DisplayCommandCode::from_primitive(u16::swap_bytes(command_u16)); + let maybe_command = CommandCode::from_primitive(u16::swap_bytes(command_u16)); return match maybe_command { None => Err(ReadHeaderError::InvalidCommand(command_u16)), Some(command) => Err(ReadHeaderError::WrongCommandEndianness( diff --git a/src/upd_loop.rs b/src/upd_loop.rs index 4a54788..a1f2b4d 100644 --- a/src/upd_loop.rs +++ b/src/upd_loop.rs @@ -2,7 +2,7 @@ use crate::font::BitmapFont; use crate::protocol::{HdrWindow, ReadHeaderError}; use crate::DISPLAY; use log::{debug, error, info, warn}; -use servicepoint2::{PixelGrid, PIXEL_WIDTH, TILE_SIZE, DisplayCommandCode}; +use servicepoint2::{PixelGrid, PIXEL_WIDTH, TILE_SIZE, CommandCode}; use std::io::ErrorKind; use std::net::{ToSocketAddrs, UdpSocket}; use std::sync::mpsc; @@ -88,20 +88,20 @@ impl UdpThread { ); match header.command { - DisplayCommandCode::Clear => { + CommandCode::Clear => { info!("clearing display"); for v in unsafe { DISPLAY.iter_mut() } { *v = false; } } - DisplayCommandCode::HardReset => { + CommandCode::HardReset => { warn!("display shutting down"); return; } - DisplayCommandCode::BitmapLinearWin => { + CommandCode::BitmapLinearWin => { Self::print_bitmap_linear_win(&header, payload); } - DisplayCommandCode::Cp437data => { + CommandCode::Cp437Data => { Self::print_cp437_data(&header, payload, font); } _ => {