2019-08-09 17:53:09 +02:00
|
|
|
# Support for custom board pin aliases
|
|
|
|
#
|
2021-08-19 21:27:50 +02:00
|
|
|
# Copyright (C) 2019-2021 Kevin O'Connor <kevin@koconnor.net>
|
2019-08-09 17:53:09 +02:00
|
|
|
#
|
|
|
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
|
|
|
|
|
|
|
class PrinterBoardAliases:
|
2020-11-20 17:36:36 +01:00
|
|
|
def __init__(self, config):
|
2019-08-09 17:53:09 +02:00
|
|
|
ppins = config.get_printer().lookup_object('pins')
|
2021-08-19 21:27:50 +02:00
|
|
|
mcu_names = config.getlist('mcu', ('mcu',))
|
2020-11-20 17:36:36 +01:00
|
|
|
pin_resolvers = [ppins.get_pin_resolver(n) for n in mcu_names]
|
|
|
|
options = ["aliases"] + config.get_prefix_options("aliases_")
|
|
|
|
for opt in options:
|
2021-08-19 21:27:50 +02:00
|
|
|
aliases = config.getlists(opt, seps=('=', ','), count=2)
|
|
|
|
for name, value in aliases:
|
2020-11-20 17:36:36 +01:00
|
|
|
if value.startswith('<') and value.endswith('>'):
|
|
|
|
for pin_resolver in pin_resolvers:
|
|
|
|
pin_resolver.reserve_pin(name, value)
|
|
|
|
else:
|
|
|
|
for pin_resolver in pin_resolvers:
|
|
|
|
pin_resolver.alias_pin(name, value)
|
2019-08-09 17:53:09 +02:00
|
|
|
|
|
|
|
def load_config(config):
|
2020-11-20 17:36:36 +01:00
|
|
|
return PrinterBoardAliases(config)
|
2019-08-09 17:53:09 +02:00
|
|
|
|
|
|
|
def load_config_prefix(config):
|
2020-11-20 17:36:36 +01:00
|
|
|
return PrinterBoardAliases(config)
|