#include "SevSeg.h"
#include "Keypad.h"

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

SevSeg sevseg;

char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {23, 22, 3, 21}; // For Arduino Microcontroller
byte colPins[COLS] = {19, 18, 33, 17};





Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
  byte numDigits = 4;
  byte digitPins[] = {14, 15, 2, 5};
  byte segmentPins[] = {12, 4, 19, 26, 27, 13, 18, 25};
  bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_ANODE; // See README.md for options
  bool updateWithDelays = false; // Default 'false' is Recommended
  bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
  bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[]

  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
               updateWithDelays, leadingZeros, disableDecPoint);
}

void loop() {
  char key = keypad.getKey();
  if (key) {
    Serial.println(key);
    // set the number on the 7 segment display if the key is a number
    if (key >= '0' && key <= '9') {
      int num = key - '0';
      sevseg.setNumber(num);
    }
  }
  sevseg.refreshDisplay();
}