Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arcage/crystal-patlite
Crystal library for controlling PATLITE signal towers by using PHN commands.
https://github.com/arcage/crystal-patlite
Last synced: about 1 month ago
JSON representation
Crystal library for controlling PATLITE signal towers by using PHN commands.
- Host: GitHub
- URL: https://github.com/arcage/crystal-patlite
- Owner: arcage
- License: mit
- Created: 2016-11-25T14:17:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-28T01:12:18.000Z (about 8 years ago)
- Last Synced: 2024-10-25T01:36:40.987Z (3 months ago)
- Language: Crystal
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Patlite for Crystal
Crystal library for controlling [PATLITE](http://www.patlite.com/) signal towers by using PHN commands.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
patlite:
github: arcage/crystal-patlite
```## Usage
```crystal
require "patlite"patlite_host = "192.168.0.100"
patlite_port = 10000# initialize host(ip) and port for a signal tower
patlite = Patlite::PHN.new(patlite_host, patlite_port)# set signal tower statuses
#
# You can set:
# - Light setting: `{{COLOR}}_{{PATTERN}}`
#
# - `{{COLOR}}` = red / yellow / green
# - `{{PATTERN}}` = off / on / flash
#
# - Beep setting: `beep_{{PATTERN}}`
#
# - `{{PATTERN}}` = off / short / long
patlite.set do
red_on
beep_long
end# get signal tower statuses
status = patlite.status
status.red #=> Patlite::PHN::Status::Light::ON
status.beep_short? #=> false
puts status
#=> "RED:on / YELLOW:off / GREEN:off / BEEP:long"sleep(2)
# add signal tower statuses to current settings
patlite.add do
green_flash
beep_off
endputs patlite.status
#=> "RED:on / YELLOW:off / GREEN:flash / BEEP:off"sleep(2)
# turn off all lights and beep
patlite.clearputs patlite.status
#=> "RED:off / YELLOW:off / GREEN:off / BEEP:off"
```## Contributors
- [arcage](https://github.com/arcage) ʕ·ᴥ·ʔAKJ - creator, maintainer