@@ -124,7 +124,7 @@ where
124
124
DI : DisplayInterface ,
125
125
{
126
126
/// Clear the display and reset the cursor to the top left corner
127
- pub fn clear ( & mut self ) -> Result < ( ) , ( ) > {
127
+ pub fn clear ( & mut self ) -> Result < ( ) , DI :: Error > {
128
128
let display_size = self . properties . get_size ( ) ;
129
129
130
130
let numchars = match display_size {
@@ -151,16 +151,20 @@ where
151
151
}
152
152
153
153
/// Reset display
154
- pub fn reset < RST , DELAY > ( & mut self , rst : & mut RST , delay : & mut DELAY )
155
- where
156
- RST : OutputPin ,
157
- DELAY : DelayMs < u8 > ,
154
+ pub fn reset < RST , DELAY , PinE > (
155
+ & mut self ,
156
+ rst : & mut RST ,
157
+ delay : & mut DELAY ,
158
+ ) -> Result < ( ) , Error < ( ) , PinE > >
159
+ where
160
+ RST : OutputPin < Error = PinE > ,
161
+ DELAY : DelayMs < u8 > ,
158
162
{
159
- rst. set_high ( ) ;
163
+ rst. set_high ( ) . map_err ( Error :: Pin ) ? ;
160
164
delay. delay_ms ( 1 ) ;
161
- rst. set_low ( ) ;
165
+ rst. set_low ( ) . map_err ( Error :: Pin ) ? ;
162
166
delay. delay_ms ( 10 ) ;
163
- rst. set_high ( ) ;
167
+ rst. set_high ( ) . map_err ( Error :: Pin )
164
168
}
165
169
166
170
/// Write out data to display. This is a noop in terminal mode.
@@ -169,7 +173,7 @@ where
169
173
}
170
174
171
175
/// Print a character to the display
172
- pub fn print_char ( & mut self , c : char ) -> Result < ( ) , ( ) > {
176
+ pub fn print_char ( & mut self , c : char ) -> Result < ( ) , DI :: Error > {
173
177
match c {
174
178
'\n' => {
175
179
let CursorWrapEvent ( new_line) = self . ensure_cursor ( ) ?. advance_line ( ) ;
@@ -195,18 +199,24 @@ where
195
199
/// Initialise the display in page mode (i.e. a byte walks down a column of 8 pixels) with
196
200
/// column 0 on the left and column _(display_width - 1)_ on the right, but no automatic line
197
201
/// wrapping.
198
- pub fn init ( & mut self ) -> Result < ( ) , ( ) > {
202
+ pub fn init ( & mut self ) -> Result < ( ) , DI :: Error > {
199
203
self . properties . init_with_mode ( AddrMode :: Page ) ?;
200
204
self . reset_pos ( ) ?;
201
205
Ok ( ( ) )
202
206
}
203
207
204
208
/// Set the display rotation
205
- pub fn set_rotation ( & mut self , rot : DisplayRotation ) -> Result < ( ) , ( ) > {
209
+ pub fn set_rotation ( & mut self , rot : DisplayRotation ) -> Result < ( ) , DI :: Error > {
206
210
// we don't need to touch the cursor because rotating 90º or 270º currently just flips
207
211
self . properties . set_rotation ( rot)
208
212
}
209
213
214
+ /// Turn the display on or off. The display can be drawn to and retains all
215
+ /// of its memory even while off.
216
+ pub fn display_on ( & mut self , on : bool ) -> Result < ( ) , DI :: Error > {
217
+ self . properties . display_on ( on)
218
+ }
219
+
210
220
/// Get the current cursor position, in character coordinates.
211
221
/// This is the (column, row) that the next character will be written to.
212
222
pub fn get_position ( & self ) -> Result < ( u8 , u8 ) , ( ) > {
0 commit comments