chore: store more hardware settings in hwdef JSON files (#7031)
This commit is contained in:
@@ -6,6 +6,9 @@ import json
|
||||
from hal_switches import Switch, parse_switches
|
||||
from hal_adc import ADCInput, SPI_ADCInput, ADC, ADCInputParser
|
||||
from hal_keys import Key, Trim, parse_trims, parse_keys
|
||||
from hal_lcd import Display, parse_lcd
|
||||
from hal_cfs import CFS, parse_cfs
|
||||
from hal_misc import Misc, parse_misc
|
||||
|
||||
import legacy_names
|
||||
|
||||
@@ -62,6 +65,12 @@ class DictEncoder(json.JSONEncoder):
|
||||
return prune_dict(obj.__dict__)
|
||||
if isinstance(obj, Key):
|
||||
return prune_dict(obj.__dict__)
|
||||
if isinstance(obj, Display):
|
||||
return prune_dict(obj.__dict__)
|
||||
if isinstance(obj, CFS):
|
||||
return prune_dict(obj.__dict__)
|
||||
if isinstance(obj, Misc):
|
||||
return prune_dict(obj.__dict__)
|
||||
|
||||
# Let the base class default method raise the TypeError
|
||||
return json.JSONEncoder.default(self, obj)
|
||||
@@ -89,5 +98,14 @@ def parse_defines(filename, target):
|
||||
trims = parse_trims(hw_defs)
|
||||
out_defs["trims"] = trims
|
||||
|
||||
display = parse_lcd(hw_defs)
|
||||
out_defs["display"] = display
|
||||
|
||||
cfs = parse_cfs(hw_defs)
|
||||
out_defs["custom_switches"] = cfs
|
||||
|
||||
misc = parse_misc(hw_defs)
|
||||
out_defs["hardware"] = misc
|
||||
|
||||
print(json.dumps(out_defs, cls=DictEncoder, indent=2))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user