Skip to content

Latest commit

 

History

History
75 lines (45 loc) · 1.55 KB

README.md

File metadata and controls

75 lines (45 loc) · 1.55 KB

TOSR0x

This gem provides an API to interact with the TOSR0x relays sold by the TinySine.

Installation

Add this line to your application's Gemfile:

gem 'tosr0x'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tosr0x

Usage

Please the following code for an example on using this gem.

require 'tosr0x'

RELAY_PORT  = '/dev/ttyUSB0' # Change this to the serial port that belongs to the relay.
RELAY_COUNT = 8              # Change this to indicate the number of relays in the board.

board = TOSR0x::Board.new(RELAY_PORT, RELAY_COUNT)

# Enable all relays

board.enable(:all)   # or
board.enable(0)      # or
board.disable(:none)

# Disable all relays

board.disable(:all)   # or
board.disable(0)      # or
board.enable(:none)

# We can also enable individual relays
relay = board.get(1)

relay.enable     # or
board.enable(1)

# ... disable individual relays
relay.disable     # or
board.disable(1)

# ... and even toggle them
relay.toggle     # or
board.toggle(1)

For more options please see the documentation generate by YARD.

Development

Use the normal flow when using Bundler and RSpec.

Also the guidelines from Git Flow

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bithium/tosr0x.

License

MIT (see LICENSE)