/* setThreshold: Sets interruption threshold configuring the corresponding digipot
 *	Parameters:	uint8_t sensor 
 * 						- SENS_SOCKET1
 * 						- SENS_SOCKET2
 * 						- SENS_SOCKET3
 * 						- SENS_SOCKET4
 * 						- SENS_SOCKET5
 * 						- SENS_SOCKET6
 * 			  : float threshold : interruption threshold of the sensor between 0
 * 								  and 3.3V
 *  Return:		uint8_t error
 * 						- 1 : success / no error detected
 * 						- -1 : wrong socket introduced
 * 						- -2 : wrong threshold introduced
 * 
 */
int8_t	WaspSensorCities::setThreshold(uint16_t sensor, float threshold) 
{
	if( ( threshold < 0 ) || ( threshold > 3.3 ) )
	{
		return -2;
	}
	
	switch( sensor )
	{
		case	SENS_CITIES_DUST			:	setDigipot0(B0101010,threshold);
												break;
		case	SENS_CITIES_LD				:	setDigipot1(B0101000,threshold);
												break;
		case	SENS_CITIES_AUDIO			:	setDigipot1(B0101010,threshold);
												break;
		case	SENS_CITIES_HUMIDITY		:	setDigipot0(B0101111,threshold);
												break;
		case	SENS_CITIES_TEMPERATURE		:	setDigipot1(B0101100,threshold);
												break;
		case	SENS_CITIES_ULTRASOUND_5V	:	setDigipot0(B0101111,threshold);
												break;
		case	SENS_CITIES_ULTRASOUND_3V3	:	setDigipot1(B0101100,threshold);
												break;
		case	SENS_CITIES_LDR				:	setDigipot0(B0101100,threshold);
												break;
		case	SENS_CITIES_CD				:	setDigipot0(B0101100,threshold);
												break;
		case	SENS_CITIES_CP				:	setDigipot0(B0101100,threshold);
												break;
		default								:	return -1;
	}
	
	return 1;
}
/* setThreshold: Sets interruption threshold configuring the corresponding digipot
 *	Parameters:	uint8_t sensor 
 * 						- SENS_SOCKET1
 * 						- SENS_SOCKET2
 * 						- SENS_SOCKET3
 * 						- SENS_SOCKET4
 * 						- SENS_SOCKET5
 * 						- SENS_SOCKET6
 * 			  : float threshold : interruption threshold of the sensor between 0
 * 								  and 3.3V
 *  Return:		uint8_t error
 * 						- 1 : success / no error detected
 * 						- -1 : wrong socket introduced
 * 						- -2 : wrong threshold introduced
 * 
 */
int8_t	WaspSensorEvent_v20::setThreshold(uint8_t sensor, float threshold) 
{
	if( ( threshold < 0 ) || ( threshold > 3.3 ) )
	{
		return -2;
	}
	
	switch( sensor )
	{
		case	SENS_SOCKET1	:	setDigipot1(B0101000,threshold);
									break;
		case	SENS_SOCKET2	:	setDigipot0(B0101000,threshold);
									break;
		case	SENS_SOCKET3	:	setDigipot0(B0101100,threshold);
									break;
		case	SENS_SOCKET4	:	setDigipot1(B0101100,threshold);
									break;
		case	SENS_SOCKET5	:	setDigipot0(B0101010,threshold);
									break;
		case	SENS_SOCKET6	:	setDigipot1(B0101010,threshold);
									break;
		default					:	return -1;
	}
	
	return 1;	
}
/* setThreshold(sensor, threshold) - set threshold configuring digipots
 *
 * It sets threshold configuring digipots
 */
void	WaspSensorEvent::setThreshold(uint8_t sensor, float threshold) 
{
	switch( sensor )
	{
		case	SENS_SOCKET1	:	setDigipot1(B0101000,threshold);
						break;
		case	SENS_SOCKET2	:	setDigipot0(B0101000,threshold);
						break;
		case	SENS_SOCKET3	:	setDigipot0(B0101100,threshold);
						break;
		case	SENS_SOCKET4	:	setDigipot1(B0101100,threshold);
						break;
		case	SENS_SOCKET5	:	setDigipot0(B0101010,threshold);
						break;
		case	SENS_SOCKET6	:	setDigipot1(B0101010,threshold);
						break;
	}
}