new design
This commit is contained in:
parent
8bbdef87ec
commit
c06794458c
@ -18,6 +18,72 @@
|
|||||||
|
|
||||||
static Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
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() {
|
void oledInit() {
|
||||||
Wire.begin(SDA_PIN, SCL_PIN);
|
Wire.begin(SDA_PIN, SCL_PIN);
|
||||||
|
|
||||||
@ -38,45 +104,85 @@ void oledInit() {
|
|||||||
|
|
||||||
void oledShowBoot() {
|
void oledShowBoot() {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, 10);
|
|
||||||
|
// Заголовок
|
||||||
|
drawHeader();
|
||||||
|
|
||||||
|
// Контент
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 25);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.println("Robot booting");
|
display.println("Robot booting");
|
||||||
display.setCursor(0, 25);
|
display.setCursor(0, 35);
|
||||||
display.println("Please wait...");
|
display.println("Please wait...");
|
||||||
|
|
||||||
|
// Подвал
|
||||||
|
drawFooter();
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void oledShowWiFi(const char* ssid, int rssi) {
|
void oledShowWiFi(const char* ssid, int rssi) {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, 10);
|
|
||||||
|
// Заголовок
|
||||||
|
drawHeader();
|
||||||
|
|
||||||
|
// Контент
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 25);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.print("WiFi: ");
|
display.print("SSID: ");
|
||||||
display.println(ssid);
|
display.println(ssid);
|
||||||
display.setCursor(0, 30);
|
display.setCursor(0, 35);
|
||||||
display.print("RSSI: ");
|
display.print("RSSI: ");
|
||||||
display.print(rssi);
|
display.print(rssi);
|
||||||
display.println(" dBm");
|
display.println(" dBm");
|
||||||
|
|
||||||
|
// Подвал
|
||||||
|
drawFooter();
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void oledShowMode(const char* mode) {
|
void oledShowMode(const char* mode) {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, 10);
|
|
||||||
|
// Заголовок
|
||||||
|
drawHeader();
|
||||||
|
|
||||||
|
// Контент
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 25);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.print("MODE: ");
|
display.print("MODE: ");
|
||||||
display.println(mode);
|
display.println(mode);
|
||||||
display.setCursor(0, 30);
|
display.setCursor(0, 35);
|
||||||
display.println("Ready");
|
display.println("Ready");
|
||||||
|
|
||||||
|
// Подвал
|
||||||
|
drawFooter();
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void oledShowText(const char* line1, const char* line2) {
|
void oledShowText(const char* line1, const char* line2) {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, 10);
|
|
||||||
|
// Заголовок
|
||||||
|
drawHeader();
|
||||||
|
|
||||||
|
// Контент
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 25);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.println(line1);
|
display.println(line1);
|
||||||
display.setCursor(0, 30);
|
display.setCursor(0, 35);
|
||||||
display.println(line2);
|
display.println(line2);
|
||||||
|
|
||||||
|
// Подвал
|
||||||
|
drawFooter();
|
||||||
|
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,3 +12,7 @@ void oledShowText(const char* line1, const char* line2);
|
|||||||
|
|
||||||
// калибровка
|
// калибровка
|
||||||
void oledShowCalibration();
|
void oledShowCalibration();
|
||||||
|
|
||||||
|
// основная отрисовка
|
||||||
|
void oledSetStage(int current, int total);
|
||||||
|
void oledShowMain(const char* line1, const char* line2, const char* line3, const char* line4);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user