Coder Social home page Coder Social logo

cybergearkit's Introduction

CyberGearKit

logo

CyberGearKit is a framework of communicating to xiaomi CyberGear.

How to integrate

This is an SPM-compliant Swift Package: First, add the following line in Package.swift to your package dependencies:

.package(url: "https://github.com/CmST0us/CyberGearKit.git", branch: "master")

Then, add the module CyberGearKit โ€“ where necessary โ€“ to your target dependencies.

Usage

Create CyberGear.CANBus to communicate with socketcan interface

let canBus = CyberGear.CANBus(hostID: 1)
do {
    try canBus.open()
} catch {
    // do some catch
}

Create CyberGear.Motor to control motor. For example, you can make motor run in speed mode.

let motor = CyberGear.Motor(canID: 127, bus: canBus)
try! motor.runMode(.speed)
try! motor.enable()
try! motor.setTargetSpeed(5)

Use RxSwift to listen frame parse

let disposeBag = DisposeBag()
motor.motorStaus
    .observe(on: MainScheduler.asyncInstance)
    .subscribe { (v: CyberGearKit.CyberGear.Frame.MotorStatus) in
        // do some thing
    }
    .disposed(by: disposeBag)

License and Contributions

This package is licensed under the term of the MIT License. Contributions are always welcome!

cybergearkit's People

Contributors

cmst0us avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.