littlewire 0.9.5 → 0.9.7

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: b02ec3c25311d8cf29a0e34fbf14a9e12f7c1d7a
4
- data.tar.gz: 139849c4608ae5ddc03e79c01b830ff9e0ec720d
3
+ metadata.gz: 672e15656164047ad4895db0099cea33b13bb861
4
+ data.tar.gz: 79ecc40349391da72aa766b11c7f2ec667a565ae
5
5
  SHA512:
6
- metadata.gz: 843864b20dc637f517247ba49982a8c5fafd28c019cd8e4c63c0eb411c145f611b4a00bac21b890cfffa247d6fdeb207ad510173fc369b66531f78250ff372e6
7
- data.tar.gz: 72a4af2222770d54a155caf7a07ac27fbb64b48c7d84534f2e34105f6c238ed87f54b446bf0a925e1afeb44506f794c6d2559297f8adeed862cd828785bde1f9
6
+ metadata.gz: 7959de400ac104e7671353af22aa9207d1d74a71ecee220ec2629bc87b08956a745eb5d8d29a01e1501fb906fb69440e8e53726854bf5ff156d28355973bc70b
7
+ data.tar.gz: f1e7674e363807d7d8e1af74d0504a9f0d5740c31ff04d5be17ec73814a5e2a0d65b4a9cb5886ecf279f1fda5a29eba74057300965086391d9897ecf1dac31bf
@@ -0,0 +1,7 @@
1
+ # Read the state of a button connecting between pin 0 and ground on a digispark
2
+ require '../lib/littlewire'
3
+ wire = LittleWire.connect
4
+
5
+ wire.pin_mode ds1: :input
6
+ wire.digital_write ds1: true
7
+ puts "Pin 1 is " + wire.digital_read(:ds1).inspect
@@ -15,7 +15,7 @@ module LittleWire::Analog
15
15
  end
16
16
 
17
17
  control_transfer(function: :read_adc,
18
- wValue: get_pin(AnalogPinMap, input_name),
18
+ wValue: get_pin(LittleWire::AnalogPinMap, input_name),
19
19
  dataIn: 2).unpack('S<').first / 1024.0
20
20
  end
21
21
 
@@ -65,7 +65,7 @@ module LittleWire::Digital
65
65
  port = control_transfer(function: :read, dataIn: 1).unpack('c').first
66
66
  mapped = pins.map do |pin|
67
67
  pin = get_pin(LittleWire::DigitalPinMap, pin)
68
- (port & pin) != 0 # discover if pin is high or low
68
+ ((port >> pin) & 1) == 1 # discover if pin is high or low
69
69
  end
70
70
 
71
71
  if args.length == 1 and (args.first.is_a?(Symbol) or args.first.is_a?(Integer))
@@ -31,8 +31,8 @@ class LittleWire
31
31
  pin3: 5, d3: 5, reset: 5, ds5: 5,
32
32
  pin4: 0, d4: 0, mosi: 0, pwm_a: 0, pwm_1: 0, ds0: 0 }
33
33
  AnalogPinMap = { # maps common names to switch index in littlewire firmware
34
- a1: 0, adc_1: 0, reset: 0, pin3: 0, d3: 0,
35
- a2: 1, adc_2: 1, sck: 1, pin2: 1, d2: 1,
34
+ a1: 0, adc_1: 0, reset: 0, pin3: 0, d3: 0, ds5: 0,
35
+ a2: 1, adc_2: 1, sck: 1, pin2: 1, d2: 1, ds2: 1,
36
36
  temperature: 2, temp: 2 }
37
37
  HardwarePWMPinMap = { # maps common pin names to @hardware_pwm array index
38
38
  pwm_b: 1, pwm_1: 1, d1: 1, pin1: 1, miso: 1,
@@ -164,6 +164,7 @@ class LittleWire
164
164
  raise "You need to update your LittleWire firmware to version 1.2 to use One Wire" unless version_hex >= 0x12
165
165
  @ws2811 ||= Array.new
166
166
  pin = get_pin(LittleWire::DigitalPinMap, pin || 0)
167
+ raise "Unknown pin #{pin.inspect}" unless pin.is_a? Integer
167
168
  @ws2811[pin] ||= WS2811.new(self, pin)
168
169
  return @ws2811[pin]
169
170
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: littlewire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bluebie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libusb
@@ -61,6 +61,7 @@ files:
61
61
  - readme.md
62
62
  - license.txt
63
63
  - examples/blinky.rb
64
+ - examples/digiread.rb
64
65
  - examples/fadey.rb
65
66
  - examples/led pixel.rb
66
67
  homepage: http://creativepony.com/littlewire/
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  version: '0'
85
86
  requirements: []
86
87
  rubyforge_project:
87
- rubygems_version: 2.0.0
88
+ rubygems_version: 2.0.3
88
89
  signing_key:
89
90
  specification_version: 4
90
91
  summary: A tiny library for littlewire.cc usb devices