33
33
34
34
from ._xyz_packet import _XYZPacket
35
35
36
+
36
37
class QuaternionPacket (_XYZPacket ):
37
38
"""A packet of x, y, z float values. Used for several different Bluefruit controller packets."""
38
39
39
40
# Use _XYZPacket to handle x, y, z, and add w.
40
41
41
- _FMT_PARSE = ' <xxffffx'
42
+ _FMT_PARSE = " <xxffffx"
42
43
PACKET_LENGTH = struct .calcsize (_FMT_PARSE )
43
44
# _FMT_CONSTRUCT doesn't include the trailing checksum byte.
44
- _FMT_CONSTRUCT = ' <2sffff'
45
- _TYPE_HEADER = b'!Q'
45
+ _FMT_CONSTRUCT = " <2sffff"
46
+ _TYPE_HEADER = b"!Q"
46
47
47
48
def __init__ (self , x , y , z , w ):
48
49
"""Construct a QuaternionPacket from the given x, y, z, and w float values."""
@@ -52,14 +53,16 @@ def __init__(self, x, y, z, w):
52
53
def to_bytes (self ):
53
54
"""Return the bytes needed to send this packet.
54
55
"""
55
- partial_packet = struct .pack (self ._FMT_CONSTRUCT , self ._TYPE_HEADER ,
56
- self ._x , self ._y , self ._z , self ._w )
56
+ partial_packet = struct .pack (
57
+ self ._FMT_CONSTRUCT , self ._TYPE_HEADER , self ._x , self ._y , self ._z , self ._w
58
+ )
57
59
return partial_packet + self .checksum (partial_packet )
58
60
59
61
@property
60
62
def w (self ):
61
63
"""The w value."""
62
64
return self ._w
63
65
66
+
64
67
# Register this class with the superclass. This allows the user to import only what is needed.
65
68
QuaternionPacket .register_packet_type ()
0 commit comments