mirror of
https://gitlab.com/fabinfra/fabhardware/fabreader.git
synced 2025-03-12 14:41:44 +01:00
Code für E-paper Variante hinzugefügt
This commit is contained in:
parent
8c2300b0a0
commit
ee72c71e53
BIN
Hardware/photo_2020-11-06_13-23-24.jpg
Normal file
BIN
Hardware/photo_2020-11-06_13-23-24.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
@ -42,6 +42,17 @@
|
|||||||
#include <WiFi.h> // ESP32
|
#include <WiFi.h> // ESP32
|
||||||
#include <WebServer.h> // ESP32
|
#include <WebServer.h> // ESP32
|
||||||
#include <ESPmDNS.h> // ESP32
|
#include <ESPmDNS.h> // ESP32
|
||||||
|
#include <pgmspace.h>
|
||||||
|
#include <GxEPD.h> // E-Paper
|
||||||
|
//#include <GxGDE0213B1/GxGDE0213B1.h> // 2.13" b/w
|
||||||
|
//#include <GxGDEH0213B72/GxGDEH0213B72.h> // 2.13" b/w new panel
|
||||||
|
#include <GxGDEH0213B73/GxGDEH0213B73.h> // E-Paper
|
||||||
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||||
|
#include <Fonts/FreeMonoBold12pt7b.h>
|
||||||
|
#include <Fonts/FreeMonoBold18pt7b.h>
|
||||||
|
#include <Fonts/FreeMonoBold24pt7b.h>
|
||||||
|
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
|
||||||
|
#include <GxIO/GxIO.h>
|
||||||
#else
|
#else
|
||||||
#include <ESP8266WiFi.h> // EPS8266
|
#include <ESP8266WiFi.h> // EPS8266
|
||||||
#include <ESP8266WebServer.h> // ESP8266
|
#include <ESP8266WebServer.h> // ESP8266
|
||||||
@ -59,24 +70,40 @@
|
|||||||
#include <SSD1306Wire.h>
|
#include <SSD1306Wire.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <DES.h>
|
#include <DES.h>
|
||||||
|
|
||||||
|
|
||||||
// #include <esp_system.h> // for retreiving the MAC adress
|
// #include <esp_system.h> // for retreiving the MAC adress
|
||||||
|
|
||||||
|
|
||||||
// Definition der Pins
|
// Definition der Pins
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#define SS_PIN 17 // GPIO17
|
#define SS_PIN 32 // GPIO17
|
||||||
#define RST_PIN 16 // GPIO16
|
#define RST_PIN 33 // GPIO16
|
||||||
#define BEEP_PIN 14 // GPIO16
|
#define BEEP_PIN 27 // GPIO16
|
||||||
#define BUTTON_PIN 13 // GPIO2
|
#define BUTTON_PIN 39 // GPIO39
|
||||||
|
#define CS 19 // ESP32
|
||||||
|
|
||||||
|
#define SPI_MOSI 23
|
||||||
|
#define SPI_MISO -1
|
||||||
|
#define SPI_CLK 18
|
||||||
|
|
||||||
|
#define ELINK_SS 5
|
||||||
|
#define ELINK_BUSY 4
|
||||||
|
#define ELINK_RESET 16
|
||||||
|
#define ELINK_DC 17
|
||||||
#else
|
#else
|
||||||
// #define SS_PIN 15 // GPIO15 -> uncomment this for the old PCB
|
// #define SS_PIN 15 // GPIO15 -> uncomment this for the old PCB
|
||||||
#define SS_PIN 2 // GPIO2
|
#define SS_PIN 2 // GPIO2
|
||||||
#define RST_PIN 0 // GPIO00
|
#define RST_PIN 0 // GPIO00
|
||||||
#define BEEP_PIN 16 // GPIO16
|
#define BEEP_PIN 16 // GPIO16
|
||||||
#define BUTTON_PIN 13 // GPIO2 -> uncomment this for the old PCB
|
#define BUTTON_PIN 13 // GPIO2 -> uncomment this for the old PCB
|
||||||
|
#define CS 15 // ESP8266
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CS 15
|
#define HSPI_MOSI 15
|
||||||
|
#define HSPI_MISO 2
|
||||||
|
#define HSPI_SCLK 14
|
||||||
|
|
||||||
|
|
||||||
// to make some messages easier to read
|
// to make some messages easier to read
|
||||||
#define CONNECT_TO_WIFI 0
|
#define CONNECT_TO_WIFI 0
|
||||||
@ -128,19 +155,20 @@ int maxMessage = 18;
|
|||||||
|
|
||||||
String lastLine1, lastLine2; // to save previous displayed messages
|
String lastLine1, lastLine2; // to save previous displayed messages
|
||||||
boolean linesSaved = 0; // no previous message has been saved
|
boolean linesSaved = 0; // no previous message has been saved
|
||||||
|
int fsize=0; // current font size (for E-paper)
|
||||||
|
|
||||||
String Message_Disp[] = {"verfügbar", // 0 - equipment available // 0
|
String Message_Disp[] = {"verfuegbar", // 0 - equipment available // 0
|
||||||
"reserviert", // 0 - equipment reserved // 1
|
"reserviert", // 0 - equipment reserved // 1
|
||||||
"reserviert ab", // 13 - reserved starting from // 2
|
"reserviert ab", // 13 - reserved starting from // 2
|
||||||
"in Benutzung", // 0 - equipment in use // 3
|
"in Benutzung", // 0 - equipment in use // 3
|
||||||
"freigegeben", // 0 - access granted // 4
|
"freigegeben", // 0 - access granted // 4
|
||||||
"Anmeld. fehlgeschlagen", // 8 - login error // 5
|
"Anmeld. fehlgeschlagen", // 8 - login error // 5
|
||||||
"Nutzungsgebühr ", // 15 - usage fee // 6
|
"Nutzungsgebuehr", // 15 - usage fee // 6
|
||||||
"Nutzung nicht erlaubt", // 13 - operation not allowed // 7
|
"Nutzung nicht erlaubt", // 13 - operation not allowed // 7
|
||||||
"Nutzung auf eigenem Risiko", // 11 - operation at own risk // 8
|
"Nutzung auf eigenem Risiko", // 11 - operation at own risk // 8
|
||||||
"gesperrt durch", // 14 - equipment locked by // 9
|
"gesperrt durch", // 14 - equipment locked by // 9
|
||||||
"freizugeben durch", // 11 - to be released by // 10
|
"freizugeben durch", // 11 - to be released by // 10
|
||||||
"außerhalb der Nutzungzeit", // 14 - outside ooperating hours// 11
|
"ausserhalb der Nutzungzeit", // 15 - outside ooperating hours// 11
|
||||||
"Nutzungsdauer", // 13 - duration of use // 12
|
"Nutzungsdauer", // 13 - duration of use // 12
|
||||||
"abgemeldet", // 0 - logged out // 13
|
"abgemeldet", // 0 - logged out // 13
|
||||||
"abschalten in", // 13 - equipment will lock down// 14
|
"abschalten in", // 13 - equipment will lock down// 14
|
||||||
@ -148,9 +176,9 @@ String Message_Disp[] = {"verfügbar", // 0 - equipment av
|
|||||||
"Karte unbekannt", // 0 - card unknown // 16
|
"Karte unbekannt", // 0 - card unknown // 16
|
||||||
"Berechtigung endet", // 12 - training to expire // 17
|
"Berechtigung endet", // 12 - training to expire // 17
|
||||||
"Ruhemodus", // 0 - sleep mode // 18
|
"Ruhemodus", // 0 - sleep mode // 18
|
||||||
"Aufsicht bestätigen"}; // 8 - confirm presence // 19
|
"Aufsicht bestaetigen"}; // 8 - confirm presence // 19
|
||||||
|
|
||||||
int SplitAt[]={0,0,13,0,0,8,15,13,11,14,11,14,14,0,13,0,0,12,0,8};
|
int SplitAt[]={0,0,13,0,0,8,15,13,11,15,11,14,14,0,13,0,0,12,0,8};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
String Message_Com[] = {"1", // equipment available
|
String Message_Com[] = {"1", // equipment available
|
||||||
@ -175,6 +203,15 @@ String Message_Com[] = {"1", // equipment availab
|
|||||||
"20"}; // sleep mode
|
"20"}; // sleep mode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//----------- E-Paper-Stuff
|
||||||
|
#ifdef ESP32
|
||||||
|
SPIClass eSPI(HSPI);
|
||||||
|
GxIO_Class io(eSPI, /*CS=5*/ ELINK_SS, /*DC=*/ ELINK_DC, /*RST=*/ ELINK_RESET);
|
||||||
|
GxEPD_Class EPaper(io, /*RST=*/ ELINK_RESET, /*BUSY=*/ ELINK_BUSY);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
EthernetClient ethClient; // in case of Ethernet connection
|
EthernetClient ethClient; // in case of Ethernet connection
|
||||||
WiFiClient wifiClient; // in case of Wifi connection
|
WiFiClient wifiClient; // in case of Wifi connection
|
||||||
PubSubClient MQTTclient; // The MQTT Client
|
PubSubClient MQTTclient; // The MQTT Client
|
||||||
@ -249,7 +286,13 @@ void setup(void){
|
|||||||
|
|
||||||
digitalWrite(CS, HIGH); // -> needs to be set, otherwise MISO will be pulled LOW
|
digitalWrite(CS, HIGH); // -> needs to be set, otherwise MISO will be pulled LOW
|
||||||
|
|
||||||
SPI.begin();
|
#ifdef ESP32
|
||||||
|
SPI.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, CS); // for the LAN Module and the RC522 module
|
||||||
|
eSPI.begin(SPI_CLK, SPI_MISO, SPI_MOSI, ELINK_SS); // For the e-Paper Module
|
||||||
|
#else
|
||||||
|
SPI.begin();
|
||||||
|
#endif
|
||||||
|
|
||||||
rfid.PCD_Init(); // RC522 initialize
|
rfid.PCD_Init(); // RC522 initialize
|
||||||
// rfid.PCD_PerformSelfTest();
|
// rfid.PCD_PerformSelfTest();
|
||||||
|
|
||||||
@ -259,6 +302,16 @@ void setup(void){
|
|||||||
|
|
||||||
des.init(C_key,IV);
|
des.init(C_key,IV);
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
|
EPaper.init(); // enable diagnostic output on Serial
|
||||||
|
EPaper.setRotation(3);
|
||||||
|
EPaper.fillScreen(GxEPD_WHITE);
|
||||||
|
EPaper.setTextColor(GxEPD_BLACK);
|
||||||
|
EPaper.setFont(&FreeMonoBold12pt7b);
|
||||||
|
EPaper.setCursor(0, 0);
|
||||||
|
EPaper.update();
|
||||||
|
#endif
|
||||||
|
|
||||||
display.init(); // initialize display
|
display.init(); // initialize display
|
||||||
display.clear();
|
display.clear();
|
||||||
display.flipScreenVertically();
|
display.flipScreenVertically();
|
||||||
@ -325,6 +378,7 @@ void setupMQTT(void){
|
|||||||
StatusToDisplay(CONNECT_TO_LAN);
|
StatusToDisplay(CONNECT_TO_LAN);
|
||||||
|
|
||||||
WiFi.macAddress(mac);
|
WiFi.macAddress(mac);
|
||||||
|
Ethernet.init(CS); // set the correct pin
|
||||||
if(Ethernet.begin(mac) == 0) {
|
if(Ethernet.begin(mac) == 0) {
|
||||||
Serial.println(F("Ethernet configuration using DHCP failed"));
|
Serial.println(F("Ethernet configuration using DHCP failed"));
|
||||||
StatusToDisplay(ERROR_DHCP);
|
StatusToDisplay(ERROR_DHCP);
|
||||||
@ -335,7 +389,7 @@ void setupMQTT(void){
|
|||||||
}
|
}
|
||||||
Serial.print("set Client to Ethernet: ");
|
Serial.print("set Client to Ethernet: ");
|
||||||
MQTTclient.setClient(ethClient);
|
MQTTclient.setClient(ethClient);
|
||||||
WiFi.forceSleepBegin(); // TODO
|
//WiFi.forceSleepBegin(); // TODO
|
||||||
//WiFi.mode(WIFI_OFF); // TODO
|
//WiFi.mode(WIFI_OFF); // TODO
|
||||||
Serial.println("OK");
|
Serial.println("OK");
|
||||||
}
|
}
|
||||||
@ -1140,6 +1194,12 @@ int len, split=16;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void StatusToDisplay(int item){
|
void StatusToDisplay(int item){
|
||||||
|
#ifdef ESP32
|
||||||
|
EPaper.setFont(&FreeMonoBold18pt7b);
|
||||||
|
fsize=18;
|
||||||
|
#endif
|
||||||
|
display.setFont(ArialMT_Plain_24);
|
||||||
|
|
||||||
if(item==CONNECT_TO_WIFI){
|
if(item==CONNECT_TO_WIFI){
|
||||||
display2lines("connecting...", "Wifi");
|
display2lines("connecting...", "Wifi");
|
||||||
}
|
}
|
||||||
@ -1153,19 +1213,15 @@ void StatusToDisplay(int item){
|
|||||||
display2lines("LAN", "connecting...");
|
display2lines("LAN", "connecting...");
|
||||||
}
|
}
|
||||||
else if(item==MQTT_RFID){
|
else if(item==MQTT_RFID){
|
||||||
display.setFont(ArialMT_Plain_24);
|
|
||||||
display2linesRAW("MQTT", "RFID");
|
display2linesRAW("MQTT", "RFID");
|
||||||
}
|
}
|
||||||
else if(item==IN_AP_MODE){
|
else if(item==IN_AP_MODE){
|
||||||
display.setFont(ArialMT_Plain_24);
|
|
||||||
display2linesRAW("AP-", "MODE");
|
display2linesRAW("AP-", "MODE");
|
||||||
}
|
}
|
||||||
else if(item==ERROR_RFID){
|
else if(item==ERROR_RFID){
|
||||||
display.setFont(ArialMT_Plain_24);
|
|
||||||
display2linesRAW("RFID-", "ERROR");
|
display2linesRAW("RFID-", "ERROR");
|
||||||
}
|
}
|
||||||
else if(item==WRONG_RFID_TYPE){
|
else if(item==WRONG_RFID_TYPE){
|
||||||
display.setFont(ArialMT_Plain_24);
|
|
||||||
display2linesRAW("Read-", "ERROR");
|
display2linesRAW("Read-", "ERROR");
|
||||||
}
|
}
|
||||||
else if(item==ERROR_DHCP){
|
else if(item==ERROR_DHCP){
|
||||||
@ -1176,6 +1232,10 @@ void StatusToDisplay(int item){
|
|||||||
void LastMessageDisplay(void){
|
void LastMessageDisplay(void){
|
||||||
if(linesSaved){
|
if(linesSaved){
|
||||||
display.setFont(ArialMT_Plain_16);
|
display.setFont(ArialMT_Plain_16);
|
||||||
|
#ifdef ESP32
|
||||||
|
EPaper.setFont(&FreeMonoBold12pt7b);
|
||||||
|
fsize=12;
|
||||||
|
#endif
|
||||||
display2linesRAW(lastLine1, lastLine2);
|
display2linesRAW(lastLine1, lastLine2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1194,6 +1254,10 @@ void popRFIDerror(void){
|
|||||||
|
|
||||||
void display2lines(String str1, String str2) {
|
void display2lines(String str1, String str2) {
|
||||||
display.setFont(ArialMT_Plain_16);
|
display.setFont(ArialMT_Plain_16);
|
||||||
|
#ifdef ESP32
|
||||||
|
EPaper.setFont(&FreeMonoBold12pt7b);
|
||||||
|
fsize=12;
|
||||||
|
#endif
|
||||||
display2linesRAW(str1, str2);
|
display2linesRAW(str1, str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1204,11 +1268,26 @@ void display2lines(String str1, String str2) {
|
|||||||
void display2linesRAW(String str1, String str2) {
|
void display2linesRAW(String str1, String str2) {
|
||||||
display.clear();
|
display.clear();
|
||||||
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display.drawString(66, 18, str1);
|
display.drawString(64, 13, str1);
|
||||||
display.drawString(66, 40, str2);
|
display.drawString(64, 35, str2);
|
||||||
display.setFont(ArialMT_Plain_10);
|
display.setFont(ArialMT_Plain_10);
|
||||||
display.drawString(64, 0, ReaderID); // Show the reader ID on top of the screen
|
display.drawString(64, 0, ReaderID); // Show the reader ID on top of the screen
|
||||||
display.display();
|
display.display();
|
||||||
|
#ifdef ESP32
|
||||||
|
EPaper.fillScreen(GxEPD_WHITE);
|
||||||
|
int x1=(EPaper.width()/2-(str1.length()*fsize)/2);
|
||||||
|
EPaper.setCursor(x1,20+2*fsize);
|
||||||
|
EPaper.println(str1);
|
||||||
|
int x2=(EPaper.width()/2-(str2.length()*fsize)/2);
|
||||||
|
EPaper.setCursor(x2,50+2*fsize);
|
||||||
|
EPaper.println(str2);
|
||||||
|
EPaper.setFont(&FreeMonoBold9pt7b);
|
||||||
|
EPaper.setCursor(EPaper.width()-8*9,12);
|
||||||
|
EPaper.print(F("ID:"));
|
||||||
|
EPaper.println(ReaderID);
|
||||||
|
EPaper.updateWindow(0, 0, EPaper.width()-1, EPaper.height()-1, true);
|
||||||
|
// EPaper.update();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user