#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 3
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(64, 32, PIN,
                                               NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
                                               NEO_GRB + NEO_KHZ800);

const uint16_t colors[] = { matrix.Color(255, 0, 255), matrix.Color(0, 255, 0), 
matrix.Color(0, 0, 255),matrix.Color(255, 255, 0) };
int digit_1, digit_2, digit_3;
int x = 42;

static const unsigned char PROGMEM zero[] = {
  0x3f, 0x00, 0x7f, 0x80, 0xff, 0xc0, 0xe1, 0xc0,  0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0,
  0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0,  0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0,
  0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0,  0xe1, 0xc0, 0xe1, 0xc0, 0xff, 0xc0, 0x7f, 0x80,
  0x3f, 0x00
};

static const unsigned char PROGMEM one[] = {
  0x06, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00,  0x3e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
  0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,  0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
  0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,  0x0e, 0x00, 0x0e, 0x00, 0x3f, 0x80, 0x3f, 0x80,
  0x3f, 0x80
};

static const unsigned char PROGMEM two[] = {

  0x3f, 0x00, 0x7f, 0x80,  0xff, 0xc0, 0xe3, 0xc0,  0xe1, 0xc0, 0x01, 0xc0,  0x01, 0xc0, 0x01, 0xc0,
  0x01, 0xc0, 0x01, 0xc0,  0x01, 0xc0, 0x03, 0xc0,  0x07, 0xc0, 0x0f, 0x80,  0x1f, 0x00, 0x3e, 0x00,
  0x7c, 0x00, 0xf8, 0x00,  0xf0, 0x00, 0xe0, 0x00,  0xe0, 0x00, 0xe0, 0x00,  0xff, 0xc0, 0xff, 0xc0,
  0xff, 0xc0
};

static const unsigned char PROGMEM three[] = {

  0x3f, 0x00,  0x7f, 0x80,  0xff, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,
  0x01, 0xc0,  0x01, 0xc0,  0x03, 0xc0,  0x1f, 0x80,  0x1f, 0x00,  0x1f, 0x80,  0x03, 0xc0,  0x01, 0xc0,
  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xff, 0xc0,  0x7f, 0x80,
  0x3f, 0x00
  };

static const unsigned char PROGMEM four[] = {

  0x03, 0x80,  0x07, 0x80,  0x07, 0x80,  0x0f, 0x80,  0x0f, 0x80,  0x1f, 0x80,  0x1f, 0x80,  0x3b, 0x80,
  0x3b, 0x80,  0x7b, 0x80,  0x73, 0x80,  0xf3, 0x80,  0xe3, 0x80,  0xff, 0xc0,  0xff, 0xc0,  0xff, 0xc0,
  0x03, 0x80,  0x03, 0x80,  0x03, 0x80,  0x03, 0x80,  0x03, 0x80,  0x03, 0x80,  0x03, 0x80,  0x03, 0x80,
  0x03, 0x80
};

static const unsigned char PROGMEM five[] = {
  0xff, 0xc0,  0xff, 0xc0,  0xff, 0xc0,  0xe0, 0x00,  0xe0, 0x00,  0xe0, 0x00,  0xe0, 0x00,  0xe0, 0x00,
  0xe0, 0x00,  0xe0, 0x00,  0xff, 0x80,  0xff, 0xc0,  0x7f, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,
  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xff, 0xc0,  0x7f, 0x80,
  0x3f, 0x00
};

static const unsigned char PROGMEM six[] = {
  0x3f, 0x00,  0x7f, 0x80,  0xff, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe0, 0x00,  0xe0, 0x00,  0xe0, 0x00,
  0xe0, 0x00,  0xe0, 0x00,  0xe0, 0x00,  0xe0, 0x00,  0xff, 0x00,  0xff, 0x80,  0xff, 0xc0,  0xe1, 0xc0,
  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xff, 0xc0,  0x7f, 0x80,  
  0x3f, 0x00
};

static const unsigned char PROGMEM seven[] = {

  0xff, 0xc0,  0xff, 0xc0,  0xff, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x03, 0xc0,  0x03, 0xc0,
  0x07, 0xc0,  0x07, 0x80,  0x0f, 0x00,  0x0f, 0x00,  0x0e, 0x00,  0x1e, 0x00,  0x1e, 0x00,  0x1c, 0x00,
  0x3c, 0x00,  0x3c, 0x00,  0x38, 0x00,  0x78, 0x00,  0x78, 0x00,  0x70, 0x00,  0xf0, 0x00,  0xf0, 0x00,
  0xe0, 0x00
};

static const unsigned char PROGMEM eight[] = {

  0x3f, 0x00,  0x7f, 0x80,  0xff, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,
  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0x7f, 0x80,  0x7f, 0x80,  0x7f, 0x80,  0xe1, 0xc0,  0xe1, 0xc0,  
  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xff, 0xc0,  0x7f, 0x80,
  0x3f, 0x00
};

static const unsigned char PROGMEM nine[] = {

  0x3f, 0x00,  0x7f, 0x80,  0xff, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,
  0xe1, 0xc0,  0xe1, 0xc0,  0xe1, 0xc0,  0xff, 0xc0,  0xff, 0xc0,  0x7f, 0xc0,  0x01, 0xc0,  0x01, 0xc0,
  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0x01, 0xc0,  0xe1, 0xc0,  0xff, 0xc0,  0x7f, 0x80,
  0x3f, 0x00
};

const uint8_t* Digit[] = { zero, one, two, three, four, five, six, seven, eight, nine };


void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(255);
  matrix.setTextColor(colors[0]);
  matrix.setTextSize(1);
}

void loop() {
  digit_3 = x % 10;
  digit_2 = (x / 10) % 10;
  digit_1 = x / 100;
  matrix.fillScreen(0);
  matrix.drawRoundRect(0, 0, 64, 32, 3, colors[1]);
  matrix.drawRoundRect(1, 1, 62, 30, 3, colors[1]);
  matrix.setTextSize(2);
  matrix.setCursor(3, 4);
  matrix.print("Token");
  matrix.setTextSize(1);
  matrix.setTextColor(colors[1]);
     matrix.setTextSize(2);
    matrix.setCursor(8, 16..3);
  matrix.print("No: 67");
 // matrix.drawBitmap(37, 3, Digit[digit_2], 10, 25, colors[3]);
  //matrix.drawBitmap(49, 3, Digit[digit_3], 10, 25, colors[3]);
  matrix.show();
  delay(300);
}