Skip to content

Commit

Permalink
Merge commit '9eb46f74ac22ba38f108f14bbddcc77107f8fdb6' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
odudex committed Aug 2, 2024
2 parents 2c08417 + 9eb46f7 commit 4f18fbe
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 90 deletions.
1 change: 1 addition & 0 deletions i18n/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Mnemonik-Backup",
"Bad signature": "Ungültige Signatur",
"Baudrate": "Baudrate",
"Binary Grid": "Binäres Gitter",
"Border Padding": "Randpolsterung",
"Brightness": "Helligkeit",
"Buttons": "Tasten",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Backup del Mnemónico",
"Bad signature": "Firma incorrecta",
"Baudrate": "Baudrate",
"Binary Grid": "Cuadrícula binaria",
"Border Padding": "Grosor del Borde",
"Brightness": "Brillo",
"Buttons": "Botones",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Sauvegarde mnémonique",
"Bad signature": "Mauvaise signature",
"Baudrate": "Débit en bauds",
"Binary Grid": "Grille binaire",
"Border Padding": "Rembourrage de bordure",
"Brightness": "Luminosité",
"Buttons": "Boutons",
Expand Down
3 changes: 2 additions & 1 deletion i18n/translations/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Backup geheugensteun",
"Bad signature": "Ongeldige handtekening",
"Baudrate": "Baudratio",
"Binary Grid": "Binair raster",
"Border Padding": "Rand opvulling",
"Brightness": "Helderheid",
"Buttons": "Knoppen",
Expand Down Expand Up @@ -308,4 +309,4 @@
"is a valid receive address!": "is een valide ontvangst adres!",
"was NOT FOUND in the first %d change addresses": "werd NIET GEVONDEN in de eerste %d wisselgeld adressen",
"was NOT FOUND in the first %d receive addresses": "werd NIET GEVONDEN in de eerste %d ontvangst adressen"
}
}
1 change: 1 addition & 0 deletions i18n/translations/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Kopia zapasowa mnemonika",
"Bad signature": "zły podpis",
"Baudrate": "Baudrate",
"Binary Grid": "Siatka binarna",
"Border Padding": "Wyściółka graniczna",
"Brightness": "Jasność",
"Buttons": "Przyciski",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Backup de Mnemônico",
"Bad signature": "Assinatura Inválida",
"Baudrate": "Baudrate",
"Binary Grid": "Grade binária",
"Border Padding": "Borda",
"Brightness": "Brilho",
"Buttons": "Botões",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Резервная мнемоника",
"Bad signature": "Плохая подпись",
"Baudrate": "Скорость Передачи Данных",
"Binary Grid": "Двоичная сетка",
"Border Padding": "Заполнение Границ",
"Brightness": "Яркость",
"Buttons": "Кнопки",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Yedek Mnemonic",
"Bad signature": "Geçersiz imza",
"Baudrate": "Baud Hızı",
"Binary Grid": "İkili Izgara",
"Border Padding": "Kenarlık Dolgusu",
"Brightness": "Parlaklık",
"Buttons": "Butonlar",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"Backup Mnemonic": "Sao lưu Mnemonic",
"Bad signature": "Chữ ký xấu",
"Baudrate": "Tốc độ baud",
"Binary Grid": "Lưới nhị phân",
"Border Padding": "Đệm viền",
"Brightness": "Độ sáng",
"Buttons": "Nút",
Expand Down
15 changes: 10 additions & 5 deletions src/krux/pages/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ def load_key_from_camera(self):
[
(t("QR Code"), self.load_key_from_qr_code),
("Tiny Seed", lambda: self.load_key_from_tiny_seed_image("TinySeed")),
("OneKey KeyTag", lambda: self.load_key_from_tiny_seed_image("OneKey KeyTag")),
(t("Binary Grid"), lambda: self.load_key_from_tiny_seed_image("Binary Grid")),
(
"OneKey KeyTag",
lambda: self.load_key_from_tiny_seed_image("OneKey KeyTag"),
),
(
t("Binary Grid"),
lambda: self.load_key_from_tiny_seed_image("Binary Grid"),
),
],
)
index, status = submenu.run_loop()
Expand Down Expand Up @@ -675,7 +681,7 @@ def load_key_from_tiny_seed(self):
return self._load_key_from_words(words)
return MENU_CONTINUE

