class Object
Constants
- COMMAND_DELAY
Delay for commands.
- DEFAULT_BACKLIGHT
Default brightness for the screen.
- DEFAULT_CONTRAST
Default contrast for the screen.
- FLASH_REPORT
Flash reports for the device.
- FLASH_TYPE
Types for flash operations.
- HID_REPORT
HID reports for device.
- ID_SPLASH
Splash IDs.
- IN_REPORT
Reports received from the device.
- KEYBD_REPORT
Keyboard reports for the device.
- OUT_REPORT
Reports sent to the device.
- RESULT
Request results.
- SCREEN_H
Height of the screen in pixels.
- SCREEN_W
Width of the screen in pixels.
- STATUS
Status codes that may be returned from the device.
Public Class Methods
Gets the default bold font.
# File lib/models/font/silkscrb.rb, line 4 def self.bold @bold_font ||= BarkestLcd::Font.new( { :name => "Silkscreen", :size => 8, :bold => true, 32 => { :char => " ", :width => 6, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ], }, 48 => { :char => "0", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 49 => { :char => "1", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " ## ", " ## ", " ## ", " #### ", " ", " ", " ", ], }, 50 => { :char => "2", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ### ", " ## ", " ##### ", " ", " ", " ", ], }, 51 => { :char => "3", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ### ", " ## ", " #### ", " ", " ", " ", ], }, 52 => { :char => "4", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " #### ", " #### ", " ##### ", " ## ", " ", " ", " ", ], }, 53 => { :char => "5", :width => 8, :height => 10, :data => [ " ", " ", " ##### ", " ## ", " #### ", " ## ", " #### ", " ", " ", " ", ], }, 54 => { :char => "6", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ", " #### ", " ## ## ", " ### ", " ", " ", " ", ], }, 55 => { :char => "7", :width => 8, :height => 10, :data => [ " ", " ", " ##### ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 56 => { :char => "8", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ### ", " ## ## ", " ### ", " ", " ", " ", ], }, 57 => { :char => "9", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " #### ", " ## ", " ### ", " ", " ", " ", ], }, 97 => { :char => "a", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ##### ", " ## ## ", " ## ## ", " ", " ", " ", ], }, 98 => { :char => "b", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " #### ", " ## ## ", " #### ", " ", " ", " ", ], }, 99 => { :char => "c", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 100 => { :char => "d", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " ## ## ", " ## ## ", " #### ", " ", " ", " ", ], }, 101 => { :char => "e", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " #### ", " ## ", " #### ", " ", " ", " ", ], }, 102 => { :char => "f", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " #### ", " ## ", " ## ", " ", " ", " ", ], }, 103 => { :char => "g", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 104 => { :char => "h", :width => 8, :height => 10, :data => [ " ", " ", " ## ## ", " ## ## ", " ##### ", " ## ## ", " ## ## ", " ", " ", " ", ], }, 105 => { :char => "i", :width => 5, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 106 => { :char => "j", :width => 8, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 107 => { :char => "k", :width => 8, :height => 10, :data => [ " ", " ", " ## ## ", " #### ", " ### ", " #### ", " ## ## ", " ", " ", " ", ], }, 108 => { :char => "l", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " #### ", " ", " ", " ", ], }, 109 => { :char => "m", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ###### ", " ###### ", " ## ## ", " ## ## ", " ", " ", " ", ], }, 110 => { :char => "n", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ### ## ", " ###### ", " ## ### ", " ## ## ", " ", " ", " ", ], }, 111 => { :char => "o", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 112 => { :char => "p", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " #### ", " ## ", " ## ", " ", " ", " ", ], }, 113 => { :char => "q", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ## ", " ", " ", ], }, 114 => { :char => "r", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " #### ", " #### ", " ## ## ", " ", " ", " ", ], }, 115 => { :char => "s", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ### ", " ## ", " #### ", " ", " ", " ", ], }, 116 => { :char => "t", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 117 => { :char => "u", :width => 8, :height => 10, :data => [ " ", " ", " ## ## ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 118 => { :char => "v", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ## ## ", " #### ", " #### ", " ## ", " ", " ", " ", ], }, 119 => { :char => "w", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ###### ", " ###### ", " ###### ", " #### ", " ", " ", " ", ], }, 120 => { :char => "x", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " #### ", " ## ", " #### ", " ## ## ", " ", " ", " ", ], }, 121 => { :char => "y", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " #### ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 122 => { :char => "z", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ## ", " ## ", " #### ", " ", " ", " ", ], }, 65 => { :char => "A", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ##### ", " ## ## ", " ## ## ", " ", " ", " ", ], }, 66 => { :char => "B", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " #### ", " ## ## ", " #### ", " ", " ", " ", ], }, 67 => { :char => "C", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 68 => { :char => "D", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " ## ## ", " ## ## ", " #### ", " ", " ", " ", ], }, 69 => { :char => "E", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " #### ", " ## ", " #### ", " ", " ", " ", ], }, 70 => { :char => "F", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " #### ", " ## ", " ## ", " ", " ", " ", ], }, 71 => { :char => "G", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 72 => { :char => "H", :width => 8, :height => 10, :data => [ " ", " ", " ## ## ", " ## ## ", " ##### ", " ## ## ", " ## ## ", " ", " ", " ", ], }, 73 => { :char => "I", :width => 5, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 74 => { :char => "J", :width => 8, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 75 => { :char => "K", :width => 8, :height => 10, :data => [ " ", " ", " ## ## ", " #### ", " ### ", " #### ", " ## ## ", " ", " ", " ", ], }, 76 => { :char => "L", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " #### ", " ", " ", " ", ], }, 77 => { :char => "M", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ###### ", " ###### ", " ## ## ", " ## ## ", " ", " ", " ", ], }, 78 => { :char => "N", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ### ## ", " ###### ", " ## ### ", " ## ## ", " ", " ", " ", ], }, 79 => { :char => "O", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 80 => { :char => "P", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " #### ", " ## ", " ## ", " ", " ", " ", ], }, 81 => { :char => "Q", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ## ", " ", " ", ], }, 82 => { :char => "R", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ## ", " #### ", " #### ", " ## ## ", " ", " ", " ", ], }, 83 => { :char => "S", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ### ", " ## ", " #### ", " ", " ", " ", ], }, 84 => { :char => "T", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 85 => { :char => "U", :width => 8, :height => 10, :data => [ " ", " ", " ## ## ", " ## ## ", " ## ## ", " ## ## ", " ### ", " ", " ", " ", ], }, 86 => { :char => "V", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ## ## ", " #### ", " #### ", " ## ", " ", " ", " ", ], }, 87 => { :char => "W", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " ###### ", " ###### ", " ###### ", " #### ", " ", " ", " ", ], }, 88 => { :char => "X", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " #### ", " ## ", " #### ", " ## ## ", " ", " ", " ", ], }, 89 => { :char => "Y", :width => 9, :height => 10, :data => [ " ", " ", " ## ## ", " #### ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 90 => { :char => "Z", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ## ", " ## ", " #### ", " ", " ", " ", ], }, 40 => { :char => "(", :width => 6, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 41 => { :char => ")", :width => 6, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 123 => { :char => "{", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " ## ", " ## ", " ## ", " ### ", " ", " ", " ", ], }, 125 => { :char => "}", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " ## ", " ## ", " ## ", " ### ", " ", " ", " ", ], }, 91 => { :char => "[", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " ## ", " ## ", " ## ", " ### ", " ", " ", " ", ], }, 93 => { :char => "]", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " ## ", " ## ", " ## ", " ### ", " ", " ", " ", ], }, 60 => { :char => "<", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 62 => { :char => ">", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 96 => { :char => "`", :width => 6, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ", " ", " ", " ", " ", " ", ], }, 126 => { :char => "~", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " #### ", " ", " ", " ", " ", " ", " ", ], }, 33 => { :char => "!", :width => 5, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ", " ## ", " ", " ", " ", ], }, 64 => { :char => "@", :width => 9, :height => 10, :data => [ " ", " ", " #### ", " ###### ", " ##### ", " ## ", " #### ", " ", " ", " ", ], }, 35 => { :char => "#", :width => 9, :height => 10, :data => [ " ", " ", " #### ", " ###### ", " #### ", " ###### ", " #### ", " ", " ", " ", ], }, 36 => { :char => "$", :width => 8, :height => 10, :data => [ " ", " ## ", " #### ", " ## ", " ### ", " ## ", " ##### ", " ## ", " ", " ", ], }, 37 => { :char => "%", :width => 9, :height => 10, :data => [ " ", " ", " ##### ", " ##### ", " ## ", " ##### ", " ##### ", " ", " ", " ", ], }, 94 => { :char => "^", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " #### ", " ", " ", " ", " ", " ", " ", ], }, 38 => { :char => "&", :width => 8, :height => 10, :data => [ " ", " ## ", " #### ", " ## ", " ### ", " ## ", " #### ", " ## ", " ", " ", ], }, 42 => { :char => "*", :width => 9, :height => 10, :data => [ " ", " ", " ## ", " ###### ", " #### ", " ###### ", " ## ", " ", " ", " ", ], }, 45 => { :char => "-", :width => 7, :height => 10, :data => [ " ", " ", " ", " ", " #### ", " ", " ", " ", " ", " ", ], }, 95 => { :char => "_", :width => 8, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", " ", " ##### ", " ", " ", ], }, 61 => { :char => "=", :width => 7, :height => 10, :data => [ " ", " ", " ", " #### ", " ", " #### ", " ", " ", " ", " ", ], }, 43 => { :char => "+", :width => 9, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ###### ", " ## ", " ## ", " ", " ", " ", ], }, 92 => { :char => "\\", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 124 => { :char => "|", :width => 5, :height => 10, :data => [ " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", ], }, 59 => { :char => ";", :width => 5, :height => 10, :data => [ " ", " ", " ", " ## ", " ", " ## ", "## ", " ", " ", " ", ], }, 58 => { :char => ":", :width => 4, :height => 10, :data => [ " ", " ", " ", "## ", " ", "## ", " ", " ", " ", " ", ], }, 39 => { :char => "'", :width => 5, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ", " ", " ", " ", " ", " ", ], }, 34 => { :char => "\"", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " #### ", " ", " ", " ", " ", " ", " ", ], }, 44 => { :char => ",", :width => 5, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", " ## ", "## ", " ", " ", ], }, 46 => { :char => ".", :width => 4, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", "## ", " ", " ", " ", ], }, 47 => { :char => "/", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " ## ", " ## ", " ## ", " ## ", " ", " ", " ", ], }, 63 => { :char => "?", :width => 8, :height => 10, :data => [ " ", " ", " #### ", " ## ", " ### ", " ", " ## ", " ", " ", " ", ], }, }).freeze end
Gets the default regular font.
# File lib/models/font/silkscr.rb, line 4 def self.regular @regular_font ||= BarkestLcd::Font.new( { :name => "Silkscreen", :size => 8, :bold => false, 32 => { :char => " ", :width => 5, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ], }, 48 => { :char => "0", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # # ", " # # ", " ## ", " ", " ", " ", ], }, 49 => { :char => "1", :width => 6, :height => 10, :data => [ " ", " ", " ## ", " # ", " # ", " # ", " ### ", " ", " ", " ", ], }, 50 => { :char => "2", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " ## ", " # ", " #### ", " ", " ", " ", ], }, 51 => { :char => "3", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " ## ", " # ", " ### ", " ", " ", " ", ], }, 52 => { :char => "4", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # # ", " #### ", " # ", " ", " ", " ", ], }, 53 => { :char => "5", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " # ", " ### ", " # ", " ### ", " ", " ", " ", ], }, 54 => { :char => "6", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # ", " ### ", " # # ", " ## ", " ", " ", " ", ], }, 55 => { :char => "7", :width => 7, :height => 10, :data => [ " ", " ", " #### ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 56 => { :char => "8", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " ## ", " # # ", " ## ", " ", " ", " ", ], }, 57 => { :char => "9", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " ### ", " # ", " ## ", " ", " ", " ", ], }, 97 => { :char => "a", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " #### ", " # # ", " # # ", " ", " ", " ", ], }, 98 => { :char => "b", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " ### ", " # # ", " ### ", " ", " ", " ", ], }, 99 => { :char => "c", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # ", " # # ", " ## ", " ", " ", " ", ], }, 100 => { :char => "d", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " # # ", " # # ", " ### ", " ", " ", " ", ], }, 101 => { :char => "e", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " ### ", " # ", " ### ", " ", " ", " ", ], }, 102 => { :char => "f", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " ### ", " # ", " # ", " ", " ", " ", ], }, 103 => { :char => "g", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " # ## ", " # # ", " ## ", " ", " ", " ", ], }, 104 => { :char => "h", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " #### ", " # # ", " # # ", " ", " ", " ", ], }, 105 => { :char => "i", :width => 4, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 106 => { :char => "j", :width => 7, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # # ", " ## ", " ", " ", " ", ], }, 107 => { :char => "k", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " ## ", " # # ", " # # ", " ", " ", " ", ], }, 108 => { :char => "l", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " ### ", " ", " ", " ", ], }, 109 => { :char => "m", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " ## ## ", " # # # ", " # # ", " # # ", " ", " ", " ", ], }, 110 => { :char => "n", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " ## # ", " # # # ", " # ## ", " # # ", " ", " ", " ", ], }, 111 => { :char => "o", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # # ", " # # ", " ## ", " ", " ", " ", ], }, 112 => { :char => "p", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " ### ", " # ", " # ", " ", " ", " ", ], }, 113 => { :char => "q", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # # ", " # # ", " ## ", " # ", " ", " ", ], }, 114 => { :char => "r", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " ### ", " # # ", " # # ", " ", " ", " ", ], }, 115 => { :char => "s", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " ## ", " # ", " ### ", " ", " ", " ", ], }, 116 => { :char => "t", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 117 => { :char => "u", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # # ", " # # ", " ## ", " ", " ", " ", ], }, 118 => { :char => "v", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # # ", " # # ", " # ", " ", " ", " ", ], }, 119 => { :char => "w", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # # ", " # # # ", " # # # ", " # # ", " ", " ", " ", ], }, 120 => { :char => "x", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # ", " # # ", " # # ", " ", " ", " ", ], }, 121 => { :char => "y", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # ", " # ", " # ", " ", " ", " ", ], }, 122 => { :char => "z", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " # ", " # ", " ### ", " ", " ", " ", ], }, 65 => { :char => "A", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " #### ", " # # ", " # # ", " ", " ", " ", ], }, 66 => { :char => "B", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " ### ", " # # ", " ### ", " ", " ", " ", ], }, 67 => { :char => "C", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # ", " # # ", " ## ", " ", " ", " ", ], }, 68 => { :char => "D", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " # # ", " # # ", " ### ", " ", " ", " ", ], }, 69 => { :char => "E", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " ### ", " # ", " ### ", " ", " ", " ", ], }, 70 => { :char => "F", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " ### ", " # ", " # ", " ", " ", " ", ], }, 71 => { :char => "G", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " # ## ", " # # ", " ## ", " ", " ", " ", ], }, 72 => { :char => "H", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " #### ", " # # ", " # # ", " ", " ", " ", ], }, 73 => { :char => "I", :width => 4, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 74 => { :char => "J", :width => 7, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # # ", " ## ", " ", " ", " ", ], }, 75 => { :char => "K", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " ## ", " # # ", " # # ", " ", " ", " ", ], }, 76 => { :char => "L", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " ### ", " ", " ", " ", ], }, 77 => { :char => "M", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " ## ## ", " # # # ", " # # ", " # # ", " ", " ", " ", ], }, 78 => { :char => "N", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " ## # ", " # # # ", " # ## ", " # # ", " ", " ", " ", ], }, 79 => { :char => "O", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # # ", " # # ", " ## ", " ", " ", " ", ], }, 80 => { :char => "P", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " ### ", " # ", " # ", " ", " ", " ", ], }, 81 => { :char => "Q", :width => 7, :height => 10, :data => [ " ", " ", " ## ", " # # ", " # # ", " # # ", " ## ", " # ", " ", " ", ], }, 82 => { :char => "R", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # # ", " ### ", " # # ", " # # ", " ", " ", " ", ], }, 83 => { :char => "S", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " ## ", " # ", " ### ", " ", " ", " ", ], }, 84 => { :char => "T", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 85 => { :char => "U", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # # ", " # # ", " ## ", " ", " ", " ", ], }, 86 => { :char => "V", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # # ", " # # ", " # ", " ", " ", " ", ], }, 87 => { :char => "W", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # # ", " # # # ", " # # # ", " # # ", " ", " ", " ", ], }, 88 => { :char => "X", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # ", " # # ", " # # ", " ", " ", " ", ], }, 89 => { :char => "Y", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " # # ", " # ", " # ", " # ", " ", " ", " ", ], }, 90 => { :char => "Z", :width => 6, :height => 10, :data => [ " ", " ", " ### ", " # ", " # ", " # ", " ### ", " ", " ", " ", ], }, 40 => { :char => "(", :width => 5, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 41 => { :char => ")", :width => 5, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 123 => { :char => "{", :width => 6, :height => 10, :data => [ " ", " ", " ## ", " # ", " # ", " # ", " ## ", " ", " ", " ", ], }, 125 => { :char => "}", :width => 6, :height => 10, :data => [ " ", " ", " ## ", " # ", " # ", " # ", " ## ", " ", " ", " ", ], }, 91 => { :char => "[", :width => 5, :height => 10, :data => [ " ", " ", " ## ", " # ", " # ", " # ", " ## ", " ", " ", " ", ], }, 93 => { :char => "]", :width => 5, :height => 10, :data => [ " ", " ", " ## ", " # ", " # ", " # ", " ## ", " ", " ", " ", ], }, 60 => { :char => "<", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 62 => { :char => ">", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 96 => { :char => "`", :width => 5, :height => 10, :data => [ " ", " ", " # ", " # ", " ", " ", " ", " ", " ", " ", ], }, 126 => { :char => "~", :width => 7, :height => 10, :data => [ " ", " ", " # # ", " # # ", " ", " ", " ", " ", " ", " ", ], }, 33 => { :char => "!", :width => 4, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " ", " # ", " ", " ", " ", ], }, 64 => { :char => "@", :width => 8, :height => 10, :data => [ " ", " ", " ### ", " # # # ", " # ## ", " # ", " ### ", " ", " ", " ", ], }, 35 => { :char => "#", :width => 8, :height => 10, :data => [ " ", " ", " # # ", " ##### ", " # # ", " ##### ", " # # ", " ", " ", " ", ], }, 36 => { :char => "$", :width => 7, :height => 10, :data => [ " ", " # ", " ### ", " # ", " ## ", " # ", " #### ", " # ", " ", " ", ], }, 37 => { :char => "%", :width => 8, :height => 10, :data => [ " ", " ", " ## # ", " ## # ", " # ", " # ## ", " # ## ", " ", " ", " ", ], }, 94 => { :char => "^", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # # ", " ", " ", " ", " ", " ", " ", ], }, 38 => { :char => "&", :width => 7, :height => 10, :data => [ " ", " # ", " ### ", " # ", " ## ", " # ", " ### ", " # ", " ", " ", ], }, 42 => { :char => "*", :width => 8, :height => 10, :data => [ " ", " ", " # ", " # # # ", " ### ", " # # # ", " # ", " ", " ", " ", ], }, 45 => { :char => "-", :width => 6, :height => 10, :data => [ " ", " ", " ", " ", " ### ", " ", " ", " ", " ", " ", ], }, 95 => { :char => "_", :width => 7, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", " ", " #### ", " ", " ", ], }, 61 => { :char => "=", :width => 6, :height => 10, :data => [ " ", " ", " ", " ### ", " ", " ### ", " ", " ", " ", " ", ], }, 43 => { :char => "+", :width => 8, :height => 10, :data => [ " ", " ", " # ", " # ", " ##### ", " # ", " # ", " ", " ", " ", ], }, 92 => { :char => "\\", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 124 => { :char => "|", :width => 4, :height => 10, :data => [ " ", " # ", " # ", " # ", " # ", " # ", " # ", " # ", " ", " ", ], }, 59 => { :char => ";", :width => 4, :height => 10, :data => [ " ", " ", " ", " # ", " ", " # ", "# ", " ", " ", " ", ], }, 58 => { :char => ":", :width => 3, :height => 10, :data => [ " ", " ", " ", "# ", " ", "# ", " ", " ", " ", " ", ], }, 39 => { :char => "'", :width => 4, :height => 10, :data => [ " ", " ", " # ", " # ", " ", " ", " ", " ", " ", " ", ], }, 34 => { :char => "\"", :width => 6, :height => 10, :data => [ " ", " ", " # # ", " # # ", " ", " ", " ", " ", " ", " ", ], }, 44 => { :char => ",", :width => 4, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", " # ", "# ", " ", " ", ], }, 46 => { :char => ".", :width => 3, :height => 10, :data => [ " ", " ", " ", " ", " ", " ", "# ", " ", " ", " ", ], }, 47 => { :char => "/", :width => 6, :height => 10, :data => [ " ", " ", " # ", " # ", " # ", " # ", " # ", " ", " ", " ", ], }, 63 => { :char => "?", :width => 7, :height => 10, :data => [ " ", " ", " ### ", " # ", " ## ", " ", " # ", " ", " ", " ", ], }, }).freeze end
Public Instance Methods
Sets the backlight level.
# File lib/models/pico_lcd_graphic/display.rb, line 28 def backlight(level = 0xFF) level &= 0xFF write [ OUT_REPORT.LCD_BACKLIGHT, level ] self end
Sets the contrast level.
# File lib/models/pico_lcd_graphic/display.rb, line 37 def contrast(level = 0xFF) level &= 0xFF write [ OUT_REPORT.LCD_CONTRAST, level ] self end
# File lib/models/pico_lcd_graphic/flasher.rb, line 72 def flash_is_enabled?(type) if is_flasher? return (FLASH_TYPE.keys.include?(type) || FLASH_TYPE.values.include?(type)) end false end
# File lib/models/pico_lcd_graphic/flasher.rb, line 101 def get_flash_read_message(type) if is_flasher? return case type when :CODE_MEMORY, FLASH_TYPE.CODE_MEMORY FLASH_REPORT.READ_MEMORY when :CODE_SPLASH, FLASH_TYPE.CODE_SPLASH KEYBD_REPORT.READ_MEMORY when :EPROM_EXTERNAL, FLASH_TYPE.EPROM_EXTERNAL OUT_REPORT.EXT_EE_READ when :EPROM_INTERNAL, FLASH_TYPE.EPROM_INTERNAL OUT_REPORT.INT_EE_READ else 0 end end 0 end
# File lib/models/pico_lcd_graphic/flasher.rb, line 79 def get_flash_write_message(type) if is_flasher? return case type when :CODE_MEMORY, FLASH_TYPE.CODE_MEMORY FLASH_REPORT.WRITE_MEMORY when :CODE_SPLASH, FLASH_TYPE.CODE_SPLASH KEYBD_REPORT.WRITE_MEMORY when :EPROM_EXTERNAL, FLASH_TYPE.EPROM_EXTERNAL OUT_REPORT.EXT_EE_WRITE when :EPROM_INTERNAL, FLASH_TYPE.EPROM_INTERNAL OUT_REPORT.INT_EE_WRITE else 0 end end 0 end
# File lib/models/pico_lcd_graphic/display.rb, line 86 def init_display(_) init_graphic SCREEN_W, SCREEN_H loop_hook { |_| paint } reset_hook do |_| clear.paint contrast DEFAULT_CONTRAST backlight DEFAULT_BACKLIGHT end end
# File lib/models/pico_lcd_graphic/flasher.rb, line 45 def init_flasher(_) @mode = :keyboard input_hook(HID_REPORT.EXIT_FLASHER) do |_,_,data| data = data.getbyte(0) if data == 0 @mode = :keyboard HIDAPI.debug 'switch to KEYBOARD mode' else @mode = :unknown log_error data, 'HID_REPORT.EXIT_FLASHER failed' end end input_hook(HID_REPORT.EXIT_KEYBOARD) do |_,_,data| data = data.getbyte(0) if data == 0 @mode = :flasher HIDAPI.debug 'switched to FLASHER mode' else @mode = :unknown log_error data, 'HID_REPORT.EXIT_KEYBOARD failed' end end end
# File lib/models/pico_lcd_graphic/ir.rb, line 17 def init_ir(_) @on_ir_data = nil input_hook IN_REPORT.IR_DATA do |_, _, data| process_ir_data data end end
# File lib/models/pico_lcd_graphic/key.rb, line 41 def init_key(_) @keys = [] @on_key_up = @on_key_down = nil # Hook the keyboard and IR data events. input_hook IN_REPORT.KEY_STATE do |_, _, data| if data.length < 2 log_error 2, 'not enough data for IN_REPORT.KEY_STATE' else process_key_state data end end end
# File lib/models/pico_lcd_graphic/splash.rb, line 22 def init_splash(_) @splash_size = nil @splash_max_size = nil input_hook(HID_REPORT.GET_MAX_STX_SIZE) do |_,_,data| if data.length < 4 @splash_size = 0 @splash_max_size = 0 log_error 2, 'not enough data for HID_REPORT.GET_MAX_STX_SIZE' else @splash_max_size = ((data.getbyte(1) << 8) & 0xFF00) | (data.getbyte(0) & 0xFF) @splash_size = ((data.getbyte(3) << 8) & 0xFF00) | (data.getbyte(2) & 0xFF) HIDAPI.debug "splash size=#{@splash_size}, max=#{@splash_max_size}" end end end
# File lib/models/pico_lcd_graphic/version.rb, line 32 def init_version(_) @version = nil input_hook(HID_REPORT.GET_VERSION_1) do |_,type,data| process_version(type, data) end end
Is the device currently functioning as a flasher?
# File lib/models/pico_lcd_graphic/flasher.rb, line 19 def is_flasher? (mode == :flasher) end
Gets the state of a specific key.
# File lib/models/pico_lcd_graphic/key.rb, line 30 def key_state(key) return false unless key return false if key <= 0 return false if @keys.length <= key @keys[key] end
Sets the code to run when IR data is received.
Yields the bytes received as a string.
# File lib/models/pico_lcd_graphic/ir.rb, line 9 def on_ir_data(&block) raise ArgumentError, 'Missing block.' unless block_given? @on_ir_data = block self end
Sets the code to run when a key is pressed down.
Yields the key number as a single byte.
# File lib/models/pico_lcd_graphic/key.rb, line 10 def on_key_down(&block) raise ArgumentError, 'Missing block.' unless block_given? @on_key_down = block self end
Sets the code to run when a key is released.
Yields the key number as a single byte.
# File lib/models/pico_lcd_graphic/key.rb, line 21 def on_key_up(&block) raise ArgumentError, 'Missing block.' unless block_given? @on_key_up = block self end
Sends the screen contents to the device.
# File lib/models/pico_lcd_graphic/display.rb, line 46 def paint(force = false) if dirty? || force # 4 chips each holding 64x64 of data. (0..3).each do |csi| cs = (csi << 2) # each memory line holds 64 bytes, or 8 rows of data. (0..7).each do |line| # use dirty rectangles to avoid sending unnecessary data to the device. if force || dirty_rect?(csi * 64, line * 8, 64, 8) # send the data in two packets for each memory line. packet_1 = [ OUT_REPORT.CMD_DATA, cs, 0x02, 0x00, 0x00, 0xb8 | line, 0x00, 0x00, 0x40, 0x00, 0x00, 32 ] packet_2 = [ OUT_REPORT.DATA, cs | 0x01, 0x00, 0x00, 32 ] (0..63).each do |index| # each byte holds the data for 8 rows. byte = 0x00 (0..7).each do |bit| x = (csi * 64) + index y = ((line * 8) + bit) % height byte |= (1 << bit) if get_bit(x, y) end # add the byte to the correct packet. (index < 32 ? packet_1 : packet_2) << byte end # send the packets. write packet_1 write packet_2 end end end clear_dirty end self end
# File lib/models/pico_lcd_graphic/ir.rb, line 24 def process_ir_data(data) HIDAPI.debug "IR data: #{data.inspect}" if @on_ir_data @on_ir_data.call(data) end end
# File lib/models/pico_lcd_graphic/key.rb, line 56 def process_key_state(data) key1 = data.length >= 1 ? (data.getbyte(0) & 0xFF) : 0 key2 = data.length >= 2 ? (data.getbyte(1) & 0xFF) : 0 # make sure the array is big enough to represent the largest reported key. max = (key1 < key2 ? key2 : key1) + 1 if @keys.length < max @keys += [nil] * (max - @keys.length) end HIDAPI.debug "Pressed keys: #{key1} #{key2}" # go through the array and process changes. @keys.each_with_index do |state,index| unless index == 0 if state && key1 != index && key2 != index # key was pressed but is not one of the currently pressed keys. if @on_key_up @on_key_up.call(index) end @keys[index] = false end if key1 == index || key2 == index unless state # key was not pressed before but is one of the currently pressed keys. if @on_key_down @on_key_down.call(index) end @keys[index] = true end end end end end
# File lib/models/pico_lcd_graphic/version.rb, line 21 def process_version(type, data) if data.length < 2 log_error 2, "not enough data for HID_REPORT.#{HID_REPORT.key(type)}" @version[0] = 0 @version[1] = 0 else @version[0] = data.getbyte(1) @version[1] = data.getbyte(0) end end
Gets the size for the splash storage.
# File lib/models/pico_lcd_graphic/splash.rb, line 7 def splash_size(refresh = false) @splash_size = nil if refresh if @splash_size.nil? write [ HID_REPORT.GET_MAX_STX_SIZE ] loop_while { @splash_size.nil? } end { size: @splash_size, max: @splash_max_size } end
Switch between keyboard and flasher mode.
# File lib/models/pico_lcd_graphic/flasher.rb, line 26 def switch_mode next_mode = (mode == :keyboard) ? :flasher : :keyboard mode = :switching if next_mode == :flasher write [ HID_REPORT.EXIT_KEYBOARD, timeout & 0xFF, (timeout >> 8) & 0xFF ] else write [ HID_REPORT.EXIT_FLASHER, timeout & 0xFF, (timeout >> 8) & 0xFF ] end loop_while { mode == :switching } self end
Gets the version of this device.
# File lib/models/pico_lcd_graphic/version.rb, line 7 def version(refresh = false) @version = nil if refresh unless @version @version = [] write [ HID_REPORT.GET_VERSION_1 ] loop_while { @version.empty? } end @version end