raspberry_pi_iot 0.0.10 → 0.0.11
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/lib/bh1750.rb +4 -0
- data/lib/bmx_sensor.rb +12 -24
- data/lib/bmx_sensor.rb.OLD +74 -0
- data/lib/button.rb +6 -2
- data/lib/dht_sensor.rb +4 -0
- data/lib/hcsr501.rb +1 -1
- data/lib/max44009.rb +5 -0
- data/lib/raspberry_pi_iot.rb +2 -1
- data/test/-test_bme280.rb +59 -0
- data/test/{standalone_test_bmp280.rb → -test_bmp280.rb} +18 -17
- data/test/test_bh1750.rb +2 -2
- data/test/test_button.rb +6 -7
- data/test/test_dht22.rb +35 -0
- data/test/test_led.rb +2 -2
- data/test/test_max44009_gy49.rb +1 -1
- metadata +9 -9
- data/doc/RaspberryPiIoT.html +0 -115
- data/doc/file.LICENSE.html +0 -92
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: b5dfdc617f598658a421bec8deb1b11237cc391bc76c4eb9b7f64fb253f053ca
         | 
| 4 | 
            +
              data.tar.gz: 28cd3de80cb85f4e22e6188e23775a58045c5679aff0d0b17e204b4959e2e7a0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 12371ba7e697be7e635563e81b10349e93b1de197b9043ecab3fbb3dd8c6ac606c7b3086c0bc7318fa3518bfebd6f1076b88bfe7a0e41b38fcf04bc2b622cd0f
         | 
| 7 | 
            +
              data.tar.gz: 71e1ed94b315807c4096ea942a16cc1a40cc55a95cff4c67e67da642b4cf305eb3654630c0942140bdb1e91fb9532de9ff1e9cb3a088ebd36d3d8eb474f11aa4
         | 
    
        data/lib/bh1750.rb
    CHANGED
    
    
    
        data/lib/bmx_sensor.rb
    CHANGED
    
    | @@ -1,13 +1,10 @@ | |
| 1 | 
            -
            gem 'i2c'
         | 
| 2 | 
            -
            require 'i2c'
         | 
| 3 | 
            -
            gem 'i2c-bme280'
         | 
| 4 1 | 
             
            require 'i2c/bme280'
         | 
| 5 2 | 
             
            require 'humiture_sensor'
         | 
| 6 3 |  | 
| 7 4 | 
             
            # BMP/BME humidity, temperature & atmospheric pressure sensor family
         | 
| 8 5 | 
             
            class BMxSensor < HumitureSensor
         | 
| 9 6 |  | 
| 10 | 
            -
              def initialize(sensor_name, bus=1)
         | 
| 7 | 
            +
              def initialize(sensor_name='BMx280', bus=1)
         | 
| 11 8 | 
             
                @sensor_name = sensor_name
         | 
| 12 9 | 
             
                @sensor = I2C::Driver::BME280.new(device: bus)
         | 
| 13 10 | 
             
                @temperature, @humidity, @pressure = read_data
         | 
| @@ -21,6 +18,10 @@ class BMxSensor < HumitureSensor | |
| 21 18 | 
             
                [@temperature, @humidity, @pressure]
         | 
| 22 19 | 
             
              end
         | 
| 23 20 |  | 
| 21 | 
            +
              def name
         | 
| 22 | 
            +
                @sensor_name
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 24 25 | 
             
              # standard atmospheric pressure @ sea level = 1.01325 bar = 1013.25 mbar = 101.325 kPa
         | 
| 25 26 | 
             
              def hPa
         | 
| 26 27 | 
             
                @pressure
         | 
| @@ -52,34 +53,21 @@ class BMxSensor < HumitureSensor | |
| 52 53 | 
             
              def to_s
         | 
| 53 54 | 
             
                sprintf "%5.2f°C, %5.2f %%, %5.2f mmHg", @temperature, @humidity, pressure(:mmHg)
         | 
| 54 55 | 
             
              end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
            # OLD implementation with 'i2c-devices.gem'
         | 
| 57 | 
            -
            #require 'bus'
         | 
| 58 | 
            -
            #require 'i2c/device/bme280'
         | 
| 59 | 
            -
             | 
| 60 | 
            -
            # BMP/BME humidity, temperature & atmospheric pressure sensor family
         | 
| 61 | 
            -
            #  def initialize(sensor_name)
         | 
| 62 | 
            -
            #    @sensor_name = sensor_name
         | 
| 63 | 
            -
            #    @sensor = I2CDevice::Bme280.new
         | 
| 64 | 
            -
            #    @temperature, @humidity, @pressure = read_data
         | 
| 65 | 
            -
            #  end
         | 
| 66 | 
            -
            #  def read_data
         | 
| 67 | 
            -
            #    data = @sensor.calc_sensor_data
         | 
