Skip to content

Commit

Permalink
orb-ui: diamond: self-serve with cone support
Browse files Browse the repository at this point in the history
initial cone support
  • Loading branch information
fouge committed Jul 31, 2024
1 parent 366d05e commit b58e06c
Show file tree
Hide file tree
Showing 12 changed files with 535 additions and 389 deletions.
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 orb-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ orb-build-info.path = "../build-info"
orb-messages.workspace = true
orb-sound.path = "sound"
orb-uart.path = "uart"
orb-cone.path = "cone"
orb-rgb.path = "rgb"
pid.path = "pid"
prost = "0.12.3"
Expand Down
1 change: 1 addition & 0 deletions orb-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Test new event with the orb-ui daemon running:

```shell
busctl --user call org.worldcoin.OrbUiState1 /org/worldcoin/OrbUiState1 org.worldcoin.OrbUiState1 OrbSignupStateEvent s "\"Bootup\""
busctl --user call org.worldcoin.OrbUserEvent1 /org/worldcoin/OrbUserEvent1 org.worldcoin.OrbUserEvent1 UserEvent s "\"ConeButtonPressed\""
```

## Platform Support
Expand Down
30 changes: 19 additions & 11 deletions orb-ui/src/dbus.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
//! Dbus interface definitions.

use crate::engine;
use crate::engine::Event;
use crate::engine::RxEvent;
use tokio::sync::mpsc;
use zbus::interface;
use zbus::{interface, proxy};

/// Dbus interface object for OrbUiState1.
#[derive(Debug)]
pub struct Interface {
events: mpsc::UnboundedSender<Event>,
pub struct InboundInterface {
events: mpsc::UnboundedSender<RxEvent>,
}

impl Interface {
pub fn new(events: mpsc::UnboundedSender<Event>) -> Self {
impl InboundInterface {
pub fn new(events: mpsc::UnboundedSender<RxEvent>) -> Self {
Self { events }
}
}

#[interface(name = "org.worldcoin.OrbUiState1")]
impl Interface {
/// Forward events to UI engine by sending serialized engine::Event to the event channel.
impl InboundInterface {
/// Forward events to UI engine by sending serialized engine::TxEvent to the event channel.
async fn orb_signup_state_event(&mut self, event: String) -> zbus::fdo::Result<()> {
// parse event to engine::Event using json_serde
// parse serialized event
tracing::debug!("received JSON event: {}", event);
let event: engine::Event = serde_json::from_str(&event).map_err(|e| {
let event: RxEvent = serde_json::from_str(&event).map_err(|e| {
zbus::fdo::Error::InvalidArgs(format!(
"invalid event: failed to parse {}",
e
Expand All @@ -35,3 +34,12 @@ impl Interface {
Ok(())
}
}

#[proxy(
default_service = "org.worldcoin.OrbUserEvent1",
default_path = "/org/worldcoin/OrbUserEvent1",
interface = "org.worldcoin.OrbUserEvent1"
)]
trait OutboundInterface {
fn user_event(&self, event: String) -> zbus::fdo::Result<()>;
}
10 changes: 10 additions & 0 deletions orb-ui/src/engine/animations/static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ impl<const N: usize> Static<N> {
}
}

impl<const N: usize> Default for Static<N> {
fn default() -> Self {
Self {
current_color: Argb::OFF,
max_time: None,
stop: false,
}
}
}

impl<const N: usize> Animation for Static<N> {
type Frame = [Argb; N];

Expand Down
Loading

0 comments on commit b58e06c

Please sign in to comment.