feat: support for RadioMaster GX12 (#5703)
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
raphaelcoeffic
philmoz
Peter Feerick
parent
0f86cd9a95
commit
36cdd93a1a
@@ -164,6 +164,11 @@ def main():
|
||||
cmake_options["PCBREV"] = "MT12"
|
||||
firmware_options = options_radiomaster_mt12
|
||||
maxsize = 65536 * 8 * 2
|
||||
elif board_name == "gx12":
|
||||
cmake_options["PCB"] = "X7"
|
||||
cmake_options["PCBREV"] = "GX12"
|
||||
firmware_options = options_radiomaster_gx12
|
||||
maxsize = 65536 * 8 * 2
|
||||
elif board_name == "t8":
|
||||
cmake_options["PCB"] = "X7"
|
||||
cmake_options["PCBREV"] = "T8"
|
||||
|
||||
@@ -259,6 +259,18 @@ options_radiomaster_boxer = {
|
||||
"internalelrs": ("INTERNAL_MODULE_ELRS", "YES", "NO"),
|
||||
}
|
||||
|
||||
options_radiomaster_gx12 = {
|
||||
"noheli": ("HELI", "NO", "YES"),
|
||||
"lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"),
|
||||
"nogvars": ("GVARS", "NO", "YES"),
|
||||
"faimode": ("FAI", "YES", None),
|
||||
"faichoice": ("FAI", "CHOICE", None),
|
||||
"nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"),
|
||||
"flexr9m": ("MODULE_PROTOCOL_FLEX", "YES", None),
|
||||
"afhds3": ("AFHDS3", "YES", "NO"),
|
||||
"internalelrs": ("INTERNAL_MODULE_ELRS", "YES", "NO"),
|
||||
}
|
||||
|
||||
options_radiomaster_pocket = {
|
||||
"noheli": ("HELI", "NO", "YES"),
|
||||
"lua": ("LUA", "YES", "NO_MODEL_SCRIPTS"),
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
from switch_config import switch_cfg_by_target
|
||||
|
||||
class Switch:
|
||||
|
||||
TYPE_2POS = '2POS'
|
||||
TYPE_3POS = '3POS'
|
||||
TYPE_ADC = 'ADC'
|
||||
|
||||
class Switch:
|
||||
TYPE_2POS = "2POS"
|
||||
TYPE_3POS = "3POS"
|
||||
TYPE_ADC = "ADC"
|
||||
|
||||
def __init__(self, name, sw_type, flags):
|
||||
self.name = name
|
||||
self.type = sw_type
|
||||
self.flags = flags
|
||||
self.inverted = False
|
||||
self.default = None
|
||||
self.display = []
|
||||
|
||||
|
||||
class Switch2POS(Switch):
|
||||
def __init__(self, name, gpio, pin, flags=0):
|
||||
super(Switch2POS, self).__init__(name, Switch.TYPE_2POS, flags)
|
||||
self.gpio = gpio
|
||||
self.pin = pin
|
||||
|
||||
|
||||
|
||||
class Switch3POS(Switch):
|
||||
def __init__(self, name, gpio_high, pin_high, gpio_low, pin_low, flags=0):
|
||||
super(Switch3POS, self).__init__(name, Switch.TYPE_3POS, flags)
|
||||
@@ -25,22 +30,38 @@ class Switch3POS(Switch):
|
||||
self.gpio_low = gpio_low
|
||||
self.pin_low = pin_low
|
||||
|
||||
|
||||
class SwitchADC(Switch):
|
||||
def __init__(self, name, adc_input, flags=0):
|
||||
super(SwitchADC, self).__init__(name, Switch.TYPE_ADC, flags)
|
||||
self.adc_input = adc_input
|
||||
|
||||
|
||||
|
||||
class SwitchCustom(Switch):
|
||||
def __init__(self, name, type, flags=0):
|
||||
super(SwitchCustom, self).__init__(name, type, flags)
|
||||
|
||||
|
||||
def AZ_seq():
|
||||
return [chr(i) for i in range(ord('A'), ord('Z') + 1)]
|
||||
return [chr(i) for i in range(ord("A"), ord("Z") + 1)]
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
from sys import stderr
|
||||
|
||||
print(*args, file=stderr, **kwargs)
|
||||
|
||||
|
||||
def prefixsearch(dictionary, prefix):
|
||||
for k in dictionary.keys():
|
||||
if k.startswith(prefix):
|
||||
return k[len(prefix) :]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
# switches from A to Z
|
||||
def parse_switches(target, hw_defs, adc_parser):
|
||||
|
||||
switches = []
|
||||
|
||||
def find_switch(name):
|
||||
@@ -48,22 +69,22 @@ def parse_switches(target, hw_defs, adc_parser):
|
||||
if name == sw.name:
|
||||
return sw
|
||||
return None
|
||||
|
||||
|
||||
for s in AZ_seq():
|
||||
name = f"S{s}"
|
||||
|
||||
name = f'S{s}'
|
||||
reg = f"SWITCHES_GPIO_REG_{s}"
|
||||
reg_high = f"{reg}_H"
|
||||
reg_low = f"{reg}_L"
|
||||
|
||||
reg = f'SWITCHES_GPIO_REG_{s}'
|
||||
reg_high = f'{reg}_H'
|
||||
reg_low = f'{reg}_L'
|
||||
pin = f"SWITCHES_GPIO_PIN_{s}"
|
||||
pin_high = f"{pin}_H"
|
||||
pin_low = f"{pin}_L"
|
||||
|
||||
pin = f'SWITCHES_GPIO_PIN_{s}'
|
||||
pin_high = f'{pin}_H'
|
||||
pin_low = f'{pin}_L'
|
||||
inverted = f"SWITCHES_{s}_INVERTED"
|
||||
|
||||
inverted = f'SWITCHES_{s}_INVERTED'
|
||||
|
||||
adc_input_name = f'SW{s}'
|
||||
adc_input_name = f"SW{s}"
|
||||
custom = f"SWITCHES_{s}_"
|
||||
|
||||
switch = None
|
||||
if reg in hw_defs:
|
||||
@@ -78,10 +99,13 @@ def parse_switches(target, hw_defs, adc_parser):
|
||||
reg_low = hw_defs[reg_low]
|
||||
pin_low = hw_defs[pin_low]
|
||||
switch = Switch3POS(name, reg_high, pin_high, reg_low, pin_low)
|
||||
else:
|
||||
elif adc_parser.find_input(adc_input_name):
|
||||
# ADC switch
|
||||
if adc_parser.find_input(adc_input_name):
|
||||
switch = SwitchADC(name, adc_input_name)
|
||||
switch = SwitchADC(name, adc_input_name)
|
||||
else:
|
||||
type = prefixsearch(hw_defs, custom)
|
||||
if type is not None:
|
||||
switch = SwitchCustom(name, type)
|
||||
|
||||
if switch:
|
||||
if inverted in hw_defs:
|
||||
@@ -89,18 +113,22 @@ def parse_switches(target, hw_defs, adc_parser):
|
||||
|
||||
cfg = switch_cfg_by_target(target, name)
|
||||
if cfg:
|
||||
switch.default = cfg.get('default')
|
||||
switch.display = cfg.get('display')
|
||||
#eprint(switch.default)
|
||||
switch.default = cfg.get("default")
|
||||
switch.display = cfg.get("display")
|
||||
# eprint(switch.default)
|
||||
|
||||
switches.append(switch)
|
||||
|
||||
for i in range(1, 6 + 1):
|
||||
f_sw_marker = f'FUNCTION_SWITCH_{i}'
|
||||
f_sw_marker = f"FUNCTION_SWITCH_{i}"
|
||||
if f_sw_marker in hw_defs:
|
||||
switch = find_switch(hw_defs[f_sw_marker])
|
||||
if switch:
|
||||
switch.type = 'FSWITCH'
|
||||
switch.name = f'SW{i}'
|
||||
switch.type = "FSWITCH"
|
||||
switch.name = f"SW{i}"
|
||||
else:
|
||||
switch = SwitchCustom(f"SW{i}", Switch.TYPE_2POS)
|
||||
switch.type = "FSWITCH"
|
||||
switches.append(switch)
|
||||
|
||||
return switches
|
||||
|
||||
@@ -1,34 +1,32 @@
|
||||
|
||||
#
|
||||
# These methods are used to build helper indexes on JSON structures
|
||||
#
|
||||
def build_adc_index(adc_inputs):
|
||||
|
||||
i = 0
|
||||
index = {}
|
||||
for adc_input in adc_inputs['inputs']:
|
||||
name = adc_input['name']
|
||||
for adc_input in adc_inputs["inputs"]:
|
||||
name = adc_input["name"]
|
||||
index[name] = i
|
||||
i = i + 1
|
||||
|
||||
return index
|
||||
|
||||
|
||||
def append_to_index(d, key, val):
|
||||
if key not in d:
|
||||
d[key] = []
|
||||
|
||||
d[key].append(val)
|
||||
|
||||
def build_adc_gpio_port_index(adc_inputs):
|
||||
|
||||
def build_adc_gpio_port_index(adc_inputs):
|
||||
i = 0
|
||||
gpios = {}
|
||||
for adc_input in adc_inputs['inputs']:
|
||||
|
||||
if adc_input['adc'] == 'SPI':
|
||||
for adc_input in adc_inputs["inputs"]:
|
||||
if adc_input["adc"] == "SPI":
|
||||
continue
|
||||
|
||||
gpio = adc_input['gpio']
|
||||
|
||||
gpio = adc_input["gpio"]
|
||||
if gpio is None:
|
||||
i = i + 1
|
||||
continue
|
||||
@@ -36,57 +34,60 @@ def build_adc_gpio_port_index(adc_inputs):
|
||||
if gpio not in gpios:
|
||||
gpios[gpio] = []
|
||||
|
||||
pin = {
|
||||
'pin': adc_input['pin'],
|
||||
'idx': i
|
||||
}
|
||||
pin = {"pin": adc_input["pin"], "idx": i}
|
||||
|
||||
gpios[gpio].append(pin)
|
||||
i = i + 1
|
||||
|
||||
return gpios
|
||||
|
||||
def build_switch_gpio_port_index(switches):
|
||||
|
||||
i = 0
|
||||
def build_switch_gpio_port_index(switches):
|
||||
gpios = {}
|
||||
for switch in switches:
|
||||
sw_type = switch['type']
|
||||
sw_type = switch["type"]
|
||||
|
||||
if sw_type == '2POS' or sw_type == 'FSWITCH':
|
||||
append_to_index(gpios, switch['gpio'], switch['pin'])
|
||||
if sw_type == "2POS" or sw_type == "FSWITCH":
|
||||
gpio = switch.get("gpio")
|
||||
pin = switch.get("pin")
|
||||
if gpio is not None and pin is not None:
|
||||
append_to_index(gpios, gpio, pin)
|
||||
|
||||
elif sw_type == '3POS':
|
||||
elif sw_type == "3POS":
|
||||
gpio_high = switch.get("gpio_high")
|
||||
pin_high = switch.get("pin_high")
|
||||
if gpio_high is not None and pin_high is not None:
|
||||
append_to_index(gpios, gpio_high, pin_high)
|
||||
|
||||
append_to_index(gpios, switch['gpio_high'], switch['pin_high'])
|
||||
append_to_index(gpios, switch['gpio_low'], switch['pin_low'])
|
||||
gpio_low = switch.get("gpio_low")
|
||||
pin_low = switch.get("pin_low")
|
||||
if gpio_low is not None and pin_low is not None:
|
||||
append_to_index(gpios, gpio_low, pin_low)
|
||||
|
||||
return gpios
|
||||
|
||||
|
||||
def build_trim_gpio_port_index(trims):
|
||||
|
||||
def index_contact(gpios, contact):
|
||||
gpio = contact['gpio']
|
||||
pin = contact['pin']
|
||||
gpio = contact["gpio"]
|
||||
pin = contact["pin"]
|
||||
if gpio and pin:
|
||||
append_to_index(gpios, contact['gpio'], contact['pin'])
|
||||
append_to_index(gpios, contact["gpio"], contact["pin"])
|
||||
|
||||
i = 0
|
||||
gpios = {}
|
||||
for trim in trims:
|
||||
dec = trim.get('dec')
|
||||
inc = trim.get('inc')
|
||||
dec = trim.get("dec")
|
||||
inc = trim.get("inc")
|
||||
if dec and inc:
|
||||
index_contact(gpios, dec)
|
||||
index_contact(gpios, inc)
|
||||
|
||||
return gpios
|
||||
|
||||
def build_key_gpio_port_index(keys):
|
||||
|
||||
i = 0
|
||||
def build_key_gpio_port_index(keys):
|
||||
gpios = {}
|
||||
for key in keys:
|
||||
append_to_index(gpios, key['gpio'], key['pin'])
|
||||
append_to_index(gpios, key["gpio"], key["pin"])
|
||||
|
||||
return gpios
|
||||
|
||||
@@ -343,6 +343,59 @@ LEGACY_NAMES = [
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"targets": {"gx12"},
|
||||
"inputs": {
|
||||
"LH": {
|
||||
"yaml": "Rud",
|
||||
"lua": "rud",
|
||||
"description": "Rudder"
|
||||
},
|
||||
"LV": {
|
||||
"yaml": "Ele",
|
||||
"lua": "ele",
|
||||
"description": "Elevator"
|
||||
},
|
||||
"RV": {
|
||||
"yaml": "Thr",
|
||||
"lua": "thr",
|
||||
"description": "Throttle"
|
||||
},
|
||||
"RH": {
|
||||
"yaml": "Ail",
|
||||
"lua": "ail",
|
||||
"description": "Aileron"
|
||||
},
|
||||
"P1": {
|
||||
"yaml": "POT1",
|
||||
"lua": "p1",
|
||||
"label": "P1",
|
||||
"short_label": "1",
|
||||
"description": "Potentiometer 1"
|
||||
},
|
||||
"P2": {
|
||||
"yaml": "POT2",
|
||||
"lua": "p2",
|
||||
"label": "P2",
|
||||
"short_label": "2",
|
||||
"description": "Potentiometer 2"
|
||||
},
|
||||
"SL1": {
|
||||
"yaml": "SLIDER1",
|
||||
"lua": "s1",
|
||||
"label": "S1",
|
||||
"short_label": "S1",
|
||||
"description": "Left slider"
|
||||
},
|
||||
"SL2": {
|
||||
"yaml": "SLIDER2",
|
||||
"lua": "s2",
|
||||
"label": "S2",
|
||||
"short_label": "S2",
|
||||
"description": "Right slider"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"targets": {"mt12"},
|
||||
"inputs": {
|
||||
|
||||
@@ -4,7 +4,14 @@ POT_CONFIG = {
|
||||
"boxer": {
|
||||
"P1": {"default": "POT_CENTER"},
|
||||
"P2": {"default": "POT_CENTER"},
|
||||
"P3": {"default": "MULTIPOS"}
|
||||
"S1": {"default": "SLIDER"},
|
||||
"S2": {"default": "SLIDER"}
|
||||
},
|
||||
"gx12": {
|
||||
"P1": {"default": "POT_CENTER"},
|
||||
"P2": {"default": "POT_CENTER"},
|
||||
"SL1": {"default": "SLIDER"},
|
||||
"SL2": {"default": "SLIDER"}
|
||||
},
|
||||
"el18": {
|
||||
"P1": {"default": "POT_CENTER"},
|
||||
|
||||
@@ -11,15 +11,18 @@ static const stm32_switch_t _switch_defs[] = {
|
||||
{% if switch.type == '2POS' %}
|
||||
{
|
||||
"{{ switch.name }}",
|
||||
{{ switch.gpio }}, {{ switch.pin }},
|
||||
{{ switch.gpio or "nullptr" }},
|
||||
{{ switch.pin or 0 }},
|
||||
nullptr, 0,
|
||||
SWITCH_HW_2POS, {{ 'SWITCH_HW_INVERTED' if switch.inverted else 0 }}
|
||||
},
|
||||
{% elif switch.type == '3POS' %}
|
||||
{
|
||||
"{{ switch.name }}",
|
||||
{{ switch.gpio_high }}, {{ switch.pin_high }},
|
||||
{{ switch.gpio_low }}, {{ switch.pin_low }},
|
||||
{{ switch.gpio_high or "nullptr" }},
|
||||
{{ switch.pin_high or 0 }},
|
||||
{{ switch.gpio_low or "nullptr" }},
|
||||
{{ switch.pin_low or 0 }},
|
||||
SWITCH_HW_3POS, {{ 'SWITCH_HW_INVERTED' if switch.inverted else 0 }}
|
||||
},
|
||||
{% elif switch.type == 'ADC' %}
|
||||
@@ -34,7 +37,8 @@ static const stm32_switch_t _switch_defs[] = {
|
||||
{% for switch in function_switches %}
|
||||
{
|
||||
"{{ switch.name }}",
|
||||
{{ switch.gpio }}, {{ switch.pin }},
|
||||
{{ switch.gpio or "nullptr" }},
|
||||
{{ switch.pin or 0 }},
|
||||
nullptr, 0,
|
||||
SWITCH_HW_2POS, {{ 'SWITCH_HW_INVERTED' if switch.inverted else 0 }}
|
||||
},
|
||||
|
||||
@@ -5,11 +5,25 @@ SWITCH_CONFIG = {
|
||||
# left side
|
||||
"SA": {"default": "2POS", "display": [0, 0]},
|
||||
"SB": {"default": "3POS", "display": [0, 1]},
|
||||
"SE": {"default": "2POS", "display": [0, 2]},
|
||||
"SE": {"default": "3POS", "display": [0, 2]},
|
||||
"SG": {"default": "2POS", "display": [0, 3]},
|
||||
# right side
|
||||
"SC": {"default": "3POS", "display": [1, 0]},
|
||||
"SD": {"default": "2POS", "display": [1, 1]},
|
||||
"SF": {"default": "TOGGLE", "display": [1, 2]},
|
||||
"SH": {"default": "2POS", "display": [1, 3]},
|
||||
},
|
||||
"gx12": {
|
||||
# left side
|
||||
"SA": {"default": "TOGGLE", "display": [0, 0]},
|
||||
"SB": {"default": "3POS", "display": [0, 1]},
|
||||
"SE": {"default": "3POS", "display": [0, 2]},
|
||||
"SG": {"default": "TOGGLE", "display": [0, 3]},
|
||||
# right side
|
||||
"SC": {"default": "3POS", "display": [1, 1]},
|
||||
"SD": {"default": "TOGGLE", "display": [1, 0]},
|
||||
"SF": {"default": "3POS", "display": [1, 2]},
|
||||
"SH": {"default": "TOGGLE", "display": [1, 3]},
|
||||
},
|
||||
"commando8": {
|
||||
# left side
|
||||
|
||||
Reference in New Issue
Block a user