This commit is contained in:
zvecr
2022-09-29 23:44:19 +01:00
parent 76a45a4e24
commit 1dbb4c0f96
12 changed files with 359 additions and 8 deletions
+26 -5
View File
@@ -2,10 +2,9 @@ from collections import namedtuple
from enum import IntFlag, IntEnum
from struct import Struct
{% set type_definitions = [{'name':'XAPRequest', 'members': 'token length data', 'fmt':'<HB61s'}, {'name':'XAPResponse', 'members': 'token flags length data', 'fmt':'<HBB60s'}] %}
{% for item in type_definitions -%}
class {{ item.name }}(namedtuple('{{ item.name }}', '{{ item.members }}')):
fmt = Struct('{{ item.fmt }}')
{% macro gen_struct(name, members, fmt) -%}
class {{ name }}(namedtuple('{{ name }}', '{{ members }}')):
fmt = Struct('{{ fmt }}')
def __new__(cls, *args):
return super().__new__(cls, *args)
@@ -18,7 +17,29 @@ class {{ item.name }}(namedtuple('{{ item.name }}', '{{ item.members }}')):
return self.fmt.pack(*list(self))
{% endfor -%}
{% endmacro -%}
{% set type_definitions = [
{'name':'XAPRequest', 'members': 'token length data', 'fmt':'<HB61s'},
{'name':'XAPResponse', 'members': 'token flags length data', 'fmt':'<HBB60s'},
{'name':'XAPConfigRgblight', 'members': 'enable mode hue sat val speed', 'fmt':'<BBBBBB'}
] %}
{% for item in type_definitions -%}{{ gen_struct(item.name, item.members, item.fmt) }}{% endfor -%}
# Spec structs
{%- for item in xap.routes.values() recursive -%}
{%- if item.routes -%}
{{ loop(item.routes.values()) }}
{%- endif -%}
{% if item.request_struct_members %}
# TODO: gen inbound object for {{ to_snake(item.define) }}
{%- endif -%}
{% if item.return_struct_members %}
# TODO: gen outbound object for {{ to_snake(item.define) }}
{%- endif -%}
{%- endfor %}
class XAPSecureStatus(IntEnum):
LOCKED = 0x00
UNLOCKING = 0x01
-1
View File
@@ -181,7 +181,6 @@
'''
This subsystem allows for control over the lighting subsystem.
'''
enable_if_preprocessor: defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
routes: {
0x01: {
type: command
+78
View File
@@ -0,0 +1,78 @@
{
version: 0.3.0
routes: {
0x06: {
routes: {
0x03: {
type: router
name: rgblight
define: RGBLIGHT
description:
'''
This subsystem allows for control over the rgblight subsystem.
'''
enable_if_preprocessor: defined(RGBLIGHT_ENABLE)
routes: {
0x01: {
type: command
name: Capabilities Query
define: CAPABILITIES_QUERY
description:
'''
rgblight subsystem capabilities query. Each bit should be considered as a "usable" route within this subsystem.
'''
return_type: u32
return_purpose: capabilities
return_constant: XAP_ROUTE_LIGHTING_RGBLIGHT_CAPABILITIES
}
0x02: {
type: command
name: Get Enabled Effects
define: GET_ENABLED_EFFECTS
description: Each bit should be considered as a "usable" effect id
return_type: u64
return_constant: ENABLED_RGBLIGHT_EFFECTS
}
0x03: {
type: command
name: Get Config
define: GET_CONFIG
description: Query the current config.
return_type: struct
return_struct_length: 6
return_struct_members: [
{
type: u8
name: enable
},
{
type: u8
name: mode
},
{
type: u8
name: hue
},
{
type: u8
name: sat
},
{
type: u8
name: val
},
{
type: u8
name: speed
},
]
return_execute: get_rgblight_config
}
}
}
}
}
}
}