Swift library for SMBus access through the i2c /dev interface on Linux

Related tags

Utility SMBus-swift
Overview

#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
You might also like...
Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos)

Focus Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos) that is inspired by Haskell's Lens library. Introduction Foc

A Swift micro library for generating Sunrise and Sunset times.

Solar A Swift helper for generating Sunrise and Sunset times. Solar performs its calculations locally using an algorithm from the United States Naval

Plugin and runtime library for using protobuf with Swift

Swift Protobuf Welcome to Swift Protobuf! Apple's Swift programming language is a perfect complement to Google's Protocol Buffer ("protobuf") serializ

A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

noppefoxwolf/notion is a notion.so API library written in swift.
noppefoxwolf/notion is a notion.so API library written in swift.

notion noppefoxwolf/notion is a notion.so API library written in swift. Installation Xcode Project Swift Packages [email protected]:noppefoxwolf/notion

This library project contains a few noise generators created in Swift.

SwiftNoiseGenerator This library project contains a few noise generators created in Swift. contains: Perlin Noise Simplex Noise How to use Edit your P

Angle is a simple Swift library that provides Angle structure representing angles.

Angle is a simple Swift library that provides Angle structure representing angles. It handles angles using circular measure by default but is al

A library to manage NVRAM Stuff in Swift

libNVRAMSwift A Library to manage NVRAM Stuff, written in Swift. CLI Example utility here Library Usage Declare a new instance of the NVRAM Struct, fo

Support library of BudouX.swift to handle HTML

HTMLBudouX.swift HTMLBudouX.swift is a support library of BudouX.swift to handle HTML. Detail about BudouX.swift is here Usage You can translate an HT

Comments
  • Migrated the codebase to Swift 3.0 preview 1

    Migrated the codebase to Swift 3.0 preview 1

    Changed:

    • method naming at call time
    • Error protocol name
    • transformed the fb, busNumber and address from private to internal with a private setter. This was necessary since the private properties are not accessible anymore from extensions.
    opened by clacladev 1
Owner
Fabio Ritrovato
Fabio Ritrovato
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!

Datez ?? Breeze through Date, DateComponents, and TimeInterval Highlights Two Custom Structs Only (value types FTW!): DateView: An Date associated wit

Kitz 263 Dec 7, 2022
Safe and fast access to SwiftUI PreviewDevice

SafePreviewDevice Motivation At WWDC 2019, Apple announced SwiftUI a new library for building UI in a simple and fast way. Xcode’s SwiftUI preview let

Antonino Francesco Musolino 11 Jun 28, 2022
XMachOViewer is a Mach-O viewer for Windows, Linux and MacOS

MachO file viewer/editor for Windows, Linux and macOS. Heuristic scan String viewer Hex viewer Disasm viewer(x86/64,ARM,PPC,m68k) Entropy viewer Hash

Hors 505 Dec 20, 2022
This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to load remote images

iOS NOW ⭐ This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to loa

William Tristão de Paula 1 Dec 7, 2021
An eject button for Interface Builder to generate swift code

Eject Eject is a utility to transition from Interface Builder to programatic view layout. This is done by using code generation to create a .swift fil

Rightpoint 524 Dec 29, 2022
Async+ for Swift provides a simple chainable interface for your async and throwing code, similar to promises and futures

Async+ for Swift provides a simple chainable interface for your async and throwing code, similar to promises and futures. Have the best of both worlds

async_plus 132 Jan 6, 2023
swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

kelvin 4 Aug 14, 2022
macOS system library in Swift

SystemKit A macOS system library in Swift based off of libtop, from Apple's top implementation. For an example usage of this library, see dshb, a macO

null 323 Jan 5, 2023
Swift library to develop custom Alexa Skills

AlexaSkillsKit AlexaSkillsKit is a Swift library that allows you to develop custom skills for Amazon Alexa, the voice service that powers Echo. It tak

Claus Höfele 170 Dec 27, 2022
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift

Bow is a cross-platform library for Typed Functional Programming in Swift. Documentation All documentation and API reference is published in our websi

Bow 613 Dec 20, 2022