update to new (unreleased) servicepoint version
This commit is contained in:
		
							parent
							
								
									06fc8e5850
								
							
						
					
					
						commit
						3264eaa567
					
				
					 7 changed files with 62 additions and 48 deletions
				
			
		
							
								
								
									
										3
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										3
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							|  | @ -1440,8 +1440,7 @@ dependencies = [ | |||
| [[package]] | ||||
| name = "servicepoint" | ||||
| version = "0.13.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "33abd53582a995aaf5d387be4a1f7eb294a084185f88f8cf61652b6272041660" | ||||
| source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint/?branch=next#300bb5d6474f0f6152ab04feed4478995fcb3ec8" | ||||
| dependencies = [ | ||||
|  "bitvec", | ||||
|  "bzip2", | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ clap = { version = "4.5", features = ["derive"] } | |||
| thiserror = "2.0" | ||||
| 
 | ||||
| # package parsing | ||||
| servicepoint = { version = "0.13.2", features = ["all_compressions"] } | ||||
| servicepoint = { features = ["all_compressions"], git = "https://git.berlin.ccc.de/servicepoint/servicepoint/", branch = "next" } | ||||
| 
 | ||||
| # font rendering | ||||
| font-kit = "0.14.2" | ||||
|  |  | |||
|  | @ -1,13 +1,19 @@ | |||
| use crate::command_executor::ExecutionResult::{Failure, Shutdown, Success}; | ||||
| use crate::cp437_font::Cp437Font; | ||||
| use crate::font_renderer::FontRenderer8x8; | ||||
| use crate::{ | ||||
|     command_executor::ExecutionResult::{Failure, Shutdown, Success}, | ||||
|     cp437_font::Cp437Font, | ||||
|     font_renderer::FontRenderer8x8, | ||||
| }; | ||||
| use log::{debug, error, info, trace, warn}; | ||||
| use servicepoint::{ | ||||
|     BitVec, Bitmap, BrightnessGrid, CharGrid, Command, Cp437Grid, Grid, Offset, | ||||
|     Origin, Tiles, PIXEL_COUNT, PIXEL_WIDTH, TILE_SIZE, | ||||
|     BinaryOperation, BitVec, BitVecCommand, Bitmap, BitmapCommand, | ||||
|     BrightnessCommand, BrightnessGrid, BrightnessGridCommand, CharGrid, | ||||
|     CharGridCommand, Cp437Grid, Cp437GridCommand, Grid, Offset, Origin, Tiles, | ||||
|     TypedCommand, PIXEL_COUNT, PIXEL_WIDTH, TILE_SIZE, | ||||
| }; | ||||
| use std::{ | ||||
|     ops::{BitAnd, BitOr, BitXor}, | ||||
|     sync::RwLock, | ||||
| }; | ||||
| use std::ops::{BitAnd, BitOr, BitXor}; | ||||
| use std::sync::RwLock; | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct CommandExecutor<'t> { | ||||
|  | @ -38,53 +44,62 @@ impl<'t> CommandExecutor<'t> { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub(crate) fn execute(&self, command: Command) -> ExecutionResult { | ||||
|     pub(crate) fn execute(&self, command: TypedCommand) -> ExecutionResult { | ||||
|         debug!("received {command:?}"); | ||||
|         match command { | ||||
|             Command::Clear => { | ||||
|             TypedCommand::Clear(_) => { | ||||
|                 info!("clearing display"); | ||||
|                 self.display.write().unwrap().fill(false); | ||||
|                 Success | ||||
|             } | ||||
|             Command::HardReset => { | ||||
|             TypedCommand::HardReset(_) => { | ||||
|                 warn!("display shutting down"); | ||||
|                 Shutdown | ||||
|             } | ||||
|             Command::BitmapLinearWin(Origin { x, y, .. }, pixels, _) => { | ||||
|                 self.print_pixel_grid(x, y, &pixels) | ||||
|             } | ||||
|             Command::Cp437Data(origin, grid) => { | ||||
|             TypedCommand::Bitmap(BitmapCommand { | ||||
|                                      origin: Origin { x, y, .. }, | ||||
|                                      bitmap, | ||||
|                                      .. | ||||
|                                  }) => self.print_pixel_grid(x, y, &bitmap), | ||||
|             TypedCommand::Cp437Grid(Cp437GridCommand { origin, grid }) => { | ||||
|                 self.print_cp437_data(origin, &grid) | ||||
|             } | ||||
|             #[allow(deprecated)] | ||||
|             Command::BitmapLegacy => { | ||||
|             TypedCommand::BitmapLegacy(_) => { | ||||
|                 warn!("ignoring deprecated command {:?}", command); | ||||
|                 Failure | ||||
|             } | ||||
|             Command::BitmapLinearAnd(offset, vec, _) => { | ||||
|                 self.execute_bitmap_linear(offset, vec, BitAnd::bitand) | ||||
|             TypedCommand::BitVec(command) => { | ||||
|                 let BitVecCommand { | ||||
|                     offset, | ||||
|                     bitvec, | ||||
|                     operation, | ||||
|                     .. | ||||
|                 } = command; | ||||
|                 fn overwrite(_: bool, new: bool) -> bool { | ||||
|                     new | ||||
|                 } | ||||
|                 let operation = match operation { | ||||
|                     BinaryOperation::Overwrite => overwrite, | ||||
|                     BinaryOperation::And => BitAnd::bitand, | ||||
|                     BinaryOperation::Or => BitOr::bitor, | ||||
|                     BinaryOperation::Xor => BitXor::bitxor, | ||||
|                 }; | ||||
|                 self.execute_bitmap_linear(offset, bitvec, operation) | ||||
|             } | ||||
|             Command::BitmapLinearOr(offset, vec, _) => { | ||||
|                 self.execute_bitmap_linear(offset, vec, BitOr::bitor) | ||||
|             } | ||||
|             Command::BitmapLinearXor(offset, vec, _) => { | ||||
|                 self.execute_bitmap_linear(offset, vec, BitXor::bitxor) | ||||
|             } | ||||
|             Command::BitmapLinear(offset, vec, _) => { | ||||
|                 self.execute_bitmap_linear(offset, vec, move |_, new| new) | ||||
|             } | ||||
|             Command::CharBrightness(origin, grid) => { | ||||
|                 self.execute_char_brightness(origin, grid) | ||||
|             } | ||||
|             Command::Brightness(brightness) => { | ||||
|             TypedCommand::BrightnessGrid(BrightnessGridCommand { | ||||
|                                              origin, | ||||
|                                              grid, | ||||
|                                          }) => self.execute_char_brightness(origin, grid), | ||||
|             TypedCommand::Brightness(BrightnessCommand { brightness }) => { | ||||
|                 self.luma.write().unwrap().fill(brightness); | ||||
|                 Success | ||||
|             } | ||||
|             Command::FadeOut => { | ||||
|             TypedCommand::FadeOut(_) => { | ||||
|                 error!("command not implemented: {command:?}"); | ||||
|                 Success | ||||
|             } | ||||
|             Command::Utf8Data(origin, grid) => { | ||||
|             TypedCommand::CharGrid(CharGridCommand { origin, grid }) => { | ||||
|                 self.print_utf8_data(origin, &grid) | ||||
|             } | ||||
|         } | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ impl Cp437Font { | |||
| impl Default for Cp437Font { | ||||
|     fn default() -> Self { | ||||
|         let mut bitmaps = | ||||
|             core::array::from_fn(|_| Bitmap::new(TILE_SIZE, TILE_SIZE)); | ||||
|             core::array::from_fn(|_| Bitmap::new(TILE_SIZE, TILE_SIZE).unwrap()); | ||||
| 
 | ||||
|         for (char_code, bitmap) in bitmaps.iter_mut().enumerate() { | ||||
|             let bits = CP437_FONT_LINEAR[char_code]; | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| use std::{sync::mpsc::Sender, sync::RwLock}; | ||||
| 
 | ||||
| use log::{info, warn}; | ||||
| use servicepoint::*; | ||||
| use std::{sync::mpsc::Sender, sync::RwLock}; | ||||
| use winit::{ | ||||
|     application::ApplicationHandler, dpi::LogicalSize, event::WindowEvent, | ||||
|     event_loop::ActiveEventLoop, keyboard::KeyCode::KeyC, window::WindowId, | ||||
|  |  | |||
|  | @ -32,7 +32,7 @@ fn main() { | |||
|         .expect("could not create event loop"); | ||||
|     event_loop.set_control_flow(ControlFlow::Wait); | ||||
| 
 | ||||
|     let display = RwLock::new(Bitmap::new(PIXEL_WIDTH, PIXEL_HEIGHT)); | ||||
|     let display = RwLock::new(Bitmap::max_sized()); | ||||
|     let luma = RwLock::new(BrightnessGrid::new(TILE_WIDTH, TILE_HEIGHT)); | ||||
|     let (stop_udp_tx, stop_udp_rx) = mpsc::channel(); | ||||
|     let font_renderer = cli | ||||
|  |  | |||
|  | @ -1,11 +1,12 @@ | |||
| use crate::command_executor::{CommandExecutor, ExecutionResult}; | ||||
| use crate::gui::AppEvents; | ||||
| use crate::{ | ||||
|     command_executor::{CommandExecutor, ExecutionResult}, | ||||
|     gui::AppEvents, | ||||
| }; | ||||
| use log::{error, warn}; | ||||
| use servicepoint::Command; | ||||
| use std::io::ErrorKind; | ||||
| use std::net::UdpSocket; | ||||
| use std::sync::mpsc::Receiver; | ||||
| use std::time::Duration; | ||||
| use servicepoint::TypedCommand; | ||||
| use std::{ | ||||
|     io::ErrorKind, net::UdpSocket, sync::mpsc::Receiver, time::Duration, | ||||
| }; | ||||
| use winit::event_loop::EventLoopProxy; | ||||
| 
 | ||||
| const BUF_SIZE: usize = 8985; | ||||
|  | @ -65,13 +66,13 @@ impl<'t> UdpServer<'t> { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     fn command_from_slice(slice: &[u8]) -> Option<Command> { | ||||
|     fn command_from_slice(slice: &[u8]) -> Option<TypedCommand> { | ||||
|         let packet = servicepoint::Packet::try_from(slice) | ||||
|             .inspect_err(|_| { | ||||
|                 warn!("could not load packet with length {}", slice.len()) | ||||
|             }) | ||||
|             .ok()?; | ||||
|         Command::try_from(packet) | ||||
|         TypedCommand::try_from(packet) | ||||
|             .inspect_err(move |err| { | ||||
|                 warn!("could not read command for packet: {:?}", err) | ||||
|             }) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter