#include "globals.h"
#include "lightsController.h"
lightsController lights(numLeds, lightDataPin); // creates the lights object
#include "colourValues.h" // needs to be after the lights object declaration 

#include "buttonsSetup.h"
#include "gameMechanics.h"

#include "menu.h"



void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud rate

  lights.begin(); // initializes the lights

  // intializes the buttons 
  for (uint8_t i = 0; i < numButtons; i++) {
    pinMode(btnPins[i], INPUT_PULLUP);
    buttonState[i] = false; // Initialize all button states to false
    buttonStateActedOn[i] = false; // Initialize all button state actions to false
    lastInterruptTime[i] = 0; // intializes the last Interupt Time 
  }

  setInterupt();

  Serial.println("Successfully Started Up!");

}


void loop() {
  //////////////////////////////////////////////
  //////////////////////////////////////////////
  //////////////////////////////////////////////
  // CALL YOUR GAME FUNCTION HERE TO TEST! 
  //////////////////////////////////////////////
  //////////////////////////////////////////////
  //////////////////////////////////////////////
  gameChoices[0].functions[2]();

  unsigned long now = millis(); // gets the current time 

  // run idle loop (music and lights)


  // check start button for a press 

    // start the game 


  // Checks all buttons for a press 
  for (uint8_t i = 0; i < numButtons; i++) { if (buttonPressCheck(now, i)) {
    // when there is a valid proper button press
    Serial.print("Button ");
    Serial.print(i);
    Serial.print(" hit by pin ");
    Serial.println(btnPins[i]);
    lights.toggleButton(i, rainbow[random(12)]); 
  }}

  // check for game mode change 
  

  delay(50);
}