我正在构建一个机器人手臂并使用iOS应用程序控制手臂。我无法将位置发送到arduino蓝牙4.0屏蔽。无法使用类型为'(UInt64)'的参数列表调用
我使用滑块来控制手臂的位置。
有两个错误。
- “不能调用 'writePosition' 类型的 '(UINT8)' 参数列表”
“不能调用 'sendPosition' 类型的 '(UINT64)' 参数列表”
func sendPosition(position: UInt8) if !self.allowTX { return } // Validate value if UInt64(position) == lastPosition { return } else if ((position < 0) || (position > 180)) { return } // Send position to BLE Shield (if service exists and is connected) if let bleService = btDiscoverySharedInstance.bleService { bleService.writePosition(position) ***1)ERROR OCCURS ON THIS LINE*** lastPosition = position // Start delay timer self.allowTX = false if timerTXDelay == nil { timerTXDelay = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("timerTXDelayElapsed"), userInfo: nil, repeats: false) } } } func timerTXDelayElapsed() { self.allowTX = true self.stopTimerTXDelay() // Send current slider position self.sendPosition(UInt64(self.currentClawValue.value)) **2)ERROR OCCURS ON THIS LINE**
}
这里是我的 “writePosition” 功能。
func writePosition(position: Int8) {
// See if characteristic has been discovered before writing to it
if self.positionCharacteristic == nil {
return
}
// Need a mutable var to pass to writeValue function
var positionValue = position
let data = NSData(bytes: &positionValue, length: sizeof(UInt8))
self.peripheral?.writeValue(data, forCharacteristic: self.positionCharacteristic, type: CBCharacteristicWriteType.WithResponse)
}
我不知道我是否要留下一些东西或完全失去一些东西。 我已经尝试过UInt8和UInt64之间的简单转换,但这些都没有奏效。