| 68 | 
            -
            #    @temperature = data[:temp]
         | 
| 69 | 
            -
            #    @pressure = data[:pressure]
         | 
| 70 | 
            -
            #    @humidity = data[:hum]
         | 
| 71 | 
            -
            #    [@temperature, @humidity, @pressure]
         | 
| 72 | 
            -
            #  end
         | 
| 73 56 | 
             
            end
         | 
| 74 57 |  | 
| 75 | 
            -
            class BMP280 < BMxSensor
         | 
| 58 | 
            +
            class BMP280 < BMxSensor # combined atmospheric pressure & temperature sensor
         | 
| 76 59 | 
             
              def initialize
         | 
| 77 60 | 
             
                super('BMP280')
         | 
| 78 61 | 
             
              end
         | 
| 79 62 | 
             
            end
         | 
| 80 63 |  | 
| 81 | 
            -
            class BME280 < BMxSensor
         | 
| 64 | 
            +
            class BME280 < BMxSensor # combined atmospheric pressure, temperature & humidity sensor
         | 
| 82 65 | 
             
              def initialize
         | 
| 83 66 | 
             
                super('BME280')
         | 
| 84 67 | 
             
              end
         | 
| 85 68 | 
             
            end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            require 'i2c/bme280'
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            bme280 = BMxSensor.new
         | 
| 73 | 
            +
            puts "Temperature: #{'%7.2f' % bme280.temperature}°C"
         | 
| @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            # OLD implementation with 'i2c-devices.gem'
         | 
| 2 | 
            +
            gem 'i2c'
         | 
| 3 | 
            +
            require 'i2c'
         | 
| 4 | 
            +
            require 'i2c/driver/i2c-dev'
         | 
| 5 | 
            +
            gem 'i2c-devices'
         | 
| 6 | 
            +
            require 'i2c/device/bme280'
         | 
| 7 | 
            +
            require 'bus'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # BMP/BME humidity, temperature & atmospheric pressure sensor family
         | 
| 10 | 
            +
            class BMxSensor < HumitureSensor
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def initialize(sensor_name)
         | 
| 13 | 
            +
                @sensor_name = sensor_name
         | 
| 14 | 
            +
                @sensor = I2CDevice::Bme280.new
         | 
| 15 | 
            +
                @temperature, @humidity, @pressure = read_data
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def read_data
         | 
| 19 | 
            +
                data = @sensor.calc_sensor_data
         | 
| 20 | 
            +
                @temperature = data[:temp]
         | 
| 21 | 
            +
                @pressure = data[:pressure]
         | 
| 22 | 
            +
                @humidity = data[:hum]
         | 
| 23 | 
            +
                [@temperature, @humidity, @pressure]
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def name
         | 
| 27 | 
            +
                @sensor_name
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              # standard atmospheric pressure @ sea level = 1.01325 bar = 1013.25 mbar = 101.325 kPa
         | 
| 31 | 
            +
              def hPa
         | 
| 32 | 
            +
                @pressure
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def pressure(mode=:hPa)
         | 
| 36 | 
            +
                case mode
         | 
| 37 | 
            +
                when :hPa       # 1 hPa = 100 Pa = 1 mbar = 1 hPa = 0.750062 mmHg [@ 0°C]
         | 
| 38 | 
            +
                  hPa
         | 
| 39 | 
            +
                when :kPa       # 1 kPa = 1000 Pa = 10 hPa
         | 
| 40 | 
            +
                  hPa / 10.0
         | 
| 41 | 
            +
                when :Pa        # 1 Pa = 0.01 hPa = 0.001 kPa
         | 
| 42 | 
            +
                  hPa * 100.0
         | 
| 43 | 
            +
                when :mmHg      # 1 mmHg = 1.3332236842105263 hPa = 133.322387415 Pa = 1.000000142466321... Torr
         | 
| 44 | 
            +
                  hPa / (1013.25 / 760) # 760 mmHg = 101.3250144354 kPa
         | 
| 45 | 
            +
                when :atm       # 1 atm = 101325 Pa = 101.325 kPa
         | 
| 46 | 
            +
                  hPa / 1013.25
         | 
| 47 | 
            +
                when :bar       # 1 bar ≡ 100000 Pa = 1000 hPa = 0.987 atm = 750.06 mmHg = 750.06 Torr
         | 
| 48 | 
            +
                  hPa / 1000.0
         | 
| 49 | 
            +
                when :mbar      # 1 mbar = 0.001 bar
         | 
| 50 | 
            +
                  bar * 1000.0
         | 
| 51 | 
            +
                when :Torr      # 1 Torr = 1/760 atm = 101325/760 Pa = 0.999999857533699... mmHg
         | 
| 52 | 
            +
                  (hPa / 1013.25) / 760
         | 
| 53 | 
            +
                else
         | 
