void FadeOnLed(void)
{
	uint8_t increment_amount = 120;			//max brightness of each color
	ColorOnLed(increment_amount, 0, 0);		//sets first color up as red
	
	/*
	RED		= 1
	GREEN	= 2
	BLUE	= 3
	*/
	while(display_select == 0x01)
	{
		IncrementUp(2, increment_amount);
		IncrementDown(1, increment_amount);
		IncrementUp(3, increment_amount);
		IncrementUp(1, increment_amount);
		IncrementDown(2, increment_amount);
		IncrementDown(1, increment_amount);
		IncrementDown(3, increment_amount);
		IncrementUp(1, increment_amount);
		IncrementUp(2, increment_amount);
		IncrementDown(2, increment_amount);
	}
}
Beispiel #2
0
void g2Spinner::Render(int pX, int pY)
{
    // Source texture coordinates for spinner
    float SourceX, SourceY, SourceWidth, SourceHeight;
    int OutWidth, OutHeight;
    GetTheme()->GetComponent(g2Theme_Spinner_Pressed, &SourceX, &SourceY, &SourceWidth, &SourceHeight, &OutWidth, &OutHeight);
    
    // Compute the offsets based on the size of the text field
    int OffsetX = TextField->GetWidth();
    int OffsetY = 0;
    GetTheme()->GetComponentSize(g2Theme_TextField, NULL, &OffsetY);
    OffsetY = OffsetY / 2 - OutHeight / 2; // Centered vertically
    
    // Is the user's mouse on the top or bottom of the button?
    // Note the ternary comparison operator to do the half-height offset
    bool IsAbove = (MouseY < (OffsetY + (OutHeight / 2)));
    bool IsVerticalBound = (MouseY >= OffsetY && MouseY <= (OffsetY + OutHeight));
    
    // Disabled
    if(GetDisabled())
        DrawComponent(g2Theme_Spinner_Disabled, pX + OffsetX, pY + OffsetY);
    
    // Actively pressed on the buttons, need to draw only the pressed button
    else if( ((ControllerState & g2ControllerState_Pressed) == g2ControllerState_Pressed) && MouseX > TextField->GetWidth() && IsVerticalBound )
    {
        // Draw background normally, then draw the pressed button
        DrawComponent(g2Theme_Spinner, pX + OffsetX, pY + OffsetY);
        DrawComponent(pX + OffsetX, pY + OffsetY + (IsAbove ? 0 : (OutHeight / 2)), OutWidth, OutHeight / 2, SourceX, SourceY + (SourceHeight / 2.0f) * (IsAbove ? 0.0f : 1.0f), SourceWidth, SourceHeight / 2.0f);
    }
    // Normal
    else
        DrawComponent(g2Theme_Spinner, pX + OffsetX, pY + OffsetY);
    
    // Increase or decrease the value based on timing
    if((PressedTime > (g2Spinner_UpdateRate + g2Spinner_UpdateMin)) || (((ControllerState & g2ControllerState_Clicked) == g2ControllerState_Clicked) && MouseX > TextField->GetWidth() && IsVerticalBound))
    {
        if(IsAbove)
            IncrementUp();
        else
            IncrementDown();
        
        PressedTime -= g2Spinner_UpdateRate;
    }
    
    // Set the live value based on what the field currently has
    if(LiveValue != NULL)
        *LiveValue = (Type == g2SpinnerType_Float) ? GetFloat() : (float)GetInt();
}