#include <Arduino.h>
#include "config.h"
#include "buttons.h"
#include "display.h"
#include "sd_manager.h"
#include "motion.h"
#include "pen.h"
#include "ui.h"
#include "uart_mode.h"

void setup() {
    Serial.begin(115200);

    buttons_init();
    display_init();
    display_show_splash();

    motion_init();
    pen_init();

    display_show_homing();
    motion_home();

    ui_init();  // startuje w MAIN_MENU
}

void loop() {
    motion_run();
    ui_update();

    if (ui_get_state() == AppState::PRINTING && motion_is_idle()) {
        ui_on_motion_idle();
    }
}
