Sha256: cbed7577c5cd4a1608eb7e6d0de8dbe8031912ff3897209e2e625e6247df8019
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'l8' require 'sdl' SDL.init(SDL::INIT_JOYSTICK) @joystick = SDL::Joystick.open(0) @x = 0 @y = 0 @l8 = L8::Row.new('/dev/tty.usbmodem1a1211', '/dev/tty.usbmodem1a1221') @l8.clear_matrix @l8.disable_status_leds # @l8.set_brightness(:low) # @l8.set_superled(0,0,0) @l8.set_led(@x,@y, 15, 15, 15) @l8.identify @colors = [ [14,0,0], [0,14,0], [0,0,14], [14,14,14], [0,0,0] ] @color_index = 0 while(true) do SDL::Joystick.update_all break if @joystick.button(9) sleep 0.1 end def read_joystick SDL::Joystick.update_all @color_index = @color_index + 1 if @joystick.button(1) @color_index = @color_index - 1 if @joystick.button(2) @color_index = 0 if @color_index > 4 @color_index = 4 if @color_index < 0 color = @colors[@color_index] @l8.set_led(@y,@x, color[0], color[1], color[2]) # @l8.set_superled(color[0], color[1], color[2]) if @joystick.button(8) @x = @x - 1 if @joystick.axis(3) < -16384 @x = @x + 1 if @joystick.axis(3) > 16384 @y = @y - 1 if @joystick.axis(4) < -16384 @y = @y + 1 if @joystick.axis(4) > 16384 @x = 0 if @x < 0 @y = 0 if @y < 0 @x = 15 if @x > 15 @y = 7 if @y > 7 @l8.set_led(@y,@x, color[0] + 1, color[1] + 1, color[2] + 1) @l8.clear_matrix if @joystick.button(9) sleep 0.2 end read_joystick while(true)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
l8-0.0.3 | examples/nes_draw.rb |