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

Function handle_command

fl16-inputmodules/src/control.rs:512–637  ·  view source on GitHub ↗
(
    command: &Command,
    state: &mut LedmatrixState,
    matrix: &mut Foo,
    random: u8,
)

Source from the content-addressed store, hash-verified

510
511#[cfg(feature = "ledmatrix")]
512pub fn handle_command(
513 command: &Command,
514 state: &mut LedmatrixState,
515 matrix: &mut Foo,
516 random: u8,
517) -> Option<[u8; 32]> {
518 use crate::games::game_of_life;
519
520 match command {
521 Command::GetBrightness => {
522 let mut response: [u8; 32] = [0; 32];
523 response[0] = state.brightness;
524 Some(response)
525 }
526 Command::SetBrightness(br) => {
527 //let _ = serial.write("Brightness".as_bytes());
528 set_brightness(state, *br, matrix);
529 None
530 }
531 Command::Percentage(p) => {
532 //let p = if count >= 5 { buf[4] } else { 100 };
533 state.grid = percentage(*p as u16);
534 None
535 }
536 Command::Pattern(pattern) => {
537 //let _ = serial.write("Pattern".as_bytes());
538 match pattern {
539 PatternVals::Gradient => state.grid = gradient(),
540 PatternVals::DoubleGradient => state.grid = double_gradient(),
541 PatternVals::DisplayLotus => state.grid = display_lotus(),
542 PatternVals::ZigZag => state.grid = zigzag(),
543 PatternVals::FullBrightness => {
544 state.grid = percentage(100);
545 set_brightness(state, BRIGHTNESS_LEVELS, matrix);
546 }
547 PatternVals::DisplayPanic => state.grid = display_panic(),
548 PatternVals::DisplayLotus2 => state.grid = display_lotus2(),
549 _ => {}
550 }
551 None
552 }
553 Command::SetAnimate(a) => {
554 state.animate = *a;
555 None
556 }
557 Command::GetAnimate => {
558 let mut response: [u8; 32] = [0; 32];
559 response[0] = state.animate as u8;
560 Some(response)
561 }
562 Command::Draw(vals) => {
563 state.grid = draw(vals);
564 None
565 }
566 Command::StageGreyCol(col, vals) => {
567 draw_grey_col(&mut state.col_buffer, *col, vals);
568 None
569 }

Callers 4

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 15

set_brightnessFunction · 0.85
gradientFunction · 0.85
double_gradientFunction · 0.85
display_lotusFunction · 0.85
zigzagFunction · 0.85
display_panicFunction · 0.85
display_lotus2Function · 0.85
drawFunction · 0.85
draw_grey_colFunction · 0.85
handle_generic_commandFunction · 0.85
clear_textFunction · 0.85
draw_textFunction · 0.85

Tested by

no test coverage detected