| 54 | 
            +
                  hPa
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              def to_s
         | 
| 59 | 
            +
                sprintf "%5.2f°C, %5.2f %%, %5.2f mmHg", @temperature, @humidity, pressure(:mmHg)
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            class BMP280 < BMxSensor # combined atmospheric pressure & temperature sensor
         | 
| 65 | 
            +
              def initialize
         | 
| 66 | 
            +
                super('BMP280')
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
            end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            class BME280 < BMxSensor # combined atmospheric pressure, temperature & humidity sensor
         | 
| 71 | 
            +
              def initialize
         | 
| 72 | 
            +
                super('BME280')
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end
         | 
    
        data/lib/button.rb
    CHANGED
    
    | @@ -5,7 +5,7 @@ class Button < BinaryReceptor | |
| 5 5 | 
             
              attr_writer :measure_pause
         | 
| 6 6 |  | 
| 7 7 | 
             
              def initialize(pin)
         | 
| 8 | 
            -
                receptor_name = 'BUTTON'
         | 
| 8 | 
            +
                @receptor_name = 'BUTTON'
         | 
| 9 9 | 
             
                super(pin)
         | 
| 10 10 | 
             
                @measure_pause = 0.01
         | 
| 11 11 | 
             
                @long_click = 1.0
         | 
| @@ -17,6 +17,10 @@ class Button < BinaryReceptor | |
| 17 17 | 
             
                # long press:   [[0.910878286, 1.109352219]]
         | 
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 | 
            +
              def name
         | 
| 21 | 
            +
                @receptor_name
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 20 24 | 
             
              # Is button being pressed?
         | 
| 21 25 | 
             
              def pressed?
         | 
| 22 26 | 
             
                low?
         | 
| @@ -85,7 +89,7 @@ class Button < BinaryReceptor | |
| 85 89 | 
             
              end
         | 
| 86 90 |  | 
| 87 91 | 
             
              def timeout?
         | 
| 88 | 
            -
                min_wait_time = 0.0
         | 
| 92 | 
            +
                min_wait_time = 60.0*60.0*60.00
         | 
| 89 93 | 
             
                @intervals.each do |interval|
         | 
| 90 94 | 
             
                  min_wait_time = [min_wait_time, interval[0]].min
         | 
| 91 95 | 
             
                end
         | 
    
        data/lib/dht_sensor.rb
    CHANGED
    
    
    
        data/lib/hcsr501.rb
    CHANGED
    
    
    
        data/lib/max44009.rb
    CHANGED
    
    | @@ -44,6 +44,10 @@ class MAX44009 | |
| 44 44 | 
             
                @value = read_sensor
         | 
| 45 45 | 
             
              end
         | 
| 46 46 |  | 
| 47 | 
            +
              def name
         | 
| 48 | 
            +
                @sensor_name
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 47 51 | 
             
              def write_config()
         | 
| 48 52 | 
             
                # Select the configuration register data from the given provided values
         | 
| 49 53 | 
             
                config = (MAX44009_REG_CONFIG_CONTMODE_CONTIN | MAX44009_REG_CONFIG_MANUAL_MODEON | MAX44009_REG_CONFIG_CDR_NODIVIDED | MAX44009_REG_CONFIG_INTRTIMER_800)
         | 
| @@ -68,6 +72,7 @@ private | |
| 68 72 | 
             
                exponent = (data[0].ord & 0xF0) >> 4
         | 
| 69 73 | 
             
                mantissa = ((data[0].ord & 0x0F) << 4) | (data[1].ord & 0x0F)
         | 
| 70 74 | 
             
                luminance = ((2 ** exponent) * mantissa) * 0.045
         | 
| 75 | 
            +
                luminance
         | 
| 71 76 | 
             
              end
         | 
| 72 77 |  | 
| 73 78 | 
             
              # convert sensor data to a float number
         | 
    
        data/lib/raspberry_pi_iot.rb
    CHANGED
    
    
| @@ -0,0 +1,59 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'minitest/autorun'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            $LOAD_PATH << "../lib"
         | 
| 6 | 
            +
            require "bmx_sensor"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            class RaspberryPiIoT_BMP280Test < MiniTest::Test
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def setup
         | 
| 11 | 
            +
                @sensor = BME280.new
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def test_temperature_value
         | 
| 15 | 
            +
                @sensor.read_data
         | 
| 16 | 
            +
                c = @sensor.celsius
         | 
| 17 | 
            +
                assert c > 15.0
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                r = @sensor.reaumur
         | 
| 20 | 
            +
                assert r < c
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                f = @sensor.fahrenheit
         | 
| 23 | 
            +
                assert f > c
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                k = @sensor.kelvin
         | 
| 26 | 
            +
                assert k > f
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def test_pressure_value
         | 
| 30 | 
            +
                @sensor.read_data 
         | 
