mirror of
https://github.com/kaesaecracker/servicepoint-simulator.git
synced 2025-01-18 18:40:14 +01:00
update shared lib
This commit is contained in:
parent
63520f5708
commit
88409faa02
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2151,7 +2151,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "servicepoint2"
|
name = "servicepoint2"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/kaesaecracker/servicepoint.git#06d3a99659dc32060c7a302fa8d7147c5227dda6"
|
source = "git+https://github.com/kaesaecracker/servicepoint.git#9eaa7462bccee02f698779b0fb4b9c1e9676bc60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num",
|
"num",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::{FromPrimitive, ToPrimitive};
|
||||||
use servicepoint2::DisplayCommandCode;
|
use servicepoint2::CommandCode;
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct HdrWindow {
|
pub struct HdrWindow {
|
||||||
pub command: DisplayCommandCode,
|
pub command: CommandCode,
|
||||||
pub x: u16,
|
pub x: u16,
|
||||||
pub y: u16,
|
pub y: u16,
|
||||||
pub w: u16,
|
pub w: u16,
|
||||||
|
@ -36,7 +36,7 @@ pub enum DisplaySubcommand {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ReadHeaderError {
|
pub enum ReadHeaderError {
|
||||||
BufferTooSmall,
|
BufferTooSmall,
|
||||||
WrongCommandEndianness(u16, DisplayCommandCode),
|
WrongCommandEndianness(u16, CommandCode),
|
||||||
InvalidCommand(u16),
|
InvalidCommand(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl HdrWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
let command_u16 = Self::read_beu16(&buffer[0..=1]);
|
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 {
|
Some(command) => Ok(HdrWindow {
|
||||||
command,
|
command,
|
||||||
x: Self::read_beu16(&buffer[2..=3]),
|
x: Self::read_beu16(&buffer[2..=3]),
|
||||||
|
@ -58,8 +58,7 @@ impl HdrWindow {
|
||||||
h: Self::read_beu16(&buffer[8..=9]),
|
h: Self::read_beu16(&buffer[8..=9]),
|
||||||
}),
|
}),
|
||||||
None => {
|
None => {
|
||||||
let maybe_command =
|
let maybe_command = CommandCode::from_primitive(u16::swap_bytes(command_u16));
|
||||||
DisplayCommandCode::from_primitive(u16::swap_bytes(command_u16));
|
|
||||||
return match maybe_command {
|
return match maybe_command {
|
||||||
None => Err(ReadHeaderError::InvalidCommand(command_u16)),
|
None => Err(ReadHeaderError::InvalidCommand(command_u16)),
|
||||||
Some(command) => Err(ReadHeaderError::WrongCommandEndianness(
|
Some(command) => Err(ReadHeaderError::WrongCommandEndianness(
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::font::BitmapFont;
|
||||||
use crate::protocol::{HdrWindow, ReadHeaderError};
|
use crate::protocol::{HdrWindow, ReadHeaderError};
|
||||||
use crate::DISPLAY;
|
use crate::DISPLAY;
|
||||||
use log::{debug, error, info, warn};
|
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::io::ErrorKind;
|
||||||
use std::net::{ToSocketAddrs, UdpSocket};
|
use std::net::{ToSocketAddrs, UdpSocket};
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
@ -88,20 +88,20 @@ impl UdpThread {
|
||||||
);
|
);
|
||||||
|
|
||||||
match header.command {
|
match header.command {
|
||||||
DisplayCommandCode::Clear => {
|
CommandCode::Clear => {
|
||||||
info!("clearing display");
|
info!("clearing display");
|
||||||
for v in unsafe { DISPLAY.iter_mut() } {
|
for v in unsafe { DISPLAY.iter_mut() } {
|
||||||
*v = false;
|
*v = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DisplayCommandCode::HardReset => {
|
CommandCode::HardReset => {
|
||||||
warn!("display shutting down");
|
warn!("display shutting down");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DisplayCommandCode::BitmapLinearWin => {
|
CommandCode::BitmapLinearWin => {
|
||||||
Self::print_bitmap_linear_win(&header, payload);
|
Self::print_bitmap_linear_win(&header, payload);
|
||||||
}
|
}
|
||||||
DisplayCommandCode::Cp437data => {
|
CommandCode::Cp437Data => {
|
||||||
Self::print_cp437_data(&header, payload, font);
|
Self::print_cp437_data(&header, payload, font);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
Loading…
Reference in a new issue