-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wifimanager and qrcode connect screen
- Loading branch information
Showing
6 changed files
with
125 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <Arduino.h> | ||
#include "qrencode.h" | ||
#include "qrcodeeink.h" | ||
|
||
QRcodeEink::QRcodeEink(GxEPD2_BW<GxEPD2_213_BN, GxEPD2_213_BN::HEIGHT> *display) { | ||
this->display = display; | ||
} | ||
|
||
void QRcodeEink::init(int x_offset, int y_offset) { | ||
this->screenwidth = display->width(); | ||
this->screenheight = display->height(); | ||
|
||
|
||
int min = screenwidth < screenheight ? screenwidth : screenheight; | ||
multiply = min / WD; | ||
|
||
offsetsX = (screenwidth-(WD*multiply))/2 + x_offset; | ||
offsetsY = (screenheight-(WD*multiply))/2 + y_offset; | ||
} | ||
|
||
void QRcodeEink::screenwhite() { | ||
display->setFullWindow(); | ||
display->fillScreen(GxEPD_WHITE); | ||
display->display(false); | ||
} | ||
|
||
void QRcodeEink::screenupdate() { | ||
// do nothing | ||
} | ||
|
||
void QRcodeEink::drawPixel(int x, int y, int color) { | ||
display->fillRect(x, y, multiply, multiply, color == 1 ? GxEPD_BLACK : GxEPD_WHITE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef ESPQRCODEEINK_H | ||
#define ESPQRCODEEINK_H | ||
|
||
/* ESP_QRcode. e-ink version | ||
* Import this .h when using some e-ink display | ||
*/ | ||
|
||
#define EINKDISPLAY | ||
|
||
#include <qrcodedisplay.h> | ||
#include <Adafruit_GFX.h> | ||
#include <GxEPD2_BW.h> | ||
|
||
#ifndef EINK_MODEL | ||
#define EINK_MODEL 128 | ||
#endif | ||
|
||
class QRcodeEink : public QRcodeDisplay | ||
{ | ||
private: | ||
GxEPD2_BW<GxEPD2_213_BN, GxEPD2_213_BN::HEIGHT> *display; | ||
void drawPixel(int x, int y, int color); | ||
public: | ||
|
||
QRcodeEink(GxEPD2_BW<GxEPD2_213_BN, GxEPD2_213_BN::HEIGHT> *display); | ||
void init(int x_offset = 0, int y_offset = 0); | ||
void screenwhite(); | ||
void screenupdate(); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
void displayWiFiStatus(DisplayType& display, bool isConnected, IPAddress ipAddress) { | ||
display.setFullWindow(); | ||
display.firstPage(); | ||
#include "qrcodeeink.h" | ||
|
||
void displayWiFiSetup(DisplayType& display, WiFiManager *wifiManager, const char* randomWifiPassword) { | ||
QRcodeEink qrcode(&display); | ||
qrcode.init(-70); | ||
do { | ||
display.fillScreen(GxEPD_WHITE); | ||
// Generate QR code for WiFi configuration | ||
String qrData = "WIFI:S:" + String(wifiManager->getConfigPortalSSID()) + ";T:WPA;P:" + String(randomWifiPassword) + ";;"; | ||
qrcode.create(qrData); | ||
|
||
display.setFont(); | ||
display.setTextColor(GxEPD_BLACK); | ||
display.setFont(&FreeSans9pt7b); | ||
|
||
display.setCursor(10, 30); | ||
if (isConnected) { | ||
display.print("WiFi connected"); | ||
display.setCursor(10, 60); | ||
display.print("IP: "); | ||
display.print(ipAddress); | ||
} else { | ||
display.print("WiFi connection failed"); | ||
} | ||
display.setCursor(115, 15); | ||
display.print("WIFI Konfigurasjon"); | ||
display.setCursor(115, 49); | ||
display.print("SSID: "); | ||
display.setCursor(115, 79); | ||
display.print("Passord: "); | ||
|
||
display.setFont(&FreeSans9pt7b); | ||
display.setCursor(115, 69); | ||
display.print(wifiManager->getConfigPortalSSID()); | ||
display.setCursor(115, 101); | ||
display.print(randomWifiPassword); | ||
} while (display.nextPage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters