MCPcopy Index your code
hub / github.com/FrameworkComputer/inputmodule-rs / handle_sleep

Function handle_sleep

qtpy/src/main.rs:172–199  ·  view source on GitHub ↗
(
    go_sleeping: bool,
    state: &mut C1MinimalState,
    _delay: &mut Delay,
    ws2812: &mut impl SmartLedsWrite<Color = RGB8, Error = ()>,
)

Source from the content-addressed store, hash-verified

170}
171
172fn 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}

Callers 1

mainFunction · 0.70

Calls 2

brightnessFunction · 0.85
unwrapMethod · 0.80

Tested by

no test coverage detected