DrawCircleOutletBox - Horizontal?

Do you have a question on how to do something.
Ask in here.
Post Reply
jerkyjunky
Posts: 12
Joined: Wed Nov 07, 2012 10:08 am

DrawCircleOutletBox - Horizontal?

Post by jerkyjunky »

I'm not sure if someone posted this before or not, but I was coding my display and saw people with the circle outlet options and thought it was great. However, the one already in RA_NokiaLCD.cpp is vertical, and since my relay box is mounted horizontal, not that awesome. I added a new function to the code and wanted to share it. Always like to give to communities that give back. Let me know what you think. ;)

Code: Select all

void RA_NokiaLCD::DrawCircleOutletBoxHorizontal(byte x, byte y, byte RelayData)
{
	// altered version of DrawCircleOutletBox by JerkyJunky
	// designed for a layout where the plugs are aligned like:
	// 8 6 4 2
	// 7 5 3 1
	
	//Variables:
	byte offset = 5;		//distance between given x,y location and the center of first circle
	byte a = 0;				//our counter of relay port
	byte b = 3;				//horizontal column counter
	byte c = 1;				//vertical row counter
	
	//Main Loop - Starting at port 1 work our way up and left
	for (a=0;a<8;a++)
	{
		DrawCircleOutline((b*10) + x + offset, (c*10) + y + offset, 5, OutletBorderColor);
		//check if relay is active and color appropriately
		if ((RelayData&(1<<a))==1<<a)
		{
			FillCircle((b*10) + x + offset, (c*10) + y + offset, 3, OutletOnBGColor);
		}
		else
		{
			FillCircle((b*10) + x + offset, (c*10) + y + offset, 3, OutletOffBGColor);
		}
		//adjust counters for next circle (up and left)
		if (c == 0)
		{
			c = 1;
			b = b - 1;
		}
		else
		{
			c = c - 1;
		}
	}
}
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: DrawCircleOutletBox - Horizontal?

Post by binder »

Awesome! Thanks for the contribution.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: DrawCircleOutletBox - Horizontal?

Post by psyrob »

Cool...my box is mounted horizontal as well, now I don't have to twist my head to match it to my screen!!
Image
Post Reply