You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The base IS31FL3731 type assumes a two-dimensional array of monochrome LEDs. This matches many hardware configurations, but some devices us an array of RGB LEDs with three LED control slots per physical array position. The current solution is to provide a wrapper struct with an additional pixel_rgb method. This generally works, but it'd be nice to deal with just one struct, not two.
Additionally, given that the hardware configuration for any device is fixed, the width, height, and calc_pixel fields of IS31FL3731 should not change at runtime. This makes them prime candidates for compile-time, type-level configuration, which could save about six bytes of RAM at runtime.
My proposed solution involves adding another generic parameter to IS31FL3731. This parameter would take a type that implements the MatrixLayout trait, which would look something like the following:
The Intensity type would, in turn, implement the following trait:
traitIntensity{constCOMPONENTS;// Either 1 or 3fncomponent(&self,index:u8) -> u8;}
Intensity would then be implemented for both u8 (for monochrome displays) and an RGB type (probably either struct Rgb { r: u8, g: u8, b: u8 } or [u8; 3]).
The final implementation of pixel would look something like the following:
For monochrome displays, pixel would be called with a plain u8 as in the current API. For RGB displays, it would be called with the RGB intensity type.
The text was updated successfully, but these errors were encountered:
The base
IS31FL3731
type assumes a two-dimensional array of monochrome LEDs. This matches many hardware configurations, but some devices us an array of RGB LEDs with three LED control slots per physical array position. The current solution is to provide a wrapperstruct
with an additionalpixel_rgb
method. This generally works, but it'd be nice to deal with just onestruct
, not two.Additionally, given that the hardware configuration for any device is fixed, the
width
,height
, andcalc_pixel
fields ofIS31FL3731
should not change at runtime. This makes them prime candidates for compile-time, type-level configuration, which could save about six bytes of RAM at runtime.My proposed solution involves adding another generic parameter to
IS31FL3731
. This parameter would take a type that implements theMatrixLayout
trait, which would look something like the following:The
Intensity
type would, in turn, implement the following trait:Intensity
would then be implemented for bothu8
(for monochrome displays) and an RGB type (probably eitherstruct Rgb { r: u8, g: u8, b: u8 }
or[u8; 3]
).The final implementation of
pixel
would look something like the following:For monochrome displays,
pixel
would be called with a plainu8
as in the current API. For RGB displays, it would be called with the RGB intensity type.The text was updated successfully, but these errors were encountered: