dc-notifier 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aed0d889a9dccb95449d534d6473e10479b807a6
4
+ data.tar.gz: 85561ab87ca83b35d33eb22b49ee34245dcb524c
5
+ SHA512:
6
+ metadata.gz: d66a1aecaacd76f7ec0b6e9fb21ede416ccdfe2b2c09b6297f3857edfe78bbc6e836fccc19409f1d5ead43f5a6ee3bbbc663a310477c9f86d738ef2f6a790979
7
+ data.tar.gz: d34e70e4003ad6e524b71af2438a854f18ff309fe0e870baa341ed322e69655ba92e5e1f670428494b88f41efbe42491136e4b4cb8b7f925dfd59868fe08fdbd
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "dc-notifier"
5
+ spec.version = "0.1.0"
6
+ spec.authors = [ "Andy Palmer", "Pat Kua" ]
7
+ spec.email = [ "andy@andypalmer.com" ]
8
+ spec.description = "Control multiple DreamCheeky Email Notifiers from Ruby"
9
+ spec.summary = "Does what it says on the tin"
10
+ spec.homepage = "https://github.com/andypalmer/dc-notifier"
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_dependency 'libusb', "~> 0.2"
17
+ spec.add_dependency 'color-tools', "~> 1.3"
18
+ end
@@ -0,0 +1,41 @@
1
+ require 'libusb'
2
+ require 'color'
3
+
4
+ module DreamCheeky
5
+ class Notifier
6
+ def self.all
7
+ @@devices ||= LIBUSB::Context.new.devices(idVendor: 0x1d34, idProduct: 4).sort.map {|device| new (device)}
8
+ end
9
+
10
+ def initialize(device)
11
+ @device = device
12
+ reset_device
13
+ end
14
+
15
+ def colour!(colour)
16
+ send("%c%c%c\x00\x00\x00\x00\x05" % [colour.r, colour.g, colour.b].map {|x| x*64 })
17
+ end
18
+
19
+ alias :colour :colour!
20
+
21
+ def turn_off
22
+ colour!(Colour.new(0, 0, 0))
23
+ end
24
+
25
+ def send(data)
26
+ @device.open do |handle|
27
+ request_type = LIBUSB::REQUEST_TYPE_CLASS | LIBUSB::RECIPIENT_INTERFACE # flags to send data to device
28
+ # other special flags that I don't know what they do
29
+ handle.control_transfer(:bmRequestType => request_type, :bRequest => 0x09, :wValue => 0x200, :wIndex => 0x00, :dataOut => data)
30
+ end
31
+ end
32
+
33
+ # Special codes that apparently need to be sent to initialise the device.
34
+ # The first three values of the last line also represent the RGB colours on initialisation
35
+ def reset_device
36
+ send "\x1f\x02\x00\x2e\x00\x00\x2b\x03"
37
+ send "\x00\x02\x00\x2e\x00\x00\x2b\x04"
38
+ send "\x00\x00\x00\x2e\x00\x00\x2b\x05"
39
+ end
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dc-notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andy Palmer
8
+ - Pat Kua
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: libusb
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: color-tools
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.3'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ description: Control multiple DreamCheeky Email Notifiers from Ruby
43
+ email:
44
+ - andy@andypalmer.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - dc-notifier.gemspec
50
+ - lib/dreamcheeky/notifier.rb
51
+ homepage: https://github.com/andypalmer/dc-notifier
52
+ licenses: []
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.2.2
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Does what it says on the tin
74
+ test_files: []
75
+ has_rdoc: