diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index fd13a41..3ec5710 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -72,7 +72,7 @@ Once a new OPCODE is decided upon, update this list. M, Write DCC packet n, Reserved for SensorCam N, Reserved for Sensorcam - o, + o, Neopixel driver (see also IO_NeoPixel.h) O, Output broadcast p, Broadcast power state P, Write DCC packet @@ -394,7 +394,34 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) return; break; - case 'z': // direct pin manipulation +#ifndef IO_NO_HAL + case 'o': // Neopixel pin manipulation + if (p[0]==0) break; + { + VPIN vpin=p[0]>0 ? p[0]:-p[0]; + bool setON=p[0]>0; + if (params==1) { // + IODevice::write(vpin,setON); + return; + } + if (params==2) { // + for (auto pix=vpin;pix<=vpin+p[1];pix++) IODevice::write(pix,setON); + return; + } + if (params==4 || params==5) { // + uint16_t colourcode=((p[1] & 0x1F)<<11) | + ((p[2] & 0x1F)<<6) | + ((p[3] & 0x1F)<<1); + if (setON) colourcode |= 0x0001; + // driver treats count 0 as 1 + for (auto pix=vpin;pix<=vpin+p[4];pix++) IODevice::writeAnalogue(pix,colourcode,0,0); + return; + } + } + break; +#endif + + case 'z': // direct pin manipulation if (p[0]==0) break; if (params==1) { // if (p[0]>0) IODevice::write(p[0],HIGH);