| Project Illuminate Home |
These lights are also capable of displaying messages. If you choose, you can program the lights to display a message and compete in the message categories. To do this task, you would need to choose a phrase and then program your lights to write letters to spell out that phrase. (Be sure to follow the rules of the competition!) As an example, these lights are scrolling a message.
To help you, we have provided a message framework (called message_framework and available on your USB drive). This message framework has essentially the same files and setup as your pattern framework, but it does differ in some important ways:
15 10 5
14 9 4
13 8 3
12 7 2
11 6 1
0
(Don't worry! We will help you get this set up correctly!) In
the framework, then, the bulbs are addressed using
their (x,y) coordinates beginning from the upper left hand
corner (this is typical for graphics in computer science) as follows:
(0,0) (1,0) (2,0)
(0,1) (1,1) (2,1)
(0,2) (1,2) (2,2)
(0,3) (1,3) (2,3)
(0,4) (1,4) (2,4)
(2,5)
Therefore, when you refer to a bulb in this framework, you will refer
to it using its (x,y) coordinate rather than its position in
the strand of lights.
This framework has a similar setup. The grid data structure, a 2D-array representing the lights in their new configuration, holds the values for the lights, and then that data structure is reflected into the live lights using grid_mirror(). Like strand, grid has some extra spots to enable scrolling.
Additionally, this framework has another data structure, letter. The letter data structure is similar to grid except that it holds ints rather than pixels. letter provides a simplified way to set the bulbs to a particular color or to turn them off (more on how to represent a color as an int below), and then its data is reflected into grid which is then reflected to the live lights. Programming of the letter data structure takes place in the letters.cpp/h files.
enum {WHITE, RED};
This line is known as an enumeration, and it simply sets up
named integer constants, so that WHITE can be used as an
integer (and, in fact, represents the value 0) and RED can
also be used as an integer (it represents 1). You can read more about
enum in C/C++
on this
web page.
In this project, the enumerated types are used to indicate the desired color in many of the given functions. You can easily add your own colors to this enum, so feel free to try it on your own or ask for advice.
There are two important predefined functions in this framework: print_message() and print_letter(). print_message() displays the given message to "screen", one letter at a time, by calling print_letter(). print_letter() has three letters defined for you: A, B, and C. These functions are well-commented, so look over them carefully and be sure you understand what they do before you begin coding. Please ask if you need help our would like to verify your conclusions.
Happy Texting!