| 31 | 
            +
                # T: 27.2782°C P: 757.3502 mmHg 1009.7172 hPa 100971.7158 Pa 0.99651 atm 1.00972 bar 0.00131 Torr 
         | 
| 32 | 
            +
                m = @sensor.pressure(:mmHg)
         | 
| 33 | 
            +
                assert m > 750.0
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                h = @sensor.pressure(:hPa)
         | 
| 36 | 
            +
                assert h > m
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                k = @sensor.pressure(:kPa)
         | 
| 39 | 
            +
                assert k == h / 10.0
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                p = @sensor.pressure(:Pa)
         | 
| 42 | 
            +
                assert p > k
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                a = @sensor.pressure(:atm)
         | 
| 45 | 
            +
                assert a < m
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                b = @sensor.pressure(:bar)
         | 
| 48 | 
            +
                assert b > a
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                t = @sensor.pressure(:Torr)
         | 
| 51 | 
            +
                assert t < b
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              def test_humidity_value
         | 
| 55 | 
            +
                h = @sensor.humidity
         | 
| 56 | 
            +
                assert h > 0.0
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
            end
         | 
| 59 | 
            +
             | 
| @@ -3,24 +3,16 @@ | |
| 3 3 | 
             
            require 'minitest/autorun'
         | 
| 4 4 |  | 
| 5 5 | 
             
            $LOAD_PATH << "../lib"
         | 
| 6 | 
            -
            require  | 
| 6 | 
            +
            require "bmx_sensor"
         | 
| 7 7 |  | 
| 8 8 | 
             
            class RaspberryPiIoT_BMP280Test < MiniTest::Test
         | 
| 9 9 |  | 
| 10 10 | 
             
              def setup
         | 
| 11 | 
            -
                @bus = 1
         | 
| 12 | 
            -
                @address = 0x76
         | 
| 13 | 
            -
                @addr_s  = sprintf("%02x", @address)
         | 
| 14 11 | 
             
                @sensor = BMP280.new
         | 
| 15 12 | 
             
              end
         | 
| 16 13 |  | 
| 17 | 
            -
              def  | 
| 18 | 
            -
                 | 
