From 09329824c65e9c484f054767f761aac89a225d07 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sat, 20 Jul 2019 19:11:12 +0200 Subject: [PATCH] e-paper display working --- platformio.ini | 7 +++++-- src/main.cpp | 28 +++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9bd14ea..0e2086b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,8 +15,9 @@ framework = arduino board = lolin_d32_pro build_flags = - -DLOG_DEFAULT_LEVEL=ESP_LOG_DEBUG -# -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DLOG_DEFAULT_LEVEL=ESP_LOG_VERBOSE + -DLOG_LOCAL_LEVEL=ESP_LOG_VERBOSE + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DWIFI_SSID="\"${sysenv.WIFI_SSID}\"" @@ -29,12 +30,14 @@ build_flags = lib_deps = GxEPD2 +; https://github.com/wemos/LOLIN_EPD_Library Adafruit GFX Library Adafruit BME680 Library Adafruit Unified Sensor ; ArduinoJSON monitor_speed = 115200 +upload_speed = 115200 extra_scripts = pre:script/autoversioning.py diff --git a/src/main.cpp b/src/main.cpp index 53e08ef..16b92ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,6 +14,7 @@ #include #include #include "bitmaps/Bitmaps128x250.h" +#include #include #include "Adafruit_BME680.h" @@ -24,11 +25,12 @@ static const char* TAG = "MAIN"; WiFiMulti wifiMulti; -GxEPD2_BW display(GxEPD2_213_B72(/*CS=TFT_CS*/ SS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72 +GxEPD2_BW display(GxEPD2_213_B72(/*CS=SS*/ TFT_CS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72 Adafruit_BME680 bme; // I2C (also available: hardware SPI XD0MQTT mqtt; + void helloWorld() { const char HelloWorld[] = "Hello World!"; @@ -53,6 +55,7 @@ void helloWorld() //Serial.println("helloWorld done"); } + void setup() { Serial.begin(115200); @@ -60,21 +63,32 @@ void setup() // initialize LED digital pin as an output. pinMode(LED_BUILTIN, OUTPUT); + Serial.println("setup"); + + // initialize e-paper display + SPI.begin(18, 19, 23, TFT_CS); + delay(200); // todo display.init(115200); + + Serial.println("display init done"); Serial.flush(); + + display.clearScreen(); + display.refresh(); + helloWorld(); display.powerOff(); if (!bme.begin()) { ESP_LOGE(TAG, "Could not find a valid BME680 sensor, check wiring!"); } - +/* // Set up oversampling and filter initialization bme.setTemperatureOversampling(BME680_OS_8X); bme.setHumidityOversampling(BME680_OS_2X); bme.setPressureOversampling(BME680_OS_4X); bme.setIIRFilterSize(BME680_FILTER_SIZE_3); bme.setGasHeater(320, 150); // 320*C for 150 ms - +*/ wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD); wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2); @@ -85,15 +99,18 @@ void setup() Serial.println("IP address: "); Serial.println(WiFi.localIP()); } - +/* XD0OTA ota("esp32-weatherstation"); ota.update(); mqtt.begin(); +*/ } void loop() { + Serial.println("loop"); +/* unsigned long endTime = bme.beginReading(); if (! bme.performReading()) { ESP_LOGE(TAG, "BME680: Failed to perform reading :("); @@ -111,11 +128,12 @@ void loop() Serial.print("Gas = "); Serial.print(bme.gas_resistance / 1000.0); Serial.println(" KOhms"); display.print("Gas: "); display.print(bme.gas_resistance / 1000.0); display.println(" KOhms"); +*/ if(wifiMulti.run() != WL_CONNECTED) { Serial.println("WiFi not connected!"); delay(1000); } - delay(1000); + delay(2000); }