// R2D2 - Simple driver for Sphero R2D2 // Copyright 2020 Ian Cowburn // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // using System; using System.Collections.Generic; namespace R2D2 { public static class Command { static private Dictionary commands; static Command() { commands = new Dictionary(); commands["Laugh"] = new byte[] {0x0A,0x18,0x00,0x1F,0x00,0x32,0x00,0x00,0x00,0x00,0x00}; commands["Yes"] = new byte[] {0x0A,0x17,0x05,0x41,0x00,0x0F}; commands["No"] = new byte[] {0x0A,0x17,0x05,0x3F,0x00,0x10}; commands["Alarm"] = new byte[] {0x0A,0x17,0x05,0x17,0x00,0x07}; commands["Angry"] = new byte[] {0x0A,0x17,0x05,0x18,0x00,0x08}; commands["Annoyed"] = new byte[] {0x0A,0x17,0x05,0x19,0x00,0x09}; commands["IonBlast"] = new byte[] {0x0A,0x17,0x05,0x1A,0x00,0x0E}; commands["Sad"] = new byte[] {0x0A,0x17,0x05,0x1C,0x00,0x11}; commands["Scared"] = new byte[] {0x0A,0x17,0x05,0x1D,0x00,0x13}; commands["Chatty"] = new byte[] {0x0A,0x17,0x05,0x17,0x00,0x0A}; commands["Confident"] = new byte[] {0x0A,0x17,0x05,0x18,0x00,0x12}; commands["Excited"] = new byte[] {0x0A,0x17,0x05,0x19,0x00,0x0C}; commands["Happy"] = new byte[] {0x0A,0x17,0x05,0x1A,0x00,0x0D}; commands["Laugh"] = new byte[] {0x0A,0x17,0x05,0x1B,0x00,0x0F}; commands["Surprise"] = new byte[] {0x0A,0x17,0x05,0x1C,0x00,0x18}; commands["Tripod"] = new byte[] {0x0A,0x17,0x0D,0x1D,0x01}; commands["Bipod"] = new byte[] {0x0A,0x17,0x0D,0x1C,0x02}; } public static ICollection GetNames() { return commands.Keys; } public static byte[] Get(string name) { if (commands.ContainsKey(name)) { return commands[name]; } else { return null; } } public static byte[] ForceCommand { get { return new byte[] {0x75,0x73,0x65,0x74,0x68,0x65,0x66,0x6F,0x72,0x63,0x65,0x2E,0x2E,0x2E,0x62,0x61,0x6E,0x64}; } } public static byte[] Wakeup { get { return new byte[] {0x0A,0x13,0x0D,0x00}; } } } }