File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,23 @@ impl<I2C, I2cError> IS31FL3741<I2C>
26
26
where
27
27
I2C : Write < Error = I2cError > ,
28
28
{
29
+ /// Fill all pixels of the display at once. The brightness should range from 0 to 255.
30
+ pub fn fill_matrix ( & mut self , brightnesses : & [ u8 ] ) -> Result < ( ) , I2cError > {
31
+
32
+ // Extend by one, to add address to the beginning
33
+ let mut buf = [ 0x00 ; 0xB5 ] ;
34
+ buf[ 0 ] = 0x00 ; // set the initial address
35
+
36
+ buf[ 1 ..=0xB4 ] . copy_from_slice ( & brightnesses[ ..=0xB3 ] ) ;
37
+ self . bank ( Page :: Pwm1 ) ?;
38
+ self . write ( & buf) ?;
39
+
40
+ buf[ 1 ..=0xAB ] . copy_from_slice ( & brightnesses[ 0xB4 ..=0xB4 +0xAA ] ) ;
41
+ self . bank ( Page :: Pwm2 ) ?;
42
+ self . write ( & buf[ ..=0xAA ] ) ?;
43
+ Ok ( ( ) )
44
+ }
45
+
29
46
/// Fill the display with a single brightness. The brightness should range from 0 to 255.
30
47
pub fn fill ( & mut self , brightness : u8 ) -> Result < ( ) , I2cError > {
31
48
self . bank ( Page :: Pwm1 ) ?;
You can’t perform that action at this time.
0 commit comments