Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed one issue - Processing was overrunning the Arduino's serial buf…

…fers.

Right now it divides the input into 32-byte chunks and this seems to
alleviate the issue.
  • Loading branch information...
commit 461a8884e26185e840b7c885de4081331c586fb9 1 parent d2c2f55
Chris Hodapp authored
33 shiftbrite_master/shiftbrite_master_processing/shiftbrite_master_processing.pde
@@ -89,9 +89,13 @@ void draw() {
89 89 // offset is in [0, lim-1]
90 90 int maskX = mirrorMask ? lim - x - 1 : x;
91 91 maskX = (maskX + offset) % lim;
92   - int val = 255 * textMask[y][maskX];
  92 +
  93 + byte mask1 = textMask[y][maskX];
  94 + int r = 255 * mask1;
  95 + int g = 255 * mask1;
  96 + int b = 90 * mask1;
93 97 //int val = 100;
94   - display.pixels[linear] = color(val);
  98 + display.pixels[linear] = color(r, g, b);
95 99 }
96 100 }
97 101 display.updatePixels();
@@ -102,16 +106,16 @@ void draw() {
102 106 //tryClear();
103 107 //testFrame();
104 108 while (serialPort.available() > 0) {
105   - delay(50);
  109 + delay(10);
106 110 byte[] msg = serialPort.readBytes();
107 111 System.out.printf("Incoming before a command? %s\n", new String(msg));
108 112 System.out.printf("flushing buffer...\n");
109 113 }
110 114 pushFrame(display);
111   - delay(200);
  115 + delay(100);
112 116 //print("Test");
113 117 while (serialPort.available() > 0) {
114   - delay(50);
  118 + delay(10);
115 119 byte[] msg = serialPort.readBytes();
116 120 System.out.printf("Incoming: %s\n", new String(msg));
117 121 System.out.printf("flushing buffer...\n");
@@ -172,11 +176,22 @@ void pushFrame(PImage img) {
172 176 }
173 177 }
174 178 try {
175   - serialPort.output.write(cmd);
176   - System.out.printf("Outgoing (%d bytes), hex: ", cmd.length);
177   - for(int i = 0; i < cmd.length; ++i) {
178   - System.out.printf("%x", cmd[i]);
  179 + int chunkSize = 32;
  180 + int offset = 0;
  181 + while (offset < cmd.length) {
  182 + int remaining = cmd.length - offset;
  183 + byte tmp[] = new byte[min(chunkSize, remaining)];
  184 + for(int i = 0; i < chunkSize && i < remaining; ++i) {
  185 + tmp[i] = cmd[offset + i];
  186 + }
  187 + serialPort.output.write(tmp);
  188 + System.out.printf("Outgoing (%d bytes), hex: ", tmp.length);
  189 + for(int i = 0; i < tmp.length; ++i) {
  190 + System.out.printf("%x", tmp[i]);
  191 + }
  192 + offset += chunkSize;
179 193 }
  194 +
180 195 System.out.printf("\nASCII: %s", new String(cmd));
181 196 System.out.printf("\n");
182 197 } catch(IOException e) {

0 comments on commit 461a888

Please sign in to comment.
Something went wrong with that request. Please try again.