/**** Includes ****/
#include "../utils/utils.h"
#include "mode.h"

using namespace dccd;

/**** Private definitions ****/
/**** Private constants ****/
/**** Private variables ****/
/**** Private function declarations ****/
/**** Public function definitions ****/
dccd::ModeBtn::ModeBtn(void)
{
	return;
}

dccd::ModeBtn::~ModeBtn(void)
{
	return;
}

void dccd::ModeBtn::init(dccd::DccdHw* dccd_hw)
{	
	this->hardware = dccd_hw;
	this->btn_repeat_time = 0;
	this->is_new = 0;
}

void dccd::ModeBtn::cfg_debounce(uint16_t dbnc_time)
{
	this->hardware->btn_mode.dbnc_lim = dbnc_time;
}

void dccd::ModeBtn::process(void)
{	
	if((this->hardware->btn_mode.state==1)&&((this->hardware->btn_mode.is_new)||((this->hardware->btn_mode.time_read() >= this->btn_repeat_time)&&(this->btn_repeat_time!=0))))
	{
		this->hardware->btn_mode.time_reset();
		this->hardware->btn_mode.is_new = 0;
		this->is_new = 1;
	};
}

/**** Private function definitions ***/
