oled
This commit is contained in:
parent
b7d0ebfe38
commit
e65c347deb
80
src/core/display/body/body.cpp
Normal file
80
src/core/display/body/body.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include "body.h"
|
||||
|
||||
// ===== OLED CONFIG =====
|
||||
// ESP32 ESP-WROOM-32D с OLED 0.96" (SSD1306)
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
#define OLED_RESET -1
|
||||
#define SCREEN_ADDR 0x3C
|
||||
|
||||
// SDA/SCL пины для CH340 с OLED
|
||||
#define SDA_PIN 21
|
||||
#define SCL_PIN 22
|
||||
|
||||
static Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
void oledInit() {
|
||||
Wire.begin(SDA_PIN, SCL_PIN);
|
||||
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDR)) {
|
||||
Serial.println("SSD1306 allocation failed");
|
||||
for (;;);
|
||||
}
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.display();
|
||||
|
||||
oledShowBoot();
|
||||
}
|
||||
|
||||
// ===== Screens =====
|
||||
|
||||
void oledShowBoot() {
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 10);
|
||||
display.setTextSize(1);
|
||||
display.println("Robot booting");
|
||||
display.setCursor(0, 25);
|
||||
display.println("Please wait...");
|
||||
display.display();
|
||||
}
|
||||
|
||||
void oledShowWiFi(const char* ssid, int rssi) {
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 10);
|
||||
display.setTextSize(1);
|
||||
display.print("WiFi: ");
|
||||
display.println(ssid);
|
||||
display.setCursor(0, 30);
|
||||
display.print("RSSI: ");
|
||||
display.print(rssi);
|
||||
display.println(" dBm");
|
||||
display.display();
|
||||
}
|
||||
|
||||
void oledShowMode(const char* mode) {
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 10);
|
||||
display.setTextSize(1);
|
||||
display.print("MODE: ");
|
||||
display.println(mode);
|
||||
display.setCursor(0, 30);
|
||||
display.println("Ready");
|
||||
display.display();
|
||||
}
|
||||
|
||||
void oledShowText(const char* line1, const char* line2) {
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 10);
|
||||
display.setTextSize(1);
|
||||
display.println(line1);
|
||||
display.setCursor(0, 30);
|
||||
display.println(line2);
|
||||
display.display();
|
||||
}
|
||||
11
src/core/display/body/body.h
Normal file
11
src/core/display/body/body.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
void oledInit();
|
||||
|
||||
// базовые экраны
|
||||
void oledShowBoot();
|
||||
void oledShowWiFi(const char* ssid, int rssi);
|
||||
void oledShowMode(const char* mode);
|
||||
|
||||
// универсально (2 строки)
|
||||
void oledShowText(const char* line1, const char* line2);
|
||||
@ -1,6 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "core/deprecate/lcd_status/lcd_status.h"
|
||||
#include "core/display/body/body.h"
|
||||
#include "core/servo/servo.h"
|
||||
#include "core/ultrasonic/ultrasonic.h"
|
||||
#include "core/display/face/face.h"
|
||||
@ -15,10 +15,10 @@
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
lcdInit();
|
||||
oledInit();
|
||||
servoInit();
|
||||
ultrasonicInit();
|
||||
faceInit();
|
||||
// faceInit();
|
||||
actuatorsInit();
|
||||
webServerInit();
|
||||
wsInit();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user