Browse Source

display values

ir
Hendrik Langer 5 years ago
parent
commit
58c7a965cf
  1. 50
      src/icons.h
  2. 26
      src/main.cpp

50
src/icons.h

@ -0,0 +1,50 @@
/* http://javl.github.io/image2cpp/ */
/* https://fontawesome.com/icons?d=gallery&m=free */
/* https://littlevgl.com/image-to-c-array */
#define ICO_HEIGHT 32
// 'wifi', 40x32px
static const uint8_t ico_wifi_height = 32;
static const uint8_t ico_wifi_width = 40;
static const uint8_t ico_wifi [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x7f, 0xff, 0xff,
0xe0, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00,
0x00, 0x00, 0x0f, 0xe0, 0x01, 0xff, 0x80, 0x07, 0xc0, 0x0f, 0xff, 0xf0, 0x03, 0x80, 0x7f, 0xff,
0xfe, 0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0x83, 0xff, 0xff, 0xff, 0xc1, 0xc7, 0xff, 0x00, 0xff,
0xe3, 0xff, 0xf8, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x00, 0x07, 0xff, 0xff, 0x80, 0x00, 0x01, 0xff,
0xff, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0xff, 0x00, 0x7f, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xff,
0x8f, 0xff, 0xf1, 0xff, 0xff, 0xdf, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xc3, 0xff, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x81, 0xff,
0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
// 'wifi, 20x16px
static const uint8_t ico_wifi16_height = 16;
static const uint8_t ico_wifi16_width = 20;
static const uint8_t ico_wifi16 [] PROGMEM = {
0xff, 0xff, 0xf0, 0xfc, 0x03, 0xf0, 0xf0, 0x00, 0xf0, 0xc0, 0x00, 0x30, 0x87, 0xfe, 0x10, 0x1f,
0xff, 0x80, 0xbe, 0x07, 0xd0, 0xf8, 0x01, 0xf0, 0xf0, 0x00, 0xf0, 0xf3, 0xfc, 0xf0, 0xff, 0xff,
0xf0, 0xff, 0x9f, 0xf0, 0xff, 0x0f, 0xf0, 0xff, 0x0f, 0xf0, 0xff, 0x9f, 0xf0, 0xff, 0xff, 0xf0
};
// 'user-circle', 31x32px
static const uint8_t ico_user_circle [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xfc, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x03, 0xff,
0x81, 0xff, 0x03, 0xfe, 0x0f, 0xff, 0x83, 0xf8, 0x7f, 0xff, 0xc3, 0xf1, 0xf8, 0x0f, 0xc7, 0xc3,
0xe0, 0x0f, 0x87, 0x0f, 0x80, 0x0f, 0x86, 0x3f, 0x1f, 0x1f, 0x8c, 0x7e, 0x3e, 0x3f, 0x10, 0xfc,
0x7c, 0x7e, 0x03, 0xf8, 0xf8, 0xfe, 0x07, 0xf1, 0xf1, 0xfc, 0x0f, 0xe0, 0x03, 0xf8, 0x1f, 0xe0,
0x0f, 0xf0, 0x3f, 0xe0, 0x3f, 0xe0, 0x7f, 0xff, 0xff, 0xc0, 0x7f, 0xff, 0xff, 0x08, 0xf8, 0x38,
0x3e, 0x31, 0xc0, 0x00, 0x1c, 0x61, 0x00, 0x00, 0x10, 0xe0, 0x1e, 0x3c, 0x03, 0xe0, 0xff, 0xfe,
0x0f, 0xc1, 0xff, 0xfc, 0x1f, 0xc1, 0xff, 0xf0, 0x7f, 0xc0, 0xff, 0x81, 0xff, 0xc0, 0x00, 0x07,
0xff, 0xe0, 0x00, 0x3f, 0xff, 0xf0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff
};
// 'thermometer-half', 16x32px
static const uint8_t ico_thermometer_half [] PROGMEM = {
0xfc, 0x3f, 0xf0, 0x0f, 0xe0, 0x07, 0xe3, 0xc7, 0xc7, 0xe3, 0xc7, 0xe3, 0xc7, 0xe3, 0xc7, 0xe3,
0xc7, 0xe3, 0xc7, 0xe3, 0xc7, 0xe3, 0xc7, 0xe3, 0xc6, 0x63, 0xc4, 0x23, 0xc4, 0x23, 0xc4, 0x23,
0xc4, 0x23, 0xc4, 0x23, 0xc4, 0x23, 0x84, 0x21, 0x8c, 0x31, 0x08, 0x10, 0x10, 0x08, 0x10, 0x08,
0x10, 0x08, 0x10, 0x08, 0x08, 0x10, 0x8c, 0x31, 0x83, 0xc1, 0xc0, 0x03, 0xe0, 0x07, 0xf8, 0x1f
};

26
src/main.cpp

@ -13,6 +13,7 @@
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include "bitmaps/Bitmaps128x250.h"
#include <Adafruit_GFX.h>
@ -25,6 +26,8 @@
#include "network/XD0OTA.h"
#include "network/XD0MQTT.h"
#include "icons.h"
static const char* TAG = "MAIN";
WiFiMulti wifiMulti;
@ -63,6 +66,14 @@ void helloWorld()
}
void displayIcoPartial(const uint8_t bitmap[], uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
display.setPartialWindow(x, y, w, h);
display.firstPage(); do {
display.drawInvertedBitmap(x, y, bitmap, w, h, GxEPD_BLACK);
} while (display.nextPage());
}
void printValues() {
#define SEALEVELPRESSURE_HPA (1013.25)
Serial.print("Temperature = ");
@ -138,6 +149,7 @@ void setup()
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
displayIcoPartial(ico_wifi16, display.width()-20, 0, ico_wifi_width, ico_wifi_height);
}
ESP_LOGD(TAG, "trying to fetch over-the-air update");
@ -161,28 +173,30 @@ void loop()
if (millis() - lastDisplayUpdate >= 2*60*1000) {
lastDisplayUpdate = millis();
display.setFullWindow();
display.setRotation(0);
display.setRotation(1);
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(&FreeMonoBold9pt7b);
display.setCursor(0, 0);
display.setFont(&FreeSans9pt7b);
display.setTextWrap(false);
display.setCursor(0, 11);
display.println("ESP32-Wetterstation");
display.println();
display.drawFastHLine(0, 14, display.width(), GxEPD_BLACK);
display.setCursor(0, 32);
display.print("Temperatur: ");
display.print(bme.readTemperature());
display.println(" *C");
display.print("Luftfeuchte: ");
display.print(bme.readHumidity());
display.println(" %%");
display.println(" %");
display.print("Luftdruck:");
display.print(bme.readPressure() / 100.0F);
display.println(" hPa");
}
while (display.nextPage());
display.powerOff();
}
/*
unsigned long endTime = bme.beginReading();

Loading…
Cancel
Save