#[derive(Debug)]
struct RobotState {
    led_on: bool,
    button_count: u32,
    last_adc: u16,
}

fn print_state(state: &RobotState) {
    println!(
        "state => led_on={}, button_count={}, last_adc={}",
        state.led_on, state.button_count, state.last_adc
    );
}

fn toggle_led(state: &mut RobotState) {
    state.led_on = !state.led_on;
}

fn record_button_press(state: &mut RobotState) {
    state.button_count += 1;
}

fn update_adc(state: &mut RobotState, raw: u16) {
    state.last_adc = raw;
}

fn main() {
    let mut state = RobotState {
        led_on: false,
        button_count: 0,
        last_adc: 0,
    };

    print_state(&state);

    toggle_led(&mut state);
    record_button_press(&mut state);
    update_adc(&mut state, 2024);

    print_state(&state);
}
