/*
 * Copyright Paul Warren 2019 <pwarren@pwarren.id.au>
 * 
 * Released under the terms of the GPLv3 license.
 */
#include "epd.h"

const int led = LED_BUILTIN;

// Font width
int dwidth = 185;

void ledOn(void)  { digitalWrite(led, HIGH);}
void ledOff(void) { digitalWrite(led, LOW);}
void wait(void)   { delay(1500);}


void setup() {
  Serial.begin(115200);                     // Start serial communication
  Serial.setTimeout(2000);
  while (!Serial) { }
  Serial.println("\r\n\r\nSTARTING\r\n");

  epd_init();
  epd_wakeup();
  delay(1500);
  epd_set_memory(MEM_TF);
  epd_disp_bitmap("0.jpg", 0, 0);
  epd_disp_bitmap("9.jpg", 185,0);
  Serial.println("Attempting to display 0 and 9");
  epd_update();
  delay(10000);    
  epd_load_pic();
  epd_set_memory(MEM_NAND);
  delay(1500);
  epd_clear();
 
}

void loop() {
  int flag = 0;
  
  delay(1500);
  Serial.println("Files uploaded");
  Serial.println("Please wait till screen LED flashes again");

    while (1) {
      if(flag) {
	flag = 0;
	ledOff();
      } else {
	flag = 1;
	ledOn();
      }
      delay(1000);
    }
}
