diff --git a/bike-lights/bike/src/main.rs b/bike-lights/bike/src/main.rs index 48b809a..a683804 100644 --- a/bike-lights/bike/src/main.rs +++ b/bike-lights/bike/src/main.rs @@ -98,17 +98,23 @@ impl< } fn update_lights(&self, dashboard_lights: DashboardPattern, body_lights: BodyPattern) { - let mut lights: [u8; 20] = [0; 20]; - lights[16] = 0xff; - lights[17] = 0xff; - lights[18] = 0xff; - lights[19] = 0xff; + let mut lights: [u8; 260] = [0; 260]; + lights[256] = 0xff; + lights[257] = 0xff; + lights[258] = 0xff; + lights[259] = 0xff; for (idx, rgb) in dashboard_lights.iter().enumerate() { lights[(idx + 1) * 4 + 0] = 0xe0 + DASHBOARD_BRIGHTESS; lights[(idx + 1) * 4 + 1] = (I16F16::from(rgb.r) * LIGHT_SCALE).saturating_as(); lights[(idx + 1) * 4 + 2] = (I16F16::from(rgb.b) * LIGHT_SCALE).saturating_as(); lights[(idx + 1) * 4 + 3] = (I16F16::from(rgb.g) * LIGHT_SCALE).saturating_as(); } + for (idx, rgb) in body_lights.iter().enumerate() { + lights[(idx + 4) * 4 + 0] = 0xe0 + BODY_BRIGHTNESS; + lights[(idx + 4) * 4 + 1] = (I16F16::from(rgb.r) * LIGHT_SCALE).saturating_as(); + lights[(idx + 4) * 4 + 2] = (I16F16::from(rgb.b) * LIGHT_SCALE).saturating_as(); + lights[(idx + 4) * 4 + 3] = (I16F16::from(rgb.g) * LIGHT_SCALE).saturating_as(); + } let mut spi = self.spi.borrow_mut(); spi.write(lights.as_slice()); }