From 9346f4a9b8679f0873faaf16ec485e34a6e16057 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Mon, 27 Nov 2023 09:37:36 -0500 Subject: [PATCH] Rotate the right side The actual bike is going to be a long loop which folds from the end of the left side to the back end of the right side. This requires that the colors get moved around for proper mirroring. --- bike-lights/core/src/lib.rs | 154 +++-- bike-lights/core/src/patterns.rs | 999 ++++++++++++++++++------------ bike-lights/simulator/src/main.rs | 8 +- 3 files changed, 714 insertions(+), 447 deletions(-) diff --git a/bike-lights/core/src/lib.rs b/bike-lights/core/src/lib.rs index d7ef41b..3573275 100644 --- a/bike-lights/core/src/lib.rs +++ b/bike-lights/core/src/lib.rs @@ -132,7 +132,12 @@ pub enum FadeDirection { FadeOut, } -pub struct LeftBlinker { +pub enum BlinkerDirection { + Left, + Right, +} + +pub struct Blinker { fade_in: Fade, fade_out: Fade, direction: FadeDirection, @@ -141,31 +146,53 @@ pub struct LeftBlinker { frames: u8, } -impl LeftBlinker { +impl Blinker { fn new( starting_dashboard: DashboardPattern, starting_body: Pattern, + direction: BlinkerDirection, time: std::time::Instant, ) -> Self { let mut ending_dashboard = starting_dashboard.clone(); - ending_dashboard[0].r = LEFT_DASHBOARD[0].r; - ending_dashboard[0].g = LEFT_DASHBOARD[0].g; - ending_dashboard[0].b = LEFT_DASHBOARD[0].b; - let mut ending_body = starting_body.clone(); - for i in 0..30 { - ending_body[i].r = LEFT[i].r; - ending_body[i].g = LEFT[i].g; - ending_body[i].b = LEFT[i].b; + match direction { + BlinkerDirection::Left => { + ending_dashboard[0].r = LEFT_DASHBOARD[0].r; + ending_dashboard[0].g = LEFT_DASHBOARD[0].g; + ending_dashboard[0].b = LEFT_DASHBOARD[0].b; + } + BlinkerDirection::Right => { + ending_dashboard[2].r = RIGHT_DASHBOARD[2].r; + ending_dashboard[2].g = RIGHT_DASHBOARD[2].g; + ending_dashboard[2].b = RIGHT_DASHBOARD[2].b; + } } - LeftBlinker { + let mut ending_body = starting_body.clone(); + match direction { + BlinkerDirection::Left => { + for i in 0..30 { + ending_body[i].r = LEFT[i].r; + ending_body[i].g = LEFT[i].g; + ending_body[i].b = LEFT[i].b; + } + } + BlinkerDirection::Right => { + for i in 30..60 { + ending_body[i].r = RIGHT[i].r; + ending_body[i].g = RIGHT[i].g; + ending_body[i].b = RIGHT[i].b; + } + } + } + + Blinker { fade_in: Fade::new( starting_dashboard.clone(), starting_body.clone(), ending_dashboard.clone(), ending_body.clone(), - LEFT_FRAMES, + BLINKER_FRAMES, time, ), fade_out: Fade::new( @@ -173,17 +200,17 @@ impl LeftBlinker { ending_body.clone(), starting_dashboard.clone(), starting_body.clone(), - LEFT_FRAMES, + BLINKER_FRAMES, time, ), direction: FadeDirection::FadeIn, start_time: time, - frames: LEFT_FRAMES, + frames: BLINKER_FRAMES, } } } -impl Animation for LeftBlinker { +impl Animation for Blinker { fn tick(&mut self, time: std::time::Instant) -> (DashboardPattern, Pattern) { let frames: u8 = ((time - self.start_time).as_millis() as f64 / FPS as f64) as u8; if frames > self.frames { @@ -249,7 +276,7 @@ impl App { } } - fn update_state(&mut self, time: std::time::Instant) { + fn update_animation(&mut self, time: std::time::Instant) { match self.state { State::Pattern(0) => { self.current_animation = Box::new(Fade::new( @@ -283,58 +310,75 @@ impl App { )); } State::LeftBlinker => { - self.current_animation = Box::new(LeftBlinker::new( + self.current_animation = Box::new(Blinker::new( self.dashboard_lights.clone(), self.lights.clone(), + BlinkerDirection::Left, + time, + )); + } + State::RightBlinker => { + self.current_animation = Box::new(Blinker::new( + self.dashboard_lights.clone(), + self.lights.clone(), + BlinkerDirection::Right, time, )); } - State::RightBlinker => (), State::BrakeLeftBlinker => (), State::BrakeRightBlinker => (), } } + fn update_state(&mut self, event: Event) { + match event { + Event::Brake => { + if self.state == State::Brake { + self.state = self.home_state.clone(); + } else { + self.state = State::Brake; + } + } + Event::BrakeRelease => self.state = self.home_state.clone(), + Event::LeftBlinker => match self.state { + State::Brake => self.state = State::BrakeLeftBlinker, + State::BrakeLeftBlinker => self.state = State::Brake, + State::LeftBlinker => self.state = self.home_state.clone(), + _ => self.state = State::LeftBlinker, + }, + Event::NextPattern => match self.state { + State::Pattern(i) => { + let next = i + 1; + self.state = State::Pattern(if next > 1 { 0 } else { next }); + self.home_state = self.state.clone(); + } + _ => (), + }, + Event::PreviousPattern => match self.state { + State::Pattern(i) => { + if i == 0 { + self.state = State::Pattern(1); + } else { + self.state = State::Pattern(i - 1); + } + self.home_state = self.state.clone(); + } + _ => (), + }, + Event::RightBlinker => match self.state { + State::Brake => self.state = State::BrakeRightBlinker, + State::BrakeRightBlinker => self.state = State::Brake, + State::RightBlinker => self.state = self.home_state.clone(), + _ => self.state = State::RightBlinker, + }, + } + } + pub fn tick(&mut self, time: std::time::Instant) { match self.ui.check_event() { Some(event) => { - match event { - Event::Brake => { - if self.state == State::Brake { - self.state = self.home_state.clone(); - } else { - self.state = State::Brake; - } - } - Event::BrakeRelease => self.state = State::Pattern(0), - Event::LeftBlinker => match self.state { - State::Brake => self.state = State::BrakeLeftBlinker, - State::BrakeLeftBlinker => self.state = State::Brake, - State::LeftBlinker => self.state = self.home_state.clone(), - _ => self.state = State::LeftBlinker, - }, - Event::NextPattern => match self.state { - State::Pattern(i) => { - let next = i + 1; - self.state = State::Pattern(if next > 1 { 0 } else { next }); - self.home_state = self.state.clone(); - } - _ => (), - }, - Event::PreviousPattern => match self.state { - State::Pattern(i) => { - if i == 0 { - self.state = State::Pattern(1); - } else { - self.state = State::Pattern(i - 1); - } - self.home_state = self.state.clone(); - } - _ => (), - }, - Event::RightBlinker => {} - } - self.update_state(time); + self.update_state(event); + self.update_animation(time); } None => {} }; diff --git a/bike-lights/core/src/patterns.rs b/bike-lights/core/src/patterns.rs index 697e087..767b835 100644 --- a/bike-lights/core/src/patterns.rs +++ b/bike-lights/core/src/patterns.rs @@ -89,16 +89,14 @@ pub const PRIDE_DASHBOARD: DashboardPattern = [ ]; pub const PRIDE: Pattern = [ + // Left Side + // Red RGB { r: 228, g: 3, b: 3 }, RGB { r: 228, g: 3, b: 3 }, RGB { r: 228, g: 3, b: 3 }, RGB { r: 228, g: 3, b: 3 }, RGB { r: 228, g: 3, b: 3 }, - RGB { r: 228, g: 3, b: 3 }, - RGB { r: 228, g: 3, b: 3 }, - RGB { r: 228, g: 3, b: 3 }, - RGB { r: 228, g: 3, b: 3 }, - RGB { r: 228, g: 3, b: 3 }, + // Orange RGB { r: 255, g: 140, @@ -124,6 +122,216 @@ pub const PRIDE: Pattern = [ g: 140, b: 0, }, + // Yellow + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + // Green + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + // Indigo + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + // Purple + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + // Right Side + // Purple + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + RGB { + r: 115, + g: 41, + b: 130, + }, + // Indigo + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + RGB { + r: 36, + g: 64, + b: 142, + }, + // Green + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + RGB { + r: 0, + g: 128, + b: 38, + }, + // Yellow + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + RGB { + r: 255, + g: 237, + b: 0, + }, + // Orange RGB { r: 255, g: 140, @@ -149,206 +357,12 @@ pub const PRIDE: Pattern = [ g: 140, b: 0, }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 255, - g: 237, - b: 0, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 0, - g: 128, - b: 38, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 36, - g: 64, - b: 142, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, - RGB { - r: 115, - g: 41, - b: 130, - }, + // Red + RGB { r: 228, g: 3, b: 3 }, + RGB { r: 228, g: 3, b: 3 }, + RGB { r: 228, g: 3, b: 3 }, + RGB { r: 228, g: 3, b: 3 }, + RGB { r: 228, g: 3, b: 3 }, ]; pub const TRANS_PRIDE_DASHBOARD: DashboardPattern = [ @@ -370,6 +384,8 @@ pub const TRANS_PRIDE_DASHBOARD: DashboardPattern = [ ]; pub const TRANS_PRIDE: Pattern = [ + // Left Side + // Light Blue RGB { r: 91, g: 206, @@ -400,66 +416,7 @@ pub const TRANS_PRIDE: Pattern = [ g: 206, b: 250, }, - RGB { - r: 91, - g: 206, - b: 250, - }, - RGB { - r: 91, - g: 206, - b: 250, - }, - RGB { - r: 91, - g: 206, - b: 250, - }, - RGB { - r: 91, - g: 206, - b: 250, - }, - RGB { - r: 91, - g: 206, - b: 250, - }, - RGB { - r: 91, - g: 206, - b: 250, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, + // Light Pink RGB { r: 245, g: 169, @@ -490,6 +447,7 @@ pub const TRANS_PRIDE: Pattern = [ g: 169, b: 184, }, + // White RGB { r: 255, g: 255, @@ -520,66 +478,7 @@ pub const TRANS_PRIDE: Pattern = [ g: 255, b: 255, }, - RGB { - r: 255, - g: 255, - b: 255, - }, - RGB { - r: 255, - g: 255, - b: 255, - }, - RGB { - r: 255, - g: 255, - b: 255, - }, - RGB { - r: 255, - g: 255, - b: 255, - }, - RGB { - r: 255, - g: 255, - b: 255, - }, - RGB { - r: 255, - g: 255, - b: 255, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, - RGB { - r: 245, - g: 169, - b: 184, - }, + // Light Pink RGB { r: 245, g: 169, @@ -610,6 +509,7 @@ pub const TRANS_PRIDE: Pattern = [ g: 169, b: 184, }, + // Light Blue RGB { r: 91, g: 206, @@ -640,6 +540,132 @@ pub const TRANS_PRIDE: Pattern = [ g: 206, b: 250, }, + // Right side + // Light Blue + RGB { + r: 91, + g: 206, + b: 250, + }, + RGB { + r: 91, + g: 206, + b: 250, + }, + RGB { + r: 91, + g: 206, + b: 250, + }, + RGB { + r: 91, + g: 206, + b: 250, + }, + RGB { + r: 91, + g: 206, + b: 250, + }, + RGB { + r: 91, + g: 206, + b: 250, + }, + // Light Pink + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + // White + RGB { + r: 255, + g: 255, + b: 255, + }, + RGB { + r: 255, + g: 255, + b: 255, + }, + RGB { + r: 255, + g: 255, + b: 255, + }, + RGB { + r: 255, + g: 255, + b: 255, + }, + RGB { + r: 255, + g: 255, + b: 255, + }, + RGB { + r: 255, + g: 255, + b: 255, + }, + // Light Pink + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + RGB { + r: 245, + g: 169, + b: 184, + }, + // Light Blue RGB { r: 91, g: 206, @@ -675,75 +701,75 @@ pub const TRANS_PRIDE: Pattern = [ pub const BRAKE_FRAMES: u8 = 15; pub const BRAKE_DASHBOARD: DashboardPattern = [ - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, ]; pub const BRAKES: Pattern = [ - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, - RGB { r: 128, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, + RGB { r: 255, g: 0, b: 0 }, ]; -pub const LEFT_FRAMES: u8 = 15; +pub const BLINKER_FRAMES: u8 = 15; pub const LEFT_DASHBOARD: DashboardPattern = [ RGB { @@ -937,3 +963,198 @@ pub const LEFT: Pattern = [ RGB { r: 0, g: 0, b: 0 }, RGB { r: 0, g: 0, b: 0 }, ]; + +pub const RIGHT_FRAMES: u8 = 15; + +pub const RIGHT_DASHBOARD: DashboardPattern = [ + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { + r: 255, + g: 191, + b: 0, + }, +]; + +pub const RIGHT: Pattern = [ + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { r: 0, g: 0, b: 0 }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, + RGB { + r: 255, + g: 191, + b: 0, + }, +]; diff --git a/bike-lights/simulator/src/main.rs b/bike-lights/simulator/src/main.rs index edba09a..11a547c 100644 --- a/bike-lights/simulator/src/main.rs +++ b/bike-lights/simulator/src/main.rs @@ -170,7 +170,9 @@ impl BikeLights { let s: Self = Object::builder().build(); s.set_width_request(WIDTH); - s.set_height_request(200); + s.set_height_request(640); + + let center = WIDTH as f64 / 2.; s.set_draw_func({ let s = s.clone(); @@ -182,7 +184,7 @@ impl BikeLights { lights[i].g as f64 / 256., lights[i].b as f64 / 256., ); - context.rectangle(5. + 20. * i as f64, 5., 15., 15.); + context.rectangle(center - 45., 5. + 20. * i as f64, 15., 15.); let _ = context.fill(); } for i in 0..30 { @@ -191,7 +193,7 @@ impl BikeLights { lights[i + 30].g as f64 / 256., lights[i + 30].b as f64 / 256., ); - context.rectangle(5. + 20. * i as f64, 30., 15., 15.); + context.rectangle(center + 15., 5. + 20. * (30. - (i + 1) as f64), 15., 15.); let _ = context.fill(); } }