add menu type

This commit is contained in:
cheykrym 2026-03-30 03:06:52 +03:00
parent c06794458c
commit 84827216c1
2 changed files with 30 additions and 10 deletions

View File

@ -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();

View File

@ -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();