Browse Source

e-paper display working

split_files
Hendrik Langer 6 years ago
parent
commit
09329824c6
  1. 7
      platformio.ini
  2. 28
      src/main.cpp

7
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

28
src/main.cpp

@ -14,6 +14,7 @@
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "bitmaps/Bitmaps128x250.h"
#include <Adafruit_GFX.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
@ -24,11 +25,12 @@
static const char* TAG = "MAIN";
WiFiMulti wifiMulti;
GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=TFT_CS*/ SS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72
GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> 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);
}

Loading…
Cancel
Save