fix(hw_defs): improve template error reporting in code generator (#7190)
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#
|
||||
# These methods are used to build helper indexes on JSON structures
|
||||
# These methods are used to build helper indexes on data structures
|
||||
#
|
||||
def build_adc_index(adc_inputs):
|
||||
i = 0
|
||||
index = {}
|
||||
for adc_input in adc_inputs["inputs"]:
|
||||
name = adc_input["name"]
|
||||
index[name] = i
|
||||
for adc_input in adc_inputs.inputs:
|
||||
index[str(adc_input.name)] = i
|
||||
i = i + 1
|
||||
|
||||
return index
|
||||
@@ -22,11 +21,11 @@ def append_to_index(d, key, val):
|
||||
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 str(adc_input.adc) == "SPI":
|
||||
continue
|
||||
|
||||
gpio = adc_input["gpio"]
|
||||
gpio = getattr(adc_input, "gpio", None)
|
||||
if gpio is None:
|
||||
i = i + 1
|
||||
continue
|
||||
@@ -34,7 +33,7 @@ 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
|
||||
@@ -45,22 +44,22 @@ def build_adc_gpio_port_index(adc_inputs):
|
||||
def build_switch_gpio_port_index(switches):
|
||||
gpios = {}
|
||||
for switch in switches:
|
||||
sw_type = switch["type"]
|
||||
sw_type = str(switch.type)
|
||||
|
||||
if sw_type == "2POS" or sw_type == "FSWITCH":
|
||||
gpio = switch.get("gpio")
|
||||
pin = switch.get("pin")
|
||||
gpio = switch.gpio
|
||||
pin = switch.pin
|
||||
if gpio is not None and pin is not None:
|
||||
append_to_index(gpios, gpio, pin)
|
||||
|
||||
elif sw_type == "3POS":
|
||||
gpio_high = switch.get("gpio_high")
|
||||
pin_high = switch.get("pin_high")
|
||||
gpio_high = switch.gpio_high
|
||||
pin_high = switch.pin_high
|
||||
if gpio_high is not None and pin_high is not None:
|
||||
append_to_index(gpios, gpio_high, pin_high)
|
||||
|
||||
gpio_low = switch.get("gpio_low")
|
||||
pin_low = switch.get("pin_low")
|
||||
gpio_low = switch.gpio_low
|
||||
pin_low = switch.pin_low
|
||||
if gpio_low is not None and pin_low is not None:
|
||||
append_to_index(gpios, gpio_low, pin_low)
|
||||
|
||||
@@ -88,6 +87,6 @@ def build_trim_gpio_port_index(trims):
|
||||
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
|
||||
return gpios
|
||||
|
||||
Reference in New Issue
Block a user