Ejemplo n.º 1
0
 public override void initializeStrand(byte strand, ColorOrdering ordering,
                                       StrandSpeed speed, byte ioPin, byte length)
 {
     writeRegister(Register.INITIALIZE, strand,
                   (byte)(ordering.Ordinal() << 4 | speed.Ordinal()), ioPin, length);
 }
Ejemplo n.º 2
0
 public IStrand InitializeStrand(byte id, ColorOrdering ordering, StrandSpeed speed, byte gpioPin, byte nLeds)
 {
     strands[id] = new Strand(id, nLeds, bridge);
     bridge.sendCommand(new byte[] { (byte)NEO_PIXEL, INITIALIZE, id, (byte)((byte)speed << 2 | (byte)ordering), gpioPin, nLeds });
     return(strands[id]);
 }
Ejemplo n.º 3
0
 /**
  * Called when the strand state has been read
  * @param strandIndex Strand index read
  * @param order Color ordering of the specific strand
  * @param speed Interface speed of the strand
  * @param pin Pin number on the MetaWear board the NeoPixel strand is connected to
  * @param strandLength Number of pixels on the strand
  */
 public void receivedStrandState(byte strandIndex, ColorOrdering order, StrandSpeed speed, byte pin, byte strandLength)
 {
 }
Ejemplo n.º 4
0
 /**
  * Initialize a NeoPixel strand
  * @param strand Index to initialize
  * @param ordering Color ordering format
  * @param speed Operating speed
  * @param ioPin MetaWear pin number the strand is connected to
  * @param length Number of pixels to initialize
  */
 public abstract void initializeStrand(byte strand, ColorOrdering ordering, StrandSpeed speed, byte ioPin, byte length);
Ejemplo n.º 5
0
            public override void notifyCallbacks(List <MetaWearController.ModuleCallbacks> callbacks,
                                                 byte[] data)
            {
                if (notifyType == NEOPIXEL_Notify_type.None)
                {
                    return;
                }

                switch (notifyType)
                {
                case NEOPIXEL_Notify_type.StrandState:
                {
//                        StrandSpeed speed= StrandSpeed.values[(byte)(data[3] & 0xf)];
                    StrandSpeed   speed = (StrandSpeed)(Enum.GetValues(typeof(StrandSpeed)) as byte[])       [(byte)(data[3] & 0xf)];
                    ColorOrdering order = (ColorOrdering)(Enum.GetValues(typeof(ColorOrdering)) as byte[]) [(byte)((data[3] >> 4) & 0xf)];
                    foreach (Callbacks cb in callbacks)
                    {
                        cb.receivedStrandState(data[2], order, speed, data[4], data[5]);
                    }

                    return;
                }

                case NEOPIXEL_Notify_type.HoldState:
                {
                    foreach (Callbacks cb in callbacks)
                    {
                        cb.receivedHoldState(data[2], data[3]);
                    }

                    return;
                }

                case NEOPIXEL_Notify_type.PixelColor:
                {
                    foreach (Callbacks cb in callbacks)
                    {
                        cb.receivedPixelColor(data[2], data[3], data[4], data[5], data[6]);
                    }

                    return;
                }

                case NEOPIXEL_Notify_type.RotationState:
                {
                    RotationDirection direction = (RotationDirection)(Enum.GetValues(typeof(RotationDirection)) as byte[])[data[3]];
//                        short delay= ByteBuffer.wrap(data, 5, 2).getShort();
                    // assumes BitConverter.IsLittleEndian is true
                    short delay = BitConverter.ToInt16(data, 5);
                    if (BitConverter.IsLittleEndian)
                    {
                        delay = delay.SwapBytes();
                    }

                    foreach (Callbacks cb in callbacks)
                    {
                        cb.receivedRotatationState(data[2], direction, data[4], delay);
                    }

                    return;
                }
                }
            }