Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
chipkit_ledboard [2015/03/10 20:21]
Joshua Woldstad [Step 5: Software]
chipkit_ledboard [2015/03/10 20:22] (current)
Joshua Woldstad [Step 5: Software]
Line 100: Line 100:
 {{:​snake.jpg?​200 |}} {{:​snake.jpg?​200 |}}
  
-In order to run the Snake program correctly, you must first install the [[https://​github.com/​mwingerson/​PICxel/​archive/​master.zip |PICxel Library]]. This library provides software designed to be used with the WS2812 LED strip. +In order to run the Snake program correctly, you must first install the [[https://​github.com/​mwingerson/​PICxel/​archive/​master.zip |PICxel Library]]. This library provides software designed to be used with the WS2812 LED strip. We'll check out the main driving force that allows our particular 30x30 array of LEDs to run as planned: the PICxel library. This library is surprisingly simple and straightforward to use. To start out and initialize the array of all 900 LEDs we first call the construction for the PICxel class:
- +
-We'll check out the main driving force that allows our particular 30x30 array of LEDs to run as planned: the PICxel library. This library is surprisingly simple and straightforward to use. +
- +
-To start out and initialize the array of all 900 LEDs we first call the construction for the PICxel class: +
 PICxel name_of_the_set_of_LEDs( how_many_LEDs_we_have,​ which_pin_the_data_is_being_sent_from_to_the_LEDs,​ color_mode);​ PICxel name_of_the_set_of_LEDs( how_many_LEDs_we_have,​ which_pin_the_data_is_being_sent_from_to_the_LEDs,​ color_mode);​
  
 Here we can provide how LEDs we are running (900), which pin the data is going to be used to connect to the data line on the LEDs (pin 3 in our case), and the desired color mode. Marshall'​s library supports two different color modes: GRB (RGB in a different order), and HSV. Our snake game happens to be using HSV since that allowed more flexibility for the user to choose both a color and the brightness. Here we can provide how LEDs we are running (900), which pin the data is going to be used to connect to the data line on the LEDs (pin 3 in our case), and the desired color mode. Marshall'​s library supports two different color modes: GRB (RGB in a different order), and HSV. Our snake game happens to be using HSV since that allowed more flexibility for the user to choose both a color and the brightness.
 +We can get the LEDs lit up and running by first calling in our setup the name_of_the_set_of_LEDs.begin();​
  
-We can get the LEDs lit up and running by first calling in our setup the name_of_the_set_of_LEDs.begin();​ 
 function and then choose the settings of the LEDs and subsequently update the strip of LEDs with our new values. function and then choose the settings of the LEDs and subsequently update the strip of LEDs with our new values.
 For HSV color mode, you can set the hue, saturation, and value. For those of you that might not know, these values roughly translate to the color, how "​bold"​ a particular color is instead of being washed out, and how "​bright"​ a color is instead of being dark, respectively. These are all set with the following function: name_of_the_set_of_LEDs.HSVsetLEDColor(which_LED_out_of_your_set_you_want_to_change,​ hue, saturaturation,​ value); For HSV color mode, you can set the hue, saturation, and value. For those of you that might not know, these values roughly translate to the color, how "​bold"​ a particular color is instead of being washed out, and how "​bright"​ a color is instead of being dark, respectively. These are all set with the following function: name_of_the_set_of_LEDs.HSVsetLEDColor(which_LED_out_of_your_set_you_want_to_change,​ hue, saturaturation,​ value);
 +
 This function will only set (but not yet update) the values on just one LED, so it's recommend to use a for loop to change multiple LED values. To update the LEDs so that they all show their new settings (or old if that particular LED was not updated), simply issue the following command: name_of_the_set_of_LEDs.refreshLEDs();​ This function will only set (but not yet update) the values on just one LED, so it's recommend to use a for loop to change multiple LED values. To update the LEDs so that they all show their new settings (or old if that particular LED was not updated), simply issue the following command: name_of_the_set_of_LEDs.refreshLEDs();​
 +
 The refresheLEDs() function utilizes port manipulation and assembly code to make for a tight library so very little time is wasted in sending out the new information to the WS2812 LEDs at their designated data rate. You can check out a screen shot of the HSV demo for this library in the picture for this step.  The refresheLEDs() function utilizes port manipulation and assembly code to make for a tight library so very little time is wasted in sending out the new information to the WS2812 LEDs at their designated data rate. You can check out a screen shot of the HSV demo for this library in the picture for this step.