Skip to content

Commit

Permalink
ga510: Add airband for SenhaiX 8800
Browse files Browse the repository at this point in the history
Fixes #11516
  • Loading branch information
kk7ds committed Sep 1, 2024
1 parent fddaaa0 commit 68591a7
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 77 deletions.
8 changes: 8 additions & 0 deletions chirp/chirp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2063,3 +2063,11 @@ def mem_to_text(mem):
elif mode == 'DTCS':
pieces.append('D%03i' % tone)
return '[%s]' % '/'.join(pieces)


def in_range(freq, ranges):
"""Check if freq is in any of the provided ranges"""
for lo, hi in ranges:
if lo <= freq <= hi:
return True
return False
28 changes: 28 additions & 0 deletions chirp/drivers/ga510.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
DTCS_CODES = tuple(sorted(chirp_common.DTCS_CODES + (645,)))

DTMFCHARS = '0123456789ABCD*#'
AIRBAND = (108000000, 136000000)


def reset(radio):
Expand Down Expand Up @@ -1046,6 +1047,33 @@ class Senhaix8800Radio(RadioddityGA510Radio):
_mem_format = MODEL_SHX8800_FORMAT
_magic = b'PROGROMSHXU'

def get_features(self):
rf = super().get_features()
rf.valid_bands = rf.valid_bands + [AIRBAND]
rf.valid_modes = rf.valid_modes + ['AM']
return rf

def get_memory(self, number):
m = super().get_memory(number)
if chirp_common.in_range(m.freq, [AIRBAND]):
m.mode = 'AM'
return m

def validate_memory(self, mem):
msgs = []
if chirp_common.in_range(mem.freq, [AIRBAND]):
if not mem.mode == 'AM':
msgs.append(chirp_common.ValidationWarning(
_('Frequency in this range requires AM mode')))
if mem.duplex or mem.tmode:
msgs.append(chirp_common.ValidationError(
_('AM mode does not allow duplex or tone')))
elif not chirp_common.in_range(
mem.freq, [AIRBAND]) and mem.mode == 'AM':
msgs.append(chirp_common.ValidationWarning(
_('Frequency in this range must not be AM mode')))
return msgs + super().validate_memory(mem)


@directory.register
class RadioddityGS5BRadio(Senhaix8800Radio):
Expand Down
20 changes: 7 additions & 13 deletions chirp/drivers/tdh8.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,6 @@
RT_730 = b"\x50\x47\x4F\x4A\x48\xC3\x44"


def in_range(freq, ranges):
for lo, hi in ranges:
if lo <= freq <= hi:
return True
return False


def _do_status(radio, block):
status = chirp_common.Status()
status.msg = "Cloning"
Expand Down Expand Up @@ -1259,9 +1252,9 @@ def get_memory(self, number):
FREQHOP_VALUES, FREQHOP_VALUES[_mem.freqhop]))
mem.extra.append(rs)

if in_range(mem.freq, self._rxbands):
if chirp_common.in_range(mem.freq, self._rxbands):
mem.duplex = 'off'
if in_range(mem.freq, [AIRBAND]):
if chirp_common.in_range(mem.freq, [AIRBAND]):
mem.mode = 'AM'

return mem
Expand Down Expand Up @@ -1328,7 +1321,7 @@ def set_memory(self, mem):
else:
_mem.txfreq = mem.freq / 10

if in_range(mem.freq, self._rxbands):
if chirp_common.in_range(mem.freq, self._rxbands):
_mem.txfreq.fill_raw(b'\xFF')

_mem.rxfreq = mem.freq / 10
Expand Down Expand Up @@ -2463,13 +2456,14 @@ def _set_fm_preset(self, settings):

def validate_memory(self, mem):
msgs = []
if in_range(mem.freq, [AIRBAND]) and not mem.mode == 'AM':
if chirp_common.in_range(mem.freq, [AIRBAND]) and not mem.mode == 'AM':
msgs.append(chirp_common.ValidationWarning(
_('Frequency in this range requires AM mode')))
if not in_range(mem.freq, [AIRBAND]) and mem.mode == 'AM':
if not chirp_common.in_range(mem.freq, [AIRBAND]) and mem.mode == 'AM':
msgs.append(chirp_common.ValidationWarning(
_('Frequency in this range must not be AM mode')))
if not in_range(mem.freq, self._txbands) and mem.duplex != 'off':
if (not chirp_common.in_range(mem.freq, self._txbands) and
mem.duplex != 'off'):
msgs.append(chirp_common.ValidationWarning(
_('Frequency outside TX bands must be duplex=off')))
return msgs + super().validate_memory(mem)
Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/bg_BG.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2024-07-05 10:00+0300\n"
"Last-Translator: Стоян <stoyanster от гмаил>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -651,6 +651,10 @@ msgid ""
"possible to download it!"
msgstr ""

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr "Относно"
Expand Down Expand Up @@ -1365,15 +1369,15 @@ msgstr "Честотата %s е извън поддържания обхват"
msgid "Frequency granularity in kHz"
msgstr "Стъпка на честотата в кХз"

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2012-10-02 22:11+0100\n"
"Last-Translator: Benjamin, HB9EUK <hb9euk@hb9d.org>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -647,6 +647,10 @@ msgid ""
"possible to download it!"
msgstr ""

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr ""
Expand Down Expand Up @@ -1385,15 +1389,15 @@ msgstr ""
msgid "Frequency granularity in kHz"
msgstr ""

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/el.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2023-02-11 15:12+0200\n"
"Last-Translator: Sokratis Alichanidis <sv2hzs@posteo.net>\n"
"Language-Team: Greek\n"
Expand Down Expand Up @@ -651,6 +651,10 @@ msgstr ""
"Μία νέα έκδοση του CHIRP είναι διαθέσιμη. Παρακαλούμε επισκεφθείτε την "
"ιστοσελίδα το συντομότερο δυνατό για να την κατεβάσετε!"

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr "Σχετικά"
Expand Down Expand Up @@ -1381,15 +1385,15 @@ msgstr ""
msgid "Frequency granularity in kHz"
msgstr ""

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2011-11-29 16:07-0800\n"
"Last-Translator: Dan Smith <dan@theine>\n"
"Language-Team: English\n"
Expand Down Expand Up @@ -645,6 +645,10 @@ msgid ""
"possible to download it!"
msgstr ""

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr ""
Expand Down Expand Up @@ -1371,15 +1375,15 @@ msgstr ""
msgid "Frequency granularity in kHz"
msgstr ""

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2024-08-25 00:38-0400\n"
"Last-Translator: MELERIX\n"
"Language-Team: \n"
Expand Down Expand Up @@ -1022,6 +1022,10 @@ msgstr ""
"Una nueva versión de CHIRP está disponible, ¡Por favor visita el sitio web "
"tan pronto como sea posible para descargarla!"

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr "Acerca de"
Expand Down Expand Up @@ -1858,15 +1862,15 @@ msgstr "La frecuencia %s está fuera del rango soportado"
msgid "Frequency granularity in kHz"
msgstr "Granularidad de frecuencia en kHz"

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2024-05-22 16:39-0400\n"
"Last-Translator: Alexandre J. Raymond <alexandre.j.raymond@gmail.com>\n"
"Language-Team: French\n"
Expand Down Expand Up @@ -1020,6 +1020,10 @@ msgstr ""
"Une nouvelle version de CHIRP est disponible. Visitez le site internet dès "
"que possible pour la télécharger!"

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr "À propos"
Expand Down Expand Up @@ -1858,15 +1862,15 @@ msgstr ""
msgid "Frequency granularity in kHz"
msgstr "Granularité fréquence en kHz"

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
12 changes: 8 additions & 4 deletions chirp/locale/hu.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-31 08:35-0700\n"
"POT-Creation-Date: 2024-09-01 16:01-0700\n"
"PO-Revision-Date: 2015-01-28 13:47+0100\n"
"Last-Translator: Attila Joubert <joubert.attila@gmail.com>\n"
"Language-Team: English\n"
Expand Down Expand Up @@ -646,6 +646,10 @@ msgid ""
"possible to download it!"
msgstr ""

#: ../drivers/ga510.py:1070
msgid "AM mode does not allow duplex or tone"
msgstr ""

#: ../wxui/main.py:924
msgid "About"
msgstr ""
Expand Down Expand Up @@ -1385,15 +1389,15 @@ msgstr ""
msgid "Frequency granularity in kHz"
msgstr ""

#: ../drivers/tdh8.py:2471
#: ../drivers/ga510.py:1074 ../drivers/tdh8.py:2464
msgid "Frequency in this range must not be AM mode"
msgstr ""

#: ../drivers/tdh8.py:2468
#: ../drivers/ga510.py:1067 ../drivers/tdh8.py:2461
msgid "Frequency in this range requires AM mode"
msgstr ""

#: ../drivers/tdh8.py:2474
#: ../drivers/tdh8.py:2468
msgid "Frequency outside TX bands must be duplex=off"
msgstr ""

Expand Down
Loading

0 comments on commit 68591a7

Please sign in to comment.