示例#1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            print("init device and start background scan");
            AntManager.Instance.Init();
            backgroundScanChannel = AntManager.Instance.OpenBackgroundScanChannel(0);
            backgroundScanChannel.onReceiveData += ReceivedBackgroundScanData;
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            Debug.Log("setting resistance to 0 %");
            byte[] pageToSend = new byte[8] {
                0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 0
            };
            FECChannel.sendAcknowledgedData(pageToSend);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            Debug.Log("setting resistance to 100 %");
            byte[] pageToSend = new byte[8] {
                0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 200
            };                                                                           //unit is 0.50%
            FECChannel.sendAcknowledgedData(pageToSend);
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("setting resistance to 75 %");
            byte[] pageToSend = new byte[8] {
                0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 150
            };                                                                           //unit is 0.50%
            FECChannel.sendAcknowledgedData(pageToSend);
        }
    }
示例#2
0
    private void Update()
    {
        // Store the value of both input axes.
        m_MovementInputValue = Input.GetAxis(m_MovementAxisName);
        //print (m_MovementInputValue);
        m_TurnInputValue = Input.GetAxis(m_TurnAxisName);
        // Store the value of both input axes.
        m_MovementInputValue = Input.GetAxis(m_MovementAxisName);
//		print (m_MovementInputValue);



        if (Input.GetKeyDown(KeyCode.S))
        {
            print("init device and start background scan");
            AntManager.Instance.Init();
            backgroundScanChannel = AntManager.Instance.OpenBackgroundScanChannel(0);
            backgroundScanChannel.onReceiveData += ReceivedBackgroundScanData;
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            Debug.Log("setting resistance to 0 %");
            byte[] pageToSend = new byte[8] {
                0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 0
            };
            FECChannel.sendAcknowledgedData(pageToSend);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            Debug.Log("setting resistance to 100 %");
            byte[] pageToSend = new byte[8] {
                0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 200
            };                                                                                               //unit is 0.50%
            FECChannel.sendAcknowledgedData(pageToSend);
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("setting resistance to 75 %");
            byte[] pageToSend = new byte[8] {
                0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 150
            };                                                                                               //unit is 0.50%
            FECChannel.sendAcknowledgedData(pageToSend);
        }
    }
示例#3
0
    void Slope()
    {
        float Angular     = Mathf.Acos(Vector3.Dot(transform.forward, Vector3.up));
        Int32 angle       = (Int32)(Angular * 180f / Mathf.PI / 1f - 90);
        float tiltAroundX = Input.GetAxis("Vertical");

        Debug.Log("Angular direction relative to the ground :" + angle + ".");

        if (angle != previousresistance)
        {
            switch (angle)
            {
            case 1:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 10
                };
                FECChannel.sendAcknowledgedData(pageToSend);
                previousresistance = angle;
                break;

            case 2:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend2 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 20
                };
                FECChannel.sendAcknowledgedData(pageToSend2);
                previousresistance = angle;
                break;

            case 3:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend3 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 30
                };
                FECChannel.sendAcknowledgedData(pageToSend3);
                previousresistance = angle;
                break;

            case 4:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend4 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 40
                };
                FECChannel.sendAcknowledgedData(pageToSend4);
                previousresistance = angle;
                break;

            case 5:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend5 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 50
                };
                previousresistance = angle;
                FECChannel.sendAcknowledgedData(pageToSend5);
                break;

            case 6:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend6 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 60
                };
                FECChannel.sendAcknowledgedData(pageToSend6);
                previousresistance = angle;
                break;

            case 7:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend7 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 70
                };
                FECChannel.sendAcknowledgedData(pageToSend7);
                previousresistance = angle;
                break;

            case 8:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend8 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 80
                };
                FECChannel.sendAcknowledgedData(pageToSend8);
                previousresistance = angle;
                break;

            case 9:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend9 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 90
                };
                FECChannel.sendAcknowledgedData(pageToSend9);
                previousresistance = angle;
                break;

            case 10:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend10 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 100
                };
                FECChannel.sendAcknowledgedData(pageToSend10);
                previousresistance = angle;
                break;

            case 11:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend11 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 110
                };
                FECChannel.sendAcknowledgedData(pageToSend11);
                previousresistance = angle;
                break;

            case 12:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend12 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 120
                };
                FECChannel.sendAcknowledgedData(pageToSend12);
                previousresistance = angle;
                break;

            case 20:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend20 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 200
                };
                FECChannel.sendAcknowledgedData(pageToSend20);
                previousresistance = angle;
                break;

            case 13:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend13 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 130
                };
                FECChannel.sendAcknowledgedData(pageToSend13);
                previousresistance = angle;
                break;

            case 14:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend14 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 140
                };
                FECChannel.sendAcknowledgedData(pageToSend14);
                previousresistance = angle;
                break;

            case 15:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend15 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 150
                };
                FECChannel.sendAcknowledgedData(pageToSend15);
                previousresistance = angle;
                break;

            case 16:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend16 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 160
                };
                FECChannel.sendAcknowledgedData(pageToSend16);
                previousresistance = angle;
                break;

            case 17:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend17 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 170
                };
                FECChannel.sendAcknowledgedData(pageToSend17);
                previousresistance = angle;
                break;

            case 18:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend18 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 180
                };
                FECChannel.sendAcknowledgedData(pageToSend18);
                previousresistance = angle;
                break;

            case 19:
                Debug.Log("setting resistance to " + 10 * angle);
                byte[] pageToSend19 = new byte[8] {
                    0x30, 0xFF, 0xFF, 0xFF, 0xFF, 4, 55, 190
                };
                FECChannel.sendAcknowledgedData(pageToSend19);
                previousresistance = angle;
                break;
            }
        }
    }