chip-gpio 0.0.5 → 0.0.6

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chip-gpio/SoftSpi.rb +8 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f70b8ed01708787a7cf556b02960218fb06e669
4
- data.tar.gz: a3b78c5c8e4969b5e9da2249c94fd8d8d18a19c3
3
+ metadata.gz: d947a58cc0720824366acfc1489e499e0df866f3
4
+ data.tar.gz: aa47ac588ab2ac5f9621e9919df0c4bca17033c4
5
5
  SHA512:
6
- metadata.gz: b287f8c9de23ba1fc5ea28f3368832608fce72978e8240310036cadc655e8a88d8a83fe99b7a00efd3739413b18ed50d5193d60f25e0a7398e3020cf9dcd6e7a
7
- data.tar.gz: 60dd01362b593661f35ab6bd6e9d021e5a87e8dfe44f0398fafeb47ff3ca71e297d285b9f48221e240ef85a5491183e4c4a62922152a3711c9dc675fdf061d3b
6
+ metadata.gz: 7298e2dcedd3e0bd35ac87eed2fe62f0dec97439682232b5bc4d5b11c98bf57f387e0bc3e17751c30285e26ea9c2ecdff353b8cdd72b1d67520e90a3b4adfa31
7
+ data.tar.gz: 512e252e8dc169bffa8522d1aaf17f4986e32a364534c7324367399e67f9f9319e5831d8f95c0edfec0caa38232c2c9a544328c011954eb5fa876390fb75c948
@@ -27,8 +27,9 @@ module ChipGPIO
27
27
  attr_reader :polarity
28
28
  attr_reader :phase
29
29
  attr_reader :word_size
30
+ attr_reader :lsb_first
30
31
 
31
- def initialize(clock_pin: nil, input_pin: nil, output_pin: nil, polarity: 1, phase: 0, word_size: 8)
32
+ def initialize(clock_pin: nil, input_pin: nil, output_pin: nil, polarity: 1, phase: 0, word_size: 8, lsb_first: false)
32
33
  raise ArgumentError, "clock_pin is required" if clock_pin == nil
33
34
  raise ArgumentError, "At least input_pin or output_pin must be specified" if ((input_pin == nil) && (output_pin == nil))
34
35
 
@@ -60,21 +61,21 @@ module ChipGPIO
60
61
  @polarity = polarity
61
62
  @phase = phase
62
63
  @word_size = word_size
64
+ @lsb_first = lsb_first
63
65
  end
64
66
 
65
67
  def max_word
66
68
  ((2**@word_size) - 1)
67
69
  end
68
70
 
69
- def write(words: [], reverse_output: true)
71
+ def write(words: [])
70
72
  raise "An output_pin must be specified to write" if !@output_pin
71
73
 
74
+ #you can't make reverse ranges so this logic is gross
75
+ #the key point is that 0 is the MSB so we only want it first if
76
+ #@lsb_first is set
72
77
  bits = Array (0..(@word_size - 1))
73
-
74
- if reverse_output
75
- words = words.reverse()
76
- bits = bits.reverse()
77
- end
78
+ bits = bits.reverse() if !@lsb_first
78
79
 
79
80
  words.each do |w|
80
81
  w = 0 if w < 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chip-gpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A ruby gem to control the IO hardware the CHIP computer
14
14
  email: james@jameswilliams.me