da_funk 3.30.0 → 3.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -1
  3. data/Gemfile.lock +12 -2
  4. data/README.md +0 -0
  5. data/README_GUIDE.md +0 -0
  6. data/RELEASE_NOTES.md +27 -0
  7. data/Rakefile +14 -0
  8. data/guides/sample_input_output.rb +0 -0
  9. data/guides/sample_message_iso8583.rb +0 -0
  10. data/guides/sample_network_gprs.rb +0 -0
  11. data/guides/sample_read_magnect_card.rb +0 -0
  12. data/guides/sample_socket.rb +0 -0
  13. data/guides/sample_transaction.rb +0 -0
  14. data/guides/sample_transaction_download_application.rb +0 -0
  15. data/guides/sample_transaction_download_file.rb +0 -0
  16. data/guides/sample_transaction_download_parameter_file.rb +0 -0
  17. data/lib/da_funk/connection_management.rb +25 -10
  18. data/lib/da_funk/event_handler.rb +1 -1
  19. data/lib/da_funk/helper.rb +55 -16
  20. data/lib/da_funk/helper/status_bar.rb +158 -105
  21. data/lib/da_funk/params_dat.rb +65 -25
  22. data/lib/da_funk/rake_task.rb +13 -6
  23. data/lib/da_funk/transaction/download.rb +0 -0
  24. data/lib/da_funk/transaction/iso.rb +0 -0
  25. data/lib/da_funk/version.rb +1 -1
  26. data/lib/device.rb +0 -0
  27. data/lib/device/crypto.rb +0 -0
  28. data/lib/device/display.rb +2 -1
  29. data/lib/device/io.rb +53 -0
  30. data/lib/device/network.rb +19 -33
  31. data/lib/device/printer.rb +0 -0
  32. data/lib/device/setting.rb +0 -0
  33. data/lib/device/system.rb +9 -0
  34. data/lib/device/version.rb +0 -0
  35. data/lib/device/virtual_keyboard.rb +81 -34
  36. data/lib/file_db.rb +0 -0
  37. data/lib/iso8583/bitmap.rb +94 -54
  38. data/lib/iso8583/codec.rb +3 -3
  39. data/lib/iso8583/field.rb +38 -3
  40. data/lib/iso8583/fields.rb +3 -1
  41. data/lib/iso8583/message.rb +25 -12
  42. data/lib/iso8583/util.rb +1 -1
  43. data/test/iso8583/bitmap_test.rb +277 -0
  44. data/test/iso8583/message_test.rb +111 -0
  45. data/test/iso8583/minitest_helper.rb +11 -0
  46. metadata +12 -6
@@ -1,6 +1,10 @@
1
1
  module DaFunk
2
2
  class ParamsDat
3
- FILE_NAME = "./main/params.dat"
3
+ FILE_NAME = "./main/params.dat"
4
+ SEARCHING_IMAGE_PATH = './shared/searching_updates_app.bmp'
5
+ UPDATING_IMAGE_PATH = './shared/updating.bmp'
6
+ ATTACH_IMAGE_PATH = './shared/network_conectar_init.bmp'
7
+ CONNECTION_ERROR_IMAGE_PATH = './shared/network_system_error.bmp'
4
8
 
5
9
  include DaFunk::Helper
6
10
 
@@ -117,31 +121,40 @@ module DaFunk
117
121
  end
118
122
 
119
123
  def self.download(enable_txt_ui = true)
124
+ ret = false
125
+ download_ret = false
126
+ Device::Display.print_bitmap(ATTACH_IMAGE_PATH) unless enable_txt_ui
120
127
  if attach(attach_options(enable_txt_ui))
121
128
  parse
122
- ret = try(3) do |attempt|
129
+ try(3) do |attempt|
123
130
  if enable_txt_ui
124
131
  Device::Display.clear
125
132
  I18n.pt(:downloading_content, :args => ["PARAMS", 1, 1])
133
+ getc(100)
126
134
  end
127
- getc(100)
128
- ret = DaFunk::Transaction::Download.request_param_file(FILE_NAME)
129
- unless check_download_error(ret, enable_txt_ui)
130
- getc(2000)
131
- false
132
- else
133
- true
134
- end
135
+ Device::Display.print_bitmap(SEARCHING_IMAGE_PATH) unless enable_txt_ui
136
+ download_ret = DaFunk::Transaction::Download.request_param_file(FILE_NAME)
137
+ ret = check_download_error(download_ret, enable_txt_ui)
135
138
  end
139
+ show_download_error(download_ret, enable_txt_ui) unless ret
136
140
  parse if ret
137
- ret
141
+ else
142
+ unless enable_txt_ui
143
+ Device::Display.print_bitmap(CONNECTION_ERROR_IMAGE_PATH)
144
+ getc(5000)
145
+ end
138
146
  end
147
+ ret
139
148
  end
140
149
 
141
150
  def self.update_apps(force_params = false, force_crc = false, force = false, enable_txt_ui = true)
142
- self.download(enable_txt_ui) if force_params || ! self.valid
151
+ ret = true
152
+ if force_params || ! self.valid
153
+ ret = self.download(enable_txt_ui)
154
+ end
155
+
143
156
  main_updated = nil
144
- if self.valid
157
+ if self.valid && ret
145
158
  apps_to_update = self.outdated_apps(force_crc, force)
146
159
  size_apps = apps_to_update.size
147
160
  apps_to_update.each_with_index do |app, index|
@@ -149,12 +162,15 @@ module DaFunk
149
162
  main_updated ||= (ret && app.main_application?)
150
163
  end
151
164
 
152
- files_to_update = self.outdated_files(force_crc, force)
153
- size_files = files_to_update.size
154
- files_to_update.each_with_index do |file_, index|
155
- self.update_file(file_, index+1, size_files, force_crc || force, enable_txt_ui)
165
+ if ret
166
+ files_to_update = self.outdated_files(force_crc, force)
167
+ size_files = files_to_update.size
168
+ files_to_update.each_with_index do |file_, index|
169
+ ret = self.update_file(file_, index+1, size_files, force_crc || force, enable_txt_ui)
170
+ end
156
171
  end
157
172
  end
173
+ ret
158
174
  ensure
159
175
  self.restart if main_updated
160
176
  end
@@ -199,34 +215,58 @@ module DaFunk
199
215
  end
200
216
 
201
217
  def self.update_app(application, index = 1, all = 1, force = false, enable_txt_ui = true)
218
+ ret = false
219
+ download_ret = false
220
+ Device::Display.print_bitmap(ATTACH_IMAGE_PATH) unless enable_txt_ui
202
221
  if attach(attach_options(enable_txt_ui)) && application
203
222
  try(3) do |attempt|
204
223
  if enable_txt_ui
205
224
  Device::Display.clear
206
225
  I18n.pt(:downloading_content, :args => [I18n.t(:apps), index, all])
226
+ getc(100)
207
227
  end
208
- getc(100)
209
- ret = check_download_error(application.download(force), enable_txt_ui)
210
- getc(1000)
211
- ret
228
+ Device::Display.print_bitmap(UPDATING_IMAGE_PATH) unless enable_txt_ui
229
+ download_ret = application.download(force)
230
+ ret = check_download_error(download_ret, enable_txt_ui)
231
+ end
232
+ show_download_error(download_ret, enable_txt_ui) unless ret
233
+ else
234
+ unless enable_txt_ui
235
+ Device::Display.print_bitmap(CONNECTION_ERROR_IMAGE_PATH)
236
+ getc(5000)
212
237
  end
213
238
  end
239
+ ret
214
240
  end
215
241
 
216
242
  def self.update_file(file_parameter, index = 1, all = 1, force = false, enable_txt_ui = true)
243
+ ret = false
244
+ download_ret = false
245
+ Device::Display.print_bitmap(ATTACH_IMAGE_PATH) unless enable_txt_ui
217
246
  if attach(attach_options(enable_txt_ui)) && file_parameter
218
247
  try(3) do |attempt|
219
248
  if enable_txt_ui
220
249
  Device::Display.clear
221
250
  I18n.pt(:downloading_content, :args => [I18n.t(:files), index, all])
251
+ getc(100)
252
+ end
253
+ Device::Display.print_bitmap(UPDATING_IMAGE_PATH) unless enable_txt_ui
254
+ download_ret = file_parameter.download(force)
255
+ ret = check_download_error(download_ret, enable_txt_ui)
256
+ if ret
257
+ file_parameter.unzip
258
+ getc(1000)
222
259
  end
223
- getc(100)
224
- ret = check_download_error(file_parameter.download(force), enable_txt_ui)
225
- file_parameter.unzip if ret
226
- getc(1000)
227
260
  ret
228
261
  end
262
+ show_download_error(download_ret, enable_txt_ui) unless ret
263
+ else
264
+ unless enable_txt_ui
265
+ Device::Display.print_bitmap(CONNECTION_ERROR_IMAGE_PATH)
266
+ getc(5000)
267
+ end
229
268
  end
269
+ ret
230
270
  end
231
271
 
232
272
  def self.apps
@@ -31,7 +31,7 @@ module DaFunk
31
31
  @resources_out ||= @resources.pathmap("%{resources,#{File.join(root_path, "out")}}p")
32
32
  @tests_res_out ||= @tests_resources.pathmap("%{test/resources,out}p")
33
33
  @mruby ||= "cloudwalk run -b"
34
- @mrbc = get_mrbc_bin(@mrbc)
34
+ @mrbc = get_mrbc_bin(@mrbc)
35
35
 
36
36
  define
37
37
  end
@@ -44,14 +44,21 @@ module DaFunk
44
44
  end
45
45
  end
46
46
 
47
+ # Searches for a mrbc binary.
47
48
  def get_mrbc_bin(from_user)
48
- if (! system("type mrbc > /dev/null 2>&1 ")) && from_user
49
+ device = "/dev/null"
50
+
51
+ if %w[i386-mingw32 x64-mingw32].include?(RUBY_PLATFORM) && !ENV['SHELL']
52
+ device = "NUL" # Windows Command Prompt
53
+ end
54
+
55
+ if !system("type mrbc > #{device} 2>&1") && from_user
49
56
  from_user
50
- elsif system("type mrbc > /dev/null 2>&1 ")
57
+ elsif system("type mrbc > #{device} 2>&1")
51
58
  "env mrbc"
52
59
  elsif ENV["MRBC"]
53
60
  ENV["MRBC"]
54
- elsif system("type cloudwalk > /dev/null 2>&1 ")
61
+ elsif system("type cloudwalk > #{device} 2>&1")
55
62
  "env cloudwalk compile"
56
63
  else
57
64
  puts "$MRBC isn't set or mrbc/cloudwalk isn't on $PATH"
@@ -64,7 +71,7 @@ module DaFunk
64
71
  command_line = File.join(File.dirname(__FILE__), "..", "..", "utils", "command_line_platform.rb")
65
72
  command_line_obj = File.join(root_path, "out", "main", "command_line_platform.mrb")
66
73
  all_files = FileList["test/test_helper.rb"] + libs + files + [command_line] + [File.join(File.dirname(__FILE__), "..", "..", "utils", "test_run.rb")]
67
- if platform_call("#{mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{mrbc} -g -o #{test_out} #{all_files.uniq}")
74
+ if platform_call("#{@mrbc} -g -o #{command_line_obj} #{command_line}") && platform_call("#{@mrbc} -g -o #{test_out} #{all_files.uniq}")
68
75
  puts "cd #{File.dirname(out_path)}"
69
76
  FileUtils.cd File.dirname(out_path)
70
77
  platform_call("#{mruby} #{File.join(name, "test.mrb")}")
@@ -108,7 +115,7 @@ module DaFunk
108
115
 
109
116
  desc "Compile app to mrb and process resources"
110
117
  task :build => :resources do
111
- platform_call "#{mrbc} #{debug_flag} -o #{main_out} #{libs} "
118
+ platform_call "#{@mrbc} #{debug_flag} -o #{main_out} #{libs} "
112
119
  end
113
120
 
114
121
  desc "Compile, build and pack app and resources"
File without changes
File without changes
@@ -1,4 +1,4 @@
1
1
  module DaFunk
2
- VERSION="3.30.0"
2
+ VERSION="3.34.0"
3
3
  end
4
4
 
data/lib/device.rb CHANGED
File without changes
data/lib/device/crypto.rb CHANGED
File without changes
@@ -81,7 +81,8 @@ class Device
81
81
 
82
82
  private
83
83
  def self.main_image_format
84
- if DaFunk::Transaction::Reversal.exists?
84
+ major, min, patch = Device.version.to_s.split('.').map { |v| v.to_i }
85
+ if DaFunk::Transaction::Reversal.exists? && major >= 8
85
86
  "main_#{Device::System.model}_reversal.bmp"
86
87
  else
87
88
  "main_#{Device::System.model}.bmp"
data/lib/device/io.rb CHANGED
@@ -161,6 +161,59 @@ class Device
161
161
  end
162
162
  end
163
163
 
164
+ def self.get_format_or_touchscreen_action(max, touch_map, options = {})
165
+ set_default_format_option(options)
166
+ key = text = options[:value] || ""
167
+ time = Time.now + (options[:timeout] || 30000) / 1000
168
+ ret = {}
169
+ touch_clear
170
+ Device::Display.clear options[:line]
171
+ Device::Display.print_line format(text, options), options[:line], options[:column]
172
+ loop do
173
+ line_x, line_y = getxy_stream(100)
174
+ if line_x && line_y
175
+ ret = parse_touchscreen(touch_map, line_x, line_y)
176
+ break(ret) if ret.include?(:touch_action)
177
+ else
178
+ key = getc(100)
179
+ if key == BACK
180
+ text = text[0..-2]
181
+ Device::Display.clear options[:line]
182
+ Device::Display.print_line format(text, options), options[:line], options[:column]
183
+ elsif options[:timeout_enabled] && time < Time.now
184
+ ret[:timeout] = Device::IO::KEY_TIMEOUT
185
+ break(ret)
186
+ elsif key == ENTER
187
+ ret[:text] = text
188
+ break(ret)
189
+ elsif key == CANCEL
190
+ ret[:cancel] = Device::IO::CANCEL
191
+ break(ret)
192
+ elsif key == F1 || key == DOWN || key == UP || key == ALPHA
193
+ change_next(text, check_mask_type(text, options))
194
+ next
195
+ elsif text.size >= max
196
+ next
197
+ elsif insert_key?(key, options)
198
+ text << key
199
+ Device::Display.clear options[:line]
200
+ Device::Display.print_line format(text, options), options[:line], options[:column]
201
+ end
202
+ end
203
+ end
204
+ end
205
+
206
+ def self.parse_touchscreen(touch_map, line_x, line_y)
207
+ ret = {}
208
+ touch_map.each do |key, value|
209
+ if value[:x].include?(line_x) && value[:y].include?(line_y)
210
+ Device::Audio.beep(7, 60)
211
+ ret[:touch_action] = key
212
+ end
213
+ end
214
+ ret
215
+ end
216
+
164
217
  def self.set_default_format_option(options)
165
218
  options[:mode] ||= IO_INPUT_LETTERS
166
219
  options[:line] ||= 2
@@ -159,9 +159,7 @@ class Device
159
159
  # Device::Setting.mode = selected[:mode]
160
160
  def self.scan
161
161
  if wifi?
162
- ThreadScheduler.pausing_communication do
163
- adapter.scan if Device::Network.init(*self.config)
164
- end
162
+ adapter.scan if Device::Network.init(*self.config)
165
163
  end
166
164
  end
167
165
 
@@ -192,39 +190,28 @@ class Device
192
190
  def self.attach(options = nil)
193
191
  Device::Network.connected?
194
192
  if self.code != SUCCESS
195
- ThreadScheduler.pausing_communication do
196
- self.code = Device::Network.init(*self.config)
197
- self.code = Device::Network.connect
198
- Device::Network.connected? if self.code != SUCCESS
199
-
200
- hash = try_user(self.attach_timeout, options) do |process|
201
- Device::Network.connected?
202
- process[:ret] = self.code
203
- # TODO develop an interface to keep waiting communication module dial
204
- # based on platform returns
205
- process[:ret] == PROCESSING || process[:ret] == 2 || process[:ret] == -3307 # if true keep trying
206
- end
207
- self.code = hash[:ret]
208
-
209
- if self.code == SUCCESS
210
- self.load_metadata
211
- self.code = Device::Network.dhcp_client(20000) if (wifi? || ethernet?)
212
- else
213
- self.code = ERR_USER_CANCEL if hash[:key] == Device::IO::CANCEL
214
- Device::Network.shutdown
215
- end
193
+ self.code = Device::Network.init(*self.config)
194
+ self.code = Device::Network.connect
195
+ Device::Network.connected? if self.code != SUCCESS
196
+
197
+ hash = try_user(self.attach_timeout, options) do |process|
198
+ Device::Network.connected?
199
+ process[:ret] = self.code
200
+ # TODO develop an interface to keep waiting communication module dial
201
+ # based on platform returns
202
+ process[:ret] == PROCESSING || process[:ret] == 2 || process[:ret] == -3307 # if true keep trying
216
203
  end
217
- end
218
- Context::ThreadPubSub.publish('communication_update')
219
- self.code
220
- end
204
+ self.code = hash[:ret]
221
205
 
222
- def self.load_metadata
223
- if Object.const_defined?(:CwMetadata)
224
- CwMetadata.load_variable if CwMetadata.respond_to?(:load_variable)
206
+ if self.code == SUCCESS
207
+ self.code = Device::Network.dhcp_client(20000) if (wifi? || ethernet?)
208
+ else
209
+ self.code = ERR_USER_CANCEL if hash[:key] == Device::IO::CANCEL
210
+ Device::Network.shutdown
211
+ end
225
212
  end
213
+ self.code
226
214
  end
227
-
228
215
  def self.shutdown
229
216
  if self.adapter.started?
230
217
  Device::Network.disconnect
@@ -276,4 +263,3 @@ class Device
276
263
  end
277
264
  end
278
265
  end
279
-
File without changes
File without changes
data/lib/device/system.rb CHANGED
@@ -45,6 +45,15 @@ class Device
45
45
  adapter.battery
46
46
  end
47
47
 
48
+ # Checks the type of the battery capacity return (percentage or scale).
49
+ def self.battery_capacity_type
50
+ begin
51
+ adapter.battery_capacity_type
52
+ rescue StandardError => exception
53
+ 'scale'
54
+ end
55
+ end
56
+
48
57
  def self.beep
49
58
  adapter.beep
50
59
  end
File without changes
@@ -82,34 +82,76 @@ class Device
82
82
  ],
83
83
 
84
84
  keyboard_symbol_number: [
85
- { x: 0..35, y: 190..210, char: '(' },
86
- { x: 0..68, y: 190..210, char: ')' },
87
- { x: 0..104, y: 190..210, char: '1' },
88
- { x: 0..138, y: 190..210, char: '2' },
89
- { x: 0..169, y: 190..210, char: '3' },
90
- { x: 0..203, y: 190..210, char: '+' },
91
- { x: 0..239, y: 190..210, char: '-' },
92
- { x: 0..35, y: 220..245, char: '?' },
93
- { x: 0..68, y: 220..245, char: '$' },
94
- { x: 0..104, y: 220..245, char: '4' },
95
- { x: 0..138, y: 220..245, char: '5' },
96
- { x: 0..169, y: 220..245, char: '6' },
97
- { x: 0..203, y: 220..245, char: '*' },
98
- { x: 0..239, y: 220..245, char: '/' },
99
- { x: 0..35, y: 255..275, char: '!' },
100
- { x: 0..68, y: 255..275, char: ';' },
101
- { x: 0..104, y: 255..275, char: '7' },
102
- { x: 0..138, y: 255..275, char: '8' },
103
- { x: 0..169, y: 255..275, char: '9' },
104
- { x: 0..203, y: 255..275, char: '=' },
105
- { x: 0..239, y: 255..275, char: :erase },
106
- { x: 0..35, y: 290..315, char: :keyboard_capital },
107
- { x: 0..68, y: 290..315, char: '@' },
108
- { x: 0..104, y: 290..315, char: '%' },
109
- { x: 0..138, y: 290..315, char: '0' },
110
- { x: 0..169, y: 290..315, char: '#' },
111
- { x: 0..203, y: 290..315, char: '_' },
112
- { x: 0..239, y: 290..315, char: :enter }
85
+ { x: 0..34, y: 191..209, char: '1' },
86
+ { x: 0..46, y: 191..209, char: '2' },
87
+ { x: 0..65, y: 191..209, char: '3' },
88
+ { x: 0..96, y: 191..209, char: '4' },
89
+ { x: 0..115, y: 191..209, char: '5' },
90
+ { x: 0..145, y: 191..209, char: '6' },
91
+ { x: 0..161, y: 191..209, char: '7' },
92
+ { x: 0..191, y: 191..209, char: '8' },
93
+ { x: 0..216, y: 191..209, char: '9' },
94
+ { x: 0..255, y: 191..209, char: '0' },
95
+ { x: 0..31, y: 223..241, char: '%' },
96
+ { x: 0..52, y: 223..241, char: '#' },
97
+ { x: 0..77, y: 223..241, char: '$' },
98
+ { x: 0..97, y: 223..241, char: '_' },
99
+ { x: 0..121, y: 223..241, char: '&' },
100
+ { x: 0..143, y: 223..241, char: '-' },
101
+ { x: 0..168, y: 223..241, char: '+' },
102
+ { x: 0..186, y: 223..241, char: '(' },
103
+ { x: 0..215, y: 223..241, char: ')' },
104
+ { x: 0..236, y: 223..241, char: '/' },
105
+ { x: 0..42, y: 223..274, char: :keyboard_symbol_number_2 },
106
+ { x: 0..60, y: 223..274, char: '*' },
107
+ { x: 0..84, y: 223..274, char: '"' },
108
+ { x: 0..107, y: 223..274, char: "'" },
109
+ { x: 0..130, y: 223..274, char: ':' },
110
+ { x: 0..152, y: 223..274, char: ';' },
111
+ { x: 0..171, y: 223..274, char: '!' },
112
+ { x: 0..197, y: 223..274, char: '?' },
113
+ { x: 0..255, y: 223..274, char: :erase },
114
+ { x: 0..36, y: 223..315, char: :keyboard_capital },
115
+ { x: 0..63, y: 223..315, char: '@' },
116
+ { x: 0..88, y: 223..315, char: ',' },
117
+ { x: 0..152, y: 223..315, char: :space },
118
+ { x: 0..168, y: 223..315, char: '.' },
119
+ { x: 0..255, y: 223..315, char: :enter }
120
+ ],
121
+
122
+ keyboard_symbol_number_2: [
123
+ { x: 0..34, y: 191..209, char: '1' },
124
+ { x: 0..46, y: 191..209, char: '2' },
125
+ { x: 0..69, y: 191..209, char: '3' },
126
+ { x: 0..96, y: 191..209, char: '4' },
127
+ { x: 0..115, y: 191..209, char: '5' },
128
+ { x: 0..145, y: 191..209, char: '6' },
129
+ { x: 0..161, y: 191..209, char: '7' },
130
+ { x: 0..191, y: 191..209, char: '8' },
131
+ { x: 0..216, y: 191..209, char: '9' },
132
+ { x: 0..255, y: 191..209, char: '0' },
133
+ { x: 0..35, y: 223..241, char: '^' },
134
+ { x: 0..63, y: 223..241, char: '[' },
135
+ { x: 0..97, y: 223..241, char: ']' },
136
+ { x: 0..128, y: 223..241, char: '{' },
137
+ { x: 0..158, y: 223..241, char: '}' },
138
+ { x: 0..193, y: 223..241, char: '<' },
139
+ { x: 0..255, y: 223..241, char: '>' },
140
+ { x: 0..39, y: 223..274, char: :keyboard_symbol_number },
141
+ { x: 0..63, y: 223..274, char: '\\' },
142
+ { x: 0..86, y: 223..274, char: '-' },
143
+ { x: 0..106, y: 223..274, char: '+' },
144
+ { x: 0..130, y: 223..274, char: '=' },
145
+ { x: 0..149, y: 223..274, char: '_' },
146
+ { x: 0..175, y: 223..274, char: '˜' },
147
+ { x: 0..195, y: 223..274, char: '|' },
148
+ { x: 0..255, y: 223..274, char: :erase },
149
+ { x: 0..34, y: 223..310, char: :keyboard_capital },
150
+ { x: 0..61, y: 223..310, char: '@' },
151
+ { x: 0..87, y: 223..310, char: ',' },
152
+ { x: 0..146, y: 223..313, char: :space },
153
+ { x: 0..168, y: 223..311, char: '.' },
154
+ { x: 0..194, y: 223..319, char: :enter }
113
155
  ]
114
156
  }
115
157
 
@@ -117,9 +159,11 @@ class Device
117
159
  phisical_keys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', "\017"]
118
160
  change_keyboard
119
161
  Device::Display.print_line("#{self.text}", params[:line], params[:column])
120
- time = Time.now + (params[:timeout] || Device::IO.timeout) / 1000
121
- key = nil
162
+ if params[:timeout_enabled]
163
+ time = Time.now + (params[:timeout] || Device::IO.timeout) / 1000
164
+ end
122
165
 
166
+ key = nil
123
167
  while text_not_ready?(key)
124
168
  line_x, line_y = getxy_stream(100)
125
169
 
@@ -127,8 +171,9 @@ class Device
127
171
  touch_clear
128
172
  key = parse(line_x, line_y, params)
129
173
  else
130
- break(Device::IO::KEY_TIMEOUT) if Time.now > time
131
-
174
+ if params[:timeout_enabled]
175
+ break(Device::IO::KEY_TIMEOUT) if Time.now > time
176
+ end
132
177
  key = getc(100)
133
178
  if phisical_keys.include?(key)
134
179
  if key == Device::IO::BACK
@@ -161,7 +206,7 @@ class Device
161
206
 
162
207
  def self.show_text(key, params)
163
208
  case key[:char]
164
- when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_capital
209
+ when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_symbol_number_2, :keyboard_capital
165
210
  self.type = key[:char]
166
211
  change_keyboard
167
212
  when :erase
@@ -170,7 +215,9 @@ class Device
170
215
  when :space
171
216
  self.text += ' '
172
217
  else
173
- self.text << key[:char] unless key[:char] == :enter
218
+ if self.text && self.text.size < 20
219
+ self.text << key[:char] unless key[:char] == :enter
220
+ end
174
221
  end
175
222
  Device::Display.print_line("#{self.text}", params[:line], params[:column])
176
223
  end