Esempio n. 1
0
 /// <summary>
 /// For "get" commands and simple "set" commands
 /// </summary>
 /// <param name="command"></param>
 public ScribblerCommand(ScribblerHelper.Commands command)
 {
     Data           = new byte[ScribblerHelper.CommandSize(command) - 1];
     CommandType    = (byte)command;
     HasEcho        = ScribblerHelper.HasEcho(command);
     ResponseLength = ScribblerHelper.ReturnSize(command);
 }
Esempio n. 2
0
 /// <summary>
 /// For setAllLEDs command
 /// </summary>
 public ScribblerCommand(ScribblerHelper.Commands command, bool left, bool center, bool right)
 {
     Data           = new byte[ScribblerHelper.CommandSize(command) - 1];
     CommandType    = (byte)command;
     Data[0]        = left ? (byte)1 : (byte)0;
     Data[1]        = center ? (byte)1 : (byte)0;
     Data[2]        = right ? (byte)1 : (byte)0;
     HasEcho        = ScribblerHelper.HasEcho(command);
     ResponseLength = ScribblerHelper.ReturnSize(command);
 }
Esempio n. 3
0
        /// <summary>
        /// for speaker commands
        /// </summary>
        /// <param name="command"></param>
        /// <param name="duration"></param>
        /// <param name="frequency1"></param>
        /// <param name="frequency2"></param>
        public ScribblerCommand(ScribblerHelper.Commands command, int duration, int frequency1, int frequency2)
        {
            Data        = new byte[ScribblerHelper.CommandSize(command) - 1];
            CommandType = (byte)command;

            Data[0] = (byte)(duration >> 8);
            Data[1] = (byte)duration;

            Data[2] = (byte)(frequency1 >> 8);
            Data[3] = (byte)frequency1;

            Data[4]        = (byte)(frequency2 >> 8);
            Data[5]        = (byte)frequency2;
            HasEcho        = ScribblerHelper.HasEcho(command);
            ResponseLength = ScribblerHelper.ReturnSize(command);
        }
Esempio n. 4
0
        /// <summary>
        /// For setName
        /// </summary>
        /// <param name="command"></param>
        /// <param name="data"></param>
        public ScribblerCommand(ScribblerHelper.Commands command, string data)
        {
            Data        = new byte[ScribblerHelper.CommandSize(command) - 1];
            CommandType = (byte)command;
            int length = Math.Min(data.Length, 8);

            char[] tmp = data.ToCharArray(0, length);
            for (int i = 0; i < length; i++)
            {
                Data[i] = (byte)tmp[i];
            }
            for (int i = length; i < 8; i++)
            {
                Data[i] = 0;
            }
            HasEcho        = ScribblerHelper.HasEcho(command);
            ResponseLength = ScribblerHelper.ReturnSize(command);
        }
Esempio n. 5
0
 /// <summary>
 /// For setAllLEDs command
 /// </summary>
 public ScribblerCommand(ScribblerHelper.Commands command, bool left, bool center, bool right)
 {
     Data = new byte[ScribblerHelper.CommandSize(command) - 1];
     CommandType = (byte)command;
     Data[0] = left ? (byte)1 : (byte)0;
     Data[1] = center ? (byte)1 : (byte)0;
     Data[2] = right ? (byte)1 : (byte)0;
     HasEcho = ScribblerHelper.HasEcho(command);
     ResponseLength = ScribblerHelper.ReturnSize(command);
 }
Esempio n. 6
0
        /// <summary>
        /// for speaker commands
        /// </summary>
        /// <param name="command"></param>
        /// <param name="duration"></param>
        /// <param name="frequency1"></param>
        /// <param name="frequency2"></param>
        public ScribblerCommand(ScribblerHelper.Commands command, int duration, int frequency1, int frequency2)
        {
            Data = new byte[ScribblerHelper.CommandSize(command) - 1];
            CommandType = (byte)command;

            Data[0] = (byte)(duration >> 8);
            Data[1] = (byte)duration;

            Data[2] = (byte)(frequency1 >> 8);
            Data[3] = (byte)frequency1;

            Data[4] = (byte)(frequency2 >> 8);
            Data[5] = (byte)frequency2;
            HasEcho = ScribblerHelper.HasEcho(command);
            ResponseLength = ScribblerHelper.ReturnSize(command);
        }
Esempio n. 7
0
 /// <summary>
 /// For setName
 /// </summary>
 /// <param name="command"></param>
 /// <param name="data"></param>
 public ScribblerCommand(ScribblerHelper.Commands command, string data)
 {
     Data = new byte[ScribblerHelper.CommandSize(command) - 1];
     CommandType = (byte)command;
     int length = Math.Min(data.Length, 8);
     char[] tmp = data.ToCharArray(0, length);
     for (int i = 0; i < length; i++)
         Data[i] = (byte)tmp[i];
     for (int i = length; i < 8; i++)
         Data[i] = 0;
     HasEcho = ScribblerHelper.HasEcho(command);
     ResponseLength = ScribblerHelper.ReturnSize(command);
 }
Esempio n. 8
0
 /// <summary>
 /// For setMotors
 /// </summary>
 /// <param name="command"></param>
 /// <param name="data1"></param>
 /// <param name="data2"></param>
 public ScribblerCommand(ScribblerHelper.Commands command, byte data1, byte data2)
 {
     Data = new byte[ScribblerHelper.CommandSize(command) - 1];
     CommandType = (byte)command;
     Data[0] = data1;
     Data[1] = data2;
     HasEcho = ScribblerHelper.HasEcho(command);
     ResponseLength = ScribblerHelper.ReturnSize(command);
 }
Esempio n. 9
0
 public ScribblerCommand(ScribblerHelper.Commands command, byte[] data, bool hasEcho, int responseLength)
 {
     CommandType = (byte)command;
     Data = data;
     HasEcho = hasEcho;
     ResponseLength = responseLength;
 }