#include "Arduino.h"
#include "Button_Controler.h"

Button_Controler::Button_Controler(int left_pin, int middle_pin, int right_pin) :
  leftBtn(left_pin, 50, false, true),
  midBtn(middle_pin, 50, false, true),
  rightBtn(right_pin, 50, false, true),
  ls(false),
  ms(false),
  rs(false)
{
  leftBtn.begin();
  midBtn.begin();
  rightBtn.begin();
}

// Clear all states
void Button_Controler::Clear()
{
  ls = false;
  ms = false;
  rs = false;
}

void Button_Controler::Refresh()
{
  leftBtn.read();
  midBtn.read();
  rightBtn.read();

  if (leftBtn.wasPressed()) ls=true;
  if (midBtn.wasPressed()) ms=true;
  if (rightBtn.wasPressed()) rs=true;
}


bool Button_Controler::GetLeftState()
{
  bool tmp = ls;
  ls = false;
  return tmp;
}

bool Button_Controler::GetMidState()
{
  bool tmp = ms;
  ms = false;
  return tmp;
}

bool Button_Controler::GetRightState()
{
  bool tmp = rs;
  rs = false;
  return tmp;
}
