@@ -72,28 +72,25 @@ pub use crate::epd1in54::graphics::Display1in54;
72
72
73
73
/// EPD1in54 driver
74
74
///
75
- pub struct EPD1in54 < SPI , CS , BUSY , DC , RST > {
75
+ pub struct EPD1in54 < SPI , CS , BUSY , DC , RST , DELAY > {
76
76
/// SPI
77
- interface : DisplayInterface < SPI , CS , BUSY , DC , RST > ,
77
+ interface : DisplayInterface < SPI , CS , BUSY , DC , RST , DELAY > ,
78
78
/// Color
79
79
background_color : Color ,
80
80
/// Refresh LUT
81
81
refresh : RefreshLUT ,
82
82
}
83
83
84
- impl < SPI , CS , BUSY , DC , RST > EPD1in54 < SPI , CS , BUSY , DC , RST >
84
+ impl < SPI , CS , BUSY , DC , RST , DELAY > EPD1in54 < SPI , CS , BUSY , DC , RST , DELAY >
85
85
where
86
86
SPI : Write < u8 > ,
87
87
CS : OutputPin ,
88
88
BUSY : InputPin ,
89
89
DC : OutputPin ,
90
90
RST : OutputPin ,
91
+ DELAY : DelayMs < u8 > ,
91
92
{
92
- fn init < DELAY : DelayMs < u8 > > (
93
- & mut self ,
94
- spi : & mut SPI ,
95
- delay : & mut DELAY ,
96
- ) -> Result < ( ) , SPI :: Error > {
93
+ fn init ( & mut self , spi : & mut SPI , delay : & mut DELAY ) -> Result < ( ) , SPI :: Error > {
97
94
self . interface . reset ( delay, 10 ) ;
98
95
99
96
// 3 Databytes:
@@ -142,14 +139,15 @@ where
142
139
}
143
140
}
144
141
145
- impl < SPI , CS , BUSY , DC , RST , E > WaveshareDisplay < SPI , CS , BUSY , DC , RST >
146
- for EPD1in54 < SPI , CS , BUSY , DC , RST >
142
+ impl < SPI , CS , BUSY , DC , RST , DELAY , E > WaveshareDisplay < SPI , CS , BUSY , DC , RST , DELAY >
143
+ for EPD1in54 < SPI , CS , BUSY , DC , RST , DELAY >
147
144
where
148
145
SPI : Write < u8 , Error = E > ,
149
146
CS : OutputPin ,
150
147
BUSY : InputPin ,
151
148
DC : OutputPin ,
152
149
RST : OutputPin ,
150
+ DELAY : DelayMs < u8 > ,
153
151
{
154
152
type DisplayColor = Color ;
155
153
fn width ( & self ) -> u32 {
@@ -160,7 +158,7 @@ where
160
158
HEIGHT
161
159
}
162
160
163
- fn new < DELAY : DelayMs < u8 > > (
161
+ fn new (
164
162
spi : & mut SPI ,
165
163
cs : CS ,
166
164
busy : BUSY ,
@@ -181,15 +179,11 @@ where
181
179
Ok ( epd)
182
180
}
183
181
184
- fn wake_up < DELAY : DelayMs < u8 > > (
185
- & mut self ,
186
- spi : & mut SPI ,
187
- delay : & mut DELAY ,
188
- ) -> Result < ( ) , SPI :: Error > {
182
+ fn wake_up ( & mut self , spi : & mut SPI , delay : & mut DELAY ) -> Result < ( ) , SPI :: Error > {
189
183
self . init ( spi, delay)
190
184
}
191
185
192
- fn sleep ( & mut self , spi : & mut SPI ) -> Result < ( ) , SPI :: Error > {
186
+ fn sleep ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , SPI :: Error > {
193
187
self . wait_until_idle ( ) ;
194
188
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
195
189
//TODO: is 0x00 needed here or would 0x01 be even more efficient?
@@ -198,7 +192,12 @@ where
198
192
Ok ( ( ) )
199
193
}
200
194
201
- fn update_frame ( & mut self , spi : & mut SPI , buffer : & [ u8 ] ) -> Result < ( ) , SPI :: Error > {
195
+ fn update_frame (
196
+ & mut self ,
197
+ spi : & mut SPI ,
198
+ buffer : & [ u8 ] ,
199
+ _delay : & mut DELAY ,
200
+ ) -> Result < ( ) , SPI :: Error > {
202
201
self . wait_until_idle ( ) ;
203
202
self . use_full_frame ( spi) ?;
204
203
self . interface
@@ -225,7 +224,7 @@ where
225
224
Ok ( ( ) )
226
225
}
227
226
228
- fn display_frame ( & mut self , spi : & mut SPI ) -> Result < ( ) , SPI :: Error > {
227
+ fn display_frame ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , SPI :: Error > {
229
228
self . wait_until_idle ( ) ;
230
229
// enable clock signal, enable cp, display pattern -> 0xC4 (tested with the arduino version)
231
230
//TODO: test control_1 or control_2 with default value 0xFF (from the datasheet)
@@ -239,13 +238,18 @@ where
239
238
Ok ( ( ) )
240
239
}
241
240
242
- fn update_and_display_frame ( & mut self , spi : & mut SPI , buffer : & [ u8 ] ) -> Result < ( ) , SPI :: Error > {
243
- self . update_frame ( spi, buffer) ?;
244
- self . display_frame ( spi) ?;
241
+ fn update_and_display_frame (
242
+ & mut self ,
243
+ spi : & mut SPI ,
244
+ buffer : & [ u8 ] ,
245
+ delay : & mut DELAY ,
246
+ ) -> Result < ( ) , SPI :: Error > {
247
+ self . update_frame ( spi, buffer, delay) ?;
248
+ self . display_frame ( spi, delay) ?;
245
249
Ok ( ( ) )
246
250
}
247
251
248
- fn clear_frame ( & mut self , spi : & mut SPI ) -> Result < ( ) , SPI :: Error > {
252
+ fn clear_frame ( & mut self , spi : & mut SPI , _delay : & mut DELAY ) -> Result < ( ) , SPI :: Error > {
249
253
self . wait_until_idle ( ) ;
250
254
self . use_full_frame ( spi) ?;
251
255
@@ -285,16 +289,17 @@ where
285
289
}
286
290
}
287
291
288
- impl < SPI , CS , BUSY , DC , RST > EPD1in54 < SPI , CS , BUSY , DC , RST >
292
+ impl < SPI , CS , BUSY , DC , RST , DELAY > EPD1in54 < SPI , CS , BUSY , DC , RST , DELAY >
289
293
where
290
294
SPI : Write < u8 > ,
291
295
CS : OutputPin ,
292
296
BUSY : InputPin ,
293
297
DC : OutputPin ,
294
298
RST : OutputPin ,
299
+ DELAY : DelayMs < u8 > ,
295
300
{
296
301
fn wait_until_idle ( & mut self ) {
297
- self . interface . wait_until_idle ( IS_BUSY_LOW ) ;
302
+ let _ = self . interface . wait_until_idle ( IS_BUSY_LOW , None ) ;
298
303
}
299
304
300
305
pub ( crate ) fn use_full_frame ( & mut self , spi : & mut SPI ) -> Result < ( ) , SPI :: Error > {
0 commit comments