pigpio 0.1.11 → 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 +5 -5
 - data/.standard_todo.yml +51 -0
 - data/README.md +1 -1
 - data/Rakefile +3 -4
 - data/ext/pigpio/extconf.rb +5 -5
 - data/ext/pigpio/pigpio.c +10 -4
 - data/lib/pigpio/bank.rb +25 -22
 - data/lib/pigpio/bit_bang_serial.rb +21 -19
 - data/lib/pigpio/bit_bang_serial_rx.rb +70 -19
 - data/lib/pigpio/bit_bang_serial_tx.rb +47 -41
 - data/lib/pigpio/buffer.rb +13 -12
 - data/lib/pigpio/constant.rb +745 -748
 - data/lib/pigpio/gpio.rb +37 -30
 - data/lib/pigpio/i2c.rb +77 -60
 - data/lib/pigpio/pwm.rb +48 -38
 - data/lib/pigpio/serial.rb +35 -29
 - data/lib/pigpio/spi.rb +37 -33
 - data/lib/pigpio/user_gpio.rb +33 -27
 - data/lib/pigpio/version.rb +1 -1
 - data/lib/pigpio/wave.rb +100 -78
 - data/lib/pigpio.rb +28 -18
 - data/pigpio.gemspec +16 -17
 - metadata +18 -3
 
    
        data/lib/pigpio.rb
    CHANGED
    
    | 
         @@ -16,49 +16,59 @@ require "pigpio/i2c" 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            class Pigpio
         
     | 
| 
       18 
18 
     | 
    
         
             
              attr_reader :pi
         
     | 
