Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/11488/uvk5 osfw #1132

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chirp/drivers/icw32.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def get_features(self):
rf.valid_tmodes = ["", "Tone", "TSQL"]
rf.valid_name_length = 8
rf.valid_special_chans = sorted(_get_special().keys())
rf.valid_tuning_steps = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0]

rf.has_sub_devices = self.VARIANT == ""
rf.has_ctone = True
Expand Down
44 changes: 32 additions & 12 deletions chirp/drivers/uvk5.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
u8 scan_resume_mode;
u8 auto_keypad_lock;
u8 power_on_dispmode;
u8 password[4];
u8 password[8];

#seekto 0xea0;
u8 keypad_tone;
Expand Down Expand Up @@ -257,9 +257,6 @@
# battery save
BATSAVE_LIST = ["OFF", "1:1", "1:2", "1:3", "1:4"]

# Backlight auto mode
BACKLIGHT_LIST = ["Off", "1s", "2s", "3s", "4s", "5s"]

# Crossband receiving/transmitting
CROSSBAND_LIST = ["Off", "Band A", "Band B"]
DUALWATCH_LIST = CROSSBAND_LIST
Expand All @@ -282,7 +279,6 @@

WELCOME_LIST = ["Full Screen", "Welcome Info", "Voltage"]
KEYPADTONE_LIST = ["Off", "Chinese", "English"]
LANGUAGE_LIST = ["Chinese", "English"]
ALARMMODE_LIST = ["SITE", "TONE"]
REMENDOFTALK_LIST = ["Off", "ROGER", "MDC"]
RTE_LIST = ["Off", "100ms", "200ms", "300ms", "400ms",
Expand Down Expand Up @@ -638,6 +634,8 @@ class UVK5RadioBase(chirp_common.CloneModeRadio):
_upload_calibration = False
_pttid_list = ["off", "BOT", "EOT", "BOTH"]
_steps = [1.0, 2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 8.33]
_langs = ["Chinese", "English"]
_backlight = ["Off"] + ['%is' % (i + 1) for i in range(5)]

@classmethod
def k5_approve_firmware(cls, firmware):
Expand Down Expand Up @@ -1047,7 +1045,7 @@ def set_settings(self, settings):
# Backlight auto mode
if element.get_name() == "backlight_auto_mode":
_mem.backlight_auto_mode = \
BACKLIGHT_LIST.index(str(element.value))
self._backlight.index(str(element.value))

# Tail tone elimination
if element.get_name() == "tail_note_elimination":
Expand Down Expand Up @@ -1084,7 +1082,7 @@ def set_settings(self, settings):

# Language
if element.get_name() == "language":
_mem.language = LANGUAGE_LIST.index(str(element.value))
_mem.language = self._langs.index(str(element.value))

# Alarm mode
if element.get_name() == "alarm_mode":
Expand Down Expand Up @@ -1681,12 +1679,12 @@ def get_settings(self):

# Backlight auto mode
tmpback = _mem.backlight_auto_mode
if tmpback >= len(BACKLIGHT_LIST):
if tmpback >= len(self._backlight):
tmpback = 0
rs = RadioSetting("backlight_auto_mode",
"Backlight auto mode",
RadioSettingValueList(
BACKLIGHT_LIST,
self._backlight,
current_index=tmpback))
basic.append(rs)

Expand Down Expand Up @@ -1758,11 +1756,12 @@ def get_settings(self):

# Language
tmplanguage = _mem.language
if tmplanguage >= len(LANGUAGE_LIST):
if tmplanguage >= len(self._langs):
tmplanguage = 0
rs = RadioSetting("language", "Language", RadioSettingValueList(
LANGUAGE_LIST, current_index=tmplanguage))
basic.append(rs)
self._langs, current_index=tmplanguage))
if self._langs:
basic.append(rs)

# Alarm mode
tmpalarmmode = _mem.alarm_mode
Expand Down Expand Up @@ -2069,6 +2068,27 @@ class MaxTalkerTK6(UVK5Radio):
MODEL = "TK-6"


@directory.register
@directory.detected_by(UVK5Radio)
class OSFWUVK5Radio(UVK5RadioBase):
VARIANT = 'OSFW'
_langs = []
_backlight = ['Off'] + ['%is' % (i + 1) for i in range(60)]

@classmethod
def k5_approve_firmware(cls, firmware):
return firmware in ("OSFW-bd90ca3",)

def _find_band(self, hz):
return _find_band(True, hz)

def set_settings(self, settings):
# Something about this firmware needs this cleared to avoid getting
# locked.
self._memobj.password.fill_raw(b'\xFF')
return super().set_settings(settings)


@directory.register
@directory.detected_by(UVK5Radio)
class UVK5RestrictedRadio(UVK5RadioBase):
Expand Down
2 changes: 2 additions & 0 deletions chirp/share/model_alias_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ TXQ:
TYT:
- alt: Explorer QRZ-1
model: QRZ-1
- alt: TH-7800
model: TH-7900
Tacklife:
- alt: Radioddity R2
model: MTR01
Expand Down
12 changes: 10 additions & 2 deletions chirp/wxui/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def is_prolific_warning(string):
return 'PL2303' in string and 'CONTACT YOUR SUPPLIER' in string


def get_model_label(rclass):
detected = ','.join(
detected_value(rclass, m)
for m in rclass.detected_models(include_self=False))
if len(detected) > (32 - 5):
detected = 'others'
return detected


def get_fakes():
return {
'Fake NOP': developer.FakeSerial(),
Expand Down Expand Up @@ -532,8 +541,7 @@ def _select_vendor(self, vendor):
for rclass in self._vendors[vendor]:
display = model_value(rclass)
actual_models.append(display)
detected = ','.join(detected_value(rclass, x) for x in
rclass.detected_models(include_self=False))
detected = get_model_label(rclass)
if detected:
display += ' (+ %s)' % detected
display_models.append(display)
Expand Down
12 changes: 3 additions & 9 deletions tests/unit/test_wxui_radiothread.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,9 @@ def test_detected_model_labels(self):
# be visible in the model box.
for rclass in [x for x in directory.DRV_TO_RADIO.values()
if issubclass(x, chirp_common.DetectableInterface)]:
labels = []
for child_rclass in rclass.detected_models(include_self=False):
label = clone.detected_value(rclass, child_rclass)
self.assertNotEqual('', label)
labels.append(label)
if labels:
label = '%s (+ %s)' % (rclass.MODEL, ','.join(labels))
self.assertLessEqual(len(label), 32,
'Label %r is too long' % label)
label = clone.get_model_label(rclass)
self.assertLessEqual(len(label), 32,
'Label %r is too long' % label)


class TestException(Exception):
Expand Down
Loading