#ifndef BUTTONS_H_
#define BUTTONS_H_

/**** Includes ****/
#include <stdint.h>
#include "../utils/vcounter.h"
#include "../bsp/board.h"

namespace hw {

/**** Public definitions ****/
const uint8_t BUTTON_OFF = 0;
const uint8_t BUTTON_ON  = 1;

class Button
{
	public:
	Button(void);
	~Button(void);
	
	uint8_t state;
	uint16_t dbnc_lim;
	uint8_t is_new;
	uint8_t update_din;
	
	void init(bsp::DigitalIn* din_ch, uint8_t act_lvl, util::VCounter* timer, uint16_t dbnc_lim);
	uint8_t process(void);
	uint8_t force_read(void);
	uint32_t time_read(void);
	void time_reset(void);
	uint32_t time_read_max(void);
	
	#ifndef TESTING
	protected:
	#endif
	bsp::DigitalIn* din_ch;
	util::VCounter* timer;
	uint8_t act_lvl;
	uint16_t state_start_ts;
	uint16_t dbnc_ts;
};

/**** Public function declarations ****/
#ifdef TESTING
#endif

} //namespace

#endif /* BUTTONS_H_ */