littlewire 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,11 +4,13 @@ require 'colorist'
4
4
  # To use, simply set colours in the 'colors' array property as css color strings
5
5
  # or Colorist::Color objects, then call #output(pin) to send it on it's way
6
6
  #
7
- # Note that this requires firmware v1.2 which is not yet released and there is a
8
- # maximum of 64 lights in the firmware at the time of writing
9
- #
10
- # Also note that you can connect 64 leds to each of the digital pins on the LittleWire
11
- # or Digispark device, and this enables you a total of 64 * 4 = 256 lights! Neato!
7
+ # Note that this requires firmware v1.2 and there is a maximum of 64 lights in the
8
+ # firmware at the time of writing. You can connect 64 leds to each of the digital
9
+ # pins on the LittleWire or Digispark device, and this enables you a total of
10
+ # 64 * 4 = 256 lights! Neato! Remember a USB port cannot supply enough current to
11
+ # power 256 lights at full brightness. Power usage is roughly (20ma * color_channel)
12
+ # per light. So 64 lights all lit full brightness white consumes 20*3*64 = 3.84 amps!
13
+ # Wow that's a lot of light for one little wire! And you can have four of those!
12
14
  class LittleWire::WS2811
13
15
  attr_accessor :colors
14
16
  attr_accessor :pin
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.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bluebie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-05 00:00:00.000000000 Z
11
+ date: 2013-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libusb
@@ -42,30 +42,54 @@ description: A little library for a little wire. Providing a pure ruby interface
42
42
  the nonpure libusb gem) to littlewire.cc's wonderful gadget. littlewire.rb provides
43
43
  general purpose digital IO, pulse width modulation analog outputs, analog inputs,
44
44
  SPI, I2C, One Wire, and rough servo control via a friendly interface which responds
45
- both to familliar Wiring/Arduino style methods and a more concise ruby alternative.
45
+ both to familiar Wiring/Arduino style methods and a more concise ruby alternative.
46
+ LittleWire can be installed on to Digisparkdevices, offering a very extensive firmata-style
47
+ option for digispark users.
46
48
  email: a@creativepony.com
47
- executables: []
49
+ executables:
50
+ - littlewire.rb
48
51
  extensions: []
49
52
  extra_rdoc_files: []
50
53
  files:
51
- - lib/analog.rb
52
- - lib/digital.rb
53
- - lib/hardware-pwm.rb
54
- - lib/i2c.rb
54
+ - lib/littlewire/analog.rb
55
+ - lib/littlewire/digital.rb
56
+ - lib/littlewire/gadgets/micronucleus.rb
57
+ - lib/littlewire/gadgets/nunchuck.rb
58
+ - lib/littlewire/hardware-pwm.rb
59
+ - lib/littlewire/i2c.rb
60
+ - lib/littlewire/one-wire.rb
61
+ - lib/littlewire/servo.rb
62
+ - lib/littlewire/software-pwm.rb
63
+ - lib/littlewire/spi.rb
64
+ - lib/littlewire/version.rb
65
+ - lib/littlewire/ws2811.rb
55
66
  - lib/littlewire.rb
56
- - lib/one-wire.rb
57
- - lib/servo.rb
58
- - lib/software-pwm.rb
59
- - lib/spi.rb
60
- - lib/ws2811.rb
61
67
  - readme.md
62
68
  - license.txt
63
69
  - examples/blinky.rb
64
70
  - examples/digiread.rb
65
71
  - examples/fadey.rb
66
- - examples/led pixel.rb
72
+ - examples/i2c/microchip-eeprom.rb
73
+ - examples/i2c/nunchuck.rb
74
+ - examples/i2c/search.rb
75
+ - examples/ws2811/all.rb
76
+ - examples/ws2811/colors.rb
77
+ - examples/ws2811/manual.rb
78
+ - examples/ws2811/scan.rb
79
+ - examples/ws2811/spin.rb
80
+ - examples/ws2811/strobe.rb
81
+ - bin/littlewire.rb
82
+ - firmware/1.0.hex
83
+ - firmware/1.1.hex
84
+ - firmware/1.2.hex
85
+ - firmware/cdc232.hex
86
+ - firmware/latest-beta.hex
87
+ - firmware/latest.hex
67
88
  homepage: http://creativepony.com/littlewire/
68
- licenses: []
89
+ licenses:
90
+ - CC0
91
+ - Unlicense
92
+ - Public Domain
69
93
  metadata: {}
70
94
  post_install_message:
71
95
  rdoc_options:
@@ -77,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
101
  requirements:
