pigpio 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,10 @@
1
1
  class Pigpio
2
2
  class GPIO
3
+ attr_reader :pi,:gpio
3
4
  def initialize(pi,gpio)
4
5
  @pi=pi #0-15
5
6
  @gpio=gpio #0-53
6
7
  end
7
- def gpio
8
- [@pi,@gpio]
9
- end
10
8
  def mode=(mode)
11
9
  ret=IF.set_mode(@pi,@gpio,mode)
12
10
  end
@@ -0,0 +1,29 @@
1
+ class Pigpio
2
+ class Serial
3
+ attr_reader :pi,:handle
4
+ TTY=%w(/dev/tty /dev/serial)
5
+ Baud=[50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400]
6
+ def initialize(pi,ser_tty,baud)
7
+ @pi=pi
8
+ @handle=IF.serial_open(pi,ser_tty,baud=19200,0)
9
+ end
10
+ def close
11
+ IF.serial_close(@pi,@handle)
12
+ end
13
+ def byte=(bVal)
14
+ IF.serial_write_byte(@pi,@handle,bVal)
15
+ end
16
+ def byte
17
+ IF.serial_read_byte(@pi,@handle)
18
+ end
19
+ def write(buf)
20
+ IF.serial_write(@pi,@handle,buf)
21
+ end
22
+ def read(count)
23
+ IF.serial_read(@pi,@handle,count)
24
+ end
25
+ def size
26
+ IF.serial_data_available(@pi,@handle)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ class Pigpio
2
+ class SPI
3
+ attr_reader :pi,:handle
4
+ def initialize(pi,spi_channel=0,enable_cex=1,baud=500000,bits_per_word: 8,first_MISO: false,first_MOSI: false,idol_bytes: 0,is_3wire: false,active_low_cex: 0,spi_mode: 0)
5
+ is_aux=(spi_channel!=0)
6
+ flg=((spi_mode.to_i & 0x03 ) |
7
+ ((active_low_cex.to_i & 0x07 )<< 2) |
8
+ ((enable_cex.to_i & 0x07 )<< 5) |
9
+ ((is_aux ? 1 : 0) << 8) |
10
+ ((is_3wire ? 1 : 0) << 9) |
11
+ ((idol_bytes.to_i & 0x0f )<< 10) |
12
+ ((first_MOSI ? 1 : 0) << 14) |
13
+ ((first_MISO ? 1 : 0) << 15) |
14
+ ((bits_per_word.to_i & 0x3f )<< 16)
15
+ )
16
+ @pi=pi
17
+ @byte_per_word=(bits_per_word/8.0).ceil
18
+ @handle=IF.spi_open(@pi,spi_channel,baud,flg)
19
+ end
20
+ def close
21
+ IF.spi_close(@pi,@handle)
22
+ end
23
+ def read(words=1)
24
+ IF.spi_read(@pi,@handle,words*@byte_per_word)
25
+ end
26
+ def write(buf)
27
+ IF.spi_write(@pi,@handle,buf)
28
+ end
29
+ def xfer(buf)
30
+ IF.spi_xfer(@pi,@handle,buf)
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  class Pigpio
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -70,8 +70,8 @@ class Pigpio
70
70
  def max_cbs
71
71
  IF.wave_get_max_cbs(@pi)
72
72
  end
73
- def pulse(on,off,tick)
74
- Pulse.make(on,off,tick)
73
+ def pulse(on,off,us)
74
+ Pulse.make(on,off,us)
75
75
  end
76
76
 
77
77
  end
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
38
  spec.require_paths = ["ext","lib"]
39
39
 
40
+ spec.required_ruby_version = '>= 2.0.0'
40
41
  spec.add_development_dependency "bundler", "> 1.17"
41
42
  spec.add_development_dependency "rake", "~> 10.0"
42
43
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pigpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - nak1114
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,6 +88,10 @@ files:
88
88
  - bin/docker.rb
89
89
  - bin/setup
90
90
  - check.txt
91
+ - example/loopback/readme.md
92
+ - example/loopback/spi.rb
93
+ - example/loopback/uart.rb
94
+ - example/loopback/uart.svg
91
95
  - example/simple/board.svg
92
96
  - example/simple/callback.rb
93
97
  - example/simple/led.rb
@@ -98,9 +102,14 @@ files:
98
102
  - ext/pigpio/pigpio.c
99
103
  - lib/pigpio.rb
100
104
  - lib/pigpio/bank.rb
105
+ - lib/pigpio/bit_bang_serial.rb
106
+ - lib/pigpio/bit_bang_serial_rx.rb
107
+ - lib/pigpio/bit_bang_serial_tx.rb
101
108
  - lib/pigpio/constant.rb
102
109
  - lib/pigpio/gpio.rb
103
110
  - lib/pigpio/pwm.rb
111
+ - lib/pigpio/serial.rb
112
+ - lib/pigpio/spi.rb
104
113
  - lib/pigpio/user_gpio.rb
105
114
  - lib/pigpio/version.rb
106
115
  - lib/pigpio/wave.rb
@@ -121,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
130
  requirements:
122
131
  - - ">="
123
132
  - !ruby/object:Gem::Version
124
- version: '0'
133
+ version: 2.0.0
125
134
  required_rubygems_version: !ruby/object:Gem::Requirement
126
135
  requirements:
127
136
  - - ">="