charlcd 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cbc4292fd38b43c45cfb88b22055fc74d64de5a
4
- data.tar.gz: f13e769873d974d025b28ec509a53a49a1218910
3
+ metadata.gz: 04885cd953df473da58df165ed186e73830d7e55
4
+ data.tar.gz: 27b15fc4b1d30231fb766f4cde6d01b5257a71cb
5
5
  SHA512:
6
- metadata.gz: 9441545dfbc039f090819b2223ed93863e709104877c2d0e5cbca9ba460719fb1f0ec38223f7307bb677d21840a0053359cb6c4f8f3e6a6bce63d450f2e11f44
7
- data.tar.gz: a1a0fc7cc7dda2db692981094045a9c7ee723c97cac5d5f29f53306b7cf9e9a70626104321068f6b1242ecbad552185d59029e3908e5daea98f43e8c9470113c
6
+ metadata.gz: 0743fa470e8b91e8c48b4a50207873fee8952abeed78fc7114bc5c43b24c6039538e4960fbdebd3fb4d3a6039aa30497d367316c9bdae9682d82f3e9aff99fbc
7
+ data.tar.gz: 102a4e85836417d721ebcc5118681e330eea60df3fdf54f7e362e374412a1124fa17c765e159de8a07d3d8471391667c1a9cfd5631a06f1a314c5f6dd76daccc
data/README.md CHANGED
@@ -18,6 +18,7 @@ require 'charlcd'
18
18
  char_lcd = CharLcd.new
19
19
  char_lcd.begin(16, 2)
20
20
  char_lcd.message("First Line\nSecond Line")
21
+ char_lcd.clean_pins()
21
22
  ```
22
23
 
23
24
  License
@@ -1,4 +1,4 @@
1
- require 'charLcd'
1
+ require 'charlcd'
2
2
 
3
3
  SLEEP_TIME = 0.005
4
4
  COLUMNS = 16
data/lib/charlcd.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'pi_piper'
1
+ require 'rpi_gpio'
2
2
 
3
3
  # code based on:
4
4
  # https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/master/Adafruit_CharLCD/Adafruit_CharLCD.py
@@ -43,11 +43,19 @@ class CharLcd
43
43
  LCD_5x8DOTS = 0x00
44
44
 
45
45
  def initialize(pin_rs = 25, pin_e = 24, pins_db = [23, 17, 27, 22])
46
- @pin_rs = PiPiper::Pin.new(:pin => pin_rs, :direction => :out)
47
- @pin_e = PiPiper::Pin.new(:pin => pin_e, :direction => :out)
46
+ RPi::GPIO.set_numbering :bcm
47
+
48
+ RPi::GPIO.setup pin_rs, :as => :output
49
+ RPi::GPIO.setup pin_e, :as => :output
50
+
51
+ @pin_rs = pin_rs
52
+ @pin_e = pin_e
48
53
  @pins_db = []
49
54
 
50
- pins_db.each { |pin_db| @pins_db.push(PiPiper::Pin.new(:pin => pin_db, :direction => :out)) }
55
+ pins_db.each { |pin_db|
56
+ @pins_db.push(pin_db)
57
+ RPi::GPIO.setup pin_db, :as => :output
58
+ }
51
59
 
52
60
  write_4_bits(0x33) # initialization
53
61
  write_4_bits(0x32) # initialization
@@ -165,25 +173,29 @@ class CharLcd
165
173
 
166
174
  bits = bits.to_s(2).rjust(8, "0")
167
175
 
168
- @pin_rs.update_value(char_mode)
176
+ if char_mode
177
+ RPi::GPIO.set_high @pin_rs
178
+ else
179
+ RPi::GPIO.set_low @pin_rs
180
+ end
169
181
 
170
- @pins_db.each { |pin_db| pin_db.off }
171
- (0..3).each { |i| @pins_db.reverse[i].on if bits[i].eql?("1") }
182
+ @pins_db.each { |pin_db| RPi::GPIO.set_low pin_db }
183
+ (0..3).each { |i| RPi::GPIO.set_high @pins_db.reverse[i] if bits[i].eql?("1") }
172
184
 
173
185
  pulse_enable
174
186
 
175
- @pins_db.each { |pin_db| pin_db.off }
176
- (4..7).each { |i| @pins_db.reverse[i - 4].on if bits[i].eql?("1") }
187
+ @pins_db.each { |pin_db| RPi::GPIO.set_low pin_db }
188
+ (4..7).each { |i| RPi::GPIO.set_high @pins_db.reverse[i - 4] if bits[i].eql?("1") }
177
189
 
178
190
  pulse_enable
179
191
  end
180
192
 
181
193
  def pulse_enable
182
- @pin_e.off
194
+ RPi::GPIO.set_low @pin_e
183
195
  delay_microseconds(1)
184
- @pin_e.on
196
+ RPi::GPIO.set_high @pin_e
185
197
  delay_microseconds(1)
186
- @pin_e.off
198
+ RPi::GPIO.set_low @pin_e
187
199
  end
188
200
 
189
201
  def delay_microseconds(microseconds)
@@ -191,4 +203,7 @@ class CharLcd
191
203
  sleep(seconds)
192
204
  end
193
205
 
206
+ def clean_pins
207
+ RPi::GPIO.clean_up
208
+ end
194
209
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charlcd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Fussuma
@@ -29,17 +29,17 @@ require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - '>='
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 2.2.2
42
+ rubygems_version: 2.4.6
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Lcd display raspberrypi library!