#include "TinyDebug.h"

#include <SmartButton.h>

constexpr int BUTTON_PIN = 2;

using namespace smartbutton;

void eventCallback(SmartButton *button, SmartButton::Event event, int clickCounter)
{

//    enum class State {
//        RELEASED,
//        PRESSED,
//        HOLD,
//        LONG_HOLD
//    };
//
//    enum class Event {
//        RELEASED,
//        PRESSED,
//        CLICK,
//        HOLD,
//        HOLD_REPEAT,
//        LONG_HOLD,
//        LONG_HOLD_REPEAT
//    };
//
//    enum class InputType {
//        NORMAL_HIGH,
//        NORMAL_LOW
//    };


	Debug.print(millis());
	Debug.print("\t");


	switch (event) {

		case SmartButton::Event::RELEASED:
			Debug.println("RELEASE");
			break;
		
		case SmartButton::Event::PRESSED:
			Debug.println("PRESS");
			break;
		
		case SmartButton::Event::CLICK:
			Debug.println("CLICK");
			break;
		
		case SmartButton::Event::HOLD:
			Debug.println("HOLD");
			break;
		
		case SmartButton::Event::HOLD_REPEAT:
			Debug.println("HOLD_REPEAT");
			break;
		
		case SmartButton::Event::LONG_HOLD:
			Debug.println("LONG_HOLD");
			break;
		
		case SmartButton::Event::LONG_HOLD_REPEAT:
			Debug.println("LONG_HOLD_REPEAT");
			break;

		default:
				break;
	}

}

SmartButton button(BUTTON_PIN, SmartButton::InputType::NORMAL_HIGH);

void setup()
{
    pinMode(BUTTON_PIN, INPUT_PULLUP);  // Digital input with pull-up resistors (normal high)

    button.begin(eventCallback);        // Initialize and register smart button
}

void loop()
{
    SmartButton::service();             // Asynchronous service routine, should be called periodically
}
ATTINY8520PU