changed the way how to select which display is used. This is still in test and there is also some testcode include
This commit is contained in:
parent
019f8768cd
commit
493642aa90
8 changed files with 229 additions and 99 deletions
|
@ -1,12 +1,72 @@
|
|||
|
||||
|
||||
#if 0
|
||||
#include "lightning_atm.h"
|
||||
|
||||
const unsigned int COINS[] = { 0, 0, 5, 10, 20, 50, 100, 200, 1, 2 };
|
||||
bool button_pressed = false;
|
||||
unsigned int inserted_cents = 0;
|
||||
unsigned long long time_last_press = millis();
|
||||
String baseURLATM;
|
||||
String secretATM;
|
||||
String currencyATM;
|
||||
//#include <GxEPD2_BW.h> // Bibliothek für Schwarz-Weiß-Displays
|
||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||
|
||||
// #define EPD_CS 26
|
||||
// #define EPD_DC 25
|
||||
// #define EPD_RST 33
|
||||
// #define EPD_BUSY 27
|
||||
|
||||
// // Treiber für das 4.2" Schwarz-Weiß E-Paper
|
||||
// GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(EPD_CS, EPD_DC, EPD_RST, EPD_BUSY));
|
||||
|
||||
void drawText(const char* text);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
/* Wichtige Pins manuell setzen
|
||||
pinMode(EPD_CS, OUTPUT);
|
||||
pinMode(EPD_DC, OUTPUT);
|
||||
pinMode(EPD_RST, OUTPUT);
|
||||
pinMode(EPD_BUSY, INPUT); // BUSY muss als INPUT definiert werden! */
|
||||
|
||||
display.init(115200, true, 2, false);
|
||||
display.setRotation(1); // 0 = Hochformat, 1 = Querformat
|
||||
|
||||
// Bildschirm löschen
|
||||
display.setFullWindow();
|
||||
display.firstPage();
|
||||
do {
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
} while (display.nextPage());
|
||||
delay(1000);
|
||||
drawText("Text Nummer Eins."); // Beispieltext anzeigen
|
||||
delay(10000);
|
||||
drawText("Text Nummer Zwei."); // Beispieltext anzeigen
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void drawText(const char* text) {
|
||||
Serial.printf("Text to show: '%s'\n",text);
|
||||
display.setFullWindow();
|
||||
display.firstPage();
|
||||
do {
|
||||
display.setCursor(50, 100);
|
||||
display.setFont(&FreeMonoBold9pt7b);
|
||||
display.setTextColor(GxEPD_BLACK);
|
||||
display.print(text);
|
||||
} while (display.nextPage());
|
||||
Serial.println("Display updated.");
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#include "lightning_atm.h"
|
||||
|
||||
constexpr unsigned int COINS[] = { 0, 0, 5, 10, 20, 50, 100, 200, 1, 2 };
|
||||
volatile bool button_pressed = false;
|
||||
static unsigned int inserted_cents = 0;
|
||||
static unsigned int pulses = 0;
|
||||
static unsigned long long time_last_press = millis();
|
||||
String baseURLATM, secretATM, currencyATM;
|
||||
|
||||
// *** for Waveshare ESP32 Driver board *** //
|
||||
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
|
||||
|
@ -14,11 +74,24 @@ SPIClass hspi(HSPI);
|
|||
#endif
|
||||
// *** end Waveshare ESP32 Driver board *** //
|
||||
|
||||
//GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(DSPLY_PIN_CS, DSPLY_PIN_DC, DSPLY_PIN_RST, DSPLY_PIN_BUSY));
|
||||
//GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(DSPLY_PIN_CS, DSPLY_PIN_DC, DSPLY_PIN_RST, DSPLY_PIN_BUSY));
|
||||
|
||||
void IRAM_ATTR button_pressed_itr() {
|
||||
button_pressed = true;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
initialize_display(); // connection to the e-ink display
|
||||
Serial.begin(9600);
|
||||
home_screen();
|
||||
Serial.printf("Selected display type: %s\n", display_type);
|
||||
|
||||
while(0 == 0){}
|
||||
|
||||
|
||||
// *** for Waveshare ESP32 Driver board *** //
|
||||
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
|
||||
hspi.begin(13, 12, 14, 15); // remap hspi for EPD (swap pins)
|
||||
|
@ -29,7 +102,7 @@ void setup()
|
|||
{
|
||||
sleep(3);
|
||||
Serial.println("Setup with debug mode..."); // for monitoring with serial monitor to debug
|
||||
Serial.println("Selected display type: " + display_type);
|
||||
Serial.printf("Selected display type: %s\n", display_type);
|
||||
}
|
||||
pinMode(COIN_PIN, INPUT_PULLUP); // coin acceptor input
|
||||
pinMode(LED_BUTTON_PIN, OUTPUT); // LED of the LED Button
|
||||
|
@ -46,9 +119,9 @@ void setup()
|
|||
|
||||
void loop()
|
||||
{
|
||||
unsigned int pulses = 0;
|
||||
unsigned long long time_last_press;
|
||||
|
||||
|
||||
pulses = 0;
|
||||
pulses = detect_coin(); // detect_coin() is a loop to detect the input of coins, will return the amount of pulses
|
||||
if (pulses >= 2 && pulses <= 9)
|
||||
{
|
||||
|
@ -101,12 +174,6 @@ void loop()
|
|||
}
|
||||
}
|
||||
|
||||
// function to handle the button interrupt
|
||||
void IRAM_ATTR button_pressed_itr()
|
||||
{
|
||||
button_pressed = true;
|
||||
}
|
||||
|
||||
// blocking loop which is called when the qr code is shown
|
||||
void wait_for_user_to_scan()
|
||||
{
|
||||
|
@ -202,37 +269,28 @@ unsigned int detect_coin()
|
|||
** DISPLAY UTILS
|
||||
*/
|
||||
|
||||
bool display_check_type(const char* in_display_type)
|
||||
{
|
||||
for(size_t type_nr = 0; type_nr < nr_supported_display_types; type_nr++)
|
||||
{
|
||||
if(0 == strcmp(supported_display_types[type_nr], in_display_type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Serial.printf("No suitable display class '%s' defined.\n", in_display_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
// sleep is to put the screen in hibernation mode for longer static frames
|
||||
void display_sleep()
|
||||
{
|
||||
if (display_type == "GxEPD2_150_BN")
|
||||
display.hibernate();
|
||||
else if (display_type == "GxEPD2_270")
|
||||
display.hibernate();
|
||||
else if (display_type == "GxEPD2_270_GDEY027T91")
|
||||
display.hibernate();
|
||||
else if (display_type == "GxEPD2_213_B74")
|
||||
display.hibernate();
|
||||
else if (display_type == "GxEPD2_213_flex")
|
||||
display.hibernate();
|
||||
else
|
||||
Serial.println("No suitable display class defined.");
|
||||
}
|
||||
|
||||
void initialize_display()
|
||||
{
|
||||
if (display_type == "GxEPD2_150_BN")
|
||||
display.init(115200, true, 2, false);
|
||||
else if (display_type == "GxEPD2_270")
|
||||
display.init(115200, true, 2, false);
|
||||
else if (display_type == "GxEPD2_270_GDEY027T91")
|
||||
display.init(115200, true, 2, false);
|
||||
else if (display_type == "GxEPD2_213_B74")
|
||||
display.init(115200, true, 2, false);
|
||||
else if (display_type == "GxEPD2_213_flex")
|
||||
display.init(115200, true, 2, false);
|
||||
else
|
||||
Serial.println("No suitable display class defined.");
|
||||
}
|
||||
|
||||
void home_screen()
|
||||
|
@ -247,6 +305,8 @@ void home_screen()
|
|||
home_screen_waveshare_2_13();
|
||||
else if (display_type == "GxEPD2_213_flex")
|
||||
home_screen_waveshare_2_13_flex();
|
||||
else if (display_type == "GxEPD2_420")
|
||||
home_screen_waveshare_2_13_flex();
|
||||
else
|
||||
Serial.println("No suitable display class defined.");
|
||||
if (DEBUG_MODE)
|
||||
|
@ -872,4 +932,6 @@ void clean_screen_waveshare_2_13_flex()
|
|||
display.firstPage();
|
||||
display.nextPage();
|
||||
display.hibernate();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue