Class: Device::VirtualKeyboard
- Inherits:
-
Object
- Object
- Device::VirtualKeyboard
- Defined in:
- lib/device/virtual_keyboard.rb
Class Attribute Summary collapse
-
.attributes ⇒ Object
Returns the value of attribute attributes.
-
.text ⇒ Object
Returns the value of attribute text.
-
.type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .change_keyboard ⇒ Object
- .parse(line_x, line_y, params) ⇒ Object
- .show_text(key, params) ⇒ Object
- .text_not_ready?(key) ⇒ Boolean
- .type_text(params = {}) ⇒ Object
- .wifi_password ⇒ Object
Class Attribute Details
.attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/device/virtual_keyboard.rb', line 6 def attributes @attributes end |
.text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/device/virtual_keyboard.rb', line 6 def text @text end |
.type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/device/virtual_keyboard.rb', line 6 def type @type end |
Class Method Details
.change_keyboard ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/device/virtual_keyboard.rb', line 170 def self.change_keyboard if type.nil? self.type = :keyboard_capital Device::Display.print_bitmap('./shared/keyboard_capital.bmp') else Device::Display.print_bitmap("./shared/#{type}.bmp") end end |
.parse(line_x, line_y, params) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/device/virtual_keyboard.rb', line 142 def self.parse(line_x, line_y, params) key = attributes[type].find do |value| value[:x].include?(line_x) && value[:y].include?(line_y) end return if key.nil? Device::Audio.beep(7, 60) show_text(key, params) key[:char] end |
.show_text(key, params) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/device/virtual_keyboard.rb', line 154 def self.show_text(key, params) case key[:char] when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_capital self.type = key[:char] change_keyboard when :erase self.text += '' if text.nil? self.text = text[0..-2] when :space self.text += ' ' else self.text << key[:char] unless key[:char] == :enter end Device::Display.print_line("#{self.text}", params[:line], params[:column]) end |
.text_not_ready?(key) ⇒ Boolean
138 139 140 |
# File 'lib/device/virtual_keyboard.rb', line 138 def self.text_not_ready?(key) key != :enter && key != Device::IO::ENTER && key != Device::IO::CANCEL end |
.type_text(params = {}) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/device/virtual_keyboard.rb', line 116 def self.type_text(params = {}) change_keyboard Device::Display.print_line("#{self.text}", params[:line], params[:column]) time = Time.now + (params[:timeout] || Device::IO.timeout) / 1000 key = nil while text_not_ready?(key) line_x, line_y = getxy_stream(100) if line_x && line_y touch_clear key = parse(line_x, line_y, params) else break(Device::IO::KEY_TIMEOUT) if Time.now > time key = getc(100) end end [key, self.text] end |
.wifi_password ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/device/virtual_keyboard.rb', line 179 def self.wifi_password self.text = if Device::Setting.wifi_password == 'false' '' else Device::Setting.wifi_password end end |