def load_key_from_tiny_seed_image(self, grid_type = "TinySeed"):
def load_key_from_tiny_seed_image(self, grid_type="TinySeed"):
"""Menu handler to scan key from Tiny Seed sheet metal storage method"""
from .tiny_seed import TinyScanner

Expand All @@ -690,9 +696,8 @@ def load_key_from_tiny_seed_image(self, grid_type = "TinySeed"):
if not self.prompt(t("Proceed?"), BOTTOM_PROMPT_LINE):
return MENU_CONTINUE

w24 = index == 1
tiny_scanner = TinyScanner(self.ctx, grid_type)
words = tiny_scanner.scanner(w24)
words = tiny_scanner.scanner(len_mnemonic == 24)
del tiny_scanner
if words is None:
self.flash_error(t("Failed to load mnemonic"))
Expand Down
128 changes: 79 additions & 49 deletions src/krux/pages/tiny_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,44 +580,50 @@ def _editable_bit():
class TinyScanner(Page):
"""Uses camera sensor to detect punch pattern on a Tiny Seed, in metal or paper"""

"""Settings for different binary grid types"""
# Settings for different binary grid types
binary_grid_settings = {
'TinySeed' : {'xpad_factor' : (240 / (12 * 345)),
'ypad_factor' : (210 / (12 * 272)),
'x_offset_factor_amigo_p0': 39 / 345,
'y_offset_factor_amigo_p0': 44 / 272,
'x_offset_factor_amigo_p1' : 42 / 345,
'y_offset_factor_amigo_p1' : 41 / 272,
'x_offset_factor_p0' : 65 / 345,
'y_offset_factor_p0' : 17 / 272,
'x_offset_factor_p1' : 62 / 345,
'y_offset_factor_p1' : 22 / 272,
'aspect_high' : 1.3,
'aspect_low' : 1.1},
'OneKey KeyTag': {'xpad_factor': 240 / (12 * 360),
'ypad_factor': 240 / (12 * 335),
'x_offset_factor_amigo_p0': 50/360,
'y_offset_factor_amigo_p0': 67/335,
'x_offset_factor_amigo_p1': 50/360,
'y_offset_factor_amigo_p1': 67/335,
'x_offset_factor_p0' : 68/360,
'y_offset_factor_p0' : 30/335,
'x_offset_factor_p1' : 68/360,
'y_offset_factor_p1' : 30/335,
'aspect_high' : 1.1,
'aspect_low' : 0.9},
'Binary Grid': {'xpad_factor': 1/14,
'ypad_factor': 1/14,
'x_offset_factor_amigo_p0': 1/14,
'y_offset_factor_amigo_p0': 1/14,
'x_offset_factor_amigo_p1': 1/14,
'y_offset_factor_amigo_p1': 1/14,
'x_offset_factor_p0': 1/14,
'y_offset_factor_p0': 1/14,
'x_offset_factor_p1': 1/14,
'y_offset_factor_p1': 1/14,
'aspect_high': 1.1,
'aspect_low': 0.9},
"TinySeed": {
"xpad_factor": (240 / (12 * 345)),
"ypad_factor": (210 / (12 * 272)),
"x_offset_factor_amigo_p0": 39 / 345,
"y_offset_factor_amigo_p0": 44 / 272,
"x_offset_factor_amigo_p1": 42 / 345,
"y_offset_factor_amigo_p1": 41 / 272,
"x_offset_factor_p0": 65 / 345,
"y_offset_factor_p0": 17 / 272,
"x_offset_factor_p1": 62 / 345,
"y_offset_factor_p1": 22 / 272,
"aspect_high": 1.3,
"aspect_low": 1.1,
},
"OneKey KeyTag": {
"xpad_factor": 240 / (12 * 360),
"ypad_factor": 240 / (12 * 335),
"x_offset_factor_amigo_p0": 50 / 360,
"y_offset_factor_amigo_p0": 67 / 335,
"x_offset_factor_amigo_p1": 50 / 360,
"y_offset_factor_amigo_p1": 67 / 335,
"x_offset_factor_p0": 68 / 360,
"y_offset_factor_p0": 30 / 335,
"x_offset_factor_p1": 68 / 360,
"y_offset_factor_p1": 30 / 335,
"aspect_high": 1.1,
"aspect_low": 0.9,
},
"Binary Grid": {
"xpad_factor": 1 / 14,
"ypad_factor": 1 / 14,
"x_offset_factor_amigo_p0": 1 / 14,
"y_offset_factor_amigo_p0": 1 / 14,
"x_offset_factor_amigo_p1": 1 / 14,
"y_offset_factor_amigo_p1": 1 / 14,
"x_offset_factor_p0": 1 / 14,
"y_offset_factor_p0": 1 / 14,
"x_offset_factor_p1": 1 / 14,
"y_offset_factor_p1": 1 / 14,
"aspect_high": 1.1,
"aspect_low": 0.9,
},
}

