налажена связь между 2 esp
This commit is contained in:
@@ -2,14 +2,28 @@
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include <Wire.h>
|
||||
#include <esp_log.h>
|
||||
#include <string.h>
|
||||
|
||||
Display::Display() : oled_(128, 32, &Wire, -1) {}
|
||||
|
||||
bool Display::begin() {
|
||||
Wire.begin(GPIO_SDA, GPIO_SCL);
|
||||
// An absent optional OLED produces a large burst of ESP-IDF NACK messages.
|
||||
// Probe it once and keep the I2C driver quiet when no display is connected.
|
||||
esp_log_level_set("i2c.master", ESP_LOG_NONE);
|
||||
Wire.beginTransmission(OLED_ADDRESS);
|
||||
if (Wire.endTransmission() != 0) {
|
||||
ok_ = false;
|
||||
Log::printf("OLED", "not detected at I2C address=0x%02X", OLED_ADDRESS);
|
||||
return false;
|
||||
}
|
||||
ok_ = oled_.begin(SSD1306_SWITCHCAPVCC, OLED_ADDRESS);
|
||||
if (ok_) { oled_.setTextColor(SSD1306_WHITE); oled_.setTextSize(1); }
|
||||
if (ok_) {
|
||||
oled_.setRotation(OLED_ROTATION);
|
||||
oled_.setTextColor(SSD1306_WHITE);
|
||||
oled_.setTextSize(1);
|
||||
}
|
||||
Log::printf("OLED", "initialization %s, I2C address=0x%02X", ok_ ? "OK" : "FAILED", OLED_ADDRESS);
|
||||
return ok_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user