Atm-Automat/firmware/include/main.h

100 lines
3.4 KiB
C++

#ifndef MAIN_H
#define MAIN_H
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "qrcode.h"
#include "Bitcoin.h"
#include <stdlib.h>
#include <Hash.h>
#include <ctype.h>
#include <stdio.h>
// ########################################
// ########### USER ACTION ###########
// ########################################
// Generate and copy in LNbits with the LNURLDevice extension the string for the ATM and paste it here:
const char* lnurlDeviceString = "https://legend.lnbits.com/lnurldevice/api/v1/lnurl/idexample,keyexample,EUR";
// #################### EXAMPLE: https://legend.lnbits.com/lnurldevice/api/v1/lnurl/idexample,keyexample,EUR
// ########################################
// ########################################
// ########################################
// Activate for debugging over Serial (1), deactivate in production use (0)
#define DEBUG_MODE 1
#define COIN_PIN 17
#define PULSE_TIMEOUT 200
const uint8_t LED_BUTTON_PIN = 21; // old: 13 | new: 21
const uint8_t BUTTON_PIN = 32;
#define MOSFET_PIN 16 // old: 12 | new: 16
#define QR_VERSION 6 // 20 is standard. 6 for simpler QR code, but does not always work.
const uint8_t DSPLY_PIN_CS = 26;
const uint8_t DSPLY_PIN_DC = 25;
const uint8_t DSPLY_PIN_RST = 33;
const uint8_t DSPLY_PIN_BUSY = 27;
constexpr unsigned int COINS[] = { 1, 2, 5, 10, 20, 50, 100, 200};
constexpr size_t COINS_COUNT = sizeof(COINS) / sizeof(COINS[0]);
const unsigned long COIN_PULSE_WIDTH_MS = 45;
typedef struct s_qrdata
{
uint8_t current_y;
uint8_t current_x;
uint8_t start_x;
uint8_t start_y;
uint8_t module_size;
uint8_t qr_size;
} t_qrdata;
extern String baseURLATM;
extern String secretATM;
extern String currencyATM;
// put function declarations here:
void clean_screen();
void initialize_display();
void to_upper(char* arr);
void qr_withdrawl_screen(const char* qr_content);
char* makeLNURL(float total);
int xor_encrypt(uint8_t* output, size_t outlen, uint8_t* key, size_t keylen, uint8_t* nonce, size_t nonce_len, uint64_t pin, uint64_t amount_in_cents);
void show_inserted_amount(int amount_in_cents);
String get_amount_string(int amount_in_cents);
unsigned int detect_coin();
void home_screen();
void IRAM_ATTR button_pressed_itr();
void wait_for_user_to_scan();
String getValue(String data, char separator, int index);
void display_sleep();
void test_macro();
// Waveshare 1.54 inch e-ink display functions
void home_screen_waveshare_1_54();
void show_inserted_amount_waveshare_1_54(String amount_in_euro);
void qr_withdrawl_screen_waveshare_1_54(const char* qr_content);
void clean_screen_waveshare_1_54();
// Waveshare 2.7 inch e-ink display functions
void home_screen_waveshare_2_7();
void show_inserted_amount_waveshare_2_7(String amount_in_euro);
void qr_withdrawl_screen_waveshare_2_7(const char* qr_content);
void clean_screen_waveshare_2_7();
// Waveshare 2.13 inch e-ink display (250x122) functions
void home_screen_waveshare_2_13();
void show_inserted_amount_waveshare_2_13(String amount_in_euro);
void qr_withdrawl_screen_waveshare_2_13(const char* qr_content);
void clean_screen_waveshare_2_13();
// Waveshare 2.13 inch e-ink display (D) flex (yellow) (212x104) functions
void home_screen_waveshare_2_13_flex();
void show_inserted_amount_waveshare_2_13_flex(String amount_in_euro);
void qr_withdrawl_screen_waveshare_2_13_flex(const char* qr_content);
void clean_screen_waveshare_2_13_flex();
#endif