void Start()
 {
     ai = GetComponent <ArduinoInterface>();
     flames.Stop();
     flameMusic.Stop();
     jutsuActivate  = false;
     jutsuActivate2 = false;
 }
Example #2
0
        void TransmitToArduino(msgType_e eType, int nMessage)
        {
            // Add transmission code here
            if (!ArduinoInterface.IsOpen)
            {
                return;
            }

            Byte[] bytes = new Byte[2];
            bytes[0] = Convert.ToByte((int)eType);
            bytes[1] = Convert.ToByte(nMessage);
            ArduinoInterface.Write(bytes, 0, 2);
        }
Example #3
0
        private void Timer_VOL_Tick(object sender, EventArgs e)
        {
            if (!ArduinoInterface.IsOpen || !m_bVolControl)
            {
                return;
            }

            if (ArduinoInterface.BytesToRead > 0)
            {
                char[] carray = new char[ArduinoInterface.BytesToRead];
                ArduinoInterface.Read(carray, 0, ArduinoInterface.BytesToRead);
                int nVol = carray[carray.Length - 1];
                VolumeVal.Text = nVol.ToString();
                VideoPlayerController.AudioManager.SetMasterVolume(nVol);
            }
        }
Example #4
0
        private void ComPort_TextChanged(object sender, EventArgs e)
        {
            if (ArduinoInterface.IsOpen)
            {
                ArduinoInterface.Close();
            }

            ArduinoInterface.PortName = ComPort.Text;

            try {
                ArduinoInterface.Open();
                ComStatus.Text = "OPEN";
            } catch {
                ComStatus.Text = "ERROR";
            }
        }
