Has anyone attempted to build a metawear app using mostly SwiftUI?

I am asking because I am encountering some weirdly unexplainable issues with my app and saw the word "SwiftUI" is not mentioned once on this forum. Please let me know if you think I will run into any difficulties! I can't imagine any, but it doesn't hurt to check.

Comments

  • But swiftUI is just a UI library. It has nothing to do with our sensors and APIs. I don't know why it would be mentioned in the forum at all.

  • edited January 2022

    @Ben_R...

    We're building a Swift SDK using Combine. It's less verbose, ditches Bolts, and requires no unsafe Swift.

    We're wrapping up a tutorial series with SwiftUI demo apps. Given your SwiftUI work, I'd love to hear your reaction to the current draft. Reading is a bit smoother in Xcode's doc browser, but the HTML version is fine. To use Xcode, double click a DocC archive here or clone the SDK package and press Control Shift CMD D to build the docs.

    For flavor, here’s a snippet logging a variant selection of sensors.

    downloadPipeline = metawear
        .publishWhenConnected()
        .first()
        .optionallyLog(configs.accelerometer)
        .optionallyLog(configs.gyroscope)
        .optionallyLog(configs.quaternion)
        .sink(receiveCompletion: { [weak self] in
            self?.displayError(ifFound: $0)
        }, receiveValue: { [weak self] in
            self?.offerDownloadCallToAction()
        })
    
    metawear.connect()
    

    Here’s a snippet that flashes the LEDs in purple or blue when pressing or releasing the MetaWear button.

    macroSub = metawear?
        .publishWhenConnected()
        .first()
        .command(.macroStartRecording(runOnStartup: true))
        .recordEvents(for: .buttonUp, { recording in
            recording.command(.ledFlash(.Presets.eight.pattern))
        })
        .recordEvents(for: .buttonDown, { recording in
            recording.command(.ledFlash(.Presets.zero.pattern))
        })
        .command(.macroStopRecordingAndGenerateIdentifier)
        .sink(receiveCompletion: { _ in }, receiveValue: { _ in })
    
    metawear?.connect()
    
Sign In or Register to comment.