2024-05-09 00:46:03 +02:00
|
|
|
#![deny(clippy::all)]
|
|
|
|
|
2024-05-09 13:26:33 +02:00
|
|
|
mod gui;
|
|
|
|
mod upd_loop;
|
|
|
|
|
2024-05-09 00:46:03 +02:00
|
|
|
use std::default::Default;
|
|
|
|
use std::sync::mpsc;
|
2024-05-08 12:42:40 +02:00
|
|
|
|
2024-05-09 13:26:33 +02:00
|
|
|
use crate::gui::App;
|
|
|
|
use crate::upd_loop::start_udp_thread;
|
2024-05-08 12:42:40 +02:00
|
|
|
use clap::Parser;
|
2024-05-09 13:26:33 +02:00
|
|
|
use log::info;
|
|
|
|
use winit::event_loop::{ControlFlow, EventLoop};
|
2024-05-08 12:42:40 +02:00
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
struct Cli {
|
|
|
|
#[arg(long = "bind", default_value = "0.0.0.0:2342")]
|
|
|
|
bind: String,
|
|
|
|
}
|
|
|
|
|
2024-05-08 20:17:39 +02:00
|
|
|
const TILE_SIZE: u16 = 8;
|
|
|
|
const TILE_WIDTH: u16 = 65;
|
|
|
|
const TILE_HEIGHT: u16 = 20;
|
|
|
|
const PIXEL_WIDTH: u16 = TILE_WIDTH * TILE_SIZE;
|
|
|
|
const PIXEL_HEIGHT: u16 = TILE_HEIGHT * TILE_SIZE;
|
2024-05-09 00:46:03 +02:00
|
|
|
const PIXEL_COUNT: usize = PIXEL_WIDTH as usize * PIXEL_HEIGHT as usize;
|
|
|
|
|
|
|
|
static mut DISPLAY: [bool; PIXEL_COUNT] = [false; PIXEL_COUNT];
|
2024-05-08 20:17:39 +02:00
|
|
|
|
2024-05-09 00:46:03 +02:00
|
|
|
fn main() {
|
|
|
|
env_logger::init();
|
|
|
|
|
2024-05-08 12:42:40 +02:00
|
|
|
let cli = Cli::parse();
|
2024-05-09 00:46:03 +02:00
|
|
|
info!("running with args: {:?}", &cli);
|
2024-05-08 13:21:31 +02:00
|
|
|
|
2024-05-09 00:46:03 +02:00
|
|
|
info!("display booting up");
|
2024-05-09 13:26:33 +02:00
|
|
|
let (stop_udp_tx, stop_udp_rx) = mpsc::channel();
|
2024-05-09 00:46:03 +02:00
|
|
|
|
2024-05-09 13:26:33 +02:00
|
|
|
let thread = start_udp_thread(cli.bind, stop_udp_rx);
|
2024-05-08 12:42:40 +02:00
|
|
|
|
2024-05-09 00:46:03 +02:00
|
|
|
let event_loop = EventLoop::new().expect("could not create event loop");
|
|
|
|
event_loop.set_control_flow(ControlFlow::Poll);
|
2024-05-08 20:17:39 +02:00
|
|
|
|
2024-05-09 00:46:03 +02:00
|
|
|
let mut app = App::default();
|
|
|
|
event_loop
|
|
|
|
.run_app(&mut app)
|
|
|
|
.expect("could not run event loop");
|
2024-05-08 12:42:40 +02:00
|
|
|
|
2024-05-09 13:26:33 +02:00
|
|
|
stop_udp_tx.send(()).expect("could not cancel thread");
|
2024-05-09 00:46:03 +02:00
|
|
|
thread.join().expect("could not join threads");
|
|
|
|
}
|