pigpio 0.1.10 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1fa3d31d3fb44ea838005f5a56348e48e5716cbd
4
- data.tar.gz: da12abb9a3d79848a8bd90c522b28640332528e2
2
+ SHA256:
3
+ metadata.gz: ea48e2455183f291ab01d01923f98291d1fc3cbdac8237e0bfb47c6918f1b94d
4
+ data.tar.gz: 4734cdafc9f127194a972f6fbe366a5c7be1554837d6bd4829ea9ce5ecf56b0f
5
5
  SHA512:
6
- metadata.gz: 92e28c29a0cc4a88f175d7960ad509356f2aa7b5fd99b6a8a1bf1c03b568ef34ea7df67f17eda4a4bcdaf9f7374095bcd79409ee1931de6f92727637d4bc0c00
7
- data.tar.gz: 9b5e95b0514e08aeb557743274958f7c25c446403b16a56140248922c30e87032a0e0010fe0fb25d0e95eec6a59f1cfb7b4c2fc68ea77b0d406299f3bf0c80a4
6
+ metadata.gz: 86aba3d72fe106c69facc776e655fb6237cbeb2ccb63ee00de8a4e7f5678f14f1dbdd3727b3d48539f6c75e06d61083a2711854d642d6799edf03d82155e3717
7
+ data.tar.gz: 19750b1ea68bd3fabbe2036fcba8924aded9edcf2e46c0a2fd3bf654d4920006729cdd051ed5cd6886c5affeeea433454968c7b774a6bd4eaba4a437020f7f02
@@ -0,0 +1,51 @@
1
+ # Auto generated files with errors to ignore.
2
+ # Remove from this list as you refactor files.
3
+ ---
4
+ ignore:
5
+ - example/e-paper_spi/epd2in13b.rb:
6
+ - Style/MixinUsage
7
+ - example/loopback/spi.rb:
8
+ - Style/MixinUsage
9
+ - Lint/UselessAssignment
10
+ - example/loopback/uart.rb:
11
+ - Style/MixinUsage
12
+ - Lint/UselessAssignment
13
+ - example/sharp_memory_display/ls013b7dn05.rb:
14
+ - Lint/UselessAssignment
15
+ - Style/SafeNavigation
16
+ - Style/MixinUsage
17
+ - example/simple/callback.rb:
18
+ - Style/MixinUsage
19
+ - example/simple/led.rb:
20
+ - Style/MixinUsage
21
+ - example/simple/pwm.rb:
22
+ - Style/MixinUsage
23
+ - Style/InfiniteLoop
24
+ - example/simple/wave.rb:
25
+ - Style/MixinUsage
26
+ - example/ssd1306_i2c/ssd1306.rb:
27
+ - Style/MixinUsage
28
+ - lib/pigpio.rb:
29
+ - Naming/VariableName
30
+ - lib/pigpio/bank.rb:
31
+ - Naming/ConstantName
32
+ - lib/pigpio/constant.rb:
33
+ - Naming/ConstantName
34
+ - lib/pigpio/gpio.rb:
35
+ - Lint/UselessAssignment
36
+ - Naming/VariableName
37
+ - lib/pigpio/i2c.rb:
38
+ - Naming/VariableName
39
+ - lib/pigpio/pwm.rb:
40
+ - Lint/UselessAssignment
41
+ - lib/pigpio/serial.rb:
42
+ - Naming/ConstantName
43
+ - Lint/UselessAssignment
44
+ - Naming/VariableName
45
+ - lib/pigpio/spi.rb:
46
+ - Naming/VariableName
47
+ - lib/pigpio/user_gpio.rb:
48
+ - Lint/UselessAssignment
49
+ - Naming/VariableName
50
+ - spec/ext/extconf.rb:
51
+ - Style/GlobalVars
data/README.md CHANGED
@@ -63,7 +63,9 @@ $ ruby example_led.rb
63
63
 
64
64
  More sample for this circuit. : [Hare](./example/simple/readme.md)
65
65
 
66
- More document : [GitHub Pages](https://nak1114.github.io/ruby-extension-pigpio/)
66
+ More sample for other circuit. : [Hare](./example/readme.md)
67
+
68
+ More document : [GitHub Pages](https://nak1114.github.io/ruby-extension-pigpio/Pigpio/IF.html)
67
69
 
68
70
  ## Development
69
71
 
data/Rakefile CHANGED
@@ -9,10 +9,9 @@ end
9
9
 
10
10
  RSpec::Core::RakeTask.new(:spec)
11
11
 
12
- task :default => :spec
12
+ task default: :spec
13
13
 
14
-
15
- RDOC_FILES = FileList["ext/pigpio/pigpio.c","lib/**/*.rb"]
14
+ RDOC_FILES = FileList["ext/pigpio/pigpio.c", "lib/**/*.rb"]
16
15
 
17
16
  Rake::RDocTask.new do |rd|
18
17
  rd.main = "pigpio.c"
@@ -33,4 +32,4 @@ end
33
32
  task :reset do
34
33
  sh "git fetch origin"
35
34
  sh "git reset --hard origin/master"
36
- end
35
+ end
@@ -1,5 +1,5 @@
1
- require 'mkmf'
2
- dir_config('pigpio')
3
- if find_header('pigpiod_if2.h','/usr/include/') && find_library('pigpiod_if2','gpio_read','/usr/lib/')
4
- create_makefile('pigpio/pigpio')
5
- end
1
+ require "mkmf"
2
+ dir_config("pigpio")
3
+ if find_header("pigpiod_if2.h", "/usr/include/") && find_library("pigpiod_if2", "gpio_read", "/usr/lib/")
4
+ create_makefile("pigpio/pigpio")
5
+ end
data/ext/pigpio/pigpio.c CHANGED
@@ -7,6 +7,7 @@
7
7
  static VALUE cCallbackID;
8
8
  static VALUE cNativeQueue;
9
9
  static VALUE cCallbackError;
10
+ static VALUE cBuffer;
10
11
 
11
12
  typedef struct{
12
13
  uint32_t tick;
@@ -2359,18 +2360,16 @@ associated with handle and writes them to buf.
2359
2360
  . .
2360
2361
  pi: >=0 (as returned by [*pigpio_start*]).
2361
2362
  handle: >=0, as returned by a call to [*serial_open*].
2362
- buf: an array to receive the read data.
2363
2363
  count: the maximum number of bytes to read.
2364
2364
  . .
2365
2365
 
2366
- Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
2366
+ Returns to buf.ret_code attribute the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
2367
2367
  PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
2368
2368
 
2369
- If no data is ready zero is returned.
2369
+ The received data is get by the buf.to_s method.
2370
2370
 
2371
2371
  :call-seq:
2372
- serial_read(Integer pi,Integer handle, Integer count) -> Integer (When onError)
2373
- serial_read(Integer pi,Integer handle, Integer count) -> String buf (When Success)
2372
+ serial_read(Integer pi,Integer handle, Integer count) -> Pigpio::Buffer buf
2374
2373
 
2375
2374
  See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#serial_read]
2376
2375
  */
@@ -2378,7 +2377,9 @@ VALUE pigpio_rbfn_serial_read(VALUE self, VALUE pi, VALUE handle, VALUE count){
2378
2377
  unsigned countc=NUM2UINT(count);
2379
2378
  VALUE buf=rb_str_new("",countc);//#<Encoding:ASCII-8BIT>;
2380
2379
  int ret=serial_read(NUM2INT(pi), NUM2UINT(handle), (void*)StringValuePtr(buf), countc);
2381
- return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2380
+ return rb_funcall((VALUE)cBuffer, rb_intern("new"), 2,INT2NUM(ret),rb_str_resize(buf,ret));
2381
+
2382
+ //return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2382
2383
  //if(ret < 0){buf=Qnil;}
2383
2384
  //return rb_ary_new_from_args(2,buf,INT2NUM(ret));
2384
2385
  }
@@ -2436,13 +2437,14 @@ bit bang serial cyclic buffer to the buffer starting at buf.
2436
2437
  . .
2437
2438
  pi: >=0 (as returned by [*pigpio_start*]).
2438
2439
  user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
2439
- buf: an array to receive the read bytes.
2440
2440
  bufSize: >=0
2441
2441
  . .
2442
2442
 
2443
- Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
2443
+ Returns to buf.ret_code attribute the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
2444
2444
  or PI_NOT_SERIAL_GPIO.
2445
2445
 
2446
+ The received data is get by the buf.to_s method.
2447
+
2446
2448
  The bytes returned for each character depend upon the number of
2447
2449
  data bits [*data_bits*] specified in the [*bb_serial_read_open*] command.
2448
2450
 
@@ -2451,8 +2453,7 @@ data bits [*data_bits*] specified in the [*bb_serial_read_open*] command.
2451
2453
  * For [*data_bits*] 17-32 there will be four bytes per character.
2452
2454
 
2453
2455
  :call-seq:
2454
- bb_serial_read(Integer pi,Integer user_gpio, Integer bufSize) -> Integer (When onError)
2455
- bb_serial_read(Integer pi,Integer user_gpio, Integer bufSize) -> String (When Success)
2456
+ bb_serial_read(Integer pi,Integer user_gpio, Integer bufSize) -> Pigpio::Buffer buf
2456
2457
 
2457
2458
  See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#bb_serial_read]
2458
2459
  */
@@ -2460,7 +2461,8 @@ VALUE pigpio_rbfn_bb_serial_read(VALUE self, VALUE pi, VALUE user_gpio, VALUE bu
2460
2461
  size_t countc=NUM2SIZET(bufSize);
2461
2462
  VALUE buf=rb_str_new("",countc);//#<Encoding:ASCII-8BIT>;
2462
2463
  int ret=bb_serial_read(NUM2INT(pi), NUM2UINT(user_gpio), (void*)StringValuePtr(buf), countc);
2463
- return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2464
+ return rb_funcall((VALUE)cBuffer, rb_intern("new"), 2,INT2NUM(ret),rb_str_resize(buf,ret));
2465
+ //return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2464
2466
  //if(ret < 0){buf=Qnil;}
2465
2467
  //return rb_ary_new_from_args(2,buf,INT2NUM(ret));
2466
2468
  }
@@ -3702,9 +3704,6 @@ This class has some constances for pigpio library.
3702
3704
  */
3703
3705
  void Init_pigpio(void){
3704
3706
  VALUE cPulse,cBscXfer,cNativeQueue;
3705
- /*
3706
- This class has some constances for pigpio library.
3707
- */
3708
3707
  VALUE cPigpio = rb_define_class("Pigpio", rb_cObject);
3709
3708
  /*
3710
3709
  This module is a ruby binding to pigpio library.
@@ -3830,13 +3829,15 @@ This class has some constances for pigpio library.
3830
3829
  /*
3831
3830
  This class wrap gpioPulse_t.
3832
3831
  */
3833
- cPulse = rb_define_class_under(cPigpio,"Pulse", rb_cData);
3832
+ cPulse = rb_define_class_under(cPigpio,"Pulse", rb_cObject);
3833
+ rb_undef_alloc_func(cPulse);
3834
3834
  rb_define_singleton_method(cPulse, "make", pigpio_rbst_gpioPulse_make, 3);
3835
3835
 
3836
3836
  /*
3837
3837
  This class wrap bsc_xfer_t.
3838
3838
  */
3839
- cBscXfer = rb_define_class_under(cPigpio,"BscXfer", rb_cData);
3839
+ cBscXfer = rb_define_class_under(cPigpio,"BscXfer", rb_cObject);
3840
+ rb_undef_alloc_func(cBscXfer);
3840
3841
  rb_define_singleton_method(cBscXfer, "make", pigpio_rbst_bsc_xfer_make, 0);
3841
3842
  rb_define_method(cBscXfer, "control=", pigpio_rbst_bsc_xfer_w_control, 1);
3842
3843
  rb_define_method(cBscXfer, "control", pigpio_rbst_bsc_xfer_r_control, 0);
@@ -3848,13 +3849,15 @@ This class has some constances for pigpio library.
3848
3849
  /*
3849
3850
  The class of native queue.
3850
3851
  */
3851
- cNativeQueue = rb_define_class_under(cAPI,"NativeQueue", rb_cData);
3852
+ cNativeQueue = rb_define_class_under(cAPI,"NativeQueue", rb_cObject);
3853
+ rb_undef_alloc_func(cNativeQueue);
3852
3854
  rb_gc_register_address(&cNativeQueue);
3853
3855
 
3854
3856
  /*
3855
3857
  The class of callback.
3856
3858
  */
3857
- cCallbackID = rb_define_class_under(cPigpio,"Callback", rb_cData);
3859
+ cCallbackID = rb_define_class_under(cPigpio,"Callback", rb_cObject);
3860
+ rb_undef_alloc_func(cCallbackID);
3858
3861
  rb_define_method(cCallbackID, "id", pigpio_rbst_callback_id_r_id, 0);
3859
3862
  rb_define_method(cCallbackID, "cancel", pigpio_rbst_callback_id_cancel, 0);
3860
3863
  rb_gc_register_address(&cCallbackID);
@@ -3863,5 +3866,13 @@ This class has some constances for pigpio library.
3863
3866
  The class of callback error.
3864
3867
  */
3865
3868
  cCallbackError = rb_define_class_under(cPigpio,"CallbackError", rb_eException);
3869
+ rb_undef_alloc_func(cCallbackError);
3866
3870
  rb_gc_register_address(&cCallbackError);
3871
+
3872
+ /*
3873
+ The class of Rx buffer.
3874
+ */
3875
+ cBuffer = rb_define_class_under(cPigpio,"Buffer", rb_cString);
3876
+ rb_undef_alloc_func(cBuffer);
3877
+ rb_gc_register_address(&cBuffer);
3867
3878
  }
data/lib/pigpio/bank.rb CHANGED
@@ -1,22 +1,25 @@
1
- class Pigpio
2
- class Bank
3
- Set={
4
- read: [:read_bank_1 ,:read_bank_2],
5
- clear: [:clear_bank_1,:clear_bank_2],
6
- set: [:set_bank_1 ,:set_bank_2],
7
- }
8
- def initialize(pi,num)
9
- @pi=pi
10
- @num=num
11
- end
12
- def read
13
- IF.send(Set[:read][@num],@pi)
14
- end
15
- def clear(bits)
16
- IF.send(Set[:clear][@num],@pi,bits)
17
- end
18
- def set(bits)
19
- IF.send(Set[:set][@num],@pi,bits)
20
- end
21
- end
22
- end
1
+ class Pigpio
2
+ class Bank
3
+ Set = {
4
+ read: [:read_bank_1, :read_bank_2],
5
+ clear: [:clear_bank_1, :clear_bank_2],
6
+ set: [:set_bank_1, :set_bank_2]
7
+ }
8
+ def initialize(pi, num)
9
+ @pi = pi
10
+ @num = num
11
+ end
12
+
13
+ def read
14
+ IF.send(Set[:read][@num], @pi)
15
+ end
16
+
17
+ def clear(bits)
18
+ IF.send(Set[:clear][@num], @pi, bits)
19
+ end
20
+
21
+ def set(bits)
22
+ IF.send(Set[:set][@num], @pi, bits)
23
+ end
24
+ end
25
+ end
@@ -1,19 +1,21 @@
1
- require_relative "./bit_bang_serial_rx"
2
- require_relative "./bit_bang_serial_tx"
3
-
4
- class Pigpio
5
- class BitBangSerial < BitBangSerialTx
6
- attr_reader :rx
7
- def initialize(rx,tx,baud=9600,data_bits=8,stop_bits=1,parity_type=:none)
8
- super(tx,baud,data_bits,stop_bits)
9
- @rx=BitBangSerialRx.new(rx,baud,data_bits)
10
- end
11
- def close
12
- super
13
- @rx.close
14
- end
15
- def read(bufsize=1)
16
- @rx.read(bufsize)
17
- end
18
- end
19
- end
1
+ require_relative "./bit_bang_serial_rx"
2
+ require_relative "./bit_bang_serial_tx"
3
+
4
+ class Pigpio
5
+ class BitBangSerial < BitBangSerialTx
6
+ attr_reader :rx
7
+ def initialize(rx, tx, baud = 9600, data_bits = 8, stop_bits = 1, parity_type = :none)
8
+ super(tx, baud, data_bits, stop_bits)
9
+ @rx = BitBangSerialRx.new(rx, baud, data_bits)
10
+ end
11
+
12
+ def close
13
+ super
14
+ @rx.close
15
+ end
16
+
17
+ def read(bufsize = 1)
18
+ @rx.read(bufsize)
19
+ end
20
+ end
21
+ end
@@ -1,19 +1,70 @@
1
- class Pigpio
2
- class BitBangSerialRx
3
- attr_reader :rx
4
- def initialize(rx,baud=9600,data_bits=8)
5
- @rx=rx
6
- IF.bb_serial_read_open(@rx.pi,@rx.gpio,baud,data_bits)
7
- IF.bb_serial_invert(@rx.pi,@rx.gpio,0)
8
- end
9
- def close
10
- IF.bb_serial_read_close(@rx.pi,@rx.gpio)
11
- end
12
- def read(bufsize=1)
13
- IF.bb_serial_read(@rx.pi,@rx.gpio,bufsize)
14
- end
15
- def invert(invert=1)
16
- IF.bb_serial_invert(@rx.pi,@rx.gpio,invert)
17
- end
18
- end
19
- end
1
+ class Pigpio
2
+ # Set a UserGPIO pin as a serial Rx.
3
+ class BitBangSerialRx
4
+ # UserGPIO#.
5
+ #
6
+ # This attribute is set at the time of ::new.
7
+ attr_reader :rx
8
+
9
+ # Set 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_GPIO_IN_USE, PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
10
+ #
11
+ # This attribute is set at the time of ::new.
12
+ attr_reader :valid
13
+
14
+ # Set a UserGPIO pin as a serial Rx.
15
+ #
16
+ # The serial data recieves in a internal cyclic buffer and is read using #read method.
17
+ # It is the caller's responsibility to read data from the cyclic buffer in a timely fashion.
18
+ #
19
+ # [Parameter]
20
+ # [rx [ Pigpio::UserGPIO ]] Set This pgio as a serial Rx.
21
+ # [baud [ Integer ]] 50-250000 [bps]. default 9600.
22
+ # [data_bits [ Integer ]] 1-32 [bit/word]. default 8.
23
+ #
24
+ # See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#bb_serial_read_open]
25
+ def initialize(rx, baud = 9600, data_bits = 8)
26
+ @rx = rx
27
+ @valid = IF.bb_serial_read_open(@rx.pi, @rx.gpio, baud, data_bits)
28
+ if @valid == 0
29
+ @valid = IF.bb_serial_invert(@rx.pi, @rx.gpio, 0)
30
+ end
31
+ end
32
+
33
+ # This method closes a GPIO for bit bang reading of serial data.
34
+ #
35
+ # [Return] [Integer] Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
36
+ #
37
+ # See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#bb_serial_read_close]
38
+ def close
39
+ IF.bb_serial_read_close(@rx.pi, @rx.gpio)
40
+ end
41
+
42
+ # This method copies up to bufSize bytes of data read from the bit bang serial cyclic buffer to the buffer starting at returned value.
43
+ #
44
+ # [Parameter] [bufSize [ Integer ]] How many bytes receive.
45
+ # [Return] [ Pigpio::Buffer ] A copied buffer and status.
46
+ #
47
+ # The details of the returned status is the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERIAL_GPIO.
48
+ #
49
+ # The bytes returned for each character depend upon the number of data bits +data_bits+ specified in the ::new method.
50
+ #
51
+ # * For +data_bits+ 1-8 there will be one byte per character.
52
+ # * For +data_bits+ 9-16 there will be two bytes per character.
53
+ # * For +data_bits+ 17-32 there will be four bytes per character.
54
+ #
55
+ # See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#bb_serial_read]
56
+ def read(bufsize = 1)
57
+ IF.bb_serial_read(@rx.pi, @rx.gpio, bufsize)
58
+ end
59
+
60
+ # This method inverts serial logic for big bang serial reads.
61
+ #
62
+ # [Parameter] [Integer] invert 0-1.1 invert, 0 normal.
63
+ # [Return] [Integer] Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
64
+ #
65
+ # See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#bb_serial_invert]
66
+ def invert(invert = 1)
67
+ IF.bb_serial_invert(@rx.pi, @rx.gpio, invert)
68
+ end
69
+ end
70
+ end
@@ -1,41 +1,47 @@
1
- class Pigpio
2
- class BitBangSerialTx
3
- attr_reader :tx
4
- def initialize(tx,baud=9600,data_bits=8,stop_bits=1)
5
- @tx=tx
6
- @baud=baud
7
- @data_bits=data_bits
8
- @stop_half_bits=(stop_bits*2).round.to_i
9
- end
10
- def close
11
- IF.wave_tx_stop(@tx.pi) if busy?
12
- IF.wave_clear(@tx.pi)
13
- end
14
- def write(buf)
15
- IF.wave_clear(@tx.pi)
16
- IF.wave_add_new(@tx.pi)
17
- ret=IF.wave_add_serial(@tx.pi,@tx.gpio,@baud,@data_bits,@stop_half_bits,0,buf)
18
- return ret if ret < 0
19
- wid=IF.wave_create(@tx.pi)
20
- return wid if wid < 0
21
- IF.wave_send_once(@tx.pi,wid)
22
- end
23
- def sync
24
- while busy?
25
- sleep 0.1
26
- end
27
- end
28
- def write_sync(buf)
29
- ret=write(buf)
30
- return ret if ret < 0
31
- sync
32
- IF.wave_clear(@tx.pi)
33
- end
34
- def busy?
35
- IF.wave_tx_busy(@tx.pi)
36
- end
37
- def stop
38
- IF.wave_tx_stop(@tx.pi)
39
- end
40
- end
41
- end
1
+ class Pigpio
2
+ class BitBangSerialTx
3
+ attr_reader :tx
4
+ def initialize(tx, baud = 9600, data_bits = 8, stop_bits = 1)
5
+ @tx = tx
6
+ @baud = baud
7
+ @data_bits = data_bits
8
+ @stop_half_bits = (stop_bits * 2).round.to_i
9
+ end
10
+
11
+ def close
12
+ IF.wave_tx_stop(@tx.pi) if busy?
13
+ IF.wave_clear(@tx.pi)
14
+ end
15
+
16
+ def write(buf)
17
+ IF.wave_clear(@tx.pi)
18
+ IF.wave_add_new(@tx.pi)
19
+ ret = IF.wave_add_serial(@tx.pi, @tx.gpio, @baud, @data_bits, @stop_half_bits, 0, buf)
20
+ return ret if ret < 0
21
+ wid = IF.wave_create(@tx.pi)
22
+ return wid if wid < 0
23
+ IF.wave_send_once(@tx.pi, wid)
24
+ end
25
+
26
+ def sync
27
+ while busy?
28
+ sleep 0.1
29
+ end
30
+ end
31
+
32
+ def write_sync(buf)
33
+ ret = write(buf)
34
+ return ret if ret < 0
35
+ sync
36
+ IF.wave_clear(@tx.pi)
37
+ end
38
+
39
+ def busy?
40
+ IF.wave_tx_busy(@tx.pi)
41
+ end
42
+
43
+ def stop
44
+ IF.wave_tx_stop(@tx.pi)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,13 @@
1
+ class Pigpio
2
+ class Buffer < String
3
+ attr_reader :ret_code
4
+ def initialize(ret_code, str = nil)
5
+ super(str)
6
+ @ret_code = ret_code
7
+ end
8
+
9
+ def valid?
10
+ @ret_code >= 0
11
+ end
12
+ end
13
+ end