madmachineio / SwiftIO

A Swift framework for microcontrollers abstraction layer.
https://madmachineio.github.io/SwiftIO/documentation/swiftio
MIT License
179 stars 14 forks source link

SwiftIO

build Discord twitter

A Swift framework for microcontrollers. You can program microcontrollers easily without worrying about complicated low-level stuff. After downloading your project to your board, you'll get the results in real time.

Documentation

SwiftIO library provides easy access to communicate with the external circuits simply by invoking the related classes/methods. You can read or write digital and analog signals, as well as use communication protocols.

Go to API Documentation for more detailed usage of all the functionalities.

Library structure

SwiftIO contains several classes to access different functionalities of the board:

Usage example

// Import the SwiftIO to use the related board functions.
import SwiftIO
// Import the MadBoard to decide which pin is used for the specific function.
import MadBoard

// Initialize the onboard blue LED to control it by setting output signal.
let led = DigitalOut(Id.BLUE)
​
while true {
    // Set a high voltage to turn off the onboard LED.
    // The onboard LED needs a low voltage to be turned on due to circuit connection.
    led.write(true)
    sleep(ms: 1000)

    // Set a low voltage to turn on the onboard LED.
    led.write(false)
    sleep(ms: 1000)
}

Examples

Before starting to create your project, let's start with these examples to get familiar with library usage.

Preparation

We created the MadMachine extension for Visual Studio Code for easier usage. Please install and configure it following this instruction.

Besides, if you are more comfortable with the command line, welcome to try mm sdk.