From 9d107d6c26688ed623835c6cc565c76a01613b85 Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Sat, 8 Mar 2025 15:22:14 -0500 Subject: [PATCH] made interface a library --- interface/src/auto.rs | 3 ++- interface/src/lib.rs | 12 ++++++++++++ interface/src/main.rs | 11 ++--------- 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 interface/src/lib.rs diff --git a/interface/src/auto.rs b/interface/src/auto.rs index 64cf59f..1f868db 100644 --- a/interface/src/auto.rs +++ b/interface/src/auto.rs @@ -35,12 +35,13 @@ struct Configurable { max: f32, } +/// A fake trait in the sense that these methods are exposed as symbols, not trait methods trait Auto { /// entrypoint async fn run(interface: &AutoInterface); /// register fn default_configs() -> [Configurable]; - + fn name() -> &'static str; } async fn auto (interface: &AutoInterface) { diff --git a/interface/src/lib.rs b/interface/src/lib.rs new file mode 100644 index 0000000..7cc9afe --- /dev/null +++ b/interface/src/lib.rs @@ -0,0 +1,12 @@ +#![feature(iter_collect_into)] + +use atomic_float::AtomicF32; +use gui::DEFAULT_VOLUME_THRESHOLD; + +pub mod gui; +pub mod storage_dir; +pub mod combatlog; +pub mod auto; + +pub const POWER_THRESHOLD: AtomicF32 = AtomicF32::new(DEFAULT_VOLUME_THRESHOLD); + diff --git a/interface/src/main.rs b/interface/src/main.rs index 1aa3d10..238af37 100644 --- a/interface/src/main.rs +++ b/interface/src/main.rs @@ -1,23 +1,16 @@ -#![feature(iter_collect_into)] use std::{fmt::format, ops::ControlFlow, result, sync::{atomic::Ordering, Arc}, thread::{self, sleep}, time::Duration}; use anyhow::{Context, Ok, Result}; use atomic_float::AtomicF32; -use combatlog::{combat_logger, CombatData}; +use interface::{combatlog::{combat_logger, CombatData}, POWER_THRESHOLD}; use common::{ControlPacket, TelemetryPacket}; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use egui_toast::{Toast, ToastKind}; -use gui::{gui, GUIData, DEFAULT_VOLUME_THRESHOLD, GUI}; +use interface::gui::{gui, GUIData, DEFAULT_VOLUME_THRESHOLD, GUI}; use pitch_detection::{detector::{mcleod::McLeodDetector, PitchDetector}, utils}; use rust_music_theory::note::{Note, NoteLetter, Pitch, Tuning}; use tokio::{io::{AsyncReadExt, AsyncWriteExt, BufWriter, WriteHalf}, net::{tcp::{OwnedReadHalf, OwnedWriteHalf}, TcpStream}, spawn, sync::{self, broadcast, mpsc, watch, RwLock}, time::timeout}; -mod gui; -mod storage_dir; -mod combatlog; -mod auto; - -pub const POWER_THRESHOLD: AtomicF32 = AtomicF32::new(DEFAULT_VOLUME_THRESHOLD); fn main() -> Result<()> { let (logging_sender, combatlog) = mpsc::channel(64);