Beispiel #1
0
    public void GetUpdate()
    {
        if (this.IsBalanceBoardConnected)
        {
            BalanceBoard.GetUpdate();

            this.BalanceBoardState.WeightKg = Math.Abs(this.BalanceBoardState.WeightKgMin
                                                       - this.BalanceBoard.WiiControllerState.BalanceBoardState.WeightKg);
            this.BalanceBoardState.WeightLb = Math.Abs(this.BalanceBoardState.WeightLbMin
                                                       - this.BalanceBoard.WiiControllerState.BalanceBoardState.WeightLb);

            this.BalanceBoardState.SensorValuesKg.TopLeft = Math.Abs(this.BalanceBoardState.SensorValuesKgMin.TopLeft
                                                                     - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesKg.TopLeft);
            this.BalanceBoardState.SensorValuesKg.TopRight = Math.Abs(this.BalanceBoardState.SensorValuesKgMin.TopRight
                                                                      - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesKg.TopRight);
            this.BalanceBoardState.SensorValuesKg.BottomLeft = Math.Abs(this.BalanceBoardState.SensorValuesKgMin.BottomLeft
                                                                        - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesKg.BottomLeft);
            this.BalanceBoardState.SensorValuesKg.BottomRight = Math.Abs(this.BalanceBoardState.SensorValuesKgMin.BottomRight
                                                                         - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesKg.BottomRight);

            this.BalanceBoardState.SensorValuesLb.TopLeft = Math.Abs(this.BalanceBoardState.SensorValuesLbMin.TopLeft
                                                                     - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesLb.TopLeft);
            this.BalanceBoardState.SensorValuesLb.TopRight = Math.Abs(this.BalanceBoardState.SensorValuesLbMin.TopRight
                                                                      - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesLb.TopRight);
            this.BalanceBoardState.SensorValuesLb.BottomLeft = Math.Abs(this.BalanceBoardState.SensorValuesLbMin.BottomLeft
                                                                        - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesLb.BottomLeft);
            this.BalanceBoardState.SensorValuesLb.BottomRight = Math.Abs(this.BalanceBoardState.SensorValuesLbMin.BottomRight
                                                                         - this.BalanceBoard.WiiControllerState.BalanceBoardState.SensorValuesLb.BottomRight);

            this.BalanceBoardState.CenterOfGravity.X = this.BalanceBoard.WiiControllerState.BalanceBoardState.CenterOfGravity.X;
            this.BalanceBoardState.CenterOfGravity.Y = this.BalanceBoard.WiiControllerState.BalanceBoardState.CenterOfGravity.Y;
        }
    }
    public void UpdateBalanceBoardState(BalanceBoard balanceBoard)
    {
        ConnectingImage.SetActive(false);
        DisconnectingImage.SetActive(false);

        if (balanceBoard == null)
        {
            SetDisconnectedState();
            InfoText.text = "not found";
        }
        else
        {
            if (balanceBoard.IsConnected && balanceBoard.IsInitialized)
            {
                SetConnectedState(true);
            }
            else
            {
                SetDisconnectedState();
                // Lieber wieder Verbindung trennen wenn initialisierung nicht erfolgreich war
                balanceBoard.Disconnect();
            }
        }
        this.updateBalanceBoardState = false;
    }
Beispiel #3
0
        static void Main(string[] args)
        {
            var infoUpdateTimer = new Timer()
            {
                Interval = 50, Enabled = false
            };

            infoUpdateTimer.Elapsed += infoUpdateTimer_Elapsed;

            Console.WriteLine("Connecting to a BalanceBoard");

            try {
                board = BalanceBoard.Create();
            }
            catch { }
            finally {
                if (board == null)
                {
                    Console.WriteLine("Could not connect to a BalanceBoard");
                }
            }

            Console.WriteLine("BalanceBoard Connected");

            infoUpdateTimer.Enabled = true;

            Console.ReadKey();

            infoUpdateTimer.Enabled = false;
            board.Disconnect();
        }
        private void WiiControllerFound(string devicePath, ControllerType controllerType)
        {
            WiiController wiiController = null;

            switch (controllerType)
            {
            case ControllerType.WiiBalanceBoard:
                wiiController = new BalanceBoard();
                break;

            default:
                throw new WiiControllerException("Not supported ControllerType!");
            }
            //wiiController.OpenWiiControllerDeviceHandle(devicePath);
            if (wiiController != null)
            {
                collection.Add(wiiController);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="balanceBoard">BalanceBoard state</param>
 public BalanceBoardConnectionChangedEventArgs(BalanceBoard balanceBoard)
 {
     this.BalanceBoard = balanceBoard;
 }