static void ConnectBalanceBoard(bool WasJustConnected)
        {
            bool Connected = true; try { bb = new Wiimote(); bb.Connect(); bb.SetLEDs(1); bb.GetStatus(); } catch { Connected = false; }

            if (!Connected || bb.WiimoteState.ExtensionType != ExtensionType.BalanceBoard)
            {
                if (ConnectionManager.ElevateProcessNeedRestart())
                {
                    Shutdown(); return;
                }
                if (cm == null)
                {
                    cm = new ConnectionManager();
                }
                cm.ConnectNextWiiMote();
                return;
            }
            if (cm != null)
            {
                cm.Cancel(); cm = null;
            }

            f.lblWeight.Text  = "...";
            f.lblQuality.Text = "";
            f.lblUnit.Text    = "";
            f.Refresh();

            ZeroedWeight = 0.0f;
            int InitWeightCount = 0;

            for (int CountMax = (WasJustConnected ? 100 : 50); InitWeightCount < CountMax || bb.WiimoteState.BalanceBoardState.WeightKg == 0.0f; InitWeightCount++)
            {
                if (bb.WiimoteState.BalanceBoardState.WeightKg < -200)
                {
                    break;
                }
                ZeroedWeight += bb.WiimoteState.BalanceBoardState.WeightKg;
                bb.GetStatus();
            }
            ZeroedWeight /= (float)InitWeightCount;

            //start with half full quality bar
            HistoryCursor = HistoryBest = History.Length / 2;
            for (int i = 0; i < History.Length; i++)
            {
                History[i] = (i > HistoryCursor ? float.MinValue : ZeroedWeight);
            }
        }
Beispiel #2
0
        void ConnectBalanceBoard(bool WasJustConnected)
        {
            bool Connected = true; try { bb = new Wiimote(); bb.Connect(); bb.SetLEDs(1); bb.GetStatus(); } catch { Connected = false; }

            if (!Connected || bb.WiimoteState.ExtensionType != ExtensionType.BalanceBoard)
            {
                if (ConnectionManager.ElevateProcessNeedRestart())
                {
                    Shutdown(); return;
                }
                if (cm == null)
                {
                    cm = new ConnectionManager();
                }
                cm.ConnectNextWiiMote();
                return;
            }
            if (cm != null)
            {
                cm.Cancel(); cm = null;
            }

            f.Refresh();
        }