From 1c8e41e8ad9d39c3722e55dbde31a0852b1ab49a Mon Sep 17 00:00:00 2001 From: Gunstick Date: Mon, 16 Feb 2015 23:36:52 +0100 Subject: [PATCH] first light for s2l type packets icorrect mapping from xy coordinates to zigzag neopixel leds the reciever arduino code has a bad xy calculation so displays garbage from ram into the pixels --- displayclient/ardupixel/ardupixel.ino | 84 ++++++++++++++++++++------ displayclient/ardupixel/feed_stream.sh | 50 +++++++++++++++ 2 files changed, 116 insertions(+), 18 deletions(-) create mode 100755 displayclient/ardupixel/feed_stream.sh diff --git a/displayclient/ardupixel/ardupixel.ino b/displayclient/ardupixel/ardupixel.ino index a03ffa0..e3587f6 100644 --- a/displayclient/ardupixel/ardupixel.ino +++ b/displayclient/ardupixel/ardupixel.ino @@ -13,10 +13,14 @@ #define PIN 6 // How many NeoPixels are attached to the Arduino? -#define NUMPIXELS 25 +// at 800Mhz we can send 33333 color values / second +// so to have 60hz refresh the max pixels is 555 so we set it to arbitryrily 512 +#define ROWS 5 +#define COLS 5 +#define NUMPIXELS ROWS*COLS + + Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); - -uint16_t brightness = 10; // the mac will be filled out by serial number, stored as ascii hex in the eeprom 6 first bytes byte mac[] = { '2', 'S', 'L', 0, 0, 0 }; // 2(to) S-yn2-L-ights (2 because unicast + locally administered) @@ -61,8 +65,22 @@ void setup() { } Serial.println(); pixels.begin(); + pixels.show(); // Initialize all pixels to 'off' + + for(int x=0;x=0) { + pixels.setPixelColor(indirect(x,y), pixels.Color(r, g, b)); + } + } + Serial.println(); } pixels.show(); } -#define ROWS 5 -uint16_t indirect(uint16_t in) { - if((in/ROWS)%2) { - uint16_t t; - t=in/ROWS; - t*=ROWS; - t+=ROWS-(in%ROWS)-1; - return t; - } else { - return in; +uint16_t indirect(uint16_t col,uint16_t row) { + if(col>COLS) { return -1;} + if(row>ROWS) { return -1;} + + // orientation is top to bottom, one right, then bottom to top + // we may want to add a mirror into this if it's put into a window + + if(col%2) { // odd column, this reverses the direction + // invert the row + uint16_t invrow=ROWS-row-1; + return col*ROWS+invrow; + } else { // check if column is even, i.e. the first = 0 = even + return col*ROWS+row; } } + diff --git a/displayclient/ardupixel/feed_stream.sh b/displayclient/ardupixel/feed_stream.sh new file mode 100755 index 0000000..77617ef --- /dev/null +++ b/displayclient/ardupixel/feed_stream.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# test program +# modify below the ethernet adress +# width and height are unfortunately hardcoded +a=-1 +while true +do +a=$((a+1)) +frame="$( + echo "s2l" + printf "55518 " + printf "1" + echo "" + #a=$(date +%S) + #a=$((0+a)) + j=0 + while [ $j -lt 5 ] + do + i=0 + while [ $i -lt 5 ] + do + n=$((i*5+j)) + if [ $n -eq $a ] + then + printf "xyz " + else + printf "012 " + fi + i=$((i+1)) + done + j=$((j+1)) + echo "" # next row + done + d=0 +# while [ $d -lt 12 ] +# do +# s=0 +# while [ $s -lt 8 ] +# do +# printf "1${s}1 " +# s=$((s+1)) +# done +# d=$((d+1)) +# echo "" # next display +# done +)" + echo "$frame" + echo "$frame" | nc -w 1 -u 10.2.113.161 8888 + sleep 1 +done