This commit is contained in:
admin committed 2026-09-11 13:44:38 +07:00
1 parent 4c68deb6bb
commit 21168d8820
3 files changed
+43 -6

No files matched your search

+8 -2
View File
@@ -11,10 +11,16 @@ OLEDDisplay::OLEDDisplay(uint8_t sdaPin, uint8_t sclPin, uint8_t i2cAddr)
}
bool OLEDDisplay::begin() {
// Khởi tạo I2C với timeout
Wire.begin(_sdaPin, _sclPin);
Wire.setClock(100000); // Giảm tốc độ I2C xuống 100kHz để ổn định hơn
delay(100); // Đợi I2C ổn định
if (!_display.begin(SSD1306_SWITCHCAPVCC, _i2cAddr)) {
Serial.println(F("[OLED] Không thể khởi tạo màn hình!"));
Serial.println(F("[OLED] Khong the khoi tao man hinh!"));
Serial.print(F("[OLED] Da thu dia chi I2C: 0x"));
Serial.println(_i2cAddr, HEX);
return false;
}
@@ -22,7 +28,7 @@ bool OLEDDisplay::begin() {
_display.setTextColor(SSD1306_WHITE);
_display.display();
Serial.println(F("[OLED] Đã khởi tạo thành công"));
Serial.println(F("[OLED] Da khoi tao thanh cong"));
return true;
}
+4 -4
View File
@@ -18,8 +18,8 @@
// Change these to match your wiring. Any two free GPIOs that
// support UART RX/TX on your ESP32-S3 board will work.
// ---------------------------------------------------------------
#define RADAR_RX_PIN 18 // ESP32-S3 RX <- LD2453 TX
#define RADAR_TX_PIN 17 // ESP32-S3 TX -> LD2453 RX
#define RADAR_RX_PIN 17 // ESP32-S3 RX <- LD2453 TX
#define RADAR_TX_PIN 18 // ESP32-S3 TX -> LD2453 RX
#define RADAR_UART_PORT 1 // which HardwareSerial to use (Serial1 or Serial2)
// Default LD2453 UART settings. 8N1 is assumed by analogy with the
@@ -39,8 +39,8 @@
// OLED Display (I2C 128x64)
// ---------------------------------------------------------------
#define OLED_ENABLED 1 // 1 = enable OLED display, 0 = disable
#define OLED_SDA_PIN 6 // I2C SDA pin
#define OLED_SCL_PIN 7 // I2C SCL pin
#define OLED_SDA_PIN 7 // I2C SDA pin
#define OLED_SCL_PIN 6 // I2C SCL pin
#define OLED_I2C_ADDR 0x3C // I2C address (0x3C or 0x3D, check your module)
// ---------------------------------------------------------------
+31
View File
@@ -87,14 +87,45 @@ void setup() {
Serial.print(F("Node ID: "));
Serial.println(NODE_ID);
#if OLED_ENABLED
// Khởi tạo màn hình OLED
Serial.println(F("[SETUP] Initializing OLED..."));
bool oledOk = false;
try {
oledOk = oledDisplay.begin();
if (oledOk) {
oledDisplay.showBootScreen(NODE_ID);
delay(2000); // Hiển thị màn hình boot 2 giây
} else {
Serial.println(F("[SETUP] OLED init failed, continuing without display"));
}
} catch (...) {
Serial.println(F("[SETUP] OLED init exception, continuing without display"));
oledOk = false;
}
#endif
Serial.println(F("[SETUP] Initializing radar..."));
radar.begin(RadarSerial, RADAR_RX_PIN, RADAR_TX_PIN, RADAR_BAUD_RATE,
NODE_ID, DEBUG_RADAR_RAW);
#if !DIAGNOSTIC_MODE
#if OLED_ENABLED
if (oledOk) oledDisplay.showWiFiConnecting(WIFI_SSID);
#endif
Serial.println(F("[SETUP] Starting WiFi..."));
webServer.begin(WIFI_SSID, WIFI_PASSWORD);
#if OLED_ENABLED
if (oledOk) oledDisplay.showWiFiConnected(WiFi.localIP());
#endif
#else
Serial.println(F("DIAGNOSTIC_MODE=1: Wi-Fi/web server disabled. Serial-only output."));
#if OLED_ENABLED
if (oledOk) oledDisplay.showDiagnosticMode();
#endif
#endif
Serial.println(F("[SETUP] Setup complete!"));
}
void loop() {