@@ -32,15 +32,17 @@ Load a BMP image of the Rust logo and display it in the center of the display. F
32
32
#![no_std]
33
33
#![no_main]
34
34
35
- use cortex_m_rt :: ExceptionFrame ;
36
- use cortex_m_rt :: {entry, exception};
37
- use embedded_graphics :: {geometry :: Point , image :: ImageBmp , prelude :: * };
35
+ use cortex_m_rt :: {entry, exception, ExceptionFrame };
36
+ use embedded_graphics :: {geometry :: Point , image :: Image , pixelcolor :: Rgb565 , prelude :: * };
38
37
use panic_semihosting as _;
39
- use ssd1331 :: {Ssd1331 , DisplayRotation :: Rotate0 };
40
- use stm32f1xx_hal :: delay :: Delay ;
41
- use stm32f1xx_hal :: prelude :: * ;
42
- use stm32f1xx_hal :: spi :: {Mode , Phase , Polarity , Spi };
43
- use stm32f1xx_hal :: stm32;
38
+ use ssd1331 :: {DisplayRotation , Ssd1331 };
39
+ use stm32f1xx_hal :: {
40
+ delay :: Delay ,
41
+ prelude :: * ,
42
+ spi :: {Mode , Phase , Polarity , Spi },
43
+ stm32,
44
+ };
45
+ use tinybmp :: Bmp ;
44
46
45
47
#[entry]
46
48
fn main () -> ! {
@@ -82,15 +84,17 @@ fn main() -> ! {
82
84
83
85
let (w , h ) = disp . dimensions ();
84
86
85
- let im = ImageBmp :: new (include_bytes! (" ./rust-pride.bmp" )). unwrap ();
87
+ let bmp = Bmp :: from_slice (include_bytes! (" ./rust-pride.bmp" )). unwrap ();
88
+
89
+ let im : Image <Bmp , Rgb565 > = Image :: new (& bmp , Point :: zero ());
86
90
87
91
// Position image in the center of the display
88
92
let moved = im . translate (Point :: new (
89
- (w as u32 - im . width ()) as i32 / 2 ,
90
- (h as u32 - im . height ()) as i32 / 2 ,
93
+ (w as u32 - bmp . width ()) as i32 / 2 ,
94
+ (h as u32 - bmp . height ()) as i32 / 2 ,
91
95
));
92
96
93
- disp . draw (moved . into_iter () );
97
+ moved . draw (& mut disp ) . unwrap ( );
94
98
95
99
disp . flush (). unwrap ();
96
100
@@ -143,9 +147,9 @@ disp.rotation();
143
147
144
148
Licensed under either of
145
149
146
- - Apache License, Version 2.0 ([ LICENSE-APACHE] ( LICENSE-APACHE ) or
147
- http://www.apache.org/licenses/LICENSE-2.0 )
148
- - MIT license ([ LICENSE-MIT] ( LICENSE-MIT ) or http://opensource.org/licenses/MIT )
150
+ - Apache License, Version 2.0 ([ LICENSE-APACHE] ( LICENSE-APACHE ) or
151
+ http://www.apache.org/licenses/LICENSE-2.0 )
152
+ - MIT license ([ LICENSE-MIT] ( LICENSE-MIT ) or http://opensource.org/licenses/MIT )
149
153
150
154
at your option.
151
155
0 commit comments