Skip to content

Commit 5dcae39

Browse files
Improve MposKeyboard
- MposKeyboard: increase font size from 16 to 22 - MposKeyboard: use checkbox instead of newline symbol for "OK, Ready" - MposKeyboard: bigger space bar
1 parent fd1064d commit 5dcae39

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
0.4.1
22
=====
33
- MposKeyboard: fix q, Q, 1 and ~ button unclickable bug
4+
- MposKeyboard: increase font size from 16 to 22
5+
- MposKeyboard: use checkbox instead of newline symbol for "OK, Ready"
6+
- MposKeyboard: bigger space bar
47
- OSUpdate app: simplify by using ConnectivityManager
58
- API: add facilities for instrumentation (screengrabs, mouse clicks)
69
- API: move WifiService to mpos.net

internal_filesystem/lib/mpos/ui/keyboard.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class MposKeyboard:
3333
# Keyboard layout labels
3434
LABEL_NUMBERS_SPECIALS = "?123"
3535
LABEL_SPECIALS = "=\<"
36-
LABEL_LETTERS = "Abc" # using abc here will trigger the default lv.keyboard() mode switch
37-
LABEL_SPACE = " "
36+
LABEL_LETTERS = "Abc"
37+
LABEL_SPACE = " "
3838

3939
# Keyboard modes - use USER modes for our API
4040
# We'll also register to standard modes to catch LVGL's internal switches
@@ -48,36 +48,49 @@ class MposKeyboard:
4848
"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n",
4949
"a", "s", "d", "f", "g", "h", "j", "k", "l", "\n",
5050
lv.SYMBOL.UP, "z", "x", "c", "v", "b", "n", "m", lv.SYMBOL.BACKSPACE, "\n",
51-
LABEL_NUMBERS_SPECIALS, ",", LABEL_SPACE, ".", lv.SYMBOL.NEW_LINE, None
51+
LABEL_NUMBERS_SPECIALS, ",", LABEL_SPACE, ".", lv.SYMBOL.OK, None
5252
]
53-
_lowercase_ctrl = [10] * len(_lowercase_map)
53+
_lowercase_ctrl = [lv.buttonmatrix.CTRL.WIDTH_10] * len(_lowercase_map)
54+
_lowercase_ctrl[29] = lv.buttonmatrix.CTRL.WIDTH_5 # comma
55+
_lowercase_ctrl[30] = lv.buttonmatrix.CTRL.WIDTH_15 # space
56+
_lowercase_ctrl[31] = lv.buttonmatrix.CTRL.WIDTH_5 # dot
5457

5558
# Uppercase letters
5659
_uppercase_map = [
5760
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "\n",
5861
"A", "S", "D", "F", "G", "H", "J", "K", "L", "\n",
5962
lv.SYMBOL.DOWN, "Z", "X", "C", "V", "B", "N", "M", lv.SYMBOL.BACKSPACE, "\n",
60-
LABEL_NUMBERS_SPECIALS, ",", LABEL_SPACE, ".", lv.SYMBOL.NEW_LINE, None
63+
LABEL_NUMBERS_SPECIALS, ",", LABEL_SPACE, ".", lv.SYMBOL.OK, None
6164
]
62-
_uppercase_ctrl = [10] * len(_uppercase_map)
65+
_uppercase_ctrl = [lv.buttonmatrix.CTRL.WIDTH_10] * len(_uppercase_map)
66+
_uppercase_ctrl[29] = lv.buttonmatrix.CTRL.WIDTH_5 # comma
67+
_uppercase_ctrl[30] = lv.buttonmatrix.CTRL.WIDTH_15 # space
68+
_uppercase_ctrl[31] = lv.buttonmatrix.CTRL.WIDTH_5 # dot
6369

