Skip to content

Commit 09a1daf

Browse files
committed
Hide not supported key actions
1 parent ea86d24 commit 09a1daf

File tree

1 file changed

+37
-42
lines changed

1 file changed

+37
-42
lines changed

uvk5_egzumer.py

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -377,25 +377,8 @@
377377
5: [400.0, 469.9999],
378378
6: [470.0, 1300.0]
379379
}
380-
SPECIALS = {
381-
"F1(50M-76M)A": 200,
382-
"F1(50M-76M)B": 201,
383-
"F2(108M-136M)A": 202,
384-
"F2(108M-136M)B": 203,
385-
"F3(136M-174M)A": 204,
386-
"F3(136M-174M)B": 205,
387-
"F4(174M-350M)A": 206,
388-
"F4(174M-350M)B": 207,
389-
"F5(350M-400M)A": 208,
390-
"F5(350M-400M)B": 209,
391-
"F6(400M-470M)A": 210,
392-
"F6(400M-470M)B": 211,
393-
"F7(470M-600M)A": 212,
394-
"F7(470M-600M)B": 213
395-
}
396380

397381
SCANLIST_LIST = ["None", "List1", "List2", "Both"]
398-
399382
SCANLIST_SELECT_LIST = ["LIST1", "LIST2", "ALL"]
400383

401384
DTMF_CHARS = "0123456789ABCD*# "
@@ -405,9 +388,20 @@
405388
DTMF_CODE_CHARS = "ABCD*# "
406389
DTMF_DECODE_RESPONSE_LIST = ["None", "Ring", "Reply", "Both"]
407390

408-
KEYACTIONS_LIST = ["None", "Flashlight", "Power", "Monitor", "Scan",
409-
"VOX", "*Alarm ", "FM radio", "*1750Hz tone",
410-
"Lock keypad", "Switch main VFO", "Switch frequency/memory mode", "Switch demodulation"]
391+
KEYACTIONS_LIST = ["None",
392+
"Flashlight",
393+
"Power",
394+
"Monitor",
395+
"Scan",
396+
"VOX",
397+
"Alarm",
398+
"FM radio",
399+
"1750Hz tone",
400+
"Lock keypad",
401+
"Switch main VFO",
402+
"Switch frequency/memory mode",
403+
"Switch demodulation"
404+
]
411405

412406
# the communication is obfuscated using this fine mechanism
413407
def xorarr(data: bytes):
@@ -675,7 +669,7 @@ def Get_SPECIALS(self):
675669
for idx, name in enumerate(self.Get_VFO_CHANNEL_NAMES()):
676670
specials[name] = 200 + idx
677671
return specials
678-
672+
679673
def get_prompts(x=None):
680674
rp = chirp_common.RadioPrompts()
681675
rp.experimental = \
@@ -1392,43 +1386,44 @@ def get_settings(self):
13921386
top.append(roinfo)
13931387

13941388
# Programmable keys
1395-
tmpval = int(_mem.key1_shortpress_action)
1396-
if tmpval >= len(KEYACTIONS_LIST):
1397-
tmpval = 0
1398-
rs = RadioSetting("key1_shortpress_action", "Side key 1 short press (F1Shrt)",
1389+
def GetActualKeyAction(actionNum):
1390+
hasAlarm = self._memobj.BUILD_OPTIONS.ENABLE_ALARM
1391+
has1750 = self._memobj.BUILD_OPTIONS.ENABLE_TX1750
1392+
lst = KEYACTIONS_LIST.copy()
1393+
if not hasAlarm:
1394+
lst.remove("Alarm")
1395+
if not has1750:
1396+
lst.remove("1750Hz tone")
1397+
1398+
actionNum = int(actionNum)
1399+
if actionNum >= len(KEYACTIONS_LIST) or KEYACTIONS_LIST[actionNum] not in lst:
1400+
actionNum = 0
1401+
return lst, KEYACTIONS_LIST[actionNum]
1402+
1403+
rs = RadioSetting("key1_shortpress_action",
1404+
"Side key 1 short press (F1Shrt)",
13991405
RadioSettingValueList(
1400-
KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
1406+
*GetActualKeyAction(_mem.key1_shortpress_action)))
14011407
keya.append(rs)
14021408

1403-
tmpval = int(_mem.key1_longpress_action)
1404-
if tmpval >= len(KEYACTIONS_LIST):
1405-
tmpval = 0
14061409
rs = RadioSetting("key1_longpress_action", "Side key 1 long press (F1Long)",
14071410
RadioSettingValueList(
1408-
KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
1411+
*GetActualKeyAction(_mem.key1_longpress_action)))
14091412
keya.append(rs)
14101413

1411-
tmpval = int(_mem.key2_shortpress_action)
1412-
if tmpval >= len(KEYACTIONS_LIST):
1413-
tmpval = 0
14141414
rs = RadioSetting("key2_shortpress_action", "Side key 2 short press (F2Shrt)",
14151415
RadioSettingValueList(
1416-
KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
1416+
*GetActualKeyAction(_mem.key2_shortpress_action)))
14171417
keya.append(rs)
14181418

1419-
tmpval = int(_mem.key2_longpress_action)
1420-
if tmpval >= len(KEYACTIONS_LIST):
1421-
tmpval = 0
14221419
rs = RadioSetting("key2_longpress_action", "Side key 2 long press (F2Long)",
14231420
RadioSettingValueList(
1424-
KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
1421+
*GetActualKeyAction(_mem.key2_longpress_action)))
14251422
keya.append(rs)
1426-
tmpval = int(_mem._0xe90.keyM_longpress_action)
1427-
if tmpval >= len(KEYACTIONS_LIST):
1428-
tmpval = 0
1423+
14291424
rs = RadioSetting("keyM_longpress_action", "Menu key long press (M Long)",
14301425
RadioSettingValueList(
1431-
KEYACTIONS_LIST, KEYACTIONS_LIST[tmpval]))
1426+
*GetActualKeyAction(_mem._0xe90.keyM_longpress_action)))
14321427
keya.append(rs)
14331428

14341429
# DTMF settings

0 commit comments

Comments
 (0)