File tree Expand file tree Collapse file tree 1 file changed +24
-12
lines changed Expand file tree Collapse file tree 1 file changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -178,8 +178,6 @@ fn main() -> ! {
178
178
// INTB. Currently ignoring
179
179
pins. intb . into_floating_input ( ) ;
180
180
181
- let sleep = pins. sleep . into_pull_down_input ( ) ;
182
-
183
181
let i2c = bsp:: hal:: I2C :: i2c1 (
184
182
pac. I2C1 ,
185
183
pins. gpio26 . into_mode :: < gpio:: FunctionI2C > ( ) ,
@@ -216,17 +214,31 @@ fn main() -> ! {
216
214
217
215
let mut startup_percentage = Some ( 0 ) ;
218
216
217
+ // Detect whether the sleep pin is connected
218
+ // Early revisions of the hardware didn't have it wired up, if that is the
219
+ // case we have to ignore its state.
220
+ let mut sleep_present = false ;
221
+ let sleep = pins. sleep . into_pull_up_input ( ) ;
222
+ if sleep. is_low ( ) . unwrap ( ) {
223
+ sleep_present = true ;
224
+ }
225
+ let sleep = sleep. into_pull_down_input ( ) ;
226
+ if sleep. is_high ( ) . unwrap ( ) {
227
+ sleep_present = true ;
228
+ }
229
+
219
230
loop {
220
- // TODO: Current hardware revision does not have the sleep pin wired up :(
221
- // Go to sleep if the host is sleeping
222
- let _host_sleeping = sleep. is_low ( ) . unwrap ( ) ;
223
- //handle_sleep(
224
- // host_sleeping,
225
- // &mut state,
226
- // &mut matrix,
227
- // &mut delay,
228
- // &mut led_enable,
229
- //);
231
+ if sleep_present {
232
+ // Go to sleep if the host is sleeping
233
+ let host_sleeping = sleep. is_low ( ) . unwrap ( ) ;
234
+ handle_sleep (
235
+ host_sleeping,
236
+ & mut state,
237
+ & mut matrix,
238
+ & mut delay,
239
+ & mut led_enable,
240
+ ) ;
241
+ }
230
242
231
243
// Handle period display updates. Don't do it too often
232
244
if timer. get_counter ( ) . ticks ( ) > prev_timer + state. animation_period {
You can’t perform that action at this time.
0 commit comments