Permalink
Browse files

fix remaining v2 bug (serial buffer size), add note for arduino duemi…

…llanove
  • Loading branch information...
1 parent b72cc52 commit 604dfcf4b6d5d70664858033043abcae58063e0a @neophob committed Feb 16, 2012
Showing with 44 additions and 18 deletions.
  1. +43 −17 arduinoFw/main/kalikut/kalikut.ino
  2. +1 −1 processingApp/kalikut/kalikut.pde
View
60 arduinoFw/main/kalikut/kalikut.ino
@@ -58,15 +58,15 @@
//-----------------------------
//v 1.0 starts here
+
const byte modulesPerLetter[TOTAL_LETTERS] = {
// 5, 2, 1, 1, 5, 2, 2, 2}; //test with one strand
16, 15, 10, 10, 16, 15, 11, 15}; //actual
-
//v 1.0 ends here
//-----------------------------
-/*
+
//-----------------------------
//v 2.0 starts here
@@ -82,7 +82,7 @@ const byte modulesPerLetter[TOTAL_LETTERS] = {
//each letter is splitted up in two segments, a lower and a higher
//"now" uses only lower segment
-const byte pixelOffsetForSplittetLetter[16][15] = {
+const uint16_t pixelOffsetForSplittetLetter[16][15] = {
{ 0, 1, 2,13,14,15}, { 3, 4, 5, 6, 7, 8, 9,10,11,12}, //K
{16,17,18,26,27,28,29,30}, {19,20,21,22,23,24,25}, //A
{35,36,37,38,39,40}, {31,32,33,34}, //L
@@ -95,21 +95,45 @@ const byte pixelOffsetForSplittetLetter[16][15] = {
//how many modules per segment
const byte segmentSize[16] = {
- 6, 10, //K
- 8, 7, //A
- 6, 4, //L
- 5, 5, //I
- 6, 10, //K
- 7, 8, //U
- 3, 8, //T
- 15,0
+ 6, 10, //K
+ 8, 7, //A
+ 6, 4, //L
+ 5, 5, //I
+ 6, 10, //K
+ 7, 8, //U
+ 3, 8, //T
+ 15, 0
+};
+
+/*
+//test with one strand
+const uint16_t pixelOffsetForSplittetLetter[16][5] = {
+ { 0 }, { 1 },
+ { 2 }, { 3 },
+ { 4 }, { 5 },
+ { 6 }, { 7 },
+ { 10 }, { 11 },
+ { 12 }, { 13 },
+ { 14 }, { 15 },
+ { 17,18,19 }, { }
+};
+
+const byte segmentSize[16] = {
+ 1, 1,
+ 1, 1,
+ 1, 1,
+ 1, 1,
+ 1, 1,
+ 1, 1,
+ 1, 1,
+ 3, 0,
};
/**/
//v 2.0 ends here
//-----------------------------
//array that will hold the serial input string
-byte serInStr[TOTAL_LETTERS+SERIAL_HEADER_SIZE];
+byte serInStr[2*TOTAL_LETTERS+SERIAL_HEADER_SIZE]; //*2 is only needed for v2
// Choose which 2 pins you will use for output.
// Can be any valid output pins.
@@ -119,6 +143,7 @@ int clockPin =3; // 'blue' wire
//initialize pixels
LPD6803 strip = LPD6803(TOTAL_MODULES, dataPin, clockPin);
+//I set it to 64 for arduino duemillanove
#define SERIALBUFFERSIZE 4
byte serialResonse[SERIALBUFFERSIZE];
@@ -170,12 +195,13 @@ void loop() {
//what kind of command we send
byte type = serInStr[3];
//get the image data
- byte* cmd = serInStr+5;
+ byte* cmd = serInStr+5;
switch (type) {
case CMD_SENDFRAME:
//the size of buffer must match the number of all letters
- if (sendlen == TOTAL_LETTERS*2) {
+ if (sendlen == TOTAL_LETTERS*2) { //v1
+// if (sendlen == TOTAL_LETTERS*4) { //v2
updatePixels(0, cmd);
g_errorCounter = 0;
} else {
@@ -218,15 +244,15 @@ void updatePixels(byte ofs, byte* buffer) {
}
//v2: two segments per letter
-/* for (byte i=0; i < TOTAL_LETTERS*2*2; i++) {
+/* for (byte i=0; i < TOTAL_LETTERS*2; i++) {
color = buffer[src]<<8 | buffer[src+1];
for (byte n=0; n < segmentSize[i]; n++) {
//two bytes per pixel
strip.setPixelColor(pixelOffsetForSplittetLetter[i][n], color);
}
src+=2;
- }
-*/
+ }*/
+
strip.doSwapBuffersAsap(0);
}
View
2 processingApp/kalikut/kalikut.pde
@@ -98,7 +98,7 @@ void draw() {
drawLetter();
- //send serial data if initialized and wait at leas 19ms before sending again
+ //send serial data if initialized and wait at least 19ms before sending again
if (initialized && System.currentTimeMillis()-lastSendTime > 19) {
lastSendTime = System.currentTimeMillis();
//println(lastSendTime+" send: "+colorArray.length);

0 comments on commit 604dfcf

Please sign in to comment.