@@ -9,20 +9,21 @@ SPI (4 wire) driver for the SSD1331 OLED display.
9
9
<!-- See the [announcement blog post](https://wapl.es/electronics/rust/2018/04/30/ssd1331-driver.html) for more information. -->
10
10
11
11
The display is configured by this driver to use a 16 bit, R5 G6 B5 pixel definition.
12
- You can convert images into the correct RAW format with the following commands (assumes 8x8 PNG input) :
12
+ You can convert images into the correct BMP format with the following commands:
13
13
14
14
``` bash
15
- convert ferris.png -flip -type truecolor -define bmp:subtype=RGB565 -depth 16 -strip ferris.bmp
16
-
17
- # Where 128 is (width * height * 2)
18
- tail -c 128 ferris.bmp > ferris.raw
15
+ convert my_image.png -flip -type truecolor -define bmp:subtype=RGB565 -depth 16 -strip my_image.bmp
19
16
```
20
17
18
+ You can also export images directly from The GIMP by saving as ` .bmp ` and choosing the following option:
19
+
20
+ ![ The GIMP RGB565 export option.] ( readme_gimp_export.png?raw=true )
21
+
21
22
## [ Documentation] ( https://docs.rs/ssd1331 )
22
23
23
24
## [ Examples] ( examples )
24
25
25
- From [ ` examples/image .rs ` ] ( examples/image .rs ) :
26
+ Load a BMP and display it in the center of the display. From [ ` examples/bmp .rs ` ] ( examples/bmp .rs ) :
26
27
27
28
``` rust
28
29
#![no_std]
@@ -78,7 +79,12 @@ fn main() -> ! {
78
79
disp . init (). unwrap ();
79
80
disp . flush (). unwrap ();
80
81
81
- let im = Image1BPP :: new (include_bytes! (" ./ferris.raw" ), 86 , 64 ). translate (Coord :: new (5 , 0 ));
82
+ // 16BPP, RGB565-format BMP image
83
+ let im = ImageBmp :: new (include_bytes! (" ./rust-pride.bmp" )). unwrap ();
84
+
85
+ let centered = im . translate (Coord :: new ((96 - im . width () as i32 ) / 2 , 0 ));
86
+
87
+ disp . draw (centered . into_iter ());
82
88
83
89
disp . draw (im . into_iter ());
84
90
disp . flush (). unwrap ();
0 commit comments