Browse Source

add E-Paper Display

split_files
Hendrik Langer 5 years ago
parent
commit
7db7ebe583
  1. 1
      README.md
  2. 4
      platformio.ini
  3. 33
      src/main.cpp

1
README.md

@ -31,3 +31,4 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md
## Acknowledgments ## Acknowledgments
* [PlatformIO](https://platformio.org) - Cross-platform IDE * [PlatformIO](https://platformio.org) - Cross-platform IDE
* [GxEPD2](https://github.com/ZinggJM/GxEPD2) - E-Paper display library

4
platformio.ini

@ -23,7 +23,9 @@ build_flags =
-DWIFI_SSID2="\"${sysenv.WIFI_SSID}\"" -DWIFI_SSID2="\"${sysenv.WIFI_SSID}\""
-DWIFI_PASSWD2="\"${sysenv.WIFI_PASSWD}\"" -DWIFI_PASSWD2="\"${sysenv.WIFI_PASSWD}\""
;lib_deps = lib_deps =
GxEPD2
Adafruit GFX Library
; ArduinoJSON ; ArduinoJSON
monitor_speed = 115200 monitor_speed = 115200

33
src/main.cpp

@ -8,7 +8,36 @@
#include <WiFi.h> #include <WiFi.h>
#include <WiFiMulti.h> #include <WiFiMulti.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "bitmaps/Bitmaps128x250.h"
WiFiMulti wifiMulti; 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
void helloWorld()
{
const char HelloWorld[] = "Hello World!";
//Serial.println("helloWorld");
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center bounding box by transposition of origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloWorld);
}
while (display.nextPage());
//Serial.println("helloWorld done");
}
void setup() void setup()
{ {
@ -17,6 +46,10 @@ void setup()
// initialize LED digital pin as an output. // initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
display.init(115200);
helloWorld();
display.powerOff();
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD); wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD);
wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2); wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2);

Loading…
Cancel
Save