pins: Add support for pull down resistors

Add initial support for selecting pull down resistors (for
micro-controllers that support it).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2019-02-27 11:07:51 -05:00
parent b6589406d4
commit dddfb681c7
6 changed files with 40 additions and 20 deletions

View File

@@ -215,8 +215,10 @@ class PrinterPins:
share_type=None):
desc = pin_desc.strip()
pullup = invert = 0
if can_pullup and desc.startswith('^'):
if can_pullup and (desc.startswith('^') or desc.startswith('~')):
pullup = 1
if desc.startswith('~'):
pullup = -1
desc = desc[1:].strip()
if can_invert and desc.startswith('!'):
invert = 1
@@ -227,7 +229,7 @@ class PrinterPins:
chip_name, pin = [s.strip() for s in desc.split(':', 1)]
if chip_name not in self.chips:
raise error("Unknown pin chip name '%s'" % (chip_name,))
if [c for c in '^!: ' if c in pin]:
if [c for c in '^~!: ' if c in pin]:
format = ""
if can_pullup:
format += "[^] "