diff --git a/Cargo.lock b/Cargo.lock index 0ebf61ea7..6dec4154f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8746,6 +8746,7 @@ dependencies = [ "hound", "humantime", "orb-build-info", + "orb-info", "orb-messages 0.0.0 (git+https://github.com/worldcoin/orb-messages?rev=cac4f26ae09ca75ca2e2911376e5273be8454a52)", "orb-rgb", "orb-sound", diff --git a/ui/Cargo.toml b/ui/Cargo.toml index 4a986bdea..ad9c5ee0d 100644 --- a/ui/Cargo.toml +++ b/ui/Cargo.toml @@ -21,6 +21,7 @@ futures.workspace = true hound = "3.5.1" humantime = "2.1.0" orb-build-info.path = "../build-info" +orb-info = { workspace = true, features = ["orb-os-release"], default-features = false } orb-messages.workspace = true orb-rgb.path = "rgb" orb-sound.path = "sound" diff --git a/ui/rgb/src/lib.rs b/ui/rgb/src/lib.rs index ef12574ec..3886c64ab 100644 --- a/ui/rgb/src/lib.rs +++ b/ui/rgb/src/lib.rs @@ -79,6 +79,7 @@ impl Argb { pub const PEARL_WAVE_MIN_COLOR_INTENSITY: Argb = Argb(None, 4, 4, 4); pub const PEARL_OPERATOR_AMBER: Argb = Argb(None, 20, 16, 0); + pub const PEARL_OPERATOR_ANALYSIS: Argb = Argb(None, 0, 20, 30); pub const PEARL_OPERATOR_DEFAULT: Argb = { Argb(None, 20, 20, 20) }; pub const PEARL_OPERATOR_RED: Argb = Argb(None, 16, 0, 0); @@ -117,6 +118,7 @@ impl Argb { /// ***** Self-serve colors ***** pub const DIAMOND_OPERATOR_AMBER: Argb = Argb(Some(10), 40, 32, 1); + pub const DIAMOND_OPERATOR_ANALYSIS: Argb = Argb(Some(10), 0, 20, 30); pub const DIAMOND_OPERATOR_DEFAULT: Argb = Argb(Some(10), 20, 25, 20); pub const DIAMOND_OPERATOR_RED: Argb = Argb(Some(10), 25, 0, 0); pub const DIAMOND_OPERATOR_VERSIONS_DEPRECATED: Argb = Argb(Some(10), 40, 40, 0); diff --git a/ui/src/engine/mod.rs b/ui/src/engine/mod.rs index 0f24eb2a2..7d1f07c19 100644 --- a/ui/src/engine/mod.rs +++ b/ui/src/engine/mod.rs @@ -2,9 +2,11 @@ use crate::sound; use crate::tokio_spawn; +use crate::RELEASE_TYPE; use async_trait::async_trait; use eyre::Result; use futures::channel::mpsc::Sender; +use orb_info::orb_os_release::OrbRelease; use orb_messages::mcu_message::Message; use orb_rgb::Argb; use pid::InstantTimer; @@ -34,6 +36,24 @@ pub enum OrbType { pub const LED_ENGINE_FPS: u64 = 30; +fn release_type() -> OrbRelease { + RELEASE_TYPE.get().copied().unwrap_or(OrbRelease::Prod) +} + +pub(crate) fn pearl_operator_default() -> Argb { + match release_type() { + OrbRelease::Analysis => Argb::PEARL_OPERATOR_ANALYSIS, + _ => Argb::PEARL_OPERATOR_DEFAULT, + } +} + +pub(crate) fn diamond_operator_default() -> Argb { + match release_type() { + OrbRelease::Analysis => Argb::DIAMOND_OPERATOR_ANALYSIS, + _ => Argb::DIAMOND_OPERATOR_DEFAULT, + } +} + const GAMMA: f64 = 2.5; const LEVEL_BACKGROUND: u8 = 0; diff --git a/ui/src/engine/operator/idle.rs b/ui/src/engine/operator/idle.rs index 5426f9593..3aa01d3f5 100644 --- a/ui/src/engine/operator/idle.rs +++ b/ui/src/engine/operator/idle.rs @@ -66,8 +66,8 @@ pub struct Idle { impl Idle { pub fn new(orb_type: OrbType) -> Self { let color = match orb_type { - OrbType::Pearl => Argb::PEARL_OPERATOR_DEFAULT, - OrbType::Diamond => Argb::DIAMOND_OPERATOR_DEFAULT, + OrbType::Pearl => crate::engine::pearl_operator_default(), + OrbType::Diamond => crate::engine::diamond_operator_default(), }; Self { orb_type, @@ -141,10 +141,10 @@ impl Idle { } else { match self.orb_type { OrbType::Pearl => { - self.color = Argb::PEARL_OPERATOR_DEFAULT; + self.color = crate::engine::pearl_operator_default(); } OrbType::Diamond => { - self.color = Argb::DIAMOND_OPERATOR_DEFAULT; + self.color = crate::engine::diamond_operator_default(); } } } diff --git a/ui/src/engine/operator/pulse.rs b/ui/src/engine/operator/pulse.rs index 307087f88..057509ec0 100644 --- a/ui/src/engine/operator/pulse.rs +++ b/ui/src/engine/operator/pulse.rs @@ -39,8 +39,8 @@ impl Pulse { Argb::OPERATOR_DEV } else { match self.orb_type { - engine::OrbType::Pearl => Argb::PEARL_OPERATOR_DEFAULT, - engine::OrbType::Diamond => Argb::DIAMOND_OPERATOR_DEFAULT, + engine::OrbType::Pearl => crate::engine::pearl_operator_default(), + engine::OrbType::Diamond => crate::engine::diamond_operator_default(), } }; self.wave_period = wave_period; diff --git a/ui/src/engine/operator/signup_phase.rs b/ui/src/engine/operator/signup_phase.rs index 4b1c1f863..19756a304 100644 --- a/ui/src/engine/operator/signup_phase.rs +++ b/ui/src/engine/operator/signup_phase.rs @@ -239,9 +239,11 @@ impl Animation for SignupPhase { .take_while(|(i, _)| *i <= (self.current_phase % 5)) .for_each(|(_, c)| { *c = match self.orb_type { - engine::OrbType::Pearl => Argb::PEARL_OPERATOR_DEFAULT, + engine::OrbType::Pearl => { + crate::engine::pearl_operator_default() + } engine::OrbType::Diamond => { - Argb::DIAMOND_OPERATOR_DEFAULT + crate::engine::diamond_operator_default() } }; }); diff --git a/ui/src/engine/pearl/operator_based.rs b/ui/src/engine/pearl/operator_based.rs index f77e84640..2131c04b6 100644 --- a/ui/src/engine/pearl/operator_based.rs +++ b/ui/src/engine/pearl/operator_based.rs @@ -78,7 +78,7 @@ impl Runner { // and then keep first LED on as a background (`operator_signup_phase`) self.operator_action.trigger( 0.6, - Argb::PEARL_OPERATOR_DEFAULT, + crate::engine::pearl_operator_default(), false, true, false, diff --git a/ui/src/engine/pearl/self_serve.rs b/ui/src/engine/pearl/self_serve.rs index 9479782d2..dcb1fbfc1 100644 --- a/ui/src/engine/pearl/self_serve.rs +++ b/ui/src/engine/pearl/self_serve.rs @@ -75,7 +75,7 @@ impl Runner { // and then keep first LED on as a background (`operator_signup_phase`) self.operator_action.trigger( 0.6, - Argb::PEARL_OPERATOR_DEFAULT, + crate::engine::pearl_operator_default(), false, true, false, diff --git a/ui/src/main.rs b/ui/src/main.rs index cadce2c9e..a4b619e12 100644 --- a/ui/src/main.rs +++ b/ui/src/main.rs @@ -1,6 +1,7 @@ #![forbid(unsafe_code)] use humantime::parse_duration; +use orb_info::orb_os_release::{OrbOsRelease, OrbRelease}; use std::env; use std::sync::OnceLock; use std::time::Duration; @@ -85,6 +86,15 @@ struct BeaconArgs { duration: Duration, } +fn current_release_type() -> Result { + let os_release = + OrbOsRelease::read_blocking().wrap_err("failed reading /etc/os-release")?; + + Ok(os_release.release_type) +} + +pub(crate) static RELEASE_TYPE: OnceLock = OnceLock::new(); + static HW_VERSION_FILE: OnceLock = OnceLock::new(); #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -208,17 +218,27 @@ async fn main_inner(args: Args) -> Result<()> { Ok(()) } -#[tokio::main] -async fn main() -> Result<()> { +fn main() -> Result<()> { color_eyre::install()?; - let telemetry = orb_telemetry::TelemetryConfig::new() - .with_journald(SYSLOG_IDENTIFIER) - .init(); + + let release_type = current_release_type().unwrap_or(OrbRelease::Prod); + RELEASE_TYPE + .set(release_type) + .expect("RELEASE_TYPE set once"); let args = Args::parse(); - let result = main_inner(args).await; - telemetry.flush().await; - result + + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build()? + .block_on(async { + let telemetry = orb_telemetry::TelemetryConfig::new() + .with_journald(SYSLOG_IDENTIFIER) + .init(); + let result = main_inner(args).await; + telemetry.flush().await; + result + }) } /// Just like `tokio::spawn()`, but if we are using unstable tokio features, we give