Class: PiLite::Commands
- Inherits:
-
Object
- Object
- PiLite::Commands
- Defined in:
- lib/pilite.rb
Constant Summary collapse
- @@pilite =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#all(action) ⇒ Object
turn on/off all LEDs.
-
#bar(column, value) ⇒ Object
draw a bar at given column with provided value (this command does not overwrite the screen).
-
#char(column, row, char) ⇒ Object
print a character at given column/row.
-
#fbuffer(bits) ⇒ Object
print framebuffer.
-
#pixel(column, row, action) ⇒ Object
do an action on a pixel at given column/row.
-
#scroll(offset) ⇒ Object
scroll to left or right with given offset.
-
#speed(value) ⇒ Object
change scroll speed.
-
#text(str) ⇒ Object
print text (will be scrolled automatically).
-
#vumeter(row, value) ⇒ Object
draw VU meter.
Class Method Details
.start(port = "/dev/ttyAMA0", params = {baudrate: 9600}, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# 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 |
Instance Method Details
#all(action) ⇒ Object
turn on/off all LEDs
76 77 78 |
# File 'lib/pilite.rb', line 76 def all(action) command "ALL,#{action.to_s.upcase}" end |
#bar(column, value) ⇒ Object
draw a bar at given column with provided value (this command does not overwrite the screen)
55 56 57 |
# File 'lib/pilite.rb', line 55 def (column, value) command "B#{column},#{value}" end |
#char(column, row, char) ⇒ Object
print a character at given column/row
90 91 92 |
# File 'lib/pilite.rb', line 90 def char(column, row, char) command "T#{column},#{row},#{char}" end |
#fbuffer(bits) ⇒ Object
print framebuffer
47 48 49 50 |
# File 'lib/pilite.rb', line 47 def fbuffer(bits) bits = bits.join if bits.kind_of? Array command "F#{bits}" end |
#pixel(column, row, action) ⇒ Object
do an action on a pixel at given column/row
70 71 72 |
# File 'lib/pilite.rb', line 70 def pixel(column, row, action) command "P#{column},#{row},#{action.to_s.upcase}" end |
#scroll(offset) ⇒ Object
scroll to left or right with given offset
82 83 84 |
# File 'lib/pilite.rb', line 82 def scroll(offset) command "SCROLL#{offset}" end |
#speed(value) ⇒ Object
change scroll speed
41 42 43 |
# File 'lib/pilite.rb', line 41 def speed(value) command "SPEED#{value}" end |
#text(str) ⇒ Object
print text (will be scrolled automatically)
96 97 98 |
# File 'lib/pilite.rb', line 96 def text(str) @serial.write("#{str}\r") end |
#vumeter(row, value) ⇒ Object
draw VU meter
62 63 64 |
# File 'lib/pilite.rb', line 62 def vumeter(row, value) command "V#{row},#{value}" end |