add menu type

This commit is contained in:
cheykrym 2026-03-30 03:15:42 +03:00
parent 84827216c1
commit e2966de1cc
3 changed files with 50 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <Adafruit_SSD1306.h>
#include "body.h"
#include "../../../config.h"
#include "../../joystick/joystick.h"
// ===== OLED CONFIG =====
// ESP32 ESP-WROOM-32D с OLED 0.96" (SSD1306)
@ -99,6 +100,21 @@ void oledShowMain(const char* line1, const char* line2, const char* line3, const
display.display();
}
// ===== Device Checks =====
bool oledCheckJoystick() {
// Проверяем наличие джойстика по значениям ADC
int x = analogRead(JOY_X_PIN);
int y = analogRead(JOY_Y_PIN);
// Если значения в разумных пределах (не 0 и не 4095) - джойстик подключен
bool connected = (x > 100 && x < 4000) && (y > 100 && y < 4000);
Serial.printf("[CHECK] Joystick: %s (X=%d, Y=%d)\n",
connected ? "OK" : "NOT FOUND", x, y);
return connected;
}
void oledInit() {
Wire.begin(SDA_PIN, SCL_PIN);

View File

@ -20,3 +20,6 @@ void oledShowMain(const char* line1, const char* line2, const char* line3, const
// состояние системы
void oledSetSystemReady(bool ready);
bool oledIsSystemReady();
// проверка устройств
bool oledCheckJoystick();

View File

@ -13,6 +13,34 @@
#include "core/controller/controller.h"
// #include "core/deprecate/ir_input/ir_input.h"
#define TOTAL_STAGES 5
void runStartupChecks() {
// Этап 1: Проверка джойстика
oledSetStage(1, TOTAL_STAGES);
bool joyOk = oledCheckJoystick();
oledShowMain("Checking devices", "Stage 1/5",
joyOk ? "Joystick: OK" : "Joystick: NOT FOUND",
"");
delay(500);
// TODO: Этап 2-5 (другие проверки)
oledSetStage(2, TOTAL_STAGES);
delay(500);
oledSetStage(3, TOTAL_STAGES);
delay(500);
oledSetStage(4, TOTAL_STAGES);
delay(500);
oledSetStage(5, TOTAL_STAGES);
delay(500);
// Все проверки пройдены
oledSetSystemReady(joyOk); // пока только джойстик влияет
}
void setup() {
Serial.begin(115200);
@ -25,6 +53,9 @@ void setup() {
webServerInit();
wsInit();
// irInit();
// Запуск проверок
runStartupChecks();
robot.lastCmdMs = millis();
}