grid_settings = None
Expand All @@ -642,22 +648,46 @@ def _map_punches_region(self, rect_size, page=0):
if not page:
if board.config["type"] == "amigo":
# Amigo has mirrored coordinates
x_offset = rect_size[0] + rect_size[2] * self.grid_settings['x_offset_factor_amigo_p0']
y_offset = rect_size[1] + rect_size[3] * self.grid_settings['y_offset_factor_amigo_p0']
x_offset = (
rect_size[0]
+ rect_size[2] * self.grid_settings["x_offset_factor_amigo_p0"]
)
y_offset = (
rect_size[1]
+ rect_size[3] * self.grid_settings["y_offset_factor_amigo_p0"]
)
else:
x_offset = rect_size[0] + rect_size[2] * self.grid_settings['x_offset_factor_p0']
y_offset = rect_size[1] + rect_size[3] * self.grid_settings['y_offset_factor_p0']
x_offset = (
rect_size[0]
+ rect_size[2] * self.grid_settings["x_offset_factor_p0"]
)
y_offset = (
rect_size[1]
+ rect_size[3] * self.grid_settings["y_offset_factor_p0"]
)
else:
if board.config["type"] == "amigo":
x_offset = rect_size[0] + rect_size[2] * self.grid_settings['x_offset_factor_amigo_p1']
y_offset = rect_size[1] + rect_size[3] * self.grid_settings['y_offset_factor_amigo_p1']
x_offset = (
rect_size[0]
+ rect_size[2] * self.grid_settings["x_offset_factor_amigo_p1"]
)
y_offset = (
rect_size[1]
+ rect_size[3] * self.grid_settings["y_offset_factor_amigo_p1"]
)
else:
x_offset = rect_size[0] + rect_size[2] * self.grid_settings['x_offset_factor_p1']
y_offset = rect_size[1] + rect_size[3] * self.grid_settings['y_offset_factor_p1']
x_offset = (
rect_size[0]
+ rect_size[2] * self.grid_settings["x_offset_factor_p1"]
)
y_offset = (
rect_size[1]
+ rect_size[3] * self.grid_settings["y_offset_factor_p1"]
)
self.x_regions.append(int(x_offset))
self.y_regions.append(int(y_offset))
x_pad = rect_size[2] * self.grid_settings['xpad_factor']
y_pad = rect_size[3] * self.grid_settings['ypad_factor']
x_pad = rect_size[2] * self.grid_settings["xpad_factor"]
y_pad = rect_size[3] * self.grid_settings["ypad_factor"]
for _ in range(12):
x_offset += x_pad
y_offset += y_pad
Expand Down Expand Up @@ -788,8 +818,8 @@ def _detect_tiny_seed(self, img):
"""Detects Tiny Seed as a bright blob against a dark surface"""

# Load Settings for the grid type we are using
aspect_low = self.grid_settings['aspect_low']
aspect_high = self.grid_settings['aspect_high']
aspect_low = self.grid_settings["aspect_low"]
aspect_high = self.grid_settings["aspect_high"]

def _choose_rect(rects):
for rect in rects:
Expand Down
Loading

0 comments on commit 4f18fbe

Please sign in to comment.