ffi-wiring_pi 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/ChangeLog.md +1 -0
- data/gemspec.yml +1 -1
- data/lib/ffi/wiring_pi.rb +1 -0
- data/lib/ffi/wiring_pi/soft_tone.rb +26 -0
- data/spec/ffi/wiring_pi/soft_tone_spec.rb +26 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e1117a25b8972026d0855e55c76dfc0264f3102efe8eb658c33f039af3628a
|
4
|
+
data.tar.gz: 32c9523cd1c4b605127760a87f0840efcc82e65fcb7ad657b4bc2bf54c7b7dd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd6b2ab6e7f04a9288f5344e3d43a8b2b88bfa7dbe1b74a62a62349adef0bc6bc83f7100c6a7a826ee298b5b0662f56e886009da21e371d07575ef7ac9925d5f
|
7
|
+
data.tar.gz: d713437e2a39be14dedcbc0297b713fd20997e34b9a2bd41a968879b3e007d9b4a0c34f05f52192928c634ccb796b233600aeb865b529e5c2000e7b04cdd074c
|
data/ChangeLog.md
CHANGED
data/gemspec.yml
CHANGED
data/lib/ffi/wiring_pi.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
#frozen_string_literal: true
|
2
|
+
|
3
|
+
module FFI::WiringPi::SoftTone
|
4
|
+
extend FFI::Library
|
5
|
+
|
6
|
+
ffi_lib 'wiringPi'
|
7
|
+
|
8
|
+
attach_function :soft_tone_create, :softToneCreate, [:int], :int
|
9
|
+
attach_function :soft_tone_write, :softToneWrite , [:int, :int], :void
|
10
|
+
|
11
|
+
class Pin
|
12
|
+
def initialize(pin)
|
13
|
+
@pin = pin
|
14
|
+
status = FFI::WiringPi::SoftTone.soft_tone_create pin
|
15
|
+
raise "Something went wrong: Errno:#{FFI::LastError.error}" unless status == 0
|
16
|
+
end
|
17
|
+
|
18
|
+
# Sets the frequency of software PWM in tone mode (50%)
|
19
|
+
# @param frequecy [Integer] if 0 - disable output, if less than 5000 usually
|
20
|
+
# produces sound (if connected to devise)
|
21
|
+
def write(frequecy)
|
22
|
+
FFI::WiringPi::SoftTone.soft_tone_write @pin, frequecy
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe FFI::WiringPi::SoftTone do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
allow(FFI::WiringPi::SoftTone).to receive(:soft_tone_create).and_return 0
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '::Pin' do
|
10
|
+
it 'raises error when soft_tone_create returns non-zero' do
|
11
|
+
allow(FFI::WiringPi::SoftTone).to receive(:soft_tone_create).and_return 1
|
12
|
+
expect { described_class::Pin.new 0 }.to raise_error('Something went wrong: Errno:0')
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#write' do
|
16
|
+
subject do
|
17
|
+
described_class::Pin.new 0
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'calls soft_tone_write', :aggregate_failures do
|
21
|
+
expect(FFI::WiringPi::SoftTone).to receive(:soft_tone_write).with(0, 100)
|
22
|
+
subject.write(100)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-wiring_pi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Huk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -93,8 +93,10 @@ files:
|
|
93
93
|
- lib/ffi/wiring_pi/gpio.rb
|
94
94
|
- lib/ffi/wiring_pi/neopixel.rb
|
95
95
|
- lib/ffi/wiring_pi/soft_pwm.rb
|
96
|
+
- lib/ffi/wiring_pi/soft_tone.rb
|
96
97
|
- spec/ffi/wiring_pi/gpio_spec.rb
|
97
98
|
- spec/ffi/wiring_pi/soft_pwm_spec.rb
|
99
|
+
- spec/ffi/wiring_pi/soft_tone_spec.rb
|
98
100
|
- spec/spec_helper.rb
|
99
101
|
homepage: https://github.com/vimutter/ffi-wiring_pi
|
100
102
|
licenses:
|
@@ -123,3 +125,4 @@ summary: FFI bindings for wiringPi
|
|
123
125
|
test_files:
|
124
126
|
- spec/ffi/wiring_pi/gpio_spec.rb
|
125
127
|
- spec/ffi/wiring_pi/soft_pwm_spec.rb
|
128
|
+
- spec/ffi/wiring_pi/soft_tone_spec.rb
|