Module: NabaztagHackKit::Message::Helper
- Extended by:
- Helper
- Includes:
- Api
- Included in:
- Helper
- Defined in:
- lib/nabaztag_hack_kit/message/helper.rb
Constant Summary
Constants included from Api
Api::B, Api::EAR_L, Api::EAR_LL, Api::EAR_LR, Api::EAR_R, Api::ERROR, Api::F, Api::INIT, Api::LED_0, Api::LED_1, Api::LED_2, Api::LED_3, Api::LED_4, Api::LED_L0, Api::LED_L1, Api::LED_L2, Api::LED_L3, Api::LED_L4, Api::LOG, Api::OK, Api::PLAY_LOAD, Api::PLAY_START, Api::PLAY_STOP, Api::PLAY_STREAM, Api::REBOOT, Api::REC_START, Api::REC_STOP
Instance Method Summary collapse
-
#bl(loops = 1, color_on = 0xFF, color_off = 0x00) ⇒ Object
blink.
- #circle(times = 15) ⇒ Object
- #fire(color = 0x110000, led1 = LED_L1, led2 = LED_L2, led3 = LED_L3) ⇒ Object
-
#kr(color = 0xFF, led1 = LED_L1, led2 = LED_L2, led3 = LED_L3) ⇒ Object
knight rider.
-
#rp(loops, pattern = 0) ⇒ Object
(also: #sl)
repeat.
- #stop ⇒ Object
- #wink(s = 1, e = 4, times = 3) ⇒ Object
Instance Method Details
#bl(loops = 1, color_on = 0xFF, color_off = 0x00) ⇒ Object
blink
10 11 12 |
# File 'lib/nabaztag_hack_kit/message/helper.rb', line 10 def bl(loops = 1, color_on = 0xFF, color_off = 0x00) repeat(loops, [color_on, color_off]) end |
#circle(times = 15) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/nabaztag_hack_kit/message/helper.rb', line 50 def circle(times = 15) { LED_0 => [r, 0, 0, 0] * times, LED_1 => [0, r, 0, 0] * times, LED_4 => [0, 0, r, 0] * times, LED_3 => [0, 0, 0, r] * times } end |
#fire(color = 0x110000, led1 = LED_L1, led2 = LED_L2, led3 = LED_L3) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nabaztag_hack_kit/message/helper.rb', line 29 def fire(color = 0x110000, led1 = LED_L1, led2 = LED_L2, led3 = LED_L3) data = Array.new(16) do |i| Message.to_3b(i * color) end + Array.new(8) do |i| Message.to_3b((15 - i) * 2 * color) end { (led1 + 10) => data + [0, 0, 0] + [0, 0, 0], (led2 + 10) => [0, 0, 0] + data + [0, 0, 0], (led3 + 10) => [0, 0, 0] + [0, 0, 0] + data } end |
#kr(color = 0xFF, led1 = LED_L1, led2 = LED_L2, led3 = LED_L3) ⇒ Object
knight rider
21 22 23 24 25 26 27 |
# File 'lib/nabaztag_hack_kit/message/helper.rb', line 21 def kr(color = 0xFF, led1 = LED_L1, led2 = LED_L2, led3 = LED_L3) { led1 => [color, 0, 0, 0], led2 => [0, color], led3 => [0, 0, color, 0] } end |
#rp(loops, pattern = 0) ⇒ Object Also known as: sl
repeat
15 16 17 |
# File 'lib/nabaztag_hack_kit/message/helper.rb', line 15 def rp(loops, pattern = 0) Array.new(loops, pattern).flatten end |
#stop ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/nabaztag_hack_kit/message/helper.rb', line 59 def stop { LED_0 => 0, LED_1 => 0, LED_2 => 0, LED_3 => 0, LED_4 => 0, LED_L0 => 0, LED_L1 => 0, LED_L2 => 0, LED_L3 => 0, LED_L4 => 0, EAR_L => 0, EAR_R => 0, EAR_LL => 0, EAR_LR => 0 } end |