builder pattern for configs

This commit is contained in:
Andy Killorin 2025-03-08 19:09:30 -05:00
commit 21e269bc43
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
2 changed files with 67 additions and 11 deletions

View file

@ -1,3 +1,6 @@
[lib]
crate-type = ["dylib"]
[package]
name = "auto"
version = "0.1.0"

View file

@ -1,12 +1,29 @@
use std::{collections::VecDeque, ops::Sub};
use std::{collections::VecDeque, ops::Sub, pin::Pin};
use common::CamState;
use interface::auto::AutoInterface;
use interface::auto::{AutoInterface, Configurable};
#[unsafe(no_mangle)]
pub fn entry(interface: AutoInterface) -> Pin<Box<dyn Future<Output = ()> + Send>> {
Box::pin(auto(interface))
}
#[unsafe(no_mangle)]
pub static NAME: &'static str = "scanseek v1";
const AUTO_GAP: i16 = 140; /// mm tofs must drop to count as a hit
const AUTO_SELF_OCCLUSION: u16 = 130; /// minimum
async fn auto (interface: &AutoInterface) {
#[unsafe(no_mangle)]
pub static CONFIGS: &[Configurable] = &[
Configurable::new("auto minimum gap").range(0. .. 300.).default(140.)
.description("distance (mm) distance measurements must instantaneously drop to indicate a detection. This should line up with the size of the smallest robot you compete against"),
Configurable::new("auto self occlusion").range(0. .. 200.).default(143.)
.description("distance (mm) below which measurements are considered noise in the scan phase"),
];
async fn auto (interface: AutoInterface) {
let mut tof_l = Stats::new();
let mut tof_r = Stats::new();
loop {