object_oriented_beaglebone_black 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbe6449f8addf886e091badbb93261750b4dc6ba
4
- data.tar.gz: 49cb896622d085d91b89cf18a22332da3fe06726
3
+ metadata.gz: 4b12eebdcfd145dcf383e623349d7f844241b2ad
4
+ data.tar.gz: 52b1e565447eda98535b8e03a7a8363d8d2a8d10
5
5
  SHA512:
6
- metadata.gz: dd858cf1e1c4af95a24f06c7ed2f2d86f281b849c551357ec4a468d3cdbc9bb4e415f3e972bfc59dcada5071fc4b7b16ee67c578ce92d8e175720b7facff5621
7
- data.tar.gz: 7f89fe31bfc36a89a8aeac9729fee670954a94393054f1235967bb1bda8b7db55e89de515b21c3f35d08832126d3a6100bd95e581b7696fd4c528576156f0969
6
+ metadata.gz: 673e08d66213879c0b2350598309a087161363dd0796e2ee08600d76dbbbcad768ce0bebb2e8a10910c0dab16486e047065de07195639ec3efa8b958cf99c4aa
7
+ data.tar.gz: 567ad8f836785de958d232f041440d3df89f40ababaae1b6c30032dcb4d0578e4da57efef0769baeca6096ffbd438b428eaff609035f6bd41f06b81c5204eddc
data/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ ## object_oriented_beaglebone_black 0.0.2 (December 26, 2014) ##
2
+
3
+ * GPIO
4
+
5
+ * Analog input
6
+
7
+ * PWM
8
+
9
+ ## object_oriented_beaglebone_black 0.1.0 ##
10
+
11
+ There is no 0.1.0. I simply made a mistake to change the version to 0.2.0, after changing the version to 0.1.1 in one commit.
12
+
13
+ ## object_oriented_beaglebone_black 0.2.0 (September 26, 2015) ##
14
+
15
+ * PWM period can be set and read.
16
+
17
+ ## object_oriented_beaglebone_black 0.2.1 (September 27, 2015) ##
18
+
19
+ * When the PWM period is set, the internal "duty" value is modified automatically to keep the same duty cycle.
20
+
21
+ Internally in BeagleBone Black, "duty" value is relative to "period" value.
22
+
23
+ e.g. For "period" = 1000, "duty" = 500 gives the duty cycle = 500 / 1000 = 0.5.
24
+
25
+ In version 0.2.0, when "period" is modified, "duty" is not modified. Hence, the duty cycle changes.
26
+
27
+ e.g. For the example above,
28
+ When "period" is modified to be 10000, the duty cycle has changed to 500 / 10000 = 0.05.
29
+
30
+ In version 0.2.1, when "period" is modified, "duty" is modified accordingly, in order to keep the same duty cycle.
31
+
32
+ e.g. For the example above,
33
+ When "period" is modified to be 10000, "duty" is modified to be 5000, which gives the duty cycle 5000 / 10000 = 0.5.
34
+
35
+ Note: This can be considered to be incompatible API change. However, at this point, it is not yet considered to be a stable public API. Hence, the MAJOR version is kept to be 0. (See, [Semantic Versioning](http://semver.org/))
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ObjectOrientedBeagleboneBlack
2
2
 
3
- This is for using Beaglebone Black in Object-Oriented way through Ruby code.
3
+ This is for using BeagleBone Black in Object-Oriented way through Ruby code.
4
4
 
5
5
  There are many Ruby projects in GitHub to do a similar thing.
6
6
  But I have decided to develop my own from scratch this time instead of using an existing one like I always do.
@@ -50,63 +50,72 @@ Or install it yourself as:
50
50
 
51
51
  ## Usage
52
52
 
53
- 1. GPIO.
53
+ 1. GPIO
54
54
 
55
55
  Example:
56
56
 
57
- require 'object_oriented_beaglebone_black'
57
+ ```ruby
58
+ require 'object_oriented_beaglebone_black'
58
59
 
59
- led_gpio_pin_number = 60
60
- button_gpio_pin_number = 15
60
+ led_gpio_pin_number = 60
61
+ button_gpio_pin_number = 15
61
62
 
62
- led_gpio = ObjectOrientedBeagleboneBlack::Gpio.new(led_gpio_pin_number)
63
+ led_gpio = ObjectOrientedBeagleboneBlack::Gpio.new(led_gpio_pin_number)
63
64
 
64
- led_gpio.export
65
+ led_gpio.export
65
66
 
66
- led_gpio.direction = ObjectOrientedBeagleboneBlack::IO::Direction::OUT
67
+ led_gpio.direction = ObjectOrientedBeagleboneBlack::IO::Direction::OUT
67
68
 
68
- led_gpio.value = ObjectOrientedBeagleboneBlack::IO::Value::HIGH
69
+ led_gpio.value = ObjectOrientedBeagleboneBlack::IO::Value::HIGH
69
70
 
70
- led_gpio.value # Read the value. HIGH (1) as set above.
71
+ led_gpio.value # Read the value. HIGH (1) as set above.
71
72
 
72
- led_gpio.value = ObjectOrientedBeagleboneBlack::IO::Value::LOW
73
+ led_gpio.value = ObjectOrientedBeagleboneBlack::IO::Value::LOW
73
74
 
74
- led_gpio.value # Read the value. LOW (0) as set above.
75
+ led_gpio.value # Read the value. LOW (0) as set above.
75
76
 
76
- led_gpio.unexport
77
+ led_gpio.unexport
78
+ ```
77
79
 
78
80
  2. Analog input
81
+
79
82
  Example:
80
83
 
81
- require 'object_oriented_beaglebone_black'
84
+ ```ruby
85
+ require 'object_oriented_beaglebone_black'
82
86
 
83
- pin_key = "P9_40"
87
+ pin_key = "P9_40"
84
88
 
85
- analog_input = ObjectOrientedBeagleboneBlack::AnalogInput.new(pin_key)
89
+ analog_input = ObjectOrientedBeagleboneBlack::AnalogInput.new(pin_key)
86
90
 
87
- analog_input.raw_value # Read the raw voltage value in the range of 0 and 1.8[V].
91
+ analog_input.raw_value # Read the raw voltage value in the range of 0 and 1.8[V].
88
92
 
89
- analog_input.value # Read the relative value between 0 and 1.
93
+ analog_input.value # Read the relative value between 0 and 1.
94
+ ```
90
95
 
91
96
  3. PWM
92
97
 
93
98
  Example:
99
+
100
+ ```ruby
101
+ require 'object_oriented_beaglebone_black'
94
102
 
95
- require 'object_oriented_beaglebone_black'
96
-
97
- pwm_pin_key = "P9_14"
103
+ pwm_pin_key = "P9_14"
98
104
 
99
- pwm = ObjectOrientedBeagleboneBlack::Pwm.new(pwm_pin_key)
105
+ pwm = ObjectOrientedBeagleboneBlack::Pwm.new(pwm_pin_key)
100
106
 
101
- pwm.duty_cycle = 0.5
107
+ pwm.period = 1000 # Unit is [ns] (nano second)
102
108
 
103
- pwm.polarity # Read the polarity. The default is direct (ObjectOrientedBeagleboneBlack::Pwm::Polarity::DIRECT)
109
+ pwm.period # Read the period. 1000[ns] as set above.
104
110
 
105
- pwm.duty_cycle # Read the duty cycle. 0.5 as set above.
111
+ pwm.duty_cycle = 0.5
106
112
 
107
- pwm.period = 1000 # Unit is [ns] (nano second)
113
+ pwm.polarity # Read the polarity.
114
+ # The default is direct:
115
+ # ObjectOrientedBeagleboneBlack::Pwm::Polarity::DIRECT
108
116
 
109
- pwm.period # Read the period. 1000[ns] as set above.
117
+ pwm.duty_cycle # Read the duty cycle. 0.5 as set above.
118
+ ```
110
119
 
111
120
  ## Contributing
112
121
 
@@ -56,7 +56,14 @@ module ObjectOrientedBeagleboneBlack
56
56
  end
57
57
 
58
58
  def period=(period)
59
+ current_duty_cycle = self.duty_cycle
60
+
59
61
  File.open(File.join(pwm_directory, "period"), "w") { |file| file.write(period) }
62
+
63
+ # Preserves the duty cycle:
64
+ # Note: Internally in BeagleBone Black, "duty" value is relative to "period" value.
65
+ # e.g. For "period" = 1000, "duty" = 500 gives the duty cycle = 500 / 1000 = 0.5.
66
+ self.duty_cycle = current_duty_cycle
60
67
  end
61
68
 
62
69
  # Unit: [ns] (nano second)
@@ -1,3 +1,3 @@
1
1
  module ObjectOrientedBeagleboneBlack
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -68,9 +68,15 @@ describe ObjectOrientedBeagleboneBlack::Pwm, pwm: true do
68
68
 
69
69
  expect(Dir.exists?(File.join(@device_directory, "pwm_test_#{pwm_pin_key}.15"))).to be true
70
70
 
71
+ # Set the duty cycle before period is modified:
72
+ pwm.duty_cycle = 0.5
73
+ expect(pwm.duty_cycle).to eq(0.5)
74
+
71
75
  pwm.period = 10000 # [ns]: nano second
72
76
 
73
77
  expect(pwm.period).to eq(10000)
78
+ # The duty cycle should be preserved:
79
+ expect(pwm.duty_cycle).to eq(0.5)
74
80
 
75
81
  end
76
82
 
@@ -90,10 +96,10 @@ describe ObjectOrientedBeagleboneBlack::Pwm, pwm: true do
90
96
 
91
97
  expect(pwm.period).to eq(1000)
92
98
 
93
- pwm.duty_cycle = 0.5
99
+ pwm.duty_cycle = 0.25
94
100
 
95
101
  expect(pwm.polarity).to eq(ObjectOrientedBeagleboneBlack::Pwm::Polarity::DIRECT)
96
- expect(pwm.duty_cycle).to eq(0.5)
102
+ expect(pwm.duty_cycle).to eq(0.25)
97
103
 
98
104
  end
99
105
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_oriented_beaglebone_black
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadatoshi Takahashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-26 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - ".gitignore"
64
64
  - ".ruby-gemset"
65
65
  - ".ruby-version"
66
+ - CHANGELOG.md
66
67
  - Gemfile
67
68
  - LICENSE.txt
68
69
  - README.md