| 
       19 
     | 
    
         
            -
              def initialize(addr=nil,port=nil 
     | 
| 
       20 
     | 
    
         
            -
                @pi=IF.pigpio_start(addr,port)
         
     | 
| 
      
 19 
     | 
    
         
            +
              def initialize(addr = nil, port = nil, &blk)
         
     | 
| 
      
 20 
     | 
    
         
            +
                @pi = IF.pigpio_start(addr, port)
         
     | 
| 
       21 
21 
     | 
    
         
             
                if blk && connect
         
     | 
| 
       22 
     | 
    
         
            -
                  blk.call(self) 
     | 
| 
      
 22 
     | 
    
         
            +
                  blk.call(self)
         
     | 
| 
       23 
23 
     | 
    
         
             
                  IF.pigpio_stop(@pi)
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       26 
27 
     | 
    
         
             
              def connect
         
     | 
| 
       27 
     | 
    
         
            -
                @pi>=0
         
     | 
| 
      
 28 
     | 
    
         
            +
                @pi >= 0
         
     | 
| 
       28 
29 
     | 
    
         
             
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       29 
31 
     | 
    
         
             
              def stop
         
     | 
| 
       30 
32 
     | 
    
         
             
                IF.pigpio_stop(@pi)
         
     | 
| 
       31 
     | 
    
         
            -
                @pi 
     | 
| 
      
 33 
     | 
    
         
            +
                @pi = -1
         
     | 
| 
       32 
34 
     | 
    
         
             
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       33 
36 
     | 
    
         
             
              def current_tick
         
     | 
| 
       34 
37 
     | 
    
         
             
                IF.get_current_tick(@pi)
         
     | 
| 
       35 
38 
     | 
    
         
             
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       36 
40 
     | 
    
         
             
              def hardware_revision
         
     | 
| 
       37 
41 
     | 
    
         
             
                IF.get_hardware_revision(@pi)
         
     | 
| 
       38 
42 
     | 
    
         
             
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       39 
44 
     | 
    
         
             
              def pigpio_version
         
     | 
| 
       40 
45 
     | 
    
         
             
                IF.get_pigpio_version(@pi)
         
     | 
| 
       41 
46 
     | 
    
         
             
              end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       43 
48 
     | 
    
         
             
              def bank(num)
         
     | 
| 
       44 
     | 
    
         
            -
                Bank.new(@pi,num)
         
     | 
| 
      
 49 
     | 
    
         
            +
                Bank.new(@pi, num)
         
     | 
| 
       45 
50 
     | 
    
         
             
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       46 
52 
     | 
    
         
             
              def gpio(gpio)
         
     | 
| 
       47 
     | 
    
         
            -
                (gpio<32 ? UserGPIO : GPIO).new(@pi,gpio)
         
     | 
| 
      
 53 
     | 
    
         
            +
                (gpio < 32 ? UserGPIO : GPIO).new(@pi, gpio)
         
     | 
| 
       48 
54 
     | 
    
         
             
              end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              def wave
         
     | 
| 
       50 
57 
     | 
    
         
             
                Wave.new(@pi)
         
     | 
| 
       51 
58 
     | 
    
         
             
              end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                return  
     | 
| 
       55 
     | 
    
         
            -
                return  
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              def serial(rx, tx = nil, baud = 9600, data_bits = 8, stop_bits = 1, parity_type = :none)
         
     | 
| 
      
 61 
     | 
    
         
            +
                return BitBangSerialRx.new(rx, baud, data_bits) if tx.nil?
         
     | 
| 
      
 62 
     | 
    
         
            +
                return BitBangSerialTx.new(tx, baud, data_bits, stop_bits) if rx.nil?
         
     | 
| 
      
 63 
     | 
    
         
            +
                BitBangSerial.new(rx, tx, baud, data_bits, stop_bits)
         
     | 
| 
       56 
64 
     | 
    
         
             
              end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                 
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              def spi(spi_channel = 0, enable_cex = 1, baud = 500000,
         
     | 
| 
      
 67 
     | 
    
         
            +
                bits_per_word: 8, first_MISO: false, first_MOSI: false, idol_bytes: 0, is_3wire: false, active_low_cex: 0, spi_mode: 0)
         
     | 
| 
      
 68 
     | 
    
         
            +
                SPI.new(@pi, spi_channel, enable_cex, baud, bits_per_word: bits_per_word, first_MISO: first_MISO, first_MOSI: first_MOSI, idol_bytes: idol_bytes, is_3wire: is_3wire, active_low_cex: active_low_cex, spi_mode: spi_mode)
         
     | 
| 
       60 
69 
     | 
    
         
             
              end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              def i2c(i2c_bus, i2c_addr)
         
     | 
| 
      
 72 
     | 
    
         
            +
                I2C.new(@pi, i2c_bus, i2c_addr)
         
     | 
| 
       63 
73 
     | 
    
         
             
              end
         
     | 
| 
       64 
74 
     | 
    
         
             
            end
         
     | 
    
        data/pigpio.gemspec
    CHANGED
    
    | 
         @@ -1,24 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
1 
     | 
    
         
             
            lib = File.expand_path("../lib", __FILE__)
         
     | 
| 
       3 
2 
     | 
    
         
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
       4 
3 
     | 
    
         
             
            require "pigpio/version"
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       7 
     | 
    
         
            -
              spec.name 
     | 
| 
       8 
     | 
    
         
            -
              spec.version 
     | 
| 
       9 
     | 
    
         
            -
              spec.authors 
     | 
| 
       10 
     | 
    
         
            -
              spec.email 
     | 
| 
      
 6 
     | 
    
         
            +
              spec.name = "pigpio"
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.version = Pigpio::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.authors = ["nak1114"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.email = ["naktak1114@gmail.com"]
         
     | 
| 
       11 
10 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              spec.summary 
     | 
| 
       13 
     | 
    
         
            -
              spec.description 
     | 
| 
       14 
     | 
    
         
            -
              spec.homepage 
     | 
| 
       15 
     | 
    
         
            -
              spec.license 
     | 
| 
       16 
     | 
    
         
            -
              spec.extensions 
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary = "This gem is a ruby binding to a pigpio library."
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description = "This gem is a ruby binding to a pigpio library."
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage = "http://www.github.com/nak1114/ruby-extension-pigpio"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.extensions = %w[ext/pigpio/extconf.rb]
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
17 
     | 
    
         
             
              # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
         
     | 
| 
       19 
18 
     | 
    
         
             
              # to allow pushing to a single host or delete this section to allow pushing to any host.
         
     | 
| 
       20 
19 
     | 
    
         
             
              if spec.respond_to?(:metadata)
         
     | 
| 
       21 
     | 
    
         
            -
            #    spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
         
     | 
| 
      
 20 
     | 
    
         
            +
                #    spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
       23 
22 
     | 
    
         
             
                spec.metadata["homepage_uri"] = spec.homepage
         
     | 
| 
       24 
23 
     | 
    
         
             
                spec.metadata["source_code_uri"] = spec.homepage
         
     | 
| 
         @@ -30,17 +29,17 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       30 
29 
     | 
    
         | 
| 
       31 
30 
     | 
    
         
             
              # Specify which files should be added to the gem when it is released.
         
     | 
| 
       32 
31 
     | 
    
         
             
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         
     | 
| 
       33 
     | 
    
         
            -
              spec.files 
     | 
| 
      
 32 
     | 
    
         
            +
              spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
         
     | 
| 
       34 
33 
     | 
    
         
             
                `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(docs|example|test|spec|features)/}) }
         
     | 
| 
       35 
34 
     | 
    
         
             
              end
         
     | 
| 
       36 
     | 
    
         
            -
              spec.bindir 
     | 
| 
       37 
     | 
    
         
            -
              spec.executables 
     | 
| 
       38 
     | 
    
         
            -
              spec.require_paths = ["ext","lib"]
         
     | 
| 
      
 35 
     | 
    
         
            +
              spec.bindir = "exe"
         
     | 
| 
      
 36 
     | 
    
         
            +
              spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
      
 37 
     | 
    
         
            +
              spec.require_paths = ["ext", "lib"]
         
     | 
| 
       39 
38 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
              spec.required_ruby_version =  
     | 
| 
      
 39 
     | 
    
         
            +
              spec.required_ruby_version = ">= 2.0.0"
         
     | 
| 
       41 
40 
     | 
    
         
             
              spec.add_development_dependency "bundler", "> 1.17"
         
     | 
| 
       42 
41 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
       43 
42 
     | 
    
         
             
              spec.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
       44 
43 
     | 
    
         
             
              spec.add_development_dependency "rake-compiler", "~> 1.0"
         
     | 
| 
       45 
     | 
    
         
            -
              
         
     | 
| 
      
 44 
     | 
    
         
            +
              spec.add_development_dependency "standard"
         
     | 
| 
       46 
45 
     | 
    
         
             
            end
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.12
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - nak1114
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-09-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -66,6 +66,20 @@ dependencies: 
     | 
|
| 
       66 
66 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '1.0'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: standard
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       69 
83 
     | 
    
         
             
            description: This gem is a ruby binding to a pigpio library.
         
     | 
| 
       70 
84 
     | 
    
         
             
            email:
         
     | 
| 
       71 
85 
     | 
    
         
             
            - naktak1114@gmail.com
         
     | 
| 
         @@ -77,6 +91,7 @@ files: 
     | 
|
| 
       77 
91 
     | 
    
         
             
            - ".dockerignore"
         
     | 
| 
       78 
92 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       79 
93 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
      
 94 
     | 
    
         
            +
            - ".standard_todo.yml"
         
     | 
| 
       80 
95 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       81 
96 
     | 
    
         
             
            - CODE_OF_CONDUCT.md
         
     | 
| 
       82 
97 
     | 
    
         
             
            - Gemfile
         
     | 
| 
         @@ -130,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       130 
145 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       131 
146 
     | 
    
         
             
            requirements: []
         
     | 
| 
       132 
147 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       133 
     | 
    
         
            -
            rubygems_version: 2.6 
     | 
| 
      
 148 
     | 
    
         
            +
            rubygems_version: 2.7.6
         
     | 
| 
       134 
149 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       135 
150 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       136 
151 
     | 
    
         
             
            summary: This gem is a ruby binding to a pigpio library.
         
     |