Interactive LED Beer Pong Table: 8. Steps (with Pictures)I have created a few basic functions to be used with the LED grid. Before we start making any animations, I will walk you through these functions so that you have a better understanding in regards to how they work. Each basic function will only modify the LED data, it won't actually write it to the grid. When you want to write the modified data to grid, you need to call a grid update (HT1. Download Ping-Pong free game for PC today. No time limits full version game! Trusted and safe download. PC games games always free! Racing games to play with no time limit restrictions! Exclusive free to download & free to play racing games. ![]() Play Creepy Pong - See how many Halloween ghouls you can beat at table tennis! UPDATE = 1). void LED_Pixel(UINT8 px, UINT8 py, UINT8 state)This function takes an (x,y) coordinate and modifies the bit that the pixel represents. If 'state' is equal to 1, the bit that the pixel represents will be set to a 1, if state is equal to 0, the bit will be cleared to 0. Back in step #4. 5 in example #2, we had to modify the LED data to turn on Pixel(1. If we were to use this function to turn on the LED at (1. LED_Pixel(1. 1,7,ON); HT1. UPDATE = 1; The reason that I don't update the pixel in the LED_Pixel(x,ystate) function itself is because we may want to modify multiple pixels and have them all update at the same time. Such as this: LED_Pixel(1. ON); LED_Pixel(1. ON); LED_Pixel(1. ON); LED_Pixel(1. ON); LED_Pixel(1. ON); LED_Pixel(1. ON); HT1. 63. 2_UPDATE = 1; Even though we have called LED_Pixel(x,y,state) six different times, the modified LED data will all be updated at the same time when the next timer. In case you were wondering, those pixels make up an 'L' shape on the grid. Draw_Circle(UINT8 px, UINT8 py, UINT8 radius)This function will modify the LED data and create a circle around the center point of (px,py). The 3rd parameter will set the radius of the circle. Photo #2 shows an example for the following code: Draw_Circle(1. HT1. 63. 2_UPDATE = 1; void Draw_Rect(UINT8 px, UINT8 py, UINT8 sx, UINT8 sy)This function is used to draw a rectangle starting at point (px,py). The size of the rectangle is specified in pixels by sx and sy. Photo #3 shows an example of how the rectangle is drawn (a square can also be created with this function). Draw_Rect(5,2,8,6); HT1. UPDATE = 1; void Fill_Grid(void)This function will set every bit in the LED data array to 1. If the grid is updated after calling this then all of the LED pixels will turn on. Fill_Grid(); HT1. UPDATE = 1; void Clear_Grid(void)This function will clear every bit in the LED data array to 0. If the grid is updated after calling this then all of the LED pixels will turn off. This function is useful when we want to draw a new frame on the LED grid, we can reset all of the old LED_data[x] bits and start modifying the data knowing that each bit has been reset to 0 (OFF). Clear_Grid(); //Clear out old data//Write in new data here. HT1. 63. 2_UPDATE = 1; void Draw_Border(UINT8 width)This function will draw a border around the perimeter of the LED grid. The width of the border is set by the value passed into 'width'. The maximum value for a border is 6 pixels (6 pixels * 2 sides = 1. COLs) and the minimum value is 1 (obviously). The example below is demonstrated in photo #4. Draw_Border(2); HT1. UPDATE = 1; void Invert_Grid(void)This function will simply invert each of the LED data bits. If you run this function right before you set HT1. UPDATE equal to 1, it will display the exact opposite of what it was going to display before running this function. LEDs that were on will be off and the LEDs that were off will be on).//Other code setting LED bits here. Invert_Grid(); HT1. UPDATE = 1; void HT1. Set_PWM(UINT8 value)This function is in the HT1. C driver files and it can set the LED grid to 1. Photo #5 shows the duty cycles for each brightness and photo #6 shows the duty cycles of each brightness in a graph form. This function does NOT need a grid update after it is called as it writes directly into the HT1. C drivers and adjusts the brightness through PWM. If we wanted to set the LED grid to dim down to a 1. HT1. 63. 2_Set_PWM(9); That's the majority of the basic functions. Now that you know how to control the LED grid we can combine these functions together and use time delays to make some really cool effects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
October 2017
Categories |