Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions ui/rgb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions ui/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions ui/src/engine/operator/idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/engine/operator/pulse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions ui/src/engine/operator/signup_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
};
});
Expand Down
2 changes: 1 addition & 1 deletion ui/src/engine/pearl/operator_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Runner<PEARL_RING_LED_COUNT, PEARL_CENTER_LED_COUNT> {
// 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,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/engine/pearl/self_serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Runner<PEARL_RING_LED_COUNT, PEARL_CENTER_LED_COUNT> {
// 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,
Expand Down
36 changes: 28 additions & 8 deletions ui/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -85,6 +86,15 @@ struct BeaconArgs {
duration: Duration,
}

fn current_release_type() -> Result<OrbRelease> {
let os_release =
OrbOsRelease::read_blocking().wrap_err("failed reading /etc/os-release")?;

Ok(os_release.release_type)
}

pub(crate) static RELEASE_TYPE: OnceLock<OrbRelease> = OnceLock::new();

static HW_VERSION_FILE: OnceLock<String> = OnceLock::new();

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
Expand Down Expand Up @@ -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
Expand Down