diff --git a/src/core/display/body/body.cpp b/src/core/display/body/body.cpp index 7049cf8..f3a92c7 100644 --- a/src/core/display/body/body.cpp +++ b/src/core/display/body/body.cpp @@ -18,6 +18,72 @@ static Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); +// ===== Main Display ===== + +static int currentStage = 0; +static int totalStages = 0; + +static void drawHeader() { + // Заголовок (инверсия) + display.fillRect(0, 0, SCREEN_WIDTH, 16, SSD1306_WHITE); + display.setTextColor(SSD1306_BLACK); + display.setCursor(2, 4); + display.setTextSize(1); + display.print(ROBOT_NAME); + + // Этапы (правый угол) + if (totalStages > 0) { + char stageStr[8]; + snprintf(stageStr, sizeof(stageStr), "%d/%d", currentStage, totalStages); + int textWidth = strlen(stageStr) * 6; // ~6px на символ + display.setCursor(SCREEN_WIDTH - textWidth - 2, 4); + display.print(stageStr); + } +} + +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); +} + +void oledSetStage(int current, int total) { + currentStage = current; + totalStages = total; +} + +void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4) { + display.clearDisplay(); + + // Заголовок + drawHeader(); + + // Основной контент (4 строки) + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 20); + if (line1) display.println(line1); + display.setCursor(0, 30); + if (line2) display.println(line2); + display.setCursor(0, 40); + if (line3) display.println(line3); + display.setCursor(0, 50); + if (line4) display.println(line4); + + // Подвал + drawFooter(); + + display.display(); +} + + void oledInit() { Wire.begin(SDA_PIN, SCL_PIN); @@ -38,45 +104,85 @@ void oledInit() { void oledShowBoot() { display.clearDisplay(); - display.setCursor(0, 10); + + // Заголовок + drawHeader(); + + // Контент + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 25); display.setTextSize(1); display.println("Robot booting"); - display.setCursor(0, 25); + display.setCursor(0, 35); display.println("Please wait..."); + + // Подвал + drawFooter(); + display.display(); } void oledShowWiFi(const char* ssid, int rssi) { display.clearDisplay(); - display.setCursor(0, 10); + + // Заголовок + drawHeader(); + + // Контент + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 25); display.setTextSize(1); - display.print("WiFi: "); + display.print("SSID: "); display.println(ssid); - display.setCursor(0, 30); + display.setCursor(0, 35); display.print("RSSI: "); display.print(rssi); display.println(" dBm"); + + // Подвал + drawFooter(); + display.display(); } void oledShowMode(const char* mode) { display.clearDisplay(); - display.setCursor(0, 10); + + // Заголовок + drawHeader(); + + // Контент + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 25); display.setTextSize(1); display.print("MODE: "); display.println(mode); - display.setCursor(0, 30); + display.setCursor(0, 35); display.println("Ready"); + + // Подвал + drawFooter(); + display.display(); } void oledShowText(const char* line1, const char* line2) { display.clearDisplay(); - display.setCursor(0, 10); + + // Заголовок + drawHeader(); + + // Контент + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 25); display.setTextSize(1); display.println(line1); - display.setCursor(0, 30); + display.setCursor(0, 35); display.println(line2); + + // Подвал + drawFooter(); + display.display(); } diff --git a/src/core/display/body/body.h b/src/core/display/body/body.h index 9deaa23..29ec566 100644 --- a/src/core/display/body/body.h +++ b/src/core/display/body/body.h @@ -12,3 +12,7 @@ void oledShowText(const char* line1, const char* line2); // калибровка void oledShowCalibration(); + +// основная отрисовка +void oledSetStage(int current, int total); +void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4);