6470
# Numbers and common special characters
6571
_numbers_map = [
6672
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\n",
6773
"@", "#", "$", "_", "&", "-", "+", "(", ")", "/", "\n",
6874
LABEL_SPECIALS, "*", "\"", "'", ":", ";", "!", "?", lv.SYMBOL.BACKSPACE, "\n",
69-
LABEL_LETTERS, ",", LABEL_SPACE, ".", lv.SYMBOL.NEW_LINE, None
75+
LABEL_LETTERS, ",", LABEL_SPACE, ".", lv.SYMBOL.OK, None
7076
]
71-
_numbers_ctrl = [10] * len(_numbers_map)
77+
_numbers_ctrl = [lv.buttonmatrix.CTRL.WIDTH_10] * len(_numbers_map)
78+
_numbers_ctrl[30] = lv.buttonmatrix.CTRL.WIDTH_5 # comma
79+
_numbers_ctrl[31] = lv.buttonmatrix.CTRL.WIDTH_15 # space
80+
_numbers_ctrl[32] = lv.buttonmatrix.CTRL.WIDTH_5 # dot
7281

7382
# Additional special characters with emoticons
7483
_specials_map = [
7584
"~", "`", "|", "•", ":-)", ";-)", ":-D", "\n",
7685
":-(" , ":'-(", "^", "°", "=", "{", "}", "\\", "\n",
77-
LABEL_NUMBERS_SPECIALS, ":-o", ":-P", "[", "]", lv.SYMBOL.BACKSPACE, "\n",
78-
LABEL_LETTERS, "<", LABEL_SPACE, ">", lv.SYMBOL.NEW_LINE, None
86+
LABEL_NUMBERS_SPECIALS, "%", ":-o", ":-P", "[", "]", lv.SYMBOL.BACKSPACE, "\n",
87+
LABEL_LETTERS, "<", LABEL_SPACE, ">", lv.SYMBOL.OK, None
7988
]
80-
_specials_ctrl = [10] * len(_specials_map)
89+
_specials_ctrl = [lv.buttonmatrix.CTRL.WIDTH_10] * len(_specials_map)
90+
_specials_ctrl[15] = lv.buttonmatrix.CTRL.WIDTH_15 # LABEL_NUMBERS_SPECIALS is pretty wide
91+
_specials_ctrl[23] = lv.buttonmatrix.CTRL.WIDTH_5 # <
92+
_specials_ctrl[24] = lv.buttonmatrix.CTRL.WIDTH_15 # space
93+
_specials_ctrl[25] = lv.buttonmatrix.CTRL.WIDTH_5 # >
8194

8295
# Map modes to their layouts
8396
mode_info = {
@@ -92,13 +105,18 @@ class MposKeyboard:
92105
def __init__(self, parent):
93106
# Create underlying LVGL keyboard widget
94107
self._keyboard = lv.keyboard(parent)
108+
self._keyboard.set_style_text_font(lv.font_montserrat_22,0)
95109

96110
# Store textarea reference (we DON'T pass it to LVGL to avoid double-typing)
97111
self._textarea = None
98112

99113
self.set_mode(self.MODE_LOWERCASE)
100114

115+
# Remove default event handler(s)
116+
for index in range(self._keyboard.get_event_count()):
117+
self._keyboard.remove_event(index)
101118
self._keyboard.add_event_cb(self._handle_events, lv.EVENT.ALL, None)
119+
102120
# Apply theme fix for light mode visibility
103121
mpos.ui.theme.fix_keyboard_button_style(self._keyboard)
104122

@@ -155,6 +173,9 @@ def _handle_events(self, event):
155173
elif text == self.LABEL_SPACE:
156174
# Space bar
157175
new_text = current_text + " "
176+
elif text == lv.SYMBOL.OK:
177+
self._keyboard.send_event(lv.EVENT.READY, None)
178+
return
158179
elif text == lv.SYMBOL.NEW_LINE:
159180
# Handle newline (only for multi-line textareas)
160181
if ta.get_one_line():

0 commit comments

Comments
 (0)