Example #5
0
        public MainWindow()
        {
            // AllocConsole();

            InitializeComponent();

            StartPosition = FormStartPosition.CenterScreen;
            for (int i = 0; i < m_VUMeters.Length; i++)
            {
                m_VUMeters[i] = new VUController();
            }

            VUController.SetupOpenHWM();

            React_VU1.SelectedIndex = 0;
            React_VU2.SelectedIndex = 0;

            ArduinoInterface.BaudRate = 9600;

            m_Settings = LoadSettingsFile();
            if (m_Settings == null)
            {
                m_Settings = GenerateSettings();
            }
            InstallSettings();

            try {
                ArduinoInterface.Open();
                ComStatus.Text = "OPEN";
            } catch {
                ComStatus.Text = "ERROR";
            }

            /*if (m_bStartHidden) {
             *      HideWindow_Click(null, null);
             * }*/
        }
 // Use this for initialization
 void Start()
 {
     ai         = cube.GetComponent <ArduinoInterface>();
     m_material = GetComponent <Renderer>().material;
 }
        private void relayMessageRecieved(object source, ArduinoInterface.ArduinoEventArgs args)
        {
            if (args.Command.Content == TetrisViewModel.moveLeft.Content)
            {
                TabViewModel[] viewModels = MainWindowViewModel.Instance.getTabByName("TetrisViewModel");
                if (viewModels != null)
                {
                    foreach (var item in viewModels)
                    {
                        ((TetrisViewModel) item).commandMoveLeft();
                    }
                }
            }
            else if (args.Command.Content == TetrisViewModel.moveRight.Content)
            {
                TabViewModel[] viewModels = MainWindowViewModel.Instance.getTabByName("TetrisViewModel");
                if (viewModels != null)
                {
                    foreach (var item in viewModels)
                    {
                        ((TetrisViewModel)item).commandMoveRight();
                    }
                }
            }
            else if (args.Command.Content == TetrisViewModel.moveDown.Content)
            {
                TabViewModel[] viewModels = MainWindowViewModel.Instance.getTabByName("TetrisViewModel");
                if (viewModels != null)
                {
                    foreach (var item in viewModels)
                    {
                        ((TetrisViewModel)item).commandMoveDown();
                    }
                }
            }
            else if (args.Command.Content == TetrisViewModel.turnLeft.Content)
            {
                TabViewModel[] viewModels = MainWindowViewModel.Instance.getTabByName("TetrisViewModel");
                if (viewModels != null)
                {
                    foreach (var item in viewModels)
                    {
                        ((TetrisViewModel)item).commandTurnLeft();
                    }
                }
            }
            else if (args.Command.Content == TetrisViewModel.turnRight.Content)
            {
                TabViewModel[] viewModels = MainWindowViewModel.Instance.getTabByName("TetrisViewModel");
                if (viewModels != null)
                {
                    foreach (var item in viewModels)
                    {
                        ((TetrisViewModel)item).commandTurnRight();
                    }
                }
            }

            else if (args.Command.Content == FlightSimViewModel.processed.Content)
            {
                TabViewModel[] viewModels = MainWindowViewModel.Instance.getTabByName("FlightSimViewModel");
                if (viewModels != null)
                {
                    foreach (var item in viewModels)
                    {
                        ((FlightSimViewModel)item).IsAirspeedProcessed = true;
                    }
                }
            }
        }
        private void processMessageRecieved(object source, ArduinoInterface.ArduinoEventArgs args)
        {
            if (!args.Command.IsFaulty)
            {
                switch (args.Command.Type)
                {
                    case ArduinoCommand.CommandTypes.Arduino_To_Arduino:
                        // Print Message
                        ArduinoConsole.AddConsoleText("Arduino to Arduino: @nobreak", ConsoleViewModel.TextColors.Turquoise);
                        // Relay to the target Arduino
                        if (ArduinoCollection.Any(p => p.ArduinoName == args.Command.Target))
                        {
                            try
                            {
                                // Send
                                ArduinoCollection.Single(p => p.ArduinoName == args.Command.Target).Send(args.Command);
                            }
                            catch (Exception e)
                            {
                                PrintError("Arduino .Send() has failed\n\t" + e.Message);
                            }

                            ArduinoConsole.AddConsoleText(String.Format("»{0}«", args.Command));
                        }
                        else
                        {
                            PrintWarning(String.Format("Ziel-Arduino »{0}« konnte nicht gefunden werden. Origin: »{1}«", args.Command.Target, args.Command.Origin));
                        }

                        break;

                    case ArduinoCommand.CommandTypes.Arduino_To_Interface:

                        if (args.Command.Content == "This is test data with 32 chars.")
                        {
                            ArduinoCollection[GetArduinoIndex(args.Command.Origin)].StopPingmeasureTime();
                        }
                        else if (args.Command.Content.Contains('$'))
                        {
                            PrintWarning(String.Format("»{0}« notifies that {1}",
                                args.Command.Origin,
                                args.Command.Content.Replace("$", "").Replace("(", "»").Replace(")", "«")));
                        }
                        else
                        {
                            ArduinoConsole.AddConsoleText("Arduino to Interface: @nobreak", ConsoleViewModel.TextColors.Blue);
                            ArduinoConsole.AddConsoleText(String.Format("»{0}«", args.Command));
                        }

                        break;

                    case ArduinoCommand.CommandTypes.Arduino_Broadcast:
                        for (int i = 0; i < ArduinoCollection.Count; i++)
                        {
                            if (ArduinoCollection[i].ArduinoName != args.Command.Origin)
                            {
                                try
                                {
                                    ArduinoCollection[i].Send(args.Command);
                                }
                                catch (Exception e)
                                {
                                    PrintError("Warning Arduino .Send() has failed\n\t" + e.Message);
                                }
                            }
                        }

                        ArduinoConsole.AddConsoleText("Arduino Broadcast: @nobreak", ConsoleViewModel.TextColors.Violet);
                        ArduinoConsole.AddConsoleText(String.Format("»{0}«", args.Command));

                        break;

                    default:
                        break;
                }
            }
        }
 private void OnMessageRecieved(object source, ArduinoInterface.ArduinoEventArgs args)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         processMessageRecieved(source, args);
         relayMessageRecieved(source, args);
     }));
 }