wiimote_sps 0.2.0 → 0.3.0

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: 09dcf0f07cd4c5f897ce97a605e00ac2feaae6b8
4
- data.tar.gz: b89732f36ae450570914b99509745858bee3523d
3
+ metadata.gz: 129410ef8990a7b8c5339a5eb63d7456289e28db
4
+ data.tar.gz: 62d9427cc0a91cba4418ab5f84f381027cd3d015
5
5
  SHA512:
6
- metadata.gz: e191d3cc1163a5965ef9c115285d6a3deceb8c5d0a0c74c342df25e06e026f8b52a7a84ec25b8b40c7ebe4384ee53d9b4608d7c740df5e5dd12e129456997227
7
- data.tar.gz: 40e39c9ff17d1f640d5029ea84b89a64ece51a2fbe1273f5309a9c34b53ca9d825f3e5665b86d1db5602edad49b229d5af1f100c920d50f245a945b4cd3011ad
6
+ metadata.gz: 675a1b1bd619048d304dafcc5a7dae9f8adfe18d3702ec2036c07f46432d4a524a20a16d8967167178d7d8371a1db3ea689eabbac00b6b36237adcc3baefbbfb
7
+ data.tar.gz: 14ff2ccd01b9ee905666ab97ed8ebd65fa02afb1dda87bda5b389bcd48acb208d2a876d5cd56a3ef32dfa85413ed56c8127eebd58ddeea7379ed579c11d27bad
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/wiimote_sps.rb CHANGED
@@ -38,16 +38,42 @@ class WiimoteSps < SimpleWiimote
38
38
  when /rumble$/
39
39
 
40
40
  case msg
41
- when /^buzz/
42
- self.rumble = true
43
- sleep 0.3
44
- self.rumble = false
41
+ when /^(buzz|vibrate|rumble|duration)/
42
+
43
+ r = msg.match(/duration\s([\d\.]+)/)
44
+
45
+ duration = r ? r.captures.first.to_f : 0.3
46
+
47
+ self.rumble = true; sleep duration; self.rumble = false
48
+
45
49
  end
46
50
 
47
51
  when /led$/
48
- case msg
49
- when /(\d+)\s+(on|off)/
50
- self.led = ($2) == 'on' ? 1 : 0
52
+
53
+ r = msg.match(/(\d+)\s*(on|off|blink|stop)\s*([\d\.]+)?(?:\s*duration\s)?([\d\.]+)?/)
54
+
55
+ if r then
56
+ index, state, seconds, raw_duration = r.captures
57
+ duration = raw_duration ? raw_duration.to_f : nil
58
+
59
+ a = case state
60
+
61
+ when 'on'
62
+ [:on, duration]
63
+
64
+ when 'off'
65
+ [:off]
66
+
67
+ when 'blink'
68
+ seconds = seconds ? seconds.to_f : 0.5
69
+ [:blink, seconds, duration: duration]
70
+
71
+ when 'stop'
72
+ [:off]
73
+
74
+ end
75
+
76
+ @led[index.to_i].send(*a)
51
77
  end
52
78
  end
53
79
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiimote_sps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file