diff --git a/Cargo.lock b/Cargo.lock index 12a9147..94e3d17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,16 +240,6 @@ dependencies = [ "cc", ] -[[package]] -name = "colored" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" -dependencies = [ - "lazy_static", - "windows-sys 0.52.0", -] - [[package]] name = "combine" version = "4.6.7" @@ -279,16 +269,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "console_log" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f" -dependencies = [ - "log", - "web-sys", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -411,15 +391,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" -[[package]] -name = "deranged" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -dependencies = [ - "powerfmt", -] - [[package]] name = "dispatch" version = "0.2.0" @@ -538,7 +509,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -559,16 +530,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "fern" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" -dependencies = [ - "colored", - "log", -] - [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -729,11 +690,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", - "js-sys", "libc", "r-efi", "wasip2", - "wasm-bindgen", ] [[package]] @@ -1291,10 +1250,8 @@ dependencies = [ "notan_glyph", "notan_graphics", "notan_input", - "notan_log", "notan_macro", "notan_math", - "notan_random", "notan_text", "notan_utils", ] @@ -1425,21 +1382,6 @@ dependencies = [ "notan_math", ] -[[package]] -name = "notan_log" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f2cb4b9804e0718e910ff0653463126a930d3a4017dc356ee8d0b2f700e8f50" -dependencies = [ - "console_log", - "fern", - "js-sys", - "log", - "notan_app", - "time", - "wasm-bindgen", -] - [[package]] name = "notan_macro" version = "0.14.0" @@ -1464,17 +1406,6 @@ dependencies = [ "glam", ] -[[package]] -name = "notan_random" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eec9025695fc94bcb967f0f64a7192b27f2ffb9d52036c2dc0a43b13941c2dcb" -dependencies = [ - "getrandom", - "rand", - "rand_pcg", -] - [[package]] name = "notan_text" version = "0.14.0" @@ -1569,12 +1500,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" - [[package]] name = "num-integer" version = "0.1.46" @@ -1638,15 +1563,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "num_threads" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" -dependencies = [ - "libc", -] - [[package]] name = "objc-sys" version = "0.3.5" @@ -2033,12 +1949,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.21" @@ -2131,15 +2041,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_pcg" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b48ac3f7ffaab7fac4d2376632268aa5f89abdb55f7ebf8f4d11fffccb2320f7" -dependencies = [ - "rand_core", -] - [[package]] name = "raw-window-handle" version = "0.6.2" @@ -2224,7 +2125,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2237,7 +2138,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2543,39 +2444,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "time" -version = "0.3.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" -dependencies = [ - "deranged", - "itoa", - "libc", - "num-conv", - "num_threads", - "powerfmt", - "serde_core", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" - -[[package]] -name = "time-macros" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tiny-skia" version = "0.11.4" @@ -2898,7 +2766,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2916,6 +2784,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.61.2" diff --git a/Cargo.toml b/Cargo.toml index 1025069..5918f11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,6 @@ edition = "2024" [dependencies] anyhow = "1.0.102" -notan = "0.14.0" +notan = { version = "0.14.0", default-features = false, features = ["backend", "draw", "shaderc"] } midly = "0.5.3" serialport = "4.9.0" diff --git a/flake.nix b/flake.nix index ee46f35..8f8d78b 100644 --- a/flake.nix +++ b/flake.nix @@ -63,6 +63,7 @@ commonBuildInputs = with pkgs; [ openssl + shaderc ] ++ pkgs.lib.optionals (!isDarwin) ( [ @@ -75,6 +76,7 @@ commonNativeBuildInputs = with pkgs; [ pkg-config cmake + git python312 makeWrapper ]; diff --git a/src/assets/Ubuntu-B.ttf b/src/assets/Ubuntu-B.ttf new file mode 100644 index 0000000..b173da2 Binary files /dev/null and b/src/assets/Ubuntu-B.ttf differ diff --git a/src/main.rs b/src/main.rs index b48e10c..c04fd14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,18 +170,23 @@ struct SingerApp { tx: Sender, rx: Receiver, connected: Option, + font: Font, } impl SingerApp { - pub fn new() -> Self { + pub fn new(gfx: &mut Graphics) -> Self { let (tx_cmd, rx_cmd) = mpsc::channel(); let (tx_status, rx_status) = mpsc::channel(); Self::spawn_serial_worker(rx_cmd, tx_status); + let font = gfx + .create_font(include_bytes!("assets/Ubuntu-B.ttf")) + .expect("failed to load embedded font"); Self { song_state: None, tx: tx_cmd, rx: rx_status, connected: None, + font, } } @@ -261,12 +266,21 @@ impl SingerApp { }; draw.rect((14.0, 14.0), (20.0, 20.0)).color(status_color); + let status_text = match &self.connected { + Some(name) => format!("Serial connected: {name}"), + None => "Serial disconnected".to_string(), + }; + draw.text(&self.font, &status_text) + .position(44.0, 30.0) + .size(22.0) + .color(Color::BLACK); + gfx.render(&draw); } } -fn setup(_gfx: &mut Graphics) -> SingerApp { - SingerApp::new() +fn setup(gfx: &mut Graphics) -> SingerApp { + SingerApp::new(gfx) } fn update(_app: &mut notan::app::App, state: &mut SingerApp) {