oleg-02/src/main.cpp
2026-03-30 03:30:06 +03:00

71 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <Arduino.h>
#include "core/display/body/body.h"
#include "core/servo/servo.h"
#include "core/ultrasonic/ultrasonic.h"
#include "core/display/face/face.h"
#include "core/robot_state/robot_state.h"
#include "core/joystick/joystick.h"
#include "core/actuators/actuators.h"
#include "server/web_server.h"
#include "server/ws_server.h"
#include "core/controller/controller.h"
// #include "core/deprecate/ir_input/ir_input.h"
#define TOTAL_STAGES 5
#define DELAY_FOR_STARTUP_CHECKS 1000
void runStartupChecks() {
delay(DELAY_FOR_STARTUP_CHECKS);
// Этап 1: Проверка джойстика
oledSetStage(1, TOTAL_STAGES);
bool joyOk = joyInit();
oledShowMain(joyOk ? "Joystick: OK" : "Joystick: NOT FOUND", "IR: NOT FOUND", "", "");
delay(DELAY_FOR_STARTUP_CHECKS);
// TODO: Этап 2-5 (другие проверки)
oledSetStage(2, TOTAL_STAGES);
delay(DELAY_FOR_STARTUP_CHECKS);
oledSetStage(3, TOTAL_STAGES);
delay(DELAY_FOR_STARTUP_CHECKS);
oledSetStage(4, TOTAL_STAGES);
delay(DELAY_FOR_STARTUP_CHECKS);
oledSetStage(5, TOTAL_STAGES);
delay(DELAY_FOR_STARTUP_CHECKS);
// Все проверки пройдены
oledSetSystemReady(joyOk); // пока только джойстик влияет
}
void setup() {
Serial.begin(115200);
oledInit();
// Запуск проверок
runStartupChecks();
servoInit();
ultrasonicInit();
// faceInit();
actuatorsInit();
webServerInit();
wsInit();
// irInit();
robot.lastCmdMs = millis();
}
void loop() {
webServerLoop();
wsLoop();
joyUpdate();
controllerUpdate();
// irPoll();
}