// Use this for initialization void Start() { UFOneAPI = new MultiWiiProtocol(); BtConnector.askEnableBluetooth(); UFOneAPI.DebugMessageEvent += (string log) => { Debug.Log(log); }; leftStick.ControllerMovedEvent += (position, stick) => { int dif = (RANGE_MAX - RANGE_MIN) / 2; int mean = (RANGE_MAX + RANGE_MIN) / 2; ROLL = (ushort)(position.x * dif / 4 + mean); PITCH = (ushort)(position.y * dif / 4 + mean); Debug.Log("Left:" + position.x + ":" + position.y); }; leftStick.FingerLiftedEvent += (CNAbstractController o) => { ROLL = _defaultRoll; PITCH = _defaultPitch; }; rightStick.ControllerMovedEvent += (position, stick) => { int dif = (RANGE_MAX - RANGE_MIN) / 2; int mean = (RANGE_MAX + RANGE_MIN) / 2; YAW = (ushort)(position.x * dif / 4 + mean); THROTTLE = (ushort)(position.y * dif + mean); Debug.Log("Right:" + position.x + ":" + position.y); }; }
void Start() { BtConnector.moduleName(stringToEdit); //BtConnector.sho UFoneInterface = new MultiWiiProtocol(); UFoneInterface.DebugMessageEvent += (string log) => { Debug.Log(log); }; UFoneInterface.IMUResultEvent += (short accx, short accy, short accz, short gyrx, short gyry, short gyrz, short magx, short magy, short magz) => { Debug.Log("IMU: accX=" + accx + " accY=" + accy + " accZ=" + accz + " gyrx=" + gyrx + " gyry=" + gyry + " gyrz=" + gyrz + " magx=" + magx + " magy=" + magy + " magz=" + magz); }; UFoneInterface.RCResultEvent += (ushort Roll, ushort Pitch, ushort Yaw, ushort Throttle, ushort AUX1, ushort AUX2, ushort AUX3, ushort AUX4) => { Debug.Log("RC: Roll=" + Roll + " PITCH=" + Pitch + " Yaw=" + Yaw + " Throttle=" + Throttle + " AUX1=" + AUX1 + " AUX2=" + AUX2 + " AUX3=" + AUX3 + " AUX4=" + AUX4); }; }