Skip to content

Instantly share code, notes, and snippets.

@hoiberg
Created October 18, 2016 12:38
Show Gist options
  • Save hoiberg/9d041623506970e927461051c16678e2 to your computer and use it in GitHub Desktop.
Save hoiberg/9d041623506970e927461051c16678e2 to your computer and use it in GitHub Desktop.
MSP_SET_RAW_RC in Swift
// ********** Here's the javascript version *************
// /**
// * Set raw Rx values over MSP protocol.
// *
// * Channels is an array of 16-bit unsigned integer channel values to be sent. 8 channels is probably the maximum.
// **/
//
//MSP.setRawRx = function(channels) {
// var buffer = [];
//
// for (var i = 0; i < channels.length; i++) {
// buffer.push(specificByte(channels[i], 0));
// buffer.push(specificByte(channels[i], 1));
// }
//
// MSP.send_message(MSP_codes.MSP_SET_RAW_RC, buffer, false);
//}
// ************** Sample swift notation **************
func sendRawRC(channels: [UInt16]) {
var bytes: [UInt8] = []
for chan in channels {
bytes.append(chan.lowByte) // lower first, small endian notation
bytes.append(chan.highByte) // ..if I'm correct :)
}
sendMSP(MSP_SET_RAW_RC, bytes)
}
@johnsilvester
Copy link

Thank you!! I will try this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment