da_funk 3.20.0 → 3.21.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.
- checksums.yaml +5 -5
- data/Gemfile.lock +16 -11
- data/RELEASE_NOTES.md +17 -0
- data/Rakefile +2 -1
- data/lib/da_funk/helper.rb +14 -14
- data/lib/da_funk/helper/status_bar.rb +66 -40
- data/lib/da_funk/version.rb +1 -1
- data/lib/device/runtime.rb +0 -1
- data/lib/device/virtual_keyboard.rb +187 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc5abcda84d3caf3982e38fe2ec5c10e59de3ea4c171ec086355a4192e610e21
|
4
|
+
data.tar.gz: a3bac877e9dc0e25a3b0da2f015c87ba64431dab8c1bc7db8f513c89cdf46289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32172e2717e34860bd3df6eb6a8a8c1bae0eb54dce61fa45e93b9dcd59af4d9da939450f724defa7a41de8612453f73bd50a05ee8dd60d950a4e56d2000768b6
|
7
|
+
data.tar.gz: 59de0b4dbdca94dbd077c37e220e22305030823b7a171b2a77e1ea1778f05fc17f6eb2d999a98911348a2a57bd0b101a7f2e2535f4acd60fe740a50289195981
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
da_funk (3.
|
4
|
+
da_funk (3.21.0)
|
5
5
|
archive-zip (~> 0.5)
|
6
6
|
bundler
|
7
7
|
cloudwalk_handshake
|
@@ -14,36 +14,41 @@ GEM
|
|
14
14
|
specs:
|
15
15
|
archive-zip (0.12.0)
|
16
16
|
io-like (~> 0.3.0)
|
17
|
-
ast (2.4.
|
17
|
+
ast (2.4.1)
|
18
18
|
cloudwalk (1.15.0)
|
19
19
|
bundler
|
20
20
|
rake
|
21
21
|
cloudwalk_handshake (1.13.1)
|
22
22
|
funky-simplehttp (~> 0.6)
|
23
|
-
funky-emv (1.
|
23
|
+
funky-emv (1.3.0)
|
24
24
|
funky-tlv (~> 0.2)
|
25
25
|
funky-mock (0.1.0)
|
26
26
|
funky-simplehttp (0.6.0)
|
27
27
|
funky-tlv (0.2.3)
|
28
28
|
io-like (0.3.1)
|
29
|
-
jaro_winkler (1.5.4)
|
30
29
|
parallel (1.19.1)
|
31
|
-
parser (2.7.
|
30
|
+
parser (2.7.1.3)
|
32
31
|
ast (~> 2.4.0)
|
33
32
|
posxml_parser (2.26.0)
|
34
33
|
funky-emv (~> 1)
|
35
34
|
rainbow (3.0.0)
|
36
35
|
rake (13.0.1)
|
37
|
-
|
38
|
-
|
36
|
+
regexp_parser (1.7.1)
|
37
|
+
rexml (3.2.4)
|
38
|
+
rubocop (0.85.1)
|
39
39
|
parallel (~> 1.10)
|
40
40
|
parser (>= 2.7.0.1)
|
41
41
|
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.7)
|
43
|
+
rexml
|
44
|
+
rubocop-ast (>= 0.0.3)
|
42
45
|
ruby-progressbar (~> 1.7)
|
43
|
-
unicode-display_width (>= 1.4.0, <
|
46
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
47
|
+
rubocop-ast (0.0.3)
|
48
|
+
parser (>= 2.7.0.1)
|
44
49
|
ruby-progressbar (1.10.1)
|
45
|
-
unicode-display_width (1.
|
46
|
-
yard (0.9.
|
50
|
+
unicode-display_width (1.7.0)
|
51
|
+
yard (0.9.25)
|
47
52
|
|
48
53
|
PLATFORMS
|
49
54
|
ruby
|
@@ -59,4 +64,4 @@ DEPENDENCIES
|
|
59
64
|
yard
|
60
65
|
|
61
66
|
BUNDLED WITH
|
62
|
-
2.
|
67
|
+
2.1.4
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# DaFunk
|
2
2
|
|
3
|
+
### 3.21.0 - 2020-06-12
|
4
|
+
|
5
|
+
- Removed unnecessary processing method call;
|
6
|
+
- Status bar refactored:
|
7
|
+
- Removed link icon;
|
8
|
+
- Added support to SLOT_MEDIA to print WIFI or GPRS;
|
9
|
+
- Renamed SLOT_CONNECTION to SLOT_SIGNAL_LEVEL;
|
10
|
+
- Added support to SLOT_BATTERY_PERCENTUAL to print percentual of battery level;
|
11
|
+
- Renamed SLOT_BATTERY to SLOT_BATTERY_LEVEL;
|
12
|
+
- Update battery and wifi images;
|
13
|
+
- Added BATTERY_PERCENTAGE_IMAGES;
|
14
|
+
- Show searching icon when network is not connected;
|
15
|
+
- Added support to virtual keyboard;
|
16
|
+
- Added support to touchscreen event on DaFunk::Helper#menu;
|
17
|
+
- Added support to return timeout parameter on DaFunk::Helper#menu when timeout is achieved;
|
18
|
+
- Update funky-emv 1.3.0.
|
19
|
+
|
3
20
|
### 3.20.0 - 2020-05-28
|
4
21
|
|
5
22
|
- Rename PaymentChannel::client to ::current;
|
data/Rakefile
CHANGED
data/lib/da_funk/helper.rb
CHANGED
@@ -296,6 +296,8 @@ module DaFunk
|
|
296
296
|
|
297
297
|
if key == Device::IO::ENTER
|
298
298
|
options[:default]
|
299
|
+
elsif key == Device::IO::KEY_TIMEOUT
|
300
|
+
options[:timeout]
|
299
301
|
else
|
300
302
|
selected
|
301
303
|
end
|
@@ -303,7 +305,10 @@ module DaFunk
|
|
303
305
|
|
304
306
|
# TODO Scalone: Refactor.
|
305
307
|
def pagination(title, options, collection, &block)
|
308
|
+
timeout = Device::IO.timeout
|
309
|
+
touchscreen_options = {}
|
306
310
|
start_line, options[:limit], options[:header] = pagination_limit(title, options)
|
311
|
+
|
307
312
|
if collection.size > (options[:limit] - options[:header]) # minus pagination header
|
308
313
|
key = Device::IO.back_key
|
309
314
|
pages = pagination_page(collection, options[:limit] - options[:header]) # minus pagination header
|
@@ -313,7 +318,13 @@ module DaFunk
|
|
313
318
|
pagination_header(title, page, pages.size, start_line, options[:default], options[:header])
|
314
319
|
values = pages[page].to_a
|
315
320
|
block.call(values, start_line + options[:header])
|
316
|
-
|
321
|
+
|
322
|
+
params = {special_keys: pagination_keys(values.size, true)}
|
323
|
+
if options.include?(:touchscreen_options)
|
324
|
+
touchscreen_options = options[:touchscreen_options]
|
325
|
+
end
|
326
|
+
|
327
|
+
_, key = wait_touchscreen_or_keyboard_event(touchscreen_options, timeout, params)
|
317
328
|
page = pagination_key_page(page, key, pages.size)
|
318
329
|
end
|
319
330
|
else
|
@@ -321,7 +332,8 @@ module DaFunk
|
|
321
332
|
print_title(title, options[:default]) if title
|
322
333
|
values = collection.to_a
|
323
334
|
block.call(values, start_line)
|
324
|
-
|
335
|
+
params = {special_keys: pagination_keys(collection.size, false)}
|
336
|
+
_, key = wait_touchscreen_or_keyboard_event(touchscreen_options, timeout, params)
|
325
337
|
end
|
326
338
|
result = values[key.to_i-1] if key.integer?
|
327
339
|
if result.is_a? Array
|
@@ -441,18 +453,6 @@ module DaFunk
|
|
441
453
|
end
|
442
454
|
end
|
443
455
|
|
444
|
-
def processing(image, message = {})
|
445
|
-
Device::Display.print_bitmap(to_bmp(image)) if bmp_exists?(image)
|
446
|
-
end
|
447
|
-
|
448
|
-
def bmp_exists?(bmp)
|
449
|
-
File.exists?(to_bmp(bmp))
|
450
|
-
end
|
451
|
-
|
452
|
-
def to_bmp(image)
|
453
|
-
"./shared/#{image.to_s}.bmp"
|
454
|
-
end
|
455
|
-
|
456
456
|
private
|
457
457
|
def parse_touchscreen_event(menu_itens, x, y)
|
458
458
|
menu_itens.each do |key, value|
|
@@ -1,18 +1,26 @@
|
|
1
1
|
module DaFunk
|
2
2
|
module Helper
|
3
3
|
class StatusBar
|
4
|
-
STATUS_TIMEOUT
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
STATUS_TIMEOUT = 60
|
5
|
+
SLOT_MEDIA = 0
|
6
|
+
SLOT_SIGNAL_LEVEL = 1
|
7
|
+
SLOT_UPDATE = 2
|
8
|
+
SLOT_BATTERY_PERCENTUAL = 6
|
9
|
+
SLOT_BATTERY_LEVEL = 7
|
9
10
|
|
10
11
|
BATTERY_IMAGES = {
|
11
|
-
0..
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
0..4 => "./shared/battery0.png",
|
13
|
+
5..9 => "./shared/baterry5.png",
|
14
|
+
10..19 => "./shared/battery10.png",
|
15
|
+
20..29 => "./shared/battery20.png",
|
16
|
+
30..39 => "./shared/battery30.png",
|
17
|
+
40..49 => "./shared/battery40.png",
|
18
|
+
50..59 => "./shared/battery50.png",
|
19
|
+
60..69 => "./shared/battery60.png",
|
20
|
+
70..79 => "./shared/battery70.png",
|
21
|
+
80..89 => "./shared/battery80.png",
|
22
|
+
90..99 => "./shared/battery90.png",
|
23
|
+
100..100 => "./shared/battery100.png",
|
16
24
|
}
|
17
25
|
|
18
26
|
BATTERY_CHARGE_IMAGES = {
|
@@ -20,11 +28,27 @@ module DaFunk
|
|
20
28
|
100 => "./shared/battery100c.png"
|
21
29
|
}
|
22
30
|
|
31
|
+
BATTERY_PERCENTAGE_IMAGES = {
|
32
|
+
0..4 => "./shared/battery1_percent.png",
|
33
|
+
5..9 => "./shared/battery5_percent.png",
|
34
|
+
10..19 => "./shared/battery10_percent.png",
|
35
|
+
20..29 => "./shared/battery20_percent.png",
|
36
|
+
30..39 => "./shared/battery30_percent.png",
|
37
|
+
40..49 => "./shared/battery40_percent.png",
|
38
|
+
50..59 => "./shared/battery50_percent.png",
|
39
|
+
60..69 => "./shared/battery60_percent.png",
|
40
|
+
70..79 => "./shared/battery70_percent.png",
|
41
|
+
80..89 => "./shared/battery80_percent.png",
|
42
|
+
90..99 => "./shared/battery90_percent.png",
|
43
|
+
100..100 => "./shared/battery100_percent.png",
|
44
|
+
}
|
45
|
+
|
23
46
|
WIFI_IMAGES = {
|
24
|
-
0..
|
25
|
-
|
26
|
-
|
27
|
-
|
47
|
+
0..0 => "./shared/wifi0.png",
|
48
|
+
1..25 => "./shared/wifi25.png",
|
49
|
+
26..50 => "./shared/wifi50.png",
|
50
|
+
59..75 => "./shared/wifi75.png",
|
51
|
+
76..200 => "./shared/wifi100.png"
|
28
52
|
}
|
29
53
|
|
30
54
|
MOBILE_IMAGES = {
|
@@ -37,14 +61,13 @@ module DaFunk
|
|
37
61
|
}
|
38
62
|
|
39
63
|
class << self
|
40
|
-
attr_accessor :signal, :battery, :power, :managment
|
64
|
+
attr_accessor :signal, :battery, :power, :managment
|
41
65
|
end
|
42
66
|
|
43
67
|
def self.check
|
44
68
|
if self.valid?
|
45
69
|
self.change_connection
|
46
70
|
self.change_battery
|
47
|
-
self.change_link
|
48
71
|
self.change_update
|
49
72
|
end
|
50
73
|
end
|
@@ -57,44 +80,45 @@ module DaFunk
|
|
57
80
|
end
|
58
81
|
end
|
59
82
|
|
60
|
-
def self.change_link
|
61
|
-
info = (!! DaFunk::PaymentChannel.alive?)
|
62
|
-
if self.link.nil? || self.link != info
|
63
|
-
self.link = info
|
64
|
-
if info
|
65
|
-
PAX::Display.print_status_bar(SLOT_LINK, "./shared/link.png")
|
66
|
-
else
|
67
|
-
PAX::Display.print_status_bar(SLOT_LINK, "./shared/unlink.png")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
83
|
def self.change_connection
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
84
|
+
if Device::Network.connected?
|
85
|
+
sig = Device::Network.signal
|
86
|
+
|
87
|
+
if self.signal != sig
|
88
|
+
self.signal = sig
|
89
|
+
|
90
|
+
if Device::Network.gprs?
|
91
|
+
Device::Display.print_status_bar(SLOT_MEDIA, "./shared/GPRS.png")
|
92
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
93
|
+
get_image_path(:gprs, self.signal))
|
94
|
+
elsif Device::Network.wifi?
|
95
|
+
Device::Display.print_status_bar(SLOT_MEDIA, "./shared/WIFI.png")
|
96
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL,
|
97
|
+
get_image_path(:wifi, self.signal))
|
98
|
+
end
|
82
99
|
end
|
100
|
+
else
|
101
|
+
Device::Display.print_status_bar(SLOT_MEDIA, nil)
|
102
|
+
Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, "./shared/searching.png")
|
83
103
|
end
|
84
104
|
end
|
85
105
|
|
86
106
|
def self.change_battery
|
87
107
|
bat = Device::System.battery
|
88
108
|
dock = Device::System.power_supply
|
109
|
+
|
89
110
|
if self.battery != bat || self.power != dock
|
90
111
|
self.battery = bat
|
91
112
|
self.power = dock
|
113
|
+
|
114
|
+
Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL,
|
115
|
+
get_image_path(:battery_percentual, self.battery))
|
92
116
|
if self.power
|
93
117
|
Device::Display.print_status_bar(
|
94
|
-
|
118
|
+
SLOT_BATTERY_LEVEL, get_image_path(:battery_charge, self.battery))
|
95
119
|
else
|
96
|
-
Device::Display.print_status_bar(
|
97
|
-
|
120
|
+
Device::Display.print_status_bar(SLOT_BATTERY_LEVEL,
|
121
|
+
get_image_path(:battery, self.battery))
|
98
122
|
end
|
99
123
|
end
|
100
124
|
end
|
@@ -110,6 +134,8 @@ module DaFunk
|
|
110
134
|
BATTERY_IMAGES.each {|k,v| return v if k.include? sig }
|
111
135
|
when :battery_charge
|
112
136
|
BATTERY_CHARGE_IMAGES[sig]
|
137
|
+
when :battery_percentual
|
138
|
+
BATTERY_PERCENTAGE_IMAGES.each {|k,v| return v if k.include? sig }
|
113
139
|
else
|
114
140
|
nil
|
115
141
|
end
|
data/lib/da_funk/version.rb
CHANGED
data/lib/device/runtime.rb
CHANGED
@@ -14,7 +14,6 @@ class Device
|
|
14
14
|
# @param json [String] Parameters to confifure new aplication.
|
15
15
|
# @return [Object] From the new runtime instance.
|
16
16
|
def self.execute(app, json = nil)
|
17
|
-
processing(:processing)
|
18
17
|
buf = "#{json.dup}" if json.is_a?(String)
|
19
18
|
mrb_eval("Context.execute('#{app.dup}', '#{Device.adapter}', '#{buf}')", "#{app.dup}")
|
20
19
|
ensure
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Device
|
4
|
+
class VirtualKeyboard
|
5
|
+
class << self
|
6
|
+
attr_accessor :attributes, :type, :text
|
7
|
+
end
|
8
|
+
|
9
|
+
self.attributes = {
|
10
|
+
keyboard_capital: [
|
11
|
+
{ x: 0..34, y: 191..209, char: 'q' },
|
12
|
+
{ x: 0..46, y: 191..209, char: 'w' },
|
13
|
+
{ x: 0..65, y: 191..209, char: 'e' },
|
14
|
+
{ x: 0..96, y: 191..209, char: 'r' },
|
15
|
+
{ x: 0..115, y: 191..209, char: 't' },
|
16
|
+
{ x: 0..145, y: 191..209, char: 'y' },
|
17
|
+
{ x: 0..161, y: 191..209, char: 'u' },
|
18
|
+
{ x: 0..191, y: 191..209, char: 'i' },
|
19
|
+
{ x: 0..216, y: 191..209, char: 'o' },
|
20
|
+
{ x: 0..255, y: 191..209, char: 'p' },
|
21
|
+
{ x: 0..34, y: 223..241, char: 'a' },
|
22
|
+
{ x: 0..59, y: 223..241, char: 's' },
|
23
|
+
{ x: 0..83, y: 223..241, char: 'd' },
|
24
|
+
{ x: 0..106, y: 223..241, char: 'f' },
|
25
|
+
{ x: 0..131, y: 223..241, char: 'g' },
|
26
|
+
{ x: 0..153, y: 223..241, char: 'h' },
|
27
|
+
{ x: 0..178, y: 223..241, char: 'j' },
|
28
|
+
{ x: 0..201, y: 223..241, char: 'k' },
|
29
|
+
{ x: 0..230, y: 223..241, char: 'l' },
|
30
|
+
{ x: 0..30, y: 223..273, char: :keyboard_uppercase },
|
31
|
+
{ x: 0..56, y: 223..273, char: 'y' },
|
32
|
+
{ x: 0..82, y: 223..273, char: 'x' },
|
33
|
+
{ x: 0..109, y: 223..273, char: 'c' },
|
34
|
+
{ x: 0..130, y: 223..273, char: 'v' },
|
35
|
+
{ x: 0..154, y: 223..273, char: 'b' },
|
36
|
+
{ x: 0..176, y: 223..273, char: 'n' },
|
37
|
+
{ x: 0..201, y: 223..273, char: 'm' },
|
38
|
+
{ x: 0..240, y: 223..273, char: :erase },
|
39
|
+
{ x: 0..34, y: 223..315, char: :keyboard_symbol_number },
|
40
|
+
{ x: 0..58, y: 223..315, char: '@' },
|
41
|
+
{ x: 0..83, y: 223..315, char: ',' },
|
42
|
+
{ x: 0..148, y: 223..315, char: :space },
|
43
|
+
{ x: 0..177, y: 223..315, char: '.' },
|
44
|
+
{ x: 0..255, y: 223..315, char: :enter }
|
45
|
+
],
|
46
|
+
|
47
|
+
keyboard_uppercase: [
|
48
|
+
{ x: 0..34, y: 191..209, char: 'Q' },
|
49
|
+
{ x: 0..46, y: 191..209, char: 'W' },
|
50
|
+
{ x: 0..65, y: 191..209, char: 'E' },
|
51
|
+
{ x: 0..96, y: 191..209, char: 'R' },
|
52
|
+
{ x: 0..115, y: 191..209, char: 'T' },
|
53
|
+
{ x: 0..145, y: 191..209, char: 'Y' },
|
54
|
+
{ x: 0..161, y: 191..209, char: 'U' },
|
55
|
+
{ x: 0..191, y: 191..209, char: 'I' },
|
56
|
+
{ x: 0..216, y: 191..209, char: 'O' },
|
57
|
+
{ x: 0..255, y: 191..209, char: 'P' },
|
58
|
+
{ x: 0..34, y: 223..241, char: 'A' },
|
59
|
+
{ x: 0..59, y: 223..241, char: 'S' },
|
60
|
+
{ x: 0..83, y: 223..241, char: 'D' },
|
61
|
+
{ x: 0..106, y: 223..241, char: 'F' },
|
62
|
+
{ x: 0..131, y: 223..241, char: 'G' },
|
63
|
+
{ x: 0..153, y: 223..241, char: 'H' },
|
64
|
+
{ x: 0..178, y: 223..241, char: 'J' },
|
65
|
+
{ x: 0..201, y: 223..241, char: 'K' },
|
66
|
+
{ x: 0..230, y: 223..241, char: 'L' },
|
67
|
+
{ x: 0..30, y: 223..273, char: :keyboard_capital },
|
68
|
+
{ x: 0..56, y: 223..273, char: 'Y' },
|
69
|
+
{ x: 0..82, y: 223..273, char: 'X' },
|
70
|
+
{ x: 0..109, y: 223..273, char: 'C' },
|
71
|
+
{ x: 0..130, y: 223..273, char: 'V' },
|
72
|
+
{ x: 0..154, y: 223..273, char: 'B' },
|
73
|
+
{ x: 0..176, y: 223..273, char: 'N' },
|
74
|
+
{ x: 0..201, y: 223..273, char: 'M' },
|
75
|
+
{ x: 0..240, y: 223..273, char: :erase },
|
76
|
+
{ x: 0..34, y: 223..315, char: :keyboard_symbol_number },
|
77
|
+
{ x: 0..58, y: 223..315, char: '@' },
|
78
|
+
{ x: 0..83, y: 223..315, char: ',' },
|
79
|
+
{ x: 0..148, y: 223..315, char: :space },
|
80
|
+
{ x: 0..177, y: 223..315, char: '.' },
|
81
|
+
{ x: 0..255, y: 223..315, char: :enter }
|
82
|
+
],
|
83
|
+
|
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 }
|
113
|
+
]
|
114
|
+
}
|
115
|
+
|
116
|
+
def self.type_text(params = {})
|
117
|
+
change_keyboard
|
118
|
+
Device::Display.print_line("#{self.text}", params[:line], params[:column])
|
119
|
+
time = Time.now + (params[:timeout] || Device::IO.timeout) / 1000
|
120
|
+
key = nil
|
121
|
+
|
122
|
+
while text_not_ready?(key)
|
123
|
+
line_x, line_y = getxy_stream(100)
|
124
|
+
|
125
|
+
if line_x && line_y
|
126
|
+
touch_clear
|
127
|
+
key = parse(line_x, line_y, params)
|
128
|
+
else
|
129
|
+
break(Device::IO::KEY_TIMEOUT) if Time.now > time
|
130
|
+
|
131
|
+
key = getc(100)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
[key, self.text]
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.text_not_ready?(key)
|
139
|
+
key != :enter && key != Device::IO::ENTER && key != Device::IO::CANCEL
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.parse(line_x, line_y, params)
|
143
|
+
key = attributes[type].find do |value|
|
144
|
+
value[:x].include?(line_x) && value[:y].include?(line_y)
|
145
|
+
end
|
146
|
+
return if key.nil?
|
147
|
+
|
148
|
+
Device::Audio.beep(7, 60)
|
149
|
+
show_text(key, params)
|
150
|
+
|
151
|
+
key[:char]
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.show_text(key, params)
|
155
|
+
case key[:char]
|
156
|
+
when :keyboard_uppercase, :keyboard_symbol_number, :keyboard_capital
|
157
|
+
self.type = key[:char]
|
158
|
+
change_keyboard
|
159
|
+
when :erase
|
160
|
+
self.text += '' if text.nil?
|
161
|
+
self.text = text[0..-2]
|
162
|
+
when :space
|
163
|
+
self.text += ' '
|
164
|
+
else
|
165
|
+
self.text << key[:char] unless key[:char] == :enter
|
166
|
+
end
|
167
|
+
Device::Display.print_line("#{self.text}", params[:line], params[:column])
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.change_keyboard
|
171
|
+
if type.nil?
|
172
|
+
self.type = :keyboard_capital
|
173
|
+
Device::Display.print_bitmap('./shared/keyboard_capital.bmp')
|
174
|
+
else
|
175
|
+
Device::Display.print_bitmap("./shared/#{type}.bmp")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.wifi_password
|
180
|
+
self.text = if Device::Setting.wifi_password == 'false'
|
181
|
+
''
|
182
|
+
else
|
183
|
+
Device::Setting.wifi_password
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: da_funk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Scalone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/device/support.rb
|
193
193
|
- lib/device/system.rb
|
194
194
|
- lib/device/version.rb
|
195
|
+
- lib/device/virtual_keyboard.rb
|
195
196
|
- lib/ext/array.rb
|
196
197
|
- lib/ext/float.rb
|
197
198
|
- lib/ext/hash.rb
|
@@ -253,8 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
254
|
- !ruby/object:Gem::Version
|
254
255
|
version: '0'
|
255
256
|
requirements: []
|
256
|
-
|
257
|
-
rubygems_version: 2.6.14
|
257
|
+
rubygems_version: 3.0.6
|
258
258
|
signing_key:
|
259
259
|
specification_version: 4
|
260
260
|
summary: MRuby Embedded System Framework
|