Example #1
0
/*!
 * @brief Thread handling the RTC
 */
void ToggleThread(void *data)
{
	LEDs_Off(LED_BLUE);
	LEDs_Off(LED_GREEN);
	LEDs_Off(LED_YELLOW);
	LEDs_Off(LED_ORANGE);
	Touch_EnableScan(bTRUE);
	uint8_t values = 0;
	for (;;)
	{
		//At least 5s, so 501 * 10ms > 5s
		if (Touch_Wait(501, &values) == OS_TIMEOUT)
		{
			break;
		}
		SetLeds(values);
	}
	LEDs_Off(LED_BLUE);
	LEDs_Off(LED_GREEN);
	LEDs_Off(LED_YELLOW);
	LEDs_Off(LED_ORANGE);
	Touch_EnableScan(bFALSE);
	(*Callback)((void *)0);
	OS_ERROR error = OS_ThreadDelete(OS_PRIORITY_SELF);
}
/**************************************************************
 *  Name                 : Valid_DOWN
 *  Description          :	Validates that DOWN button has been 
 								pressed for at least 10ms
 *  Parameters           :  Void
 *  Return               :	Void
 *  Critical/explanation :	No
 **************************************************************/
void Valid_DOWN(void)
{
	if(Switch_DOWN())
	{
		rsw_ValidationTime++;
		if(rsw_ValidationTime == ValidationPeriod)
		{
			if(WindowPtr != &WindowIdle)
			{
				WindowPtr = &WindowIdle;
				while(Switch_DOWN())
				{
					LEDs_Off();
				}
			}
			else
			{
				WindowPtr = &OneTouchDown;
			}
		}
		else if(rsw_ValidationTime >= OneTouchTimeOut)
		{
			ButtonPtr = &WindowIdle;
			WindowPtr = &ManualMode;
			rsw_ValidationTime = ValidationClear;
		}
	}
	else
	{
		ButtonPtr = &ButtonIdle;
		rsw_ValidationTime = ValidationClear;
	}
}
Example #3
0
File: state.c Project: Bobakka/uhd
void prefer_external(void){
    // if external is NOT OK, then force internal
    if(global_ext_ref_is_present)
        force_external();
    else if(global_gps_present)
        force_internal();
    else
        LEDs_Off();
}
Example #4
0
void Prefer_External(){
    // if external is NOT OK, then force Internal
    if(Global_Ext_Ref_Is_Present)
        Force_External();
    else if(Global_GPS_Present)
        Force_Internal();
    else
        LEDs_Off();
}
Example #5
0
void Prefer_Internal(){

    if(Global_GPS_Present)
        Force_Internal();
    else if(Global_Ext_Ref_Is_Present)
        Force_External();
    else
        LEDs_Off();
}
/**************************************************************
 *  Name                 : Valid_Pinch
 *  Description          :	Validates that pinch button has been 
 								pressed for at least 10ms
 *  Parameters           :	Void
 *  Return               :	Void
 *  Critical/explanation :  No
 **************************************************************/
void Valid_Pinch(void)
{
	if(PinchSwitch())
	{
		Delay_ms(10);
		if(PinchSwitch())
		{
			LEDs_Off();
			WindowPosition--;
			WindowPtr = &PinchOpen;
			LEDs_Off();
			LED_DOWN();
		}
	}
	else
	{
		/* Do nothing */
	}
}
/**************************************************************
 *  Name                 :	Task_400ms
 *  Description          :	Modifies WindowPosition depending on 
 								the button pressed
 *  Parameters           :  Void
 *  Return               :	Void
 *  Critical/explanation :  No
 **************************************************************/
void Task_400ms(void)	/* Manual operation; transition each 400ms */
{
	LEDs_Off();
	if(Switch_Combination())
	{
		WindowPtr = &WindowIdle;
		ButtonPtr = &ButtonIdle;
		LEDs_Off();
	}
	else if(Switch_UP())
	{
		LED_UP();
		WindowPosition++;
		if(WindowPosition >= CLOSED)
		{
			LEDs_Off();
			WindowPosition = CLOSED;
			WindowPtr = &WindowIdle;
			ButtonPtr = &ButtonIdle;
		}
		Valid_Pinch();
	}
	else if(Switch_DOWN())
	{
		LED_DOWN();
		WindowPosition--;
		if(WindowPosition <= OPENED)
		{
			LEDs_Off();
			WindowPosition = OPENED;
			WindowPtr = &WindowIdle;
			ButtonPtr = &ButtonIdle;
		}	
	}
	else
	{
		WindowPtr = &WindowIdle;
		ButtonPtr = &ButtonIdle;
		LEDs_Off();
	}
}
/**************************************************************
 *  Name                 : SafeOpen
 *  Description          :	Opens window and ignores button's signal
 *  Parameters           :  Void
 *  Return               :	Void
 *  Critical/explanation :  No
 **************************************************************/
void SafeOpen(void)
{
	WindowPosition--;
	if(WindowPosition <= OPENED)
	{
		WindowPosition = OPENED;
		WindowPtr = &PinchIdle;
		LEDs_Off();
	}
	else
	{
		/* Do nothing */
	}
}
/**************************************************************
 *  Name                 : OneTouch_DOWN
 *  Description          :	Activates the one-touch window function 
 								to open it
 *  Parameters           :	Void
 *  Return               :	Void
 *  Critical/explanation :	No
 **************************************************************/
void OneTouch_DOWN(void)
{
	LED_DOWN();
	WindowPosition--;
	if(WindowPosition <= OPENED)
	{
		LEDs_Off();
		WindowPosition = OPENED;
		WindowPtr = &WindowIdle;
	}
	else
	{
		/* Do nothing */
	}
	if(Switch_DOWN() | Switch_UP())
	{
		WindowPtr = &ManualMode;
	}
	else
	{
		/* Do nothing */
	}
}
/**************************************************************
 *  Name                 : OneTouch_UP
 *  Description          :	Activates the one-touch window 
 								function to close it
 *  Parameters           :	Void
 *  Return               :	Void
 *  Critical/explanation :	No
 **************************************************************/
void OneTouch_UP(void)
{
	LED_UP();
	WindowPosition++;
	if(WindowPosition >= CLOSED)
	{
		LEDs_Off();
		WindowPosition = CLOSED;
		WindowPtr = &WindowIdle;
	}
	else
	{
		/* Do nothing */
	}
	if(Switch_DOWN() | Switch_UP())
	{
		WindowPtr = &ManualMode;
	}
	else
	{
		/* Do nothing */
	}
	Valid_Pinch();
}
Example #11
0
/*!
 * @brief Callback after the UART timer expires.
 */
void BlueOff(void *arguments)
{
	LEDs_Off(LED_BLUE);
}