From 84827216c167f7195f500ad41d8d99218b3790e5 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Mon, 30 Mar 2026 03:06:52 +0300 Subject: [PATCH] add menu type --- src/core/display/body/body.cpp | 36 ++++++++++++++++++++++++---------- src/core/display/body/body.h | 4 ++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/core/display/body/body.cpp b/src/core/display/body/body.cpp index f3a92c7..f73fc02 100644 --- a/src/core/display/body/body.cpp +++ b/src/core/display/body/body.cpp @@ -21,7 +21,8 @@ static Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // ===== Main Display ===== static int currentStage = 0; -static int totalStages = 0; +static int totalStages = 5; +static bool systemReady = false; static void drawHeader() { // Заголовок (инверсия) @@ -30,9 +31,9 @@ static void drawHeader() { display.setCursor(2, 4); display.setTextSize(1); display.print(ROBOT_NAME); - - // Этапы (правый угол) - if (totalStages > 0) { + + // Этапы (правый угол) - только если система не готова + if (!systemReady && totalStages > 0) { char stageStr[8]; snprintf(stageStr, sizeof(stageStr), "%d/%d", currentStage, totalStages); int textWidth = strlen(stageStr) * 6; // ~6px на символ @@ -42,17 +43,24 @@ static void drawHeader() { } static void drawFooter() { - // Нижняя строка (резерв под кнопки) + // Нижняя строка (разделитель) // display.drawLine(0, SCREEN_HEIGHT - 12, SCREEN_WIDTH, SCREEN_HEIGHT - 12, SSD1306_WHITE); - // Версия (правый угол) display.setTextColor(SSD1306_WHITE); - display.setCursor(0, SCREEN_HEIGHT - 10); display.setTextSize(1); - int textWidth = strlen(FIRMWARE_VERSION) * 6; - display.setCursor(SCREEN_WIDTH - textWidth - 2, SCREEN_HEIGHT - 10); - display.print(FIRMWARE_VERSION); + if (systemReady) { + // Кнопка Menu (правый угол) + const char* menuBtn = "[MENU]"; + int textWidth = strlen(menuBtn) * 6; + display.setCursor(SCREEN_WIDTH - textWidth - 2, SCREEN_HEIGHT - 10); + display.print(menuBtn); + } else { + // Версия (правый угол) + int textWidth = strlen(FIRMWARE_VERSION) * 6; + display.setCursor(SCREEN_WIDTH - textWidth - 2, SCREEN_HEIGHT - 10); + display.print(FIRMWARE_VERSION); + } } void oledSetStage(int current, int total) { @@ -60,6 +68,14 @@ void oledSetStage(int current, int total) { totalStages = total; } +void oledSetSystemReady(bool ready) { + systemReady = ready; +} + +bool oledIsSystemReady() { + return systemReady; +} + void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4) { display.clearDisplay(); diff --git a/src/core/display/body/body.h b/src/core/display/body/body.h index 29ec566..fc08320 100644 --- a/src/core/display/body/body.h +++ b/src/core/display/body/body.h @@ -16,3 +16,7 @@ void oledShowCalibration(); // основная отрисовка void oledSetStage(int current, int total); void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4); + +// состояние системы +void oledSetSystemReady(bool ready); +bool oledIsSystemReady();