BBB 0.1.1 → 0.1.2
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.
- data/.travis.yml +1 -2
- data/examples/servo_ldr.rb +34 -0
- data/lib/BBB/components/pinnable.rb +1 -0
- data/lib/BBB/components/servo.rb +6 -3
- data/lib/BBB/version.rb +1 -1
- metadata +5 -4
    
        data/.travis.yml
    CHANGED
    
    
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            require 'BBB'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Circuit < BBB::Circuit
         | 
| 4 | 
            +
              include BBB::Components
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def initialize
         | 
| 7 | 
            +
                attach Servo, pins: :P8_13, as: :servo
         | 
| 8 | 
            +
                attach AnalogComponent, pin: :P9_40, as: :ldr
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            class LDRServo < BBB::Application
         | 
| 13 | 
            +
              attr_accessor :min, :max
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              circuit Circuit.new
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def initialize(min, max)
         | 
| 18 | 
            +
                @min = min
         | 
| 19 | 
            +
                @max = max
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def run
         | 
| 23 | 
            +
                servo.angle(angle)
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def range
         | 
| 27 | 
            +
                max - min
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def angle
         | 
| 31 | 
            +
                (ldr.value - min) / range.to_f * 180
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            end
         | 
    
        data/lib/BBB/components/servo.rb
    CHANGED
    
    | @@ -14,12 +14,15 @@ module BBB | |
| 14 14 | 
             
                  def after_pin_initialization
         | 
| 15 15 | 
             
                    pin.period = 17e6
         | 
| 16 16 | 
             
                    pin.duty   = (min_duty + duty_range / 2)
         | 
| 17 | 
            -
                    pin.run    =  | 
| 17 | 
            +
                    pin.run    = 1
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 |  | 
| 20 20 | 
             
                  def angle(degrees)
         | 
| 21 | 
            -
                     | 
| 22 | 
            -
             | 
| 21 | 
            +
                    pin.duty = degrees_to_ns(degrees)
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def degrees_to_ns(degrees)
         | 
| 25 | 
            +
                    degrees / 180.to_f * duty_range + min_duty
         | 
| 23 26 | 
             
                  end
         | 
| 24 27 |  | 
| 25 28 | 
             
                  def activate!
         | 
    
        data/lib/BBB/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: BBB
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013-12- | 
| 12 | 
            +
            date: 2013-12-30 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: json
         | 
| @@ -91,6 +91,7 @@ files: | |
| 91 91 | 
             
            - examples/analog_pin.rb
         | 
| 92 92 | 
             
            - examples/led.rb
         | 
| 93 93 | 
             
            - examples/light_switch.rb
         | 
| 94 | 
            +
            - examples/servo_ldr.rb
         | 
| 94 95 | 
             
            - examples/sketches.rb
         | 
| 95 96 | 
             
            - lib/BBB.rb
         | 
| 96 97 | 
             
            - lib/BBB/application.rb
         | 
| @@ -142,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 142 143 | 
             
                  version: '0'
         | 
| 143 144 | 
             
                  segments:
         | 
| 144 145 | 
             
                  - 0
         | 
| 145 | 
            -
                  hash: - | 
| 146 | 
            +
                  hash: -4269646228377431993
         | 
| 146 147 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 147 148 | 
             
              none: false
         | 
| 148 149 | 
             
              requirements:
         | 
| @@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 151 152 | 
             
                  version: '0'
         | 
| 152 153 | 
             
                  segments:
         | 
| 153 154 | 
             
                  - 0
         | 
| 154 | 
            -
                  hash: - | 
| 155 | 
            +
                  hash: -4269646228377431993
         | 
| 155 156 | 
             
            requirements: []
         | 
| 156 157 | 
             
            rubyforge_project: 
         | 
| 157 158 | 
             
            rubygems_version: 1.8.25
         |