Skip to content

Commit

Permalink
Update gitignore file, removed the old info about the old wiring batc…
Browse files Browse the repository at this point in the history
…h 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.
  • Loading branch information
devries committed Jul 15, 2015
1 parent 16c8a5a commit 57eb178
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 9 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*~
.*.swp
*.py[co]
*.egg
*.egg-info
*.old
MANIFEST
dist/
build/
venv/
.DS_Store
.cache
arduino-TCL-*.zip
8 changes: 0 additions & 8 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ Yellow: Clock
Green: Data
Blue: Ground

If you're cutting and connecting individual LEDs, the color coding is
somewhat different, with the following mappings:

Red: +5V
Green: Clock
White: Data
Blue: Ground

If you are using a small number of LEDs the Arduino itself can provide power
to the strand, but for a significant number of lights (greater than 5) an
external power source should be attached. The Arduino will control the lights
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project name="arduino-tcl" default="zip" basedir=".">

<target name="init">
<property name="version" value="1.2"/>
<property name="version" value="1.3"/>
<property name="zipname" value="arduino-TCL-${version}.zip"/>
</target>

Expand Down
166 changes: 166 additions & 0 deletions examples/PixelStepper/PixelStepper.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*****************************************************************************
* PixelStepper.ino
* Version 1.0.0
*
* Notes: Needs better comments and docs!
*
*
* Copyright 2014 Chris O'Halloran - cknight __ ghostwheel _ com
* Copyright Chris O'Halloran
* License: Attribution Non-commercial Share Alike (by-nc-sa) (CC BY-NC-SA 4.0)
* https://creativecommons.org/licenses/by-nc-sa/4.0/
* https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
****************************************************************************/

#include <SPI.h>
#include <TCL.h>

const int LEDS = 25;
byte red_values[LEDS];
byte green_values[LEDS];
byte blue_values[LEDS];
byte color_temp[4];
char* myColors[]={"NULL", "RED", "GREEN", "BLUE"};

int SWITCHSTATE; // A single point of reference for the state of the switches

int MOMENTARY1_Initial_State;
int MOMENTARY2_Initial_State;
int TCL_SWITCH1_Initial_State;
int TCL_SWITCH2_Initial_State;


void setup() {
TCL.begin();
TCL.setupDeveloperShield();
Serial.begin(9600); // Start serial communication at 9600 baud

MOMENTARY1_Initial_State = digitalRead(TCL_MOMENTARY1);
MOMENTARY2_Initial_State = digitalRead(TCL_MOMENTARY2);

reset_strand();

}

void loop() {
int i;

CheckSwitches();
check_button_press();

for(i=1;i<LEDS;i++) {
red_values[i]=color_temp[1];
green_values[i]=color_temp[2];
blue_values[i]=color_temp[3];
}

update_strand();
}



void print_color_status() {

Serial.print("TCL.sendColor(0x");
Serial.print(color_temp[1],HEX);
Serial.print(",0x");
Serial.print(color_temp[2],HEX);
Serial.print(",0x");
Serial.print(color_temp[3],HEX);
Serial.println(")");
}




void CheckSwitches() {

if (digitalRead(TCL_SWITCH1) == 0 && digitalRead(TCL_SWITCH2) == 0){
SWITCHSTATE = 0;
red_values[0] = 0;
green_values[0] = 0;
blue_values[0] = 0;
}
else if (digitalRead(TCL_SWITCH1) == 1 && digitalRead(TCL_SWITCH2) == 0){
SWITCHSTATE = 1;
red_values[0] = 255;
green_values[0] = 0;
blue_values[0] = 0;
}
else if (digitalRead(TCL_SWITCH1) == 0 && digitalRead(TCL_SWITCH2) == 1){
SWITCHSTATE = 2;
red_values[0] = 0;
green_values[0] = 255;
blue_values[0] = 0;
}
else{
SWITCHSTATE = 3;
red_values[0] = 0;
green_values[0] = 0;
blue_values[0] = 255;
}

}

void check_button_press() {
int was_reset=0;

if (digitalRead(TCL_MOMENTARY1) != MOMENTARY1_Initial_State) {
while (digitalRead(TCL_MOMENTARY1) != MOMENTARY1_Initial_State) {
if (digitalRead(TCL_MOMENTARY2) != MOMENTARY2_Initial_State && was_reset == 0) {
color_temp[SWITCHSTATE] = 255;
was_reset = 1;
Serial.print("Jump to 255: ");
Serial.println(myColors[SWITCHSTATE]);
}
}
if ( was_reset == 0 ) {
color_temp[SWITCHSTATE] = min(color_temp[SWITCHSTATE]++, 255);
Serial.print("up: ");
Serial.println(myColors[SWITCHSTATE]);
}
print_color_status();
}

if (digitalRead(TCL_MOMENTARY2) != MOMENTARY2_Initial_State) {
while (digitalRead(TCL_MOMENTARY2) != MOMENTARY2_Initial_State) {
if (digitalRead(TCL_MOMENTARY1) != MOMENTARY1_Initial_State && was_reset == 0) {
color_temp[SWITCHSTATE] = 0;
was_reset = 1;
Serial.print("Jump to 000: ");
Serial.println(myColors[SWITCHSTATE]);
}
}
if ( was_reset == 0 ) {
color_temp[SWITCHSTATE] = max(color_temp[SWITCHSTATE]--, 0);
Serial.print("down: ");
Serial.println(myColors[SWITCHSTATE]);
}
print_color_status();
}

}

void reset_strand() {
int i;

for(i=0;i<LEDS;i++) {
red_values[i]=0;
green_values[i]=0;
blue_values[i]=0;
}
update_strand();
}


void update_strand() {
int i;

TCL.sendEmptyFrame();
for(i=0;i<LEDS;i++) {
TCL.sendColor(red_values[i],green_values[i],blue_values[i]);
}
TCL.sendEmptyFrame();
}


0 comments on commit 57eb178

Please sign in to comment.