public void SendValue(byte value, Codes.MessageType type)
        {
            switch (type)
            {
            case Codes.MessageType.BRIGHTNESS:
                this.leds.SetBrightness(value);
                break;

            case Codes.MessageType.PALETTE_CHANGE_DIVIDER:
            case Codes.MessageType.PALETTE:
            case Codes.MessageType.MODE:
            case Codes.MessageType.UPDATES_PER_SECOND:
                Console.WriteLine("Does nothing with Simulation Message Sender");
                break;

            default:
            case Codes.MessageType.CONTROL_HUE:
            case Codes.MessageType.CONTROL_RGB:
            case Codes.MessageType.CONTROL_HVS:
            case Codes.MessageType.COLOR:
            case Codes.MessageType.UNSET:
                throw new System.NotImplementedException("enum value not impleted with for this value");
            }
            this.leds.Render();
        }
示例#2
0
        public void SendValue(byte value, Codes.MessageType type)
        {
            var bytes = new byte[3];

            bytes[0] = 2;
            bytes[1] = (byte)type;
            bytes[2] = value;
            this.port.Write(bytes, 0, 3);
        }
示例#3
0
        public void SendValue(short value, Codes.MessageType type)
        {
            var shortBytes = BitConverter.GetBytes(value);
            var bytes      = new byte[4];

            bytes[0] = 3;
            bytes[1] = (byte)type;
            bytes[2] = shortBytes[0];
            bytes[3] = shortBytes[1];
            this.port.Write(bytes, 0, 4);
        }
示例#4
0
        public void SendValues(byte[] values, Codes.MessageType type)
        {
            var dataLength = values.Length;
            var msgLength  = dataLength + 1; // with control code
            var fullLength = msgLength + 1;  // with length

            if (fullLength > ARDUINO_UNO_BUFFER_SIZE)
            {
                throw new SerialException("Message is larger than buffer size");
            }

            var bytes = new byte[fullLength];

            bytes[0] = (byte)msgLength;
            bytes[1] = (byte)type;
            Array.Copy(values, 0, bytes, 2, dataLength);
            this.port.Write(bytes, 0, fullLength);
        }
示例#5
0
 public MessageBuilder(Codes.MessageType messageType)
 {
     this.MessageType = messageType;
 }