@@ -37,7 +37,7 @@ const bool kMatrixSerpentineLayout = true;
3737// **********************************************************************************************************
3838
3939qindesign::teensydmx::Receiver dmxRx{Serial1};
40- uint8_t dmxRxBuf[6 ]; // Buffer up to 512 channels
40+ uint8_t dmxRxBuf[513 ]; // Buffer up to 513 channels, including the start code
4141
4242CRGB leds[NUM_LEDS];
4343CRGB ledsAudio[NUM_AUDIO_LEDS];
@@ -239,30 +239,29 @@ elapsedMillis elapsed;
239239int pattern = 0 ;
240240void loop ()
241241{
242- // Read up to 6 bytes (3rd param) starting from channel 1 (2nd param)
243- // Channel 0 is the start code
244- int read = dmxRx.readPacket (dmxRxBuf, 1 , 6 );
245- if (read == 6 ) {
242+ // Read up to 7 bytes (6 channels) starting from channel 0 (start code)
243+ int read = dmxRx.readPacket (dmxRxBuf, 0 , 7 );
244+ if (read == 7 && dmxRxBuf[0 ] == 0 ) { // Ensure start code is zero
246245 led = !led;
247246 digitalWrite (LED_BUILTIN, led);
248- int b = dmxRxBuf[0 ]; // brightness = 1
247+ int b = dmxRxBuf[1 ]; // brightness = 1
249248 if (b != BRIGHTNESS) {
250249 BRIGHTNESS = b;
251250 FastLED.setBrightness (BRIGHTNESS);
252251 Serial.printf (" Brightness: %u\n " , BRIGHTNESS);
253252 }
254- STEPS = dmxRxBuf[1 ]; // steps = 2
255- SPEEDO = dmxRxBuf[2 ]; // speed = 3
256- FADE = dmxRxBuf[3 ]; // fade = 4
257- int p = dmxRxBuf[4 ]; // pattern = 5
253+ STEPS = dmxRxBuf[2 ]; // steps = 2
254+ SPEEDO = dmxRxBuf[3 ]; // speed = 3
255+ FADE = dmxRxBuf[4 ]; // fade = 4
256+ int p = dmxRxBuf[5 ]; // pattern = 5
258257 pattern = map (p, 0 , 255 , 0 , (gPatternCount - 1 ));
259258 if (p > (gPatternCount - 1 )) {
260259 p = 0 ;
261260 }
262261 else {
263262 pattern = p;
264263 }
265- currentPalette = palettes[map (dmxRxBuf[5 ], 0 , 255 , 0 , (paletteCount - 1 ))]; // channel 6
264+ currentPalette = palettes[map (dmxRxBuf[6 ], 0 , 255 , 0 , (paletteCount - 1 ))]; // channel 6
266265// EVERY_N_SECONDS( 2 ) {
267266// Serial.println(p);
268267// Serial.print("b=");
0 commit comments