crystalfontz.dbus.domain

DBus uses a collection of types that are documented in the specification. The base types are more fine-grained than Python's base types, but are non-nullable - ie, there's no None type in DBus. Moreover, its collection types don't map cleanly to arbitrary Python class instances - rather, you get basic structs (which correspond to Python tuples) and arrays (which correspond to Python lists). This means that, when interacting with the DBus client, you will need to work with types other than the domain objects used in the standard crystalfontz client.

To facilitate this, crystalfontz includes a submodule for mapping between domain objects and DBus types, at crystalfontz.dbus.domain. This module exports both aliases for the types used by the DBus interface, and mapper classes for packing and unpacking domain objects to and from DBus types.

Represent entities in the crystalfontz domain model with dbus-compatible types, and map between the crystalfontz and dbus domains.

While these classes don't all implement the same protocols, they do follow a number of important conventions.

Naming Conventions

In general classes corresponding to entities share their names, but with a postfix naming convention.

Dbus types corresponding to entities in the crystalfontz domain have T appended to them. For instance, the dbus type corresponding to Optional[bytes] is OptBytesT, which corresponds to the "ay" dbus type signature. This applies to more complex entities as well - for instance, the dbus type corresponding to the Versions response is VersionsT.

Mappers - classes that map between entities and dbus types - have M appended to their names. For intance, the mapper for Optional[bytes] and OptBytesT is called OptBytesM.

pack methods and none properties

Mappers which support it have a pack class method, which takes objects from the crystalfontz domain and converts them into dbus data types. For instance, OptBytesM packs an Optional[bytes] value into a OptBytesT.

Additionally, mappers representing optional data have a property called none, which contains the value that the dbus client canonically interprets as None. For instance, TimeoutM.none is equal to -1.0. Note that, in this case, the dbus client treats any value less than 0 as None.

As a user, you would typically use these APIs when constructing arguments for the dbus client. For example, if you were to call dbus_client.ping, it would look like this:

pong: PongT = await dbus_client.ping(
    b"Hello world!", TimeoutM.pack(timeout), RetryTimesM.pack(retry_times)
)

unpack methods

Dbus client methods will not only be called with dbus-compatible types, but will return dbus-compatible types as well. Sometimes these are sensible - in fact, most methods return None. However, for non-trivial response types, you will likely want to unpack them back into the crystalfontz domain. For example, the ping command returns a PongT, and you will probably want to unpack it into a Pong object:

print(PongM.unpack(pong).response)

ConfigM

Map Config to and from ConfigT (Tuple[Optional[str], str, str, str, str, int, float, int]).

Source code in crystalfontz/dbus/domain/config.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class ConfigM:
    """
    Map `Config` to and from `ConfigT`
    (`Tuple[Optional[str], str, str, str, str, int, float, int]`).
    """

    t: ClassVar[str] = struct(
        FileM,
        PortM,
        ModelM,
        RevisionM,
        RevisionM,
        BaudRateM,
        TimeoutM,
        RetryTimesM,
    )

    @staticmethod
    def pack(config: Config) -> ConfigT:
        """
        Pack `Config` to `ConfigT`.
        """

        return (
            FileM.pack(config.file),
            config.port,
            config.model,
            RevisionM.pack(config.hardware_rev),
            RevisionM.pack(config.firmware_rev),
            config.baud_rate,
            TimeoutM.pack(config.timeout),
            RetryTimesM.pack(config.retry_times),
        )

    @staticmethod
    def unpack(config: ConfigT) -> Config:
        """
        Unpack `ConfigT` to `Config`.
        """

        (
            file,
            port,
            model,
            hardware_rev,
            firmware_rev,
            baud_rate,
            timeout,
            retry_times,
        ) = config

        return cast(Any, Config)(
            file=file,
            port=port,
            model=model,
            hardware_rev=RevisionM.unpack(hardware_rev),
            firmware_rev=RevisionM.unpack(firmware_rev),
            baud_rate=baud_rate,
            timeout=TimeoutM.unpack(timeout),
            retry_times=RetryTimesM.unpack(retry_times),
        )

pack(config) staticmethod

Pack Config to ConfigT.

Source code in crystalfontz/dbus/domain/config.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@staticmethod
def pack(config: Config) -> ConfigT:
    """
    Pack `Config` to `ConfigT`.
    """

    return (
        FileM.pack(config.file),
        config.port,
        config.model,
        RevisionM.pack(config.hardware_rev),
        RevisionM.pack(config.firmware_rev),
        config.baud_rate,
        TimeoutM.pack(config.timeout),
        RetryTimesM.pack(config.retry_times),
    )

unpack(config) staticmethod

Unpack ConfigT to Config.

Source code in crystalfontz/dbus/domain/config.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@staticmethod
def unpack(config: ConfigT) -> Config:
    """
    Unpack `ConfigT` to `Config`.
    """

    (
        file,
        port,
        model,
        hardware_rev,
        firmware_rev,
        baud_rate,
        timeout,
        retry_times,
    ) = config

    return cast(Any, Config)(
        file=file,
        port=port,
        model=model,
        hardware_rev=RevisionM.unpack(hardware_rev),
        firmware_rev=RevisionM.unpack(firmware_rev),
        baud_rate=baud_rate,
        timeout=TimeoutM.unpack(timeout),
        retry_times=RetryTimesM.unpack(retry_times),
    )

CursorStyleM

Map CursorStyle to and from CursorStyleT (int).

Source code in crystalfontz/dbus/domain/cursor.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class CursorStyleM:
    """
    Map `CursorStyle` to and from `CursorStyleT` (`int`).
    """

    t: ClassVar[str] = "q"

    @staticmethod
    def pack(style: CursorStyle) -> CursorStyleT:
        """
        Pack `CursorStyle` to `CursorStyleT`.
        """

        return style.value

    @staticmethod
    def unpack(style: CursorStyleT) -> CursorStyle:
        """
        Unpack `CursorStyleT` to `CursorStyle`.
        """

        return CURSOR_STYLES[style]

pack(style) staticmethod

Pack CursorStyle to CursorStyleT.

Source code in crystalfontz/dbus/domain/cursor.py
17
18
19
20
21
22
23
@staticmethod
def pack(style: CursorStyle) -> CursorStyleT:
    """
    Pack `CursorStyle` to `CursorStyleT`.
    """

    return style.value

unpack(style) staticmethod

Unpack CursorStyleT to CursorStyle.

Source code in crystalfontz/dbus/domain/cursor.py
25
26
27
28
29
30
31
@staticmethod
def unpack(style: CursorStyleT) -> CursorStyle:
    """
    Unpack `CursorStyleT` to `CursorStyle`.
    """

    return CURSOR_STYLES[style]

DowDeviceInformationM

Map DowDeviceInformation to and from DowDeviceInformationT (Tuple[int, int]).

Source code in crystalfontz/dbus/domain/response.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class DowDeviceInformationM:
    """
    Map `DowDeviceInformation` to and from `DowDeviceInformationT`
    (`Tuple[int, int]`).
    """

    t: ClassVar[str] = t(IndexM, "t")

    @staticmethod
    def pack(info: DowDeviceInformation) -> DowDeviceInformationT:
        return (info.index, info.rom_id)

    @staticmethod
    def unpack(info: DowDeviceInformationT) -> DowDeviceInformation:
        """
        Unpack `DowDeviceInformation` to `DowDeviceInformationT`.
        """

        index, rom_id = info
        return DowDeviceInformation(index, rom_id)

unpack(info) staticmethod

Unpack DowDeviceInformation to DowDeviceInformationT.

Source code in crystalfontz/dbus/domain/response.py
157
158
159
160
161
162
163
164
@staticmethod
def unpack(info: DowDeviceInformationT) -> DowDeviceInformation:
    """
    Unpack `DowDeviceInformation` to `DowDeviceInformationT`.
    """

    index, rom_id = info
    return DowDeviceInformation(index, rom_id)

DowTransactionResultM

Map DowTransactionResult to and from DowTransactionResultT (Tuple[int, bytes, int]).

Source code in crystalfontz/dbus/domain/response.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
class DowTransactionResultM:
    """
    Map `DowTransactionResult` to and from `DowTransactionResultT`
    (`Tuple[int, bytes, int]`).
    """

    t: ClassVar[str] = t(IndexM, BytesM, Uint16M)

    @staticmethod
    def pack(res: DowTransactionResult) -> DowTransactionResultT:
        return (res.index, res.data, res.crc)

    @staticmethod
    def unpack(res: DowTransactionResultT) -> DowTransactionResult:
        """
        Unpack `DowTransactionResultT` to `DowTransactionResult`.
        """

        index, data, crc = res
        return DowTransactionResult(index, data, crc)

unpack(res) staticmethod

Unpack DowTransactionResultT to DowTransactionResult.

Source code in crystalfontz/dbus/domain/response.py
182
183
184
185
186
187
188
189
@staticmethod
def unpack(res: DowTransactionResultT) -> DowTransactionResult:
    """
    Unpack `DowTransactionResultT` to `DowTransactionResult`.
    """

    index, data, crc = res
    return DowTransactionResult(index, data, crc)

GpioReadM

Map GpioRead to and from GpioReadT (Tuple[int, Tuple[bool, bool, bool], int, int]).

Source code in crystalfontz/dbus/domain/response.py
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
class GpioReadM:
    """
    Map `GpioRead` to and from `GpioReadT`
    (`Tuple[int, Tuple[bool, bool, bool], int, int]`).
    """

    t: ClassVar[str] = t(IndexM, struct(GpioStateM), ByteM, GpioSettingsM)

    @staticmethod
    def pack(gpio_read: GpioRead) -> GpioReadT:
        return (
            gpio_read.index,
            GpioStateM.pack(gpio_read.state),
            gpio_read.requested_level,
            GpioSettingsM.pack(gpio_read.settings),
        )

    @staticmethod
    def unpack(gpio_read: GpioReadT) -> GpioRead:
        """
        Unpack `GpioReadT` to `GpioRead`.
        """

        index, state, requested_level, settings = gpio_read
        return GpioRead(
            index=index,
            state=GpioStateM.unpack(state),
            requested_level=requested_level,
            settings=GpioSettingsM.unpack(settings),
        )

unpack(gpio_read) staticmethod

Unpack GpioReadT to GpioRead.

Source code in crystalfontz/dbus/domain/response.py
237
238
239
240
241
242
243
244
245
246
247
248
249
@staticmethod
def unpack(gpio_read: GpioReadT) -> GpioRead:
    """
    Unpack `GpioReadT` to `GpioRead`.
    """

    index, state, requested_level, settings = gpio_read
    return GpioRead(
        index=index,
        state=GpioStateM.unpack(state),
        requested_level=requested_level,
        settings=GpioSettingsM.unpack(settings),
    )

KeyActivityReportM

Map KeyActivityReport to and from KeyActivityReportT

Source code in crystalfontz/dbus/domain/response.py
255
256
257
258
259
260
261
262
263
264
265
266
267
268
class KeyActivityReportM:
    """
    Map `KeyActivityReport` to and from `KeyActivityReportT`
    """

    t: ClassVar[str] = KeyActivityM.t

    @staticmethod
    def pack(report: KeyActivityReport) -> KeyActivityReportT:
        return KeyActivityM.pack(report.activity)

    @staticmethod
    def unpack(report: KeyActivityReportT) -> KeyActivityReport:
        return KeyActivityReport(KeyActivityM.unpack(report))

KeypadBrightnessM

Bases: OptFloatM

Map Optional[float] to and from KeypadBrightnessT (float).

KeypadBrightnessM is an alias for OptFloatM.

Source code in crystalfontz/dbus/domain/keys.py
91
92
93
94
95
96
97
98
class KeypadBrightnessM(OptFloatM):
    """
    Map `Optional[float]` to and from `KeypadBrightnessT` (`float`).

    `KeypadBrightnessM` is an alias for `OptFloatM`.
    """

    t: ClassVar[str] = OptFloatM.t

KeypadPolledM

Map KeypadPolled to and from KeypadPolledT (Tuple[KeyStateT, KeyStateT, KeyStateT, KeyStateT, KeyStateT, KeyStateT], where KeyStateT = Tuple[bool, bool, bool]).

Source code in crystalfontz/dbus/domain/response.py
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
class KeypadPolledM:
    """
    Map `KeypadPolled` to and from `KeypadPolledT`
    (`Tuple[KeyStateT, KeyStateT, KeyStateT, KeyStateT, KeyStateT, KeyStateT]`,
    where `KeyStateT = Tuple[bool, bool, bool]`).
    """

    t: ClassVar[str] = KeyStatesM.t

    @staticmethod
    def pack(polled: KeypadPolled) -> KeyStatesT:
        return KeyStatesM.pack(polled.states)

    @staticmethod
    def unpack(polled: KeypadPolledT) -> KeypadPolled:
        """
        Unpack `KeypadPolledT` to `KeypadPolled`.
        """

        return KeypadPolled(KeyStatesM.unpack(polled))

unpack(polled) staticmethod

Unpack KeypadPolledT to KeypadPolled.

Source code in crystalfontz/dbus/domain/response.py
208
209
210
211
212
213
214
@staticmethod
def unpack(polled: KeypadPolledT) -> KeypadPolled:
    """
    Unpack `KeypadPolledT` to `KeypadPolled`.
    """

    return KeypadPolled(KeyStatesM.unpack(polled))

LcdMemoryM

Map LcdMemory to and from LcdMemoryT (Tuple[int, bytes]).

Source code in crystalfontz/dbus/domain/response.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
class LcdMemoryM:
    """
    Map `LcdMemory` to and from `LcdMemoryT` (`Tuple[int, bytes]`).
    """

    t: ClassVar[str] = t(AddressM, BytesM)

    @staticmethod
    def pack(memory: LcdMemory) -> LcdMemoryT:
        return (memory.address, memory.data)

    @staticmethod
    def unpack(obj: LcdMemoryT) -> LcdMemory:
        """
        Unpack `LcdMemoryT` to `LcdMemory`.
        """

        address, buff = obj
        return LcdMemory(address, buff)

unpack(obj) staticmethod

Unpack LcdMemoryT to LcdMemory.

Source code in crystalfontz/dbus/domain/response.py
132
133
134
135
136
137
138
139
@staticmethod
def unpack(obj: LcdMemoryT) -> LcdMemory:
    """
    Unpack `LcdMemoryT` to `LcdMemory`.
    """

    address, buff = obj
    return LcdMemory(address, buff)

LcdRegisterM

Map LcdRegister to and from LcdRegisterT (bool).

Source code in crystalfontz/dbus/domain/lcd.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class LcdRegisterM:
    """
    Map `LcdRegister` to and from `LcdRegisterT` (`bool`).
    """

    t: ClassVar[str] = "b"

    @staticmethod
    def pack(register: LcdRegister) -> LcdRegisterT:
        return bool(register.value)

    @staticmethod
    def unpack(register: LcdRegisterT) -> LcdRegister:
        return LCD_REGISTERS[register]

OptBytesM

Map Optional[bytes] to and from OptBytesT (bytes).

None values are represented by an empty bytestring.

Source code in crystalfontz/dbus/domain/base.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
class OptBytesM:
    """
    Map `Optional[bytes]` to and from `OptBytesT` (`bytes`).

    None values are represented by an empty bytestring.
    """

    t: ClassVar[str] = BytesM.t
    none: ClassVar[OptBytesT] = b""

    @classmethod
    def pack(cls: Type[Self], buff: Optional[bytes]) -> OptBytesT:
        """
        Pack `Optional[bytes]` to `OptBytesT`.
        """

        if buff is None:
            return cls.none
        return buff

    @staticmethod
    def unpack(buff: OptBytesT) -> Optional[bytes]:
        """
        Unpack `OptBytesT` to `Optional[bytes]`.
        """

        if not buff:
            return None
        return buff

pack(buff) classmethod

Pack Optional[bytes] to OptBytesT.

Source code in crystalfontz/dbus/domain/base.py
175
176
177
178
179
180
181
182
183
@classmethod
def pack(cls: Type[Self], buff: Optional[bytes]) -> OptBytesT:
    """
    Pack `Optional[bytes]` to `OptBytesT`.
    """

    if buff is None:
        return cls.none
    return buff

unpack(buff) staticmethod

Unpack OptBytesT to Optional[bytes].

Source code in crystalfontz/dbus/domain/base.py
185
186
187
188
189
190
191
192
193
@staticmethod
def unpack(buff: OptBytesT) -> Optional[bytes]:
    """
    Unpack `OptBytesT` to `Optional[bytes]`.
    """

    if not buff:
        return None
    return buff

OptFloatM

Map Optional[float] to and from OptFloatT (float), where float values are expected to be positive.

None values are represented by negative values, namely -1.0.

Source code in crystalfontz/dbus/domain/base.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class OptFloatM:
    """
    Map `Optional[float]` to and from `OptFloatT` (`float`), where float values
    are expected to be positive.

    None values are represented by negative values, namely `-1.0`.
    """

    t: ClassVar[str] = "d"
    none: ClassVar[OptFloatT] = -1.0

    @classmethod
    def pack(cls: Type[Self], t: Optional[float]) -> OptFloatT:
        """
        Pack `Optional[float]` to `OptFloatT`.
        """

        return t if t is not None else cls.none

    @staticmethod
    def unpack(t: OptFloatT) -> Optional[float]:
        """
        Unpack `OptFloatT` to `Optional[float]`.
        """

        return t if t >= 0 else None

pack(t) classmethod

Pack Optional[float] to OptFloatT.

Source code in crystalfontz/dbus/domain/base.py
76
77
78
79
80
81
82
@classmethod
def pack(cls: Type[Self], t: Optional[float]) -> OptFloatT:
    """
    Pack `Optional[float]` to `OptFloatT`.
    """

    return t if t is not None else cls.none

unpack(t) staticmethod

Unpack OptFloatT to Optional[float].

Source code in crystalfontz/dbus/domain/base.py
84
85
86
87
88
89
90
@staticmethod
def unpack(t: OptFloatT) -> Optional[float]:
    """
    Unpack `OptFloatT` to `Optional[float]`.
    """

    return t if t >= 0 else None

OptGpioSettingsM

Map Optional[GpioSettings] to and from OptGpioSettingsT (int).

Optional GPIO settings are represented by a UINT16, where values higher than 0xFF are treated as None. When GPIO settings are defined, the integer value will be the same as with required GPIO settings.

Source code in crystalfontz/dbus/domain/gpio.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class OptGpioSettingsM:
    """
    Map `Optional[GpioSettings]` to and from `OptGpioSettingsT` (`int`).

    Optional GPIO settings are represented by a UINT16, where values higher
    than 0xFF are treated as None. When GPIO settings are defined, the integer
    value will be the same as with required GPIO settings.
    """

    t: ClassVar[str] = Uint16M.t
    none: ClassVar[int] = 0xFF00

    @classmethod
    def pack(cls: Type[Self], settings: Optional[GpioSettings]) -> OptGpioSettingsT:
        return GpioSettingsM.pack(settings) if settings is not None else cls.none

    @staticmethod
    def unpack(settings: OptGpioSettingsT) -> Optional[GpioSettings]:
        return GpioSettingsM.unpack(settings) if settings <= 0xFF else None

OptStrM

Map Optional[str] to and from StrT (str).

None values are represented by an empty string.

Source code in crystalfontz/dbus/domain/base.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class OptStrM:
    """
    Map `Optional[str]` to and from `StrT` (`str`).

    None values are represented by an empty string.
    """

    t: ClassVar[str] = "s"
    none: ClassVar[str] = ""

    @classmethod
    def pack(cls: Type[Self], string: Optional[str]) -> OptStrT:
        """
        Pack `Optional[str]` to `OptStrT`.
        """

        return string or cls.none

    @classmethod
    def unpack(cls: Type[Self], string: OptStrT) -> Optional[str]:
        """
        Unpack `OptStrT` to `Optional[str]`.
        """

        return string if string != cls.none else None

pack(string) classmethod

Pack Optional[str] to OptStrT.

Source code in crystalfontz/dbus/domain/base.py
106
107
108
109
110
111
112
@classmethod
def pack(cls: Type[Self], string: Optional[str]) -> OptStrT:
    """
    Pack `Optional[str]` to `OptStrT`.
    """

    return string or cls.none

unpack(string) classmethod

Unpack OptStrT to Optional[str].

Source code in crystalfontz/dbus/domain/base.py
114
115
116
117
118
119
120
@classmethod
def unpack(cls: Type[Self], string: OptStrT) -> Optional[str]:
    """
    Unpack `OptStrT` to `Optional[str]`.
    """

    return string if string != cls.none else None

PongM

Map Pong to and from PongT (bytes).

Source code in crystalfontz/dbus/domain/response.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class PongM:
    """
    Map `Pong` to and from `PongT` (`bytes`).
    """

    t: ClassVar[str] = BytesM.t

    @staticmethod
    def pack(pong: Pong) -> PongT:
        """
        Pack `Pong` to `PongT`.
        """

        return pong.response

    @staticmethod
    def unpack(pong: PongT) -> Pong:
        """
        Unpack `PongT` to `Pong`.
        """

        return Pong(pong)

pack(pong) staticmethod

Pack Pong to PongT.

Source code in crystalfontz/dbus/domain/response.py
55
56
57
58
59
60
61
@staticmethod
def pack(pong: Pong) -> PongT:
    """
    Pack `Pong` to `PongT`.
    """

    return pong.response

unpack(pong) staticmethod

Unpack PongT to Pong.

Source code in crystalfontz/dbus/domain/response.py
63
64
65
66
67
68
69
@staticmethod
def unpack(pong: PongT) -> Pong:
    """
    Unpack `PongT` to `Pong`.
    """

    return Pong(pong)

RetryTimesM

Bases: OptIntM

Map Optional[int] to and from RetryTimesT (int).

RetryTimesM is an alias for OptIntM.

Source code in crystalfontz/dbus/domain/base.py
234
235
236
237
238
239
240
241
242
class RetryTimesM(OptIntM):
    """
    Map `Optional[int]` to and from `RetryTimesT` (`int`).

    `RetryTimesM` is an alias for `OptIntM`.
    """

    t: ClassVar[str] = OptIntM.t
    none: ClassVar[int] = OptIntM.none

TemperatureDisplayItemM

Map TemperatureDisplayItem to and from TemperatureDisplayItemT (Tuple[int, int, int, int, bool]).

Source code in crystalfontz/dbus/domain/temperature.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class TemperatureDisplayItemM:
    """
    Map `TemperatureDisplayItem` to and from `TemperatureDisplayItemT`
    (`Tuple[int, int, int, int, bool]`).
    """

    t: ClassVar[str] = t(IndexM, TemperatureDigitsM, PositionM, PositionM, "b")

    @staticmethod
    def pack(item: TemperatureDisplayItem) -> TemperatureDisplayItemT:
        """
        Pack `TemperatureDisplayItem` to `TemperatureDisplayItemT`.
        """

        return (
            item.index,
            item.n_digits,
            item.column,
            item.row,
            TemperatureUnitM.pack(item.units),
        )

    @staticmethod
    def unpack(
        item: TemperatureDisplayItemT,
    ) -> TemperatureDisplayItem:
        """
        Unpack `TemperatureDisplayItemT` to `TemperatureDisplayItem`.
        """

        index, n_digits, column, row, units = item
        return TemperatureDisplayItem(
            index,
            TemperatureDigitsM.unpack(n_digits),
            column,
            row,
            TemperatureUnitM.unpack(units),
        )

pack(item) staticmethod

Pack TemperatureDisplayItem to TemperatureDisplayItemT.

Source code in crystalfontz/dbus/domain/temperature.py
53
54
55
56
57
58
59
60
61
62
63
64
65
@staticmethod
def pack(item: TemperatureDisplayItem) -> TemperatureDisplayItemT:
    """
    Pack `TemperatureDisplayItem` to `TemperatureDisplayItemT`.
    """

    return (
        item.index,
        item.n_digits,
        item.column,
        item.row,
        TemperatureUnitM.pack(item.units),
    )

unpack(item) staticmethod

Unpack TemperatureDisplayItemT to TemperatureDisplayItem.

Source code in crystalfontz/dbus/domain/temperature.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@staticmethod
def unpack(
    item: TemperatureDisplayItemT,
) -> TemperatureDisplayItem:
    """
    Unpack `TemperatureDisplayItemT` to `TemperatureDisplayItem`.
    """

    index, n_digits, column, row, units = item
    return TemperatureDisplayItem(
        index,
        TemperatureDigitsM.unpack(n_digits),
        column,
        row,
        TemperatureUnitM.unpack(units),
    )

TemperatureReportM

Map TemperatureReport to and from KeyActivityReportT

Source code in crystalfontz/dbus/domain/response.py
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
class TemperatureReportM:
    """
    Map `TemperatureReport` to and from `KeyActivityReportT`
    """

    t: ClassVar[str] = t(IndexM, "dd")

    @staticmethod
    def pack(report: TemperatureReport) -> TemperatureReportT:
        return (report.index, report.celsius, report.fahrenheit)

    @staticmethod
    def unpack(report: TemperatureReportT) -> TemperatureReport:
        index, celsius, fahrenheit = report
        return TemperatureReport(index, celsius, fahrenheit)

TimeoutM

Bases: OptFloatM

Map Optional[float] to and from TimeoutT (float).

TimeoutM is an alias for OptFloatM.

Source code in crystalfontz/dbus/domain/base.py
220
221
222
223
224
225
226
227
228
class TimeoutM(OptFloatM):
    """
    Map `Optional[float]` to and from `TimeoutT` (`float`).

    `TimeoutM` is an alias for `OptFloatM`.
    """

    t: ClassVar[str] = OptFloatM.t
    none: ClassVar[float] = OptFloatM.none

VersionsM

Map Versions to and from VersionsT (Tuple[str, str, str]).

Source code in crystalfontz/dbus/domain/response.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class VersionsM:
    """
    Map `Versions` to and from `VersionsT` (`Tuple[str, str, str]`).
    """

    t: ClassVar[str] = t(ModelM, RevisionM, RevisionM)

    @staticmethod
    def pack(versions: Versions) -> VersionsT:
        return (versions.model, versions.hardware_rev, versions.firmware_rev)

    @staticmethod
    def unpack(versions: VersionsT) -> Versions:
        """
        Unpack `VersionsT` to `Versions`.
        """

        return Versions(*versions)

unpack(versions) staticmethod

Unpack VersionsT to Versions.

Source code in crystalfontz/dbus/domain/response.py
86
87
88
89
90
91
92
@staticmethod
def unpack(versions: VersionsT) -> Versions:
    """
    Unpack `VersionsT` to `Versions`.
    """

    return Versions(*versions)