71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
#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();
|
||
}
|