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

using namespace dccd;

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

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

void dccd::Thtrottle::init(dccd::DccdHw* dccd_hw)
{	
	this->hardware = dccd_hw;
	this->is_new = 0;
	this->active = 0;
	
	this->treshold_on = 55;
	this->treshold_off = 45;
}

void dccd::Thtrottle::process(void)
{
	if(this->active)
	{
		if(this->hardware->pot.last_percent <= this->treshold_off)
		{
			this->active = 0;
			this->is_new = 1;
		}
		else this->active = 1;
	}
	else
	{
		if(this->hardware->pot.last_percent >= this->treshold_on)
		{
			this->active = 1;
			this->is_new = 1;
		}
		else this->active = 0;
	}
}

uint8_t dccd::Thtrottle::is_active(void)
{
	return this->active;
}

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