78
102
  - - '>='
79
103
  - !ruby/object:Gem::Version
80
- version: '0'
104
+ version: 1.9.1
81
105
  required_rubygems_version: !ruby/object:Gem::Requirement
82
106
  requirements:
83
107
  - - '>='
@@ -1,55 +0,0 @@
1
- # Connects to an LPD6803 LED Pixel of the type sold by ladyada, bliptronics, and alibaba
2
- # and sends rgb info to the pixel. While these lights have worse colour reproduction than
3
- # the PWM in Little Wire, they're chainable so you can run hundreds off one Little Wire!
4
- #
5
- # This sort: http://bliptronics.com/item.aspx?ItemID=113
6
- #
7
- # Note if you're running more than five or so from a littlewire you should power them
8
- # with an external power supply instead of Little Wire's VCC pin
9
- require 'littlewire'
10
-
11
- wire = LittleWire.connect
12
- spi = wire.spi
13
-
14
- wire.pin_mode :pin1 => :output, :pin3 => :output
15
-
16
- def lpd6803_data red, green, blue
17
- # TODO: could add some dithering here
18
- bits = [green, blue, red].map { |v| (v * 31).round.to_s(2).rjust(5, '0') }
19
- "1#{bits.join ''}".to_i(2)
20
- end
21
-
22
- $lights = [[1.0, 0.0, 1.0]] # just one light, with red, green, blue set to bright violet
23
- def update_lights
24
- new_sequence = $lights.map { |pix| lpd6803_data(*pix) }
25
- new_sequence.unshift 0, 0 # add start frame
26
- $data_sequence = new_sequence
27
- end
28
-
29
- update_lights
30
-
31
- spi.delay = 10
32
-
33
- $x = 0.0
34
-
35
- require 'benchmark'
36
- Benchmark.benchmark do
37
- for i in 1..1000000
38
- wire.digital_write pin1: true
39
- end
40
- end
41
- # loop do
42
- # $data_sequence.each_slice(2) do |cells|
43
- # spi.send cells.pack('S>*')
44
- # end
45
- #
46
- # $lights = [[0.0, $x % 1.0, 0.0]]
47
- # $x += 1.0/32.0
48
- # update_lights
49
- #
50
- # # and now we use software pwm to run the light's clock for a little while
51
- # wire.software_pwm_write(pin2: 127)
52
- # sleep (1.0/32.0)
53
- # wire.software_pwm_enabled = false
54
- # end
55
-
data/lib/i2c.rb DELETED
@@ -1,43 +0,0 @@
1
- class LittleWire::I2C
2
- def initialize wire
3
- @wire = wire
4
- @wire.control_transfer(function: :i2c_init)
5
- end
6
-
7
- # start an i2c message
8
- #
9
- # Arguments:
10
- # address: (Integer) 7 bit numeric address
11
- # direction: (Symbol) :in or :out
12
- def start address_7bit, direction
13
- direction = 1 if direction == :out || direction == :output || direction == :write
14
- direction = 0 if direction != 1
15
- config = (address_7bit.to_i << 1) | direction
16
- @wire.control_transfer(function: :i2c_begin, wValue: config)
17
- @wire.control_transfer(function: :read_buffer, dataIn: 8).bytes.first != 0
18
- end
19
-
20
- # read bytes from i2c device, optionally ending with a stop when finished
21
- def read length, endWithStop = false
22
- @wire.control_transfer(function: :i2c_read, wValue: (length.to_i & 0xFF) << 8 | (endWithStop ? 1 : 0))
23
- @wire.control_transfer(function: :read_buffer, dataIn: 8)[0...length.to_i]
24
- end
25
-
26
- # write data to i2c device, optionally sending a stop when finished
27
- def write send_buffer, end_with_stop = false
28
- send_buffer = send_buffer.pack('c*') if send_buffer.is_a? Array
29
- raise "Send buffer is too long" if send_buffer.length > 7
30
-
31
- # TODO: Send multiple requests to handle send buffers longer than 7 bytes
32
- @wire.control_transfer(
33
- wRequest: 0xE0 | send_buffer.length | (end_with_stop << 3),
34
- wValue: (send_buffer.bytes[1] << 8) + send_buffer.bytes[0],
35
- wIndex: (send_buffer.bytes[3] << 8) + send_buffer.bytes[2]
36
- )
37
- end
38
-
39
- # set the update delay of LittleWire's i2c module
40
- def delay= update_delay
41
- @wire.control_transfer(function: :i2c_update_delay, wValue: update_delay.to_i)
42
- end
43
- end