#include "main.h"
#include <Arduino.h>
#include "epaperdisplay.h"
#include "button.h"
#include "coinacceptor.h"
#include "lnurlutil.h"
#include "config.h"

EpaperDisplay epDisp(DSPLY_PIN_CS, DSPLY_PIN_DC, DSPLY_PIN_RST, DSPLY_PIN_BUSY);
AtmButton button(BUTTON_PIN, LED_BUTTON_PIN);
CoinAcceptor cacc(COIN_PIN, MOSFET_PIN, COINS, COINS_COUNT, COIN_PULSE_WIDTH_MS);

void setup()
{
  Serial.begin(115200);
  cacc.begin();
  button.begin();
  epDisp.init(); 
  std::string lnurl = lnurlutil::createQrContent(0.05);
  epDisp.qrCode(lnurl.c_str());
  while(0==0)
  {delay(1000);}

  epDisp.homeScreen();

  while(0 == 0)
  {
    Serial.println("Insert coin please.");
    cacc.enable();
    do
    {
    } while (false == cacc.detectCoin());
    delay(1000);
  }  

  while(0==0)
  {delay(1000);}
}

void loop()
{
}

