graphics: more figments updates

This commit is contained in:
2026-02-28 16:58:11 +01:00
parent 22d1b4d077
commit e8a7a18539
6 changed files with 16 additions and 16 deletions

View File

@@ -50,12 +50,12 @@ impl<'a, T: SmartLedsWrite + 'a> Output<'a, SegmentSpace> for BikeOutput<T, T::C
}) })
} }
fn controls(&self) -> Option<&Self::Controls> { fn controls(&mut self) -> Option<&mut Self::Controls> {
Some(&self.controls) Some(&mut self.controls)
} }
} }
impl<'a, T: SmartLedsWriteAsync + 'a> OutputAsync<'a, SegmentSpace> for BikeOutput<T, T::Color> where T::Color: 'static + Copy + Fract8Ops + WithGamma + Default + Debug + AsMilliwatts + 'a { impl<'a, T: SmartLedsWriteAsync + 'a> OutputAsync<'a, SegmentSpace> for BikeOutput<T, T::Color> where T::Color: 'static + Copy + Mul<Fract8, Output = T::Color> + WithGamma + Default + Debug + AsMilliwatts + 'a {
async fn commit_async(&mut self) -> Result<(), T::Error> where T: SmartLedsWriteAsync { async fn commit_async(&mut self) -> Result<(), T::Error> where T: SmartLedsWriteAsync {
self.writer.controls().set_brightness(self.controls.brightness()); self.writer.controls().set_brightness(self.controls.brightness());
self.writer.controls().set_on(self.controls.is_on()); self.writer.controls().set_on(self.controls.is_on());
@@ -67,8 +67,8 @@ impl<'a, T: SmartLedsWriteAsync + 'a> OutputAsync<'a, SegmentSpace> for BikeOutp
type Error = T::Error; type Error = T::Error;
type Controls = DisplayControls; type Controls = DisplayControls;
fn controls(&self) -> Option<&Self::Controls> { fn controls(&mut self) -> Option<&mut Self::Controls> {
Some(&self.controls) Some(&mut self.controls)
} }
} }

View File

@@ -10,9 +10,9 @@ use embedded_graphics::primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder,
use embedded_graphics::text::{Alignment, Text}; use embedded_graphics::text::{Alignment, Text};
use embedded_graphics::{image::Image, prelude::Point, Drawable}; use embedded_graphics::{image::Image, prelude::Point, Drawable};
use enum_map::EnumMap; use enum_map::EnumMap;
use figments::liber8tion::trig::sin8; use figments::liber8tion::trig::Trig8;
use figments::mappings::embedded_graphics::Matrix2DSpace; use figments::mappings::embedded_graphics::Matrix2DSpace;
use figments::{liber8tion::trig::cos8, mappings::embedded_graphics::EmbeddedGraphicsSampler}; use figments::{mappings::embedded_graphics::EmbeddedGraphicsSampler};
use figments::prelude::*; use figments::prelude::*;
use nalgebra::Vector2; use nalgebra::Vector2;
use micromath::F32Ext; use micromath::F32Ext;

View File

@@ -62,7 +62,7 @@ impl AdditivePixelSink<BinaryColor> for SsdPixel {
Fract8::MIN => (), Fract8::MIN => (),
Fract8::MAX => self.set_pixel(pixel), Fract8::MAX => self.set_pixel(pixel),
_ => { _ => {
let dither_value = DITHER_MAP[opacity as usize / 17]; let dither_value = DITHER_MAP[opacity.to_raw() as usize / 17];
let dither_x = self.coords.x % 4; let dither_x = self.coords.x % 4;
let dither_y = self.coords.y % 4; let dither_y = self.coords.y % 4;
if dither_value.shr(dither_x).shr(dither_y * 4).bitand(0x01) == 1 { if dither_value.shr(dither_x).shr(dither_y * 4).bitand(0x01) == 1 {
@@ -231,14 +231,14 @@ impl<'a> OutputAsync<'a, Matrix2DSpace> for SsdOutput {
self.is_on = new_power; self.is_on = new_power;
} }
if self.last_brightness != new_brightness { if self.last_brightness != new_brightness {
self.target.set_brightness(ssd1306::prelude::Brightness::custom(1, new_brightness)).await.unwrap(); self.target.set_brightness(ssd1306::prelude::Brightness::custom(1, new_brightness.to_raw())).await.unwrap();
self.last_brightness = new_brightness; self.last_brightness = new_brightness;
} }
self.target.draw(&self.pixbuf).await self.target.draw(&self.pixbuf).await
} }
fn controls(&self) -> Option<&Self::Controls> { fn controls(&mut self) -> Option<&mut Self::Controls> {
Some(&self.controls) Some(&mut self.controls)
} }
} }

View File

@@ -9,12 +9,12 @@ use log::*;
use crate::{animation::Animation, events::{Personality, Prediction}, graphics::{display::DisplayControls, oled_ui::{OledUniforms, Screen}}}; use crate::{animation::Animation, events::{Personality, Prediction}, graphics::{display::DisplayControls, oled_ui::{OledUniforms, Screen}}};
#[cfg(feature="oled")] #[cfg(feature="oled")]
pub type OledUiSurfacePool = BufferedSurfacePool<OledUniforms, Matrix2DSpace, BinaryColor>; pub type OledUiSurfacePool = figments::surface::BufferedSurfacePool<OledUniforms, Matrix2DSpace, BinaryColor>;
#[cfg(not(feature="oled"))] #[cfg(not(feature="oled"))]
pub type OledUiSurfacePool = NullBufferPool<OledUniforms, Matrix2DSpace, BinaryColor>; pub type OledUiSurfacePool = figments::surface::NullBufferPool<OledUniforms, Matrix2DSpace, BinaryColor>;
type OledSurface = <OledUiSurfacePool as Surfaces<Matrix2DSpace>>::Surface; type OledSurface = <OledUiSurfacePool as Surfaces>::Surface;
pub type LockedUniforms = Arc<Mutex<CriticalSectionRawMutex, OledUniforms>>; pub type LockedUniforms = Arc<Mutex<CriticalSectionRawMutex, OledUniforms>>;

View File

@@ -20,7 +20,7 @@ pub struct SafetyUi<S: Surface> {
} }
impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pixel = Rgba<u8>>> SafetyUi<S> { impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pixel = Rgba<u8>>> SafetyUi<S> {
pub fn new<SS: Surfaces<SegmentSpace, Surface = S>>(surfaces: &mut SS, display: DisplayControls) -> Self where SS::Error: Debug { pub fn new<SS: Surfaces<Surface = S>>(surfaces: &mut SS, display: DisplayControls) -> Self where SS::Error: Debug {
let ret = Self { let ret = Self {
overlay: SurfaceBuilder::build(surfaces) overlay: SurfaceBuilder::build(surfaces)
.rect(Rectangle::everything()) .rect(Rectangle::everything())

View File

@@ -23,7 +23,7 @@ pub struct Ui<S: Surface> {
} }
impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pixel = Rgba<u8>>> Ui<S> { impl<S: Debug + Surface<Uniforms = Uniforms, CoordinateSpace = SegmentSpace, Pixel = Rgba<u8>>> Ui<S> {
pub fn new<SS: Surfaces<SegmentSpace, Surface = S>>(surfaces: &mut SS) -> Self where SS::Error: Debug { pub fn new<SS: Surfaces<Surface = S>>(surfaces: &mut SS) -> Self where SS::Error: Debug {
Self { Self {
background: SurfaceBuilder::build(surfaces) background: SurfaceBuilder::build(surfaces)
.rect(Rectangle::everything()) .rect(Rectangle::everything())