class BarkestLcd::PicoLcdGraphic

A class to interface with the picoLCD 256x64 (aka picoLCD Graphic) from [www.mini-box.com](http://www.mini-box.com).

Constants

AlreadyOpen

The device has already been opened.

DEVICE_ID

USB Device ID

NotOpen

The device is not currently open.

OpenFailed

The device failed to open (no address returned).

PicoLcdError

Any of the Pico LCD errors.

Timeout

The operation has timed out.

VENDOR_ID

USB Vendor ID

Public Class Methods

devices(refresh = false) click to toggle source

Enumerates the picoLCD devices attached to the system.

# File lib/models/pico_lcd_graphic.rb, line 45
def self.devices(refresh = false)
  @devices = nil if refresh
  @devices ||= HIDAPI.enumerate(VENDOR_ID, DEVICE_ID, as: 'BarkestLcd::PicoLcdGraphic')
end

Public Instance Methods

loop() click to toggle source

Processes any waiting input from the device and paints the screen if it is dirty.

# File lib/models/pico_lcd_graphic.rb, line 68
def loop
  data = read
  if data && data.length > 0

    type = data.getbyte(0)
    data = data[1..-1]

    input_hook(type).call(self, type, data)

  end

  loop_hook.each { |hook| hook.call(self) }

  self
end
reset() click to toggle source

Resets the device.

# File lib/models/pico_lcd_graphic.rb, line 52
def reset
  write [ OUT_REPORT.LCD_RESET, 0x01, 0x00 ]

  (0...4).each do |csi|
    cs = (csi << 2) & 0xFF
    write [ OUT_REPORT.CMD, cs, 0x02, 0x00, 0x64, 0x3F, 0x00, 0x64, 0xC0 ]
  end

  reset_hook.each { |hook| hook.call(self) }

  self
end