mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-17 17:01:58 +08:00
26 lines
1.2 KiB
Django/Jinja
26 lines
1.2 KiB
Django/Jinja
|
|
# TODO: This file is dangerous because the enums could potentially change between API versions. Should transmit as part of the JSON.
|
|
# To regenerate this file, nagivate to the top level of the ODrive repository and run:
|
|
# python Firmware/interface_generator_stub.py --definitions Firmware/odrive-interface.yaml --template tools/enums_template.j2 --output tools/odrive/enums.py
|
|
|
|
import enum
|
|
|
|
[%- for _, enum in value_types.items() %]
|
|
[%- if enum.is_enum %]
|
|
|
|
# [[enum.fullname]]
|
|
[%- for k, value in enum['values'].items() %]
|
|
[[((((enum.parent.name if enum.name in ['Error', 'Mode'] else '') + enum.name) | to_macro_case) + "_" + (k | to_macro_case)).ljust(40)]] = [% if enum.is_flags %]0x[['%08x' | format(value.value)]][% else %][[value.value]][% endif %]
|
|
[%- endfor %]
|
|
[%- endif %]
|
|
[%- endfor %]
|
|
|
|
[%- for _, enum in value_types.items() %]
|
|
[%- if enum.is_enum %]
|
|
class [[(enum.parent.name if enum.name in ['Error', 'Mode', 'Protocol'] else '') + enum.name]][% if enum.is_flags %](enum.IntFlag)[% else %](enum.Enum)[% endif %]:
|
|
[%- for k, value in enum['values'].items() %]
|
|
[[((k | to_macro_case)).ljust(40)]] = [% if enum.is_flags %]0x[['%08x' | format(value.value)]][% else %][[value.value]][% endif %]
|
|
[%- endfor %]
|
|
[%- endif %]
|
|
[%- endfor %]
|