/*
 * ButtonStateSm.h
 *
 *  Created on: 19 nov. 2023
 *      Author: remi.heredero
 */

#ifndef BUTTON_BUTTONSTATESM_H_
#define BUTTON_BUTTONSTATESM_H_

#include "xf/behavior.h"

class ButtonStateSm : public XFBehavior {
public:
	ButtonStateSm();
	virtual ~ButtonStateSm() = default;
	void genButtonPressed();
	void genButtonReleased();

protected:
	XFEventStatus processEvent();

	typedef enum {
		evButtonPressed,
		evButtonReleased,
		evTimeout
	} event;

	typedef enum {
		initial,
		waitButtonPressed,
		buttonPressed,
		buttonShortPressed,
		buttonLongPressed
	} state;

	state currentState_;
	state oldState_;
	bool changeState_;
	const uint8_t buttonIndex_;

private:
	static uint8_t getNbInstance();


};

#endif /* BUTTON_BUTTONSTATESM_H_ */
