|
33 | 33 | //! known by the display controller and must be manually set by the user as |
34 | 34 | //! `Builder` settings when the display is initialized. |
35 | 35 | //! |
36 | | -//! To make it easier to identify the correct settings the `mipidsi` crate |
| 36 | +//! To make it easier to identify the correct settings the `lcd-async` crate |
37 | 37 | //! provides a [`TestImage`](crate::TestImage), which can be used to verify the |
38 | 38 | //! color settings and adjust them in case they are incorrect. |
39 | 39 | //! |
40 | 40 | //! ``` |
41 | 41 | //! use embedded_graphics::prelude::*; |
42 | | -//! use mipidsi::{Builder, TestImage, models::ILI9486Rgb666}; |
43 | | -//! |
44 | | -//! # let di = mipidsi::_mock::MockDisplayInterface; |
45 | | -//! # let rst = mipidsi::_mock::MockOutputPin; |
46 | | -//! # let mut delay = mipidsi::_mock::MockDelay; |
47 | | -//! let mut display = Builder::new(ILI9486Rgb666, di) |
| 42 | +//! use embedded_graphics::pixelcolor::Rgb565; |
| 43 | +//! use lcd_async::{Builder, TestImage, models::ILI9341Rgb565, raw_framebuf::RawFrameBuf}; |
| 44 | +//! |
| 45 | +//! # tokio_test::block_on(async { |
| 46 | +//! # let di = lcd_async::_mock::MockDisplayInterface; |
| 47 | +//! # let rst = lcd_async::_mock::MockOutputPin; |
| 48 | +//! # let mut delay = lcd_async::_mock::MockDelay; |
| 49 | +//! let mut display = Builder::new(ILI9341Rgb565, di) |
48 | 50 | //! .reset_pin(rst) |
49 | 51 | //! .init(&mut delay) |
50 | | -//! .unwrap();; |
| 52 | +//! .await |
| 53 | +//! .unwrap(); |
| 54 | +//! |
| 55 | +//! // Create framebuffer for drawing |
| 56 | +//! const WIDTH: usize = 240; |
| 57 | +//! const HEIGHT: usize = 320; |
| 58 | +//! let mut buffer = [0u8; WIDTH * HEIGHT * 2]; // 2 bytes per pixel for RGB565 |
| 59 | +//! let mut framebuf = RawFrameBuf::<Rgb565, _>::new(&mut buffer[..], WIDTH, HEIGHT); |
| 60 | +//! |
| 61 | +//! // Draw test image to framebuffer |
| 62 | +//! TestImage::new().draw(&mut framebuf)?; |
| 63 | +//! |
| 64 | +//! // IMPORTANT: After drawing to the framebuffer, you must send it to the display! |
| 65 | +//! // This is the key step that actually updates the screen. |
| 66 | +//! // display.show_raw_data(0, 0, WIDTH as u16, HEIGHT as u16, &buffer).await.unwrap(); |
51 | 67 | //! |
52 | | -//! TestImage::new().draw(&mut display)?; |
| 68 | +//! // For a complete working example, see: examples/spi-st7789-esp32-c3/src/main.rs |
53 | 69 | //! # Ok::<(), core::convert::Infallible>(()) |
| 70 | +//! # }); |
54 | 71 | //! ``` |
55 | 72 | //! |
56 | 73 | //! The expected output from drawing the test image is: |
|
67 | 84 | //! |
68 | 85 | //! ``` |
69 | 86 | //! # use embedded_graphics::prelude::*; |
70 | | -//! # use mipidsi::{Builder, TestImage, models::ILI9486Rgb666}; |
| 87 | +//! # use embedded_graphics::pixelcolor::Rgb565; |
| 88 | +//! # use lcd_async::{Builder, TestImage, models::ILI9341Rgb565, raw_framebuf::RawFrameBuf}; |
71 | 89 | //! # |
72 | | -//! # let di = mipidsi::_mock::MockDisplayInterface; |
73 | | -//! # let mut delay = mipidsi::_mock::MockDelay; |
74 | | -//! # let mut display = Builder::new(ILI9486Rgb666, di) |
75 | | -//! .color_order(mipidsi::options::ColorOrder::Bgr) |
76 | | -//! # .init(&mut delay).unwrap(); |
| 90 | +//! # tokio_test::block_on(async { |
| 91 | +//! # let di = lcd_async::_mock::MockDisplayInterface; |
| 92 | +//! # let mut delay = lcd_async::_mock::MockDelay; |
| 93 | +//! # let mut display = Builder::new(ILI9341Rgb565, di) |
| 94 | +//! .color_order(lcd_async::options::ColorOrder::Bgr) |
| 95 | +//! # .init(&mut delay).await.unwrap(); |
| 96 | +//! # }); |
77 | 97 | //! ``` |
78 | 98 | //! |
79 | 99 | //! ### Wrong color inversion |
|
82 | 102 | //! |
83 | 103 | //! ``` |
84 | 104 | //! # use embedded_graphics::prelude::*; |
85 | | -//! # use mipidsi::{Builder, TestImage, models::ILI9486Rgb666}; |
| 105 | +//! # use embedded_graphics::pixelcolor::Rgb565; |
| 106 | +//! # use lcd_async::{Builder, TestImage, models::ILI9341Rgb565, raw_framebuf::RawFrameBuf}; |
86 | 107 | //! # |
87 | | -//! # let di = mipidsi::_mock::MockDisplayInterface; |
88 | | -//! # let mut delay = mipidsi::_mock::MockDelay; |
89 | | -//! # let mut display = Builder::new(ILI9486Rgb666, di) |
90 | | -//! .invert_colors(mipidsi::options::ColorInversion::Inverted) |
91 | | -//! # .init(&mut delay).unwrap(); |
| 108 | +//! # tokio_test::block_on(async { |
| 109 | +//! # let di = lcd_async::_mock::MockDisplayInterface; |
| 110 | +//! # let mut delay = lcd_async::_mock::MockDelay; |
| 111 | +//! # let mut display = Builder::new(ILI9341Rgb565, di) |
| 112 | +//! .invert_colors(lcd_async::options::ColorInversion::Inverted) |
| 113 | +//! # .init(&mut delay).await.unwrap(); |
| 114 | +//! # }); |
92 | 115 | //! ``` |
93 | 116 | //! |
94 | 117 | //! ### Wrong subpixel order and color inversion |
|
97 | 120 | //! |
98 | 121 | //! ``` |
99 | 122 | //! # use embedded_graphics::prelude::*; |
100 | | -//! # use mipidsi::{Builder, TestImage, models::ILI9486Rgb666}; |
| 123 | +//! # use embedded_graphics::pixelcolor::Rgb565; |
| 124 | +//! # use lcd_async::{Builder, TestImage, models::ILI9341Rgb565, raw_framebuf::RawFrameBuf}; |
101 | 125 | //! # |
102 | | -//! # let di = mipidsi::_mock::MockDisplayInterface; |
103 | | -//! # let mut delay = mipidsi::_mock::MockDelay; |
104 | | -//! # let mut display = Builder::new(ILI9486Rgb666, di) |
105 | | -//! .color_order(mipidsi::options::ColorOrder::Bgr) |
106 | | -//! .invert_colors(mipidsi::options::ColorInversion::Inverted) |
107 | | -//! # .init(&mut delay).unwrap(); |
| 126 | +//! # tokio_test::block_on(async { |
| 127 | +//! # let di = lcd_async::_mock::MockDisplayInterface; |
| 128 | +//! # let mut delay = lcd_async::_mock::MockDelay; |
| 129 | +//! # let mut display = Builder::new(ILI9341Rgb565, di) |
| 130 | +//! .color_order(lcd_async::options::ColorOrder::Bgr) |
| 131 | +//! .invert_colors(lcd_async::options::ColorInversion::Inverted) |
| 132 | +//! # .init(&mut delay).await.unwrap(); |
| 133 | +//! # }); |
108 | 134 | //! ``` |
0 commit comments