Debounce buttons, fix colors, and add a new water pattern
This commit is contained in:
parent
80d8dedbaf
commit
2b0fc7639e
|
@ -54,7 +54,7 @@ impl<P: PinId> DebouncedButton<P> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_debounce(&mut self, time: Instant) {
|
fn set_debounce(&mut self, time: Instant) {
|
||||||
self.debounce = time + Instant((100 as u32).into());
|
self.debounce = time + Instant((250 as u32).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,15 @@ pub trait Animation {
|
||||||
fn tick(&mut self, time: Instant) -> (DashboardPattern, BodyPattern);
|
fn tick(&mut self, time: Instant) -> (DashboardPattern, BodyPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
pub struct DefaultAnimation {}
|
pub struct DefaultAnimation {}
|
||||||
|
|
||||||
impl Animation for DefaultAnimation {
|
impl Animation for DefaultAnimation {
|
||||||
fn tick(&mut self, _: Instant) -> (DashboardPattern, BodyPattern) {
|
fn tick(&mut self, _: Instant) -> (DashboardPattern, BodyPattern) {
|
||||||
(PRIDE_DASHBOARD, PRIDE_BODY)
|
(WATER_DASHBOARD, WATER_BODY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
pub struct Fade {
|
pub struct Fade {
|
||||||
starting_dashboard: DashboardPattern,
|
starting_dashboard: DashboardPattern,
|
||||||
|
@ -300,8 +302,9 @@ pub enum Event {
|
||||||
RightBlinker,
|
RightBlinker,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum Pattern {
|
pub enum Pattern {
|
||||||
|
Water,
|
||||||
GayPride,
|
GayPride,
|
||||||
TransPride,
|
TransPride,
|
||||||
}
|
}
|
||||||
|
@ -309,20 +312,23 @@ pub enum Pattern {
|
||||||
impl Pattern {
|
impl Pattern {
|
||||||
fn previous(&self) -> Pattern {
|
fn previous(&self) -> Pattern {
|
||||||
match self {
|
match self {
|
||||||
Pattern::GayPride => Pattern::TransPride,
|
Pattern::Water => Pattern::TransPride,
|
||||||
|
Pattern::GayPride => Pattern::Water,
|
||||||
Pattern::TransPride => Pattern::GayPride,
|
Pattern::TransPride => Pattern::GayPride,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next(&self) -> Pattern {
|
fn next(&self) -> Pattern {
|
||||||
match self {
|
match self {
|
||||||
|
Pattern::Water => Pattern::GayPride,
|
||||||
Pattern::GayPride => Pattern::TransPride,
|
Pattern::GayPride => Pattern::TransPride,
|
||||||
Pattern::TransPride => Pattern::GayPride,
|
Pattern::TransPride => Pattern::Water,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dashboard(&self) -> DashboardPattern {
|
fn dashboard(&self) -> DashboardPattern {
|
||||||
match self {
|
match self {
|
||||||
|
Pattern::Water => WATER_DASHBOARD,
|
||||||
Pattern::GayPride => PRIDE_DASHBOARD,
|
Pattern::GayPride => PRIDE_DASHBOARD,
|
||||||
Pattern::TransPride => TRANS_PRIDE_DASHBOARD,
|
Pattern::TransPride => TRANS_PRIDE_DASHBOARD,
|
||||||
}
|
}
|
||||||
|
@ -330,13 +336,14 @@ impl Pattern {
|
||||||
|
|
||||||
fn body(&self) -> BodyPattern {
|
fn body(&self) -> BodyPattern {
|
||||||
match self {
|
match self {
|
||||||
|
Pattern::Water => OFF_BODY,
|
||||||
Pattern::GayPride => PRIDE_BODY,
|
Pattern::GayPride => PRIDE_BODY,
|
||||||
Pattern::TransPride => TRANS_PRIDE_BODY,
|
Pattern::TransPride => TRANS_PRIDE_BODY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
Pattern(Pattern),
|
Pattern(Pattern),
|
||||||
Brake,
|
Brake,
|
||||||
|
@ -357,11 +364,19 @@ pub struct App {
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(ui: Box<dyn UI>) -> Self {
|
pub fn new(ui: Box<dyn UI>) -> Self {
|
||||||
|
let pattern = Pattern::Water;
|
||||||
Self {
|
Self {
|
||||||
ui,
|
ui,
|
||||||
state: State::Pattern(Pattern::GayPride),
|
state: State::Pattern(pattern),
|
||||||
home_pattern: Pattern::GayPride,
|
home_pattern: pattern,
|
||||||
current_animation: Box::new(DefaultAnimation {}),
|
current_animation: Box::new(Fade::new(
|
||||||
|
OFF_DASHBOARD,
|
||||||
|
OFF_BODY,
|
||||||
|
pattern.dashboard(),
|
||||||
|
pattern.body(),
|
||||||
|
DEFAULT_FRAMES,
|
||||||
|
Instant((0 as u32).into()),
|
||||||
|
)),
|
||||||
dashboard_lights: OFF_DASHBOARD,
|
dashboard_lights: OFF_DASHBOARD,
|
||||||
lights: OFF_BODY,
|
lights: OFF_BODY,
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,11 +73,33 @@ pub const TRANS_PINK: RGB<I8F8> = RGB {
|
||||||
b: I8F8::lit("0.32"),
|
b: I8F8::lit("0.32"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const WATER_1: RGB<I8F8> = RGB {
|
||||||
|
r: I8F8::lit("0.0"),
|
||||||
|
g: I8F8::lit("0.0"),
|
||||||
|
b: I8F8::lit("0.75"),
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const WATER_2: RGB<I8F8> = RGB {
|
||||||
|
r: I8F8::lit("0.8"),
|
||||||
|
g: I8F8::lit("0.8"),
|
||||||
|
b: I8F8::lit("0.8"),
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const WATER_3: RGB<I8F8> = RGB {
|
||||||
|
r: I8F8::lit("0.00"),
|
||||||
|
g: I8F8::lit("0.75"),
|
||||||
|
b: I8F8::lit("0.75"),
|
||||||
|
};
|
||||||
|
|
||||||
pub const OFF_DASHBOARD: DashboardPattern = [RGB_OFF; 3];
|
pub const OFF_DASHBOARD: DashboardPattern = [RGB_OFF; 3];
|
||||||
pub const OFF_BODY: BodyPattern = [RGB_OFF; 60];
|
pub const OFF_BODY: BodyPattern = [RGB_OFF; 60];
|
||||||
|
|
||||||
pub const DEFAULT_FRAMES: U16F0 = U16F0::lit("30");
|
pub const DEFAULT_FRAMES: U16F0 = U16F0::lit("30");
|
||||||
|
|
||||||
|
pub const WATER_DASHBOARD: DashboardPattern = [WATER_1, WATER_2, WATER_3];
|
||||||
|
|
||||||
|
pub const WATER_BODY: BodyPattern = [RGB_OFF; 60];
|
||||||
|
|
||||||
pub const PRIDE_DASHBOARD: DashboardPattern = [PRIDE_RED, PRIDE_GREEN, PRIDE_INDIGO];
|
pub const PRIDE_DASHBOARD: DashboardPattern = [PRIDE_RED, PRIDE_GREEN, PRIDE_INDIGO];
|
||||||
|
|
||||||
pub const PRIDE_BODY: BodyPattern = [
|
pub const PRIDE_BODY: BodyPattern = [
|
||||||
|
|
Loading…
Reference in New Issue