| 19 | 
            -
                hex = i2cd.scan(/ (#{@addr_s})/).flatten
         | 
| 20 | 
            -
                assert hex.size == 1 && hex[0] == @addr_s
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              def test_temperature
         | 
| 14 | 
            +
              def test_temperature_value
         | 
| 15 | 
            +
                @sensor.read_data
         | 
| 24 16 | 
             
                c = @sensor.celsius
         | 
| 25 17 | 
             
                assert c > 15.0
         | 
| 26 18 |  | 
| @@ -34,20 +26,29 @@ class RaspberryPiIoT_BMP280Test < MiniTest::Test | |
| 34 26 | 
             
                assert k > f
         | 
| 35 27 | 
             
              end
         | 
| 36 28 |  | 
| 37 | 
            -
              def  | 
| 29 | 
            +
              def test_pressure_value
         | 
| 30 | 
            +
                @sensor.read_data 
         | 
| 31 | 
            +
                # T: 27.2782°C P: 757.3502 mmHg 1009.7172 hPa 100971.7158 Pa 0.99651 atm 1.00972 bar 0.00131 Torr 
         | 
| 38 32 | 
             
                m = @sensor.pressure(:mmHg)
         | 
| 39 | 
            -
                assert m >  | 
| 33 | 
            +
                assert m > 750.0
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                h = @sensor.pressure(:hPa)
         | 
| 36 | 
            +
                assert h > m
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                k = @sensor.pressure(:kPa)
         | 
| 39 | 
            +
                assert k == h / 10.0
         | 
| 40 40 |  | 
| 41 41 | 
             
                p = @sensor.pressure(:Pa)
         | 
| 42 | 
            -
                assert p >  | 
| 42 | 
            +
                assert p > k
         | 
| 43 43 |  | 
| 44 44 | 
             
                a = @sensor.pressure(:atm)
         | 
| 45 | 
            -
                assert a  | 
| 45 | 
            +
                assert a < m
         | 
| 46 46 |  | 
| 47 47 | 
             
                b = @sensor.pressure(:bar)
         | 
| 48 | 
            -
                assert b  | 
| 48 | 
            +
                assert b > a
         | 
| 49 49 |  | 
| 50 50 | 
             
                t = @sensor.pressure(:Torr)
         | 
| 51 | 
            -
                assert t  | 
| 51 | 
            +
                assert t < b
         | 
| 52 52 | 
             
              end
         | 
| 53 53 | 
             
            end
         | 
| 54 | 
            +
             | 
    
        data/test/test_bh1750.rb
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'minitest/autorun'
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 5 | 
            +
            #$LOAD_PATH << "../lib"
         | 
| 6 6 | 
             
            require 'bh1750'
         | 
| 7 7 |  | 
| 8 8 | 
             
            class RaspberryPiIoT_BH1750Test < MiniTest::Test
         | 
| @@ -15,7 +15,7 @@ class RaspberryPiIoT_BH1750Test < MiniTest::Test | |
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 17 | 
             
              def test_i2c_bus
         | 
| 18 | 
            -
                assert File. | 
| 18 | 
            +
                assert File.exist?(Bus::I2C.bus)
         | 
| 19 19 | 
             
              end
         | 
| 20 20 |  | 
| 21 21 | 
             
              def test_device_address
         | 
    
        data/test/test_button.rb
    CHANGED
    
    | @@ -10,21 +10,20 @@ class RaspberryPiIoT_ButtonTest < MiniTest::Test | |
| 10 10 | 
             
              def setup
         | 
| 11 11 | 
             
                @pin = 21
         | 
| 12 12 | 
             
                @button = Button.new(@pin)
         | 
| 13 | 
            -
                @button.set_timeout  | 
| 13 | 
            +
                @button.set_timeout 12
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| 16 16 | 
             
              def test_wait_for_press
         | 
| 17 17 | 
             
                assert @button.not_pressed?
         | 
| 18 18 | 
             
                assert @button.was_not_pressed?
         | 
| 19 | 
            -
                printf "Waiting for press...\n"
         | 
| 19 | 
            +
                printf "Waiting for a press...\n"
         | 
| 20 20 | 
             
                @button.wait_for_press
         | 
| 21 21 | 
             
                assert @button.was_pressed? unless @button.timeout?
         | 
| 22 22 |  | 
| 23 23 | 
             
              end
         | 
| 24 24 |  | 
| 25 | 
            -
             | 
| 26 25 | 
             
              def test_wait_for_short_press
         | 
| 27 | 
            -
                printf "Waiting for 1 short press...\n"
         | 
| 26 | 
            +
                printf "Waiting for 1 short press (< 1 second)...\n"
         | 
| 28 27 | 
             
                @button.wait_for_press
         | 
| 29 28 | 
             
                unless @button.timeout?
         | 
| 30 29 | 
             
                  assert @button.single_press?
         | 
| @@ -35,15 +34,15 @@ class RaspberryPiIoT_ButtonTest < MiniTest::Test | |
| 35 34 | 
             
              def test_wait_for_long_press
         | 
| 36 35 | 
             
                printf "Waiting for 1 long press (> 1 second)...\n"
         | 
| 37 36 | 
             
                @button.wait_for_press
         | 
| 38 | 
            -
                unless  | 
| 39 | 
            -
                  assert @button.single_press?
         | 
| 37 | 
            +
                unless @button.timeout?
         | 
| 40 38 | 
             
                  assert !@button.double_press?
         | 
| 39 | 
            +
                  assert @button.single_press?
         | 
| 41 40 | 
             
                  assert @button.long_press?
         | 
| 42 41 | 
             
                end
         | 
| 43 42 | 
             
              end
         | 
| 44 43 |  | 
| 45 44 | 
             
              def test_wait_for_double_press
         | 
| 46 | 
            -
                printf "Waiting for double press...\n" | 
| 45 | 
            +
                printf "Waiting for double press (2 sequential short presses)...\n"
         | 
| 47 46 | 
             
                @button.wait_for_presses 2
         | 
| 48 47 | 
             
                unless @button.timeout?
         | 
| 49 48 | 
             
                  assert @button.double_press?
         | 
    
        data/test/test_dht22.rb
    ADDED
    
    | @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'minitest/autorun'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            $LOAD_PATH << "../lib"
         | 
| 6 | 
            +
            require "dht_sensor"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            class RaspberryPiIoT_DHT22Test < MiniTest::Test
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def setup
         | 
| 11 | 
            +
                @pin = 23
         | 
| 12 | 
            +
                @sensor = DHT22.new(@pin)
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def test_temperature
         | 
| 16 | 
            +
                c = @sensor.celsius
         | 
| 17 | 
            +
                assert c > 15.0
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                r = @sensor.reaumur
         | 
| 20 | 
            +
                assert r < c
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                f = @sensor.fahrenheit
         | 
| 23 | 
            +
                assert f > c
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                k = @sensor.temperature(:kelvin)
         | 
| 26 | 
            +
                assert k > f
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def test_humidity
         | 
| 30 | 
            +
                h = @sensor.humidity
         | 
| 31 | 
            +
                assert h > 10.0
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
             | 
    
        data/test/test_led.rb
    CHANGED
    
    | @@ -13,7 +13,7 @@ class RaspberryPiIoT_LedTest < Minitest::Test | |
| 13 13 | 
             
                @led.off
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| 16 | 
            -
              def  | 
| 16 | 
            +
              def test_on_off
         | 
| 17 17 | 
             
                @led.on
         | 
| 18 18 | 
             
                assert @led.on?
         | 
| 19 19 | 
             
                assert !@led.off?
         | 
| @@ -21,7 +21,7 @@ class RaspberryPiIoT_LedTest < Minitest::Test | |
| 21 21 | 
             
                @led.off
         | 
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
| 24 | 
            -
              def  | 
| 24 | 
            +
              def test_off_on
         | 
| 25 25 | 
             
                @led.off
         | 
| 26 26 | 
             
                assert @led.off?
         | 
| 27 27 | 
             
                assert !@led.on?
         | 
    
        data/test/test_max44009_gy49.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: raspberry_pi_iot
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.11
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Mike Shock (Mikhail V. Shokhirev)
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2020-06-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -166,7 +166,7 @@ dependencies: | |
| 166 166 | 
             
                - - ">="
         | 
| 167 167 | 
             
                  - !ruby/object:Gem::Version
         | 
| 168 168 | 
             
                    version: 0.2.0
         | 
| 169 | 
            -
            description: A set of classes for IoT ( | 
| 169 | 
            +
            description: A set of classes for IoT (Internet of Things) / physical computing with
         | 
| 170 170 | 
             
              Raspberry Pi
         | 
| 171 171 | 
             
            email: mshock25@gmail.com
         | 
| 172 172 | 
             
            executables: []
         | 
| @@ -199,13 +199,11 @@ files: | |
| 199 199 | 
             
            - doc/LED.html
         | 
| 200 200 | 
             
            - doc/MAX44009.html
         | 
| 201 201 | 
             
            - doc/RaspberryPi.html
         | 
| 202 | 
            -
            - doc/RaspberryPiIoT.html
         | 
| 203 202 | 
             
            - doc/Receptor.html
         | 
| 204 203 | 
             
            - doc/Sensor.html
         | 
| 205 204 | 
             
            - doc/TemperatureSensor.html
         | 
| 206 205 | 
             
            - doc/_index.html
         | 
| 207 206 | 
             
            - doc/class_list.html
         | 
| 208 | 
            -
            - doc/file.LICENSE.html
         | 
| 209 207 | 
             
            - doc/file.README.html
         | 
| 210 208 | 
             
            - doc/file_list.html
         | 
| 211 209 | 
             
            - doc/frames.html
         | 
| @@ -218,6 +216,7 @@ files: | |
| 218 216 | 
             
            - lib/binary_receptor.rb
         | 
| 219 217 | 
             
            - lib/binary_sensor.rb
         | 
| 220 218 | 
             
            - lib/bmx_sensor.rb
         | 
| 219 | 
            +
            - lib/bmx_sensor.rb.OLD
         | 
| 221 220 | 
             
            - lib/bus.rb
         | 
| 222 221 | 
             
            - lib/button.rb
         | 
| 223 222 | 
             
            - lib/dht_sensor.rb
         | 
| @@ -239,11 +238,13 @@ files: | |
| 239 238 | 
             
            - lib/receptor.rb
         | 
| 240 239 | 
             
            - lib/temperature_sensor.rb
         | 
| 241 240 | 
             
            - lib/thermal_sensor.rb
         | 
| 242 | 
            -
            - test | 
| 241 | 
            +
            - test/-test_bme280.rb
         | 
| 242 | 
            +
            - test/-test_bmp280.rb
         | 
| 243 243 | 
             
            - test/test_Raspberry_Pi_IoT.rb
         | 
| 244 244 | 
             
            - test/test_bh1750.rb
         | 
| 245 245 | 
             
            - test/test_button.rb
         | 
| 246 246 | 
             
            - test/test_dht11.rb
         | 
| 247 | 
            +
            - test/test_dht22.rb
         | 
| 247 248 | 
             
            - test/test_ds18b20.rb
         | 
| 248 249 | 
             
            - test/test_helper.rb
         | 
| 249 250 | 
             
            - test/test_info.rb
         | 
| @@ -257,8 +258,7 @@ licenses: | |
| 257 258 | 
             
            metadata:
         | 
| 258 259 | 
             
              allowed_push_host: https://rubygems.org
         | 
| 259 260 | 
             
              homepage_uri: https://github.com/mike-shock/Ruby-Raspberry_Pi_IoT/
         | 
| 260 | 
            -
              source_code_uri:  | 
| 261 | 
            -
              changelog_uri: 'TODO: Put your gem''s CHANGELOG.md URL here.'
         | 
| 261 | 
            +
              source_code_uri: https://github.com/mike-shock/Ruby-Raspberry_Pi_IoT/
         | 
| 262 262 | 
             
            post_install_message: 
         | 
| 263 263 | 
             
            rdoc_options: []
         | 
| 264 264 | 
             
            require_paths:
         | 
| @@ -275,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 275 275 | 
             
                  version: '0'
         | 
| 276 276 | 
             
            requirements: []
         | 
| 277 277 | 
             
            rubyforge_project: 
         | 
| 278 | 
            -
            rubygems_version: 2. | 
| 278 | 
            +
            rubygems_version: 2.7.6.2
         | 
| 279 279 | 
             
            signing_key: 
         | 
| 280 280 | 
             
            specification_version: 4
         | 
| 281 281 | 
             
            summary: IoT library for Raspberry Pi projects in Ruby
         | 
    
        data/doc/RaspberryPiIoT.html
    DELETED
    
    | @@ -1,115 +0,0 @@ | |
| 1 | 
            -
            <!DOCTYPE html>
         | 
| 2 | 
            -
            <html>
         | 
| 3 | 
            -
              <head>
         | 
| 4 | 
            -
                <meta charset="utf-8">
         | 
| 5 | 
            -
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 6 | 
            -
            <title>
         | 
| 7 | 
            -
              Module: RaspberryPiIoT
         | 
| 8 | 
            -
              
         | 
| 9 | 
            -
                — Documentation by YARD 0.9.16
         | 
| 10 | 
            -
              
         | 
| 11 | 
            -
            </title>
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            <script type="text/javascript" charset="utf-8">
         | 
| 18 | 
            -
              pathId = "RaspberryPiIoT";
         | 
| 19 | 
            -
              relpath = '';
         | 
| 20 | 
            -
            </script>
         | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
              <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
         | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
              </head>
         | 
| 29 | 
            -
              <body>
         | 
| 30 | 
            -
                <div class="nav_wrap">
         | 
| 31 | 
            -
                  <iframe id="nav" src="class_list.html?1"></iframe>
         | 
| 32 | 
            -
                  <div id="resizer"></div>
         | 
| 33 | 
            -
                </div>
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                <div id="main" tabindex="-1">
         | 
| 36 | 
            -
                  <div id="header">
         | 
| 37 | 
            -
                    <div id="menu">
         | 
| 38 | 
            -
              
         | 
| 39 | 
            -
                <a href="_index.html">Index (R)</a> »
         | 
| 40 | 
            -
                
         | 
| 41 | 
            -
                
         | 
| 42 | 
            -
                <span class="title">RaspberryPiIoT</span>
         | 
| 43 | 
            -
              
         | 
| 44 | 
            -
            </div>
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                    <div id="search">
         | 
| 47 | 
            -
              
         | 
| 48 | 
            -
                <a class="full_list_link" id="class_list_link"
         | 
| 49 | 
            -
                    href="class_list.html">
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                    <svg width="24" height="24">
         | 
| 52 | 
            -
                      <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
         | 
| 53 | 
            -
                      <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
         | 
| 54 | 
            -
                      <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
         | 
| 55 | 
            -
                    </svg>
         | 
| 56 | 
            -
                </a>
         | 
| 57 | 
            -
              
         | 
| 58 | 
            -
            </div>
         | 
| 59 | 
            -
                    <div class="clear"></div>
         | 
| 60 | 
            -
                  </div>
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                  <div id="content"><h1>Module: RaspberryPiIoT
         | 
| 63 | 
            -
              
         | 
| 64 | 
            -
              
         | 
| 65 | 
            -
              
         | 
| 66 | 
            -
            </h1>
         | 
| 67 | 
            -
            <div class="box_info">
         | 
| 68 | 
            -
              
         | 
| 69 | 
            -
             | 
| 70 | 
            -
              
         | 
| 71 | 
            -
              
         | 
| 72 | 
            -
              
         | 
| 73 | 
            -
              
         | 
| 74 | 
            -
              
         | 
| 75 | 
            -
             | 
| 76 | 
            -
              
         | 
| 77 | 
            -
             | 
| 78 | 
            -
              
         | 
| 79 | 
            -
              <dl>
         | 
| 80 | 
            -
                <dt>Defined in:</dt>
         | 
| 81 | 
            -
                <dd>lib/raspberry_pi_iot.rb</dd>
         | 
| 82 | 
            -
              </dl>
         | 
| 83 | 
            -
              
         | 
| 84 | 
            -
            </div>
         | 
| 85 | 
            -
             | 
| 86 | 
            -
            <h2>Defined Under Namespace</h2>
         | 
| 87 | 
            -
            <p class="children">
         | 
| 88 | 
            -
              
         | 
| 89 | 
            -
                
         | 
| 90 | 
            -
              
         | 
| 91 | 
            -
                
         | 
| 92 | 
            -
                  <strong class="classes">Classes:</strong> <span class='object_link'><a href="RaspberryPiIoT/Error.html" title="RaspberryPiIoT::Error (class)">Error</a></span>
         | 
| 93 | 
            -
                
         | 
| 94 | 
            -
              
         | 
| 95 | 
            -
            </p>
         | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
            </div>
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                  <div id="footer">
         | 
| 108 | 
            -
              Generated on Wed Dec 26 18:10:00 2018 by
         | 
| 109 | 
            -
              <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
         | 
| 110 | 
            -
              0.9.16 (ruby-2.3.3).
         | 
| 111 | 
            -
            </div>
         | 
| 112 | 
            -
             | 
| 113 | 
            -
                </div>
         | 
| 114 | 
            -
              </body>
         | 
| 115 | 
            -
            </html>
         | 
    
        data/doc/file.LICENSE.html
    DELETED
    
    | @@ -1,92 +0,0 @@ | |
| 1 | 
            -
            <!DOCTYPE html>
         | 
| 2 | 
            -
            <html>
         | 
| 3 | 
            -
              <head>
         | 
| 4 | 
            -
                <meta charset="UTF-8">
         | 
| 5 | 
            -
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 6 | 
            -
            <title>
         | 
| 7 | 
            -
              File: LICENSE
         | 
| 8 | 
            -
              
         | 
| 9 | 
            -
                — Documentation by YARD 0.9.16
         | 
| 10 | 
            -
              
         | 
| 11 | 
            -
            </title>
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            <script type="text/javascript" charset="utf-8">
         | 
| 18 | 
            -
              pathId = "LICENSE";
         | 
| 19 | 
            -
              relpath = '';
         | 
| 20 | 
            -
            </script>
         | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
              <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
         | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
              </head>
         | 
| 29 | 
            -
              <body>
         | 
| 30 | 
            -
                <div class="nav_wrap">
         | 
| 31 | 
            -
                  <iframe id="nav" src="file_list.html?1"></iframe>
         | 
| 32 | 
            -
                  <div id="resizer"></div>
         | 
| 33 | 
            -
                </div>
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                <div id="main" tabindex="-1">
         | 
| 36 | 
            -
                  <div id="header">
         | 
| 37 | 
            -
                    <div id="menu">
         | 
| 38 | 
            -
              
         | 
| 39 | 
            -
                <a href="_index.html">Index</a> » 
         | 
| 40 | 
            -
                <span class="title">File: LICENSE</span>
         | 
| 41 | 
            -
              
         | 
| 42 | 
            -
            </div>
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                    <div id="search">
         | 
| 45 | 
            -
              
         | 
| 46 | 
            -
                <a class="full_list_link" id="class_list_link"
         | 
| 47 | 
            -
                    href="class_list.html">
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                    <svg width="24" height="24">
         | 
| 50 | 
            -
                      <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
         | 
| 51 | 
            -
                      <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
         | 
| 52 | 
            -
                      <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
         | 
| 53 | 
            -
                    </svg>
         | 
| 54 | 
            -
                </a>
         | 
| 55 | 
            -
              
         | 
| 56 | 
            -
            </div>
         | 
| 57 | 
            -
                    <div class="clear"></div>
         | 
| 58 | 
            -
                  </div>
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                  <div id="content"><div id='filecontents'>
         | 
| 61 | 
            -
            <p>The MIT License (MIT)</p>
         | 
| 62 | 
            -
             | 
| 63 | 
            -
            <p>Copyright © 2018 Mike Shock (Mikhail V. Shokhirev)</p>
         | 
| 64 | 
            -
             | 
| 65 | 
            -
            <p>Permission is hereby granted, free of charge, to any person obtaining a
         | 
| 66 | 
            -
            copy of this software and associated documentation files (the “Software”),
         | 
| 67 | 
            -
            to deal in the Software without restriction, including without limitation
         | 
| 68 | 
            -
            the rights to use, copy, modify, merge, publish, distribute, sublicense,
         | 
| 69 | 
            -
            and/or sell copies of the Software, and to permit persons to whom the
         | 
| 70 | 
            -
            Software is furnished to do so, subject to the following conditions:</p>
         | 
| 71 | 
            -
             | 
| 72 | 
            -
            <p>The above copyright notice and this permission notice shall be included in
         | 
| 73 | 
            -
            all copies or substantial portions of the Software.</p>
         | 
| 74 | 
            -
             | 
| 75 | 
            -
            <p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 76 | 
            -
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 77 | 
            -
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 78 | 
            -
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 79 | 
            -
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
         | 
| 80 | 
            -
            FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
         | 
| 81 | 
            -
            DEALINGS IN THE SOFTWARE.</p>
         | 
| 82 | 
            -
            </div></div>
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                  <div id="footer">
         | 
| 85 | 
            -
              Generated on Wed Dec 26 18:10:00 2018 by
         | 
| 86 | 
            -
              <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
         | 
| 87 | 
            -
              0.9.16 (ruby-2.3.3).
         | 
| 88 | 
            -
            </div>
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                </div>
         | 
| 91 | 
            -
              </body>
         | 
| 92 | 
            -
            </html>
         |