Git Product home page Git Product logo

smbus-swift's Introduction

#SMBus-swift Join the chat at https://gitter.im/Sephiroth87/SMBus-swift

SMBus-swift is a linux library to communicate with SMBus/I2C devices through /dev/i2c.

##Requirements Before beign able to use SMBus in your Swift code, you should install some Linux C libraries.

On a Debian-like distro:

sudo apt-get install i2c-tools libi2c-dev

Then you have to make sure the i2c module is active. So check or add i2c-dev to /etc/modules. Like:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with 	"#" are ignored.

i2c-dev

##Installation The library is being written for/on a Raspberry Pi where the Package Manager is not functional yet, so I couldn't really figure out a way to make it work with that, and you'll have to do it manually for now. After cloning, compile your program adding the 2 system dependencies and the main file, like

swiftc -o MyProgram -I ./SMBus-swift/Packages/Ci2c -I ./SMBus-swift/Packages/CioctlHelper ./SMBus-swift/Sources/SMBus.swift main.swift

You can look here for some examples on how to include the library in your program.

##Usage No need to import anything since the library is built together with your other sources. To open the connection create an SMBus object:

try bus = SMBus(busNumber: 1) // opens /dev/i2c-1

and then send your commands:

try bus.writeI2CBlockData(0x60, command: UInt8(0x01), values: [UInt8(2)])

##TODO

  • Add missing functions
  • Add documentation
  • Support Package Manager

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.