(
go_sleeping: bool,
state: &mut C1MinimalState,
_delay: &mut Delay,
ws2812: &mut impl SmartLedsWrite<Color = RGB8, Error = ()>,
)
| 170 | } |
| 171 | |
| 172 | fn handle_sleep( |
| 173 | go_sleeping: bool, |
| 174 | state: &mut C1MinimalState, |
| 175 | _delay: &mut Delay, |
| 176 | ws2812: &mut impl SmartLedsWrite<Color = RGB8, Error = ()>, |
| 177 | ) { |
| 178 | match (state.sleeping.clone(), go_sleeping) { |
| 179 | (SimpleSleepState::Awake, false) => (), |
| 180 | (SimpleSleepState::Awake, true) => { |
| 181 | state.sleeping = SimpleSleepState::Sleeping; |
| 182 | |
| 183 | // Turn off LED |
| 184 | ws2812.write([colors::BLACK].iter().cloned()).unwrap(); |
| 185 | } |
| 186 | (SimpleSleepState::Sleeping, true) => (), |
| 187 | (SimpleSleepState::Sleeping, false) => { |
| 188 | state.sleeping = SimpleSleepState::Awake; |
| 189 | |
| 190 | // Turn LED back on |
| 191 | ws2812 |
| 192 | .write(smart_leds::brightness( |
| 193 | [state.color].iter().cloned(), |
| 194 | state.brightness, |
| 195 | )) |
| 196 | .unwrap(); |
| 197 | } |
| 198 | } |
| 199 | } |
no test coverage detected