class PiLite::Commands
Public Class Methods
# File lib/pilite.rb, line 21 def initialize(port, params) @serial = SerialPort.new(port, params) end
# File lib/pilite.rb, line 29 def self.start(port = "/dev/ttyAMA0", params = {baudrate: 9600}, &block) @@pilite = PiLite::Commands.new(port, params) unless @@pilite if block_given? yield @@pilite else return @@pilite end end
Public Instance Methods
turn on/off all LEDs @param action [Symbol] :on / :off
# File lib/pilite.rb, line 76 def all(action) command "ALL,#{action.to_s.upcase}" end
draw a bar at given column with provided value (this command does not overwrite the screen) @param column [Number] column number (1 ~ 14) @param value [Number] percentage (0 ~ 100)
# File lib/pilite.rb, line 55 def bar(column, value) command "B#{column},#{value}" end
print a character at given column/row @param column [Number] column number (1 ~ 14) @param row [Number] row number (1 ~ 9) @param char [String] character
# File lib/pilite.rb, line 90 def char(column, row, char) command "T#{column},#{row},#{char}" end
print framebuffer @param bits [String/Array] array of 0/1s for each LED’s state (0:off, 1:on, 14 x 9 total)
# File lib/pilite.rb, line 47 def fbuffer(bits) bits = bits.join if bits.kind_of? Array command "F#{bits}" end
do an action on a pixel at given column/row @param column [Number] column number (1 ~ 14) @param row [Number] row number (1 ~ 9) @param action [Symbol] :on / :off / :toggle
# File lib/pilite.rb, line 70 def pixel(column, row, action) command "P#{column},#{row},#{action.to_s.upcase}" end
scroll to left or right with given offset @param offset [Number] -1 ~ -14: shift to right / 1 ~ 14: shift to left
# File lib/pilite.rb, line 82 def scroll(offset) command "SCROLL#{offset}" end
change scroll speed @param value [Number] scrolling delay from 1ms to 1000ms (default: 80)
# File lib/pilite.rb, line 41 def speed(value) command "SPEED#{value}" end
print text (will be scrolled automatically) @param str [String] text
# File lib/pilite.rb, line 96 def text(str) @serial.write("#{str}\r") end
draw VU meter @param row [Number] row number (1 ~ 2) @param value [Number] percentage (0 ~ 100)
# File lib/pilite.rb, line 62 def vumeter(row, value) command "V#{row},#{value}" end
Private Instance Methods
# File lib/pilite.rb, line 24 def command(cmd) @serial.write("$$$#{cmd}\r") end