Ejemplo n.º 1
0
 public Helper()
 {
     tinker = new TinkerAPI(coreID, accessToken);
 }
Ejemplo n.º 2
0
        private void driveCommand(TinkerAPI.SetStates? LeftDir, TinkerAPI.SetStates? RightDir, Speed LeftSpeed, Speed RightSpeed)
        {
            TinkerAPI.DigitalWriteDelegate dwdL = new TinkerAPI.DigitalWriteDelegate(tinker.DigitalWrite);
            TinkerAPI.DigitalWriteDelegate dwdR = new TinkerAPI.DigitalWriteDelegate(tinker.DigitalWrite);

            TinkerAPI.AnalogWriteDelegate awdL = new TinkerAPI.AnalogWriteDelegate(tinker.AnalogWrite);
            TinkerAPI.AnalogWriteDelegate awdR = new TinkerAPI.AnalogWriteDelegate(tinker.AnalogWrite);

            IAsyncResult resultL;
            IAsyncResult resultR;

            if (LeftDir.HasValue && RightDir.HasValue)
            {
                resultL = dwdL.BeginInvoke(leftDirPin, LeftDir.Value, null, null);
                resultR = dwdR.BeginInvoke(rightDirPin, RightDir.Value, null, null);

                TinkerAPI.GetStates gsresultL = dwdL.EndInvoke(resultL);
                TinkerAPI.GetStates gsresultR = dwdR.EndInvoke(resultR);
            }

            resultL = awdL.BeginInvoke(leftMotorPin, (short)LeftSpeed, null, null);
            resultR = awdR.BeginInvoke(rightMotorPin, (short)RightSpeed, null, null);

            bool bresultL = awdL.EndInvoke(resultL);
            bool bresultR = awdR.EndInvoke(resultR);
        }