Skip to content

Instantly share code, notes, and snippets.

@hoiberg
hoiberg / simpleprotocol.swift
Created June 11, 2017 10:44
A simple communications protocol
let START_BYTE: UInt8 = 0x42 // or whatever
let ACTION_ON: UInt8 = 0x01 // or whatever
let ACTION_SLIDER: UInt8 = 0x02 // same here
var state = 0
var code: UInt8 = 0
var expected_count = 0
var data = [UInt8]()
func serialDidReceiveBytes(bytes: [UInt8]) {
@hoiberg
hoiberg / mspsetrawrc.swift
Created October 18, 2016 12:38
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) {