add menu type
This commit is contained in:
parent
c06794458c
commit
84827216c1
@ -21,7 +21,8 @@ static Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
|||||||
// ===== Main Display =====
|
// ===== Main Display =====
|
||||||
|
|
||||||
static int currentStage = 0;
|
static int currentStage = 0;
|
||||||
static int totalStages = 0;
|
static int totalStages = 5;
|
||||||
|
static bool systemReady = false;
|
||||||
|
|
||||||
static void drawHeader() {
|
static void drawHeader() {
|
||||||
// Заголовок (инверсия)
|
// Заголовок (инверсия)
|
||||||
@ -31,8 +32,8 @@ static void drawHeader() {
|
|||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.print(ROBOT_NAME);
|
display.print(ROBOT_NAME);
|
||||||
|
|
||||||
// Этапы (правый угол)
|
// Этапы (правый угол) - только если система не готова
|
||||||
if (totalStages > 0) {
|
if (!systemReady && totalStages > 0) {
|
||||||
char stageStr[8];
|
char stageStr[8];
|
||||||
snprintf(stageStr, sizeof(stageStr), "%d/%d", currentStage, totalStages);
|
snprintf(stageStr, sizeof(stageStr), "%d/%d", currentStage, totalStages);
|
||||||
int textWidth = strlen(stageStr) * 6; // ~6px на символ
|
int textWidth = strlen(stageStr) * 6; // ~6px на символ
|
||||||
@ -42,24 +43,39 @@ static void drawHeader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void drawFooter() {
|
static void drawFooter() {
|
||||||
// Нижняя строка (резерв под кнопки)
|
// Нижняя строка (разделитель)
|
||||||
// display.drawLine(0, SCREEN_HEIGHT - 12, SCREEN_WIDTH, SCREEN_HEIGHT - 12, SSD1306_WHITE);
|
// display.drawLine(0, SCREEN_HEIGHT - 12, SCREEN_WIDTH, SCREEN_HEIGHT - 12, SSD1306_WHITE);
|
||||||
|
|
||||||
// Версия (правый угол)
|
|
||||||
display.setTextColor(SSD1306_WHITE);
|
display.setTextColor(SSD1306_WHITE);
|
||||||
display.setCursor(0, SCREEN_HEIGHT - 10);
|
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
|
|
||||||
|
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;
|
int textWidth = strlen(FIRMWARE_VERSION) * 6;
|
||||||
display.setCursor(SCREEN_WIDTH - textWidth - 2, SCREEN_HEIGHT - 10);
|
display.setCursor(SCREEN_WIDTH - textWidth - 2, SCREEN_HEIGHT - 10);
|
||||||
display.print(FIRMWARE_VERSION);
|
display.print(FIRMWARE_VERSION);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void oledSetStage(int current, int total) {
|
void oledSetStage(int current, int total) {
|
||||||
currentStage = current;
|
currentStage = current;
|
||||||
totalStages = 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) {
|
void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4) {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
|
|
||||||
|
|||||||
@ -16,3 +16,7 @@ void oledShowCalibration();
|
|||||||
// основная отрисовка
|
// основная отрисовка
|
||||||
void oledSetStage(int current, int total);
|
void oledSetStage(int current, int total);
|
||||||
void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4);
|
void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4);
|
||||||
|
|
||||||
|
// состояние системы
|
||||||
|
void oledSetSystemReady(bool ready);
|
||||||
|
bool oledIsSystemReady();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user