#include <TimerOne.h>
#include <Wire.h>
#include <MultiFuncShield.h>

void setup() {
  Serial.begin(9600);
  Timer1.initialize();
  MFS.initialize(&Timer1);

  // short beep for 200 milliseconds
  MFS.beep();

  delay(1000);

  // 4 short beeps, repeated 3 times.
  MFS.beep(5, // beep for 50 milliseconds
           5, // silent for 50 milliseconds
           4, // repeat above cycle 4 times
           3, // loop 3 times
           50 // wait 500 milliseconds between loop
          );
}

void loop() {
  byte btn = MFS.getButton();

  if (btn) {
    byte buttonNumber = btn & B00111111;
    byte buttonAction = btn & B11000000;

    Serial.print("BUTTON_");
    Serial.write(buttonNumber + '0');
    Serial.print("_");

    if (buttonAction == BUTTON_PRESSED_IND) {
      Serial.println("PRESSED");
    }
    else if (buttonAction == BUTTON_SHORT_RELEASE_IND) {
      Serial.println("SHORT_RELEASE");
    }
    else if (buttonAction == BUTTON_LONG_PRESSED_IND) {
      Serial.println("LONG_PRESSED");
    }
    else if (buttonAction == BUTTON_LONG_RELEASE_IND) {
      Serial.println("LONG_RELEASE");
    }
  }

}
