Skip to content

Commit 57eb178

Browse files
committed
Update gitignore file, removed the old info about the old wiring batch from the README.txt. Update the version number to 1.3 in the build.xml file and added Chris's PixelStepper code which uses all the developer shield features.
1 parent 16c8a5a commit 57eb178

File tree

4 files changed

+180
-9
lines changed

4 files changed

+180
-9
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*~
2+
.*.swp
3+
*.py[co]
4+
*.egg
5+
*.egg-info
6+
*.old
7+
MANIFEST
8+
dist/
9+
build/
10+
venv/
11+
.DS_Store
12+
.cache
13+
arduino-TCL-*.zip

README.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ Yellow: Clock
2828
Green: Data
2929
Blue: Ground
3030

31-
If you're cutting and connecting individual LEDs, the color coding is
32-
somewhat different, with the following mappings:
33-
34-
Red: +5V
35-
Green: Clock
36-
White: Data
37-
Blue: Ground
38-
3931
If you are using a small number of LEDs the Arduino itself can provide power
4032
to the strand, but for a significant number of lights (greater than 5) an
4133
external power source should be attached. The Arduino will control the lights

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project name="arduino-tcl" default="zip" basedir=".">
22

33
<target name="init">
4-
<property name="version" value="1.2"/>
4+
<property name="version" value="1.3"/>
55
<property name="zipname" value="arduino-TCL-${version}.zip"/>
66
</target>
77

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/*****************************************************************************
2+
* PixelStepper.ino
3+
* Version 1.0.0
4+
*
5+
* Notes: Needs better comments and docs!
6+
*
7+
*
8+
* Copyright 2014 Chris O'Halloran - cknight __ ghostwheel _ com
9+
* Copyright Chris O'Halloran
10+
* License: Attribution Non-commercial Share Alike (by-nc-sa) (CC BY-NC-SA 4.0)
11+
* https://creativecommons.org/licenses/by-nc-sa/4.0/
12+
* https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
13+
****************************************************************************/
14+
15+
#include <SPI.h>
16+
#include <TCL.h>
17+
18+
const int LEDS = 25;
19+
byte red_values[LEDS];
20+
byte green_values[LEDS];
21+
byte blue_values[LEDS];
22+
byte color_temp[4];
23+
char* myColors[]={"NULL", "RED", "GREEN", "BLUE"};
24+
25+
int SWITCHSTATE; // A single point of reference for the state of the switches
26+
27+
int MOMENTARY1_Initial_State;
28+
int MOMENTARY2_Initial_State;
29+
int TCL_SWITCH1_Initial_State;
30+
int TCL_SWITCH2_Initial_State;
31+
32+
33+
void setup() {
34+
TCL.begin();
35+
TCL.setupDeveloperShield();
36+
Serial.begin(9600); // Start serial communication at 9600 baud
37+
38+
MOMENTARY1_Initial_State = digitalRead(TCL_MOMENTARY1);
39+
MOMENTARY2_Initial_State = digitalRead(TCL_MOMENTARY2);
40+
41+
reset_strand();
42+
43+
}
44+
45+
void loop() {
46+
int i;
47+
48+
CheckSwitches();
49+
check_button_press();
50+
51+
for(i=1;i<LEDS;i++) {
52+
red_values[i]=color_temp[1];
53+
green_values[i]=color_temp[2];
54+
blue_values[i]=color_temp[3];
55+
}
56+
57+
update_strand();
58+
}
59+
60+
61+
62+
void print_color_status() {
63+
64+
Serial.print("TCL.sendColor(0x");
65+
Serial.print(color_temp[1],HEX);
66+
Serial.print(",0x");
67+
Serial.print(color_temp[2],HEX);
68+
Serial.print(",0x");
69+
Serial.print(color_temp[3],HEX);
70+
Serial.println(")");
71+
}
72+
73+
74+
75+
76+
void CheckSwitches() {
77+
78+
if (digitalRead(TCL_SWITCH1) == 0 && digitalRead(TCL_SWITCH2) == 0){
79+
SWITCHSTATE = 0;
80+
red_values[0] = 0;
81+
green_values[0] = 0;
82+
blue_values[0] = 0;
83+
}
84+
else if (digitalRead(TCL_SWITCH1) == 1 && digitalRead(TCL_SWITCH2) == 0){
85+
SWITCHSTATE = 1;
86+
red_values[0] = 255;
87+
green_values[0] = 0;
88+
blue_values[0] = 0;
89+
}
90+
else if (digitalRead(TCL_SWITCH1) == 0 && digitalRead(TCL_SWITCH2) == 1){
91+
SWITCHSTATE = 2;
92+
red_values[0] = 0;
93+
green_values[0] = 255;
94+
blue_values[0] = 0;
95+
}
96+
else{
97+
SWITCHSTATE = 3;
98+
red_values[0] = 0;
99+
green_values[0] = 0;
100+
blue_values[0] = 255;
101+
}
102+
103+
}
104+
105+
void check_button_press() {
106+
int was_reset=0;
107+
108+
if (digitalRead(TCL_MOMENTARY1) != MOMENTARY1_Initial_State) {
109+
while (digitalRead(TCL_MOMENTARY1) != MOMENTARY1_Initial_State) {
110+
if (digitalRead(TCL_MOMENTARY2) != MOMENTARY2_Initial_State && was_reset == 0) {
111+
color_temp[SWITCHSTATE] = 255;
112+
was_reset = 1;
113+
Serial.print("Jump to 255: ");
114+
Serial.println(myColors[SWITCHSTATE]);
115+
}
116+
}
117+
if ( was_reset == 0 ) {
118+
color_temp[SWITCHSTATE] = min(color_temp[SWITCHSTATE]++, 255);
119+
Serial.print("up: ");
120+
Serial.println(myColors[SWITCHSTATE]);
121+
}
122+
print_color_status();
123+
}
124+
125+
if (digitalRead(TCL_MOMENTARY2) != MOMENTARY2_Initial_State) {
126+
while (digitalRead(TCL_MOMENTARY2) != MOMENTARY2_Initial_State) {
127+
if (digitalRead(TCL_MOMENTARY1) != MOMENTARY1_Initial_State && was_reset == 0) {
128+
color_temp[SWITCHSTATE] = 0;
129+
was_reset = 1;
130+
Serial.print("Jump to 000: ");
131+
Serial.println(myColors[SWITCHSTATE]);
132+
}
133+
}
134+
if ( was_reset == 0 ) {
135+
color_temp[SWITCHSTATE] = max(color_temp[SWITCHSTATE]--, 0);
136+
Serial.print("down: ");
137+
Serial.println(myColors[SWITCHSTATE]);
138+
}
139+
print_color_status();
140+
}
141+
142+
}
143+
144+
void reset_strand() {
145+
int i;
146+
147+
for(i=0;i<LEDS;i++) {
148+
red_values[i]=0;
149+
green_values[i]=0;
150+
blue_values[i]=0;
151+
}
152+
update_strand();
153+
}
154+
155+
156+
void update_strand() {
157+
int i;
158+
159+
TCL.sendEmptyFrame();
160+
for(i=0;i<LEDS;i++) {
161+
TCL.sendColor(red_values[i],green_values[i],blue_values[i]);
162+
}
163+
TCL.sendEmptyFrame();
164+
}
165+
166+

0 commit comments

Comments
 (0)