You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,6 @@ Note that this work is not affiliated with Adafruit.
9
9
## Optional features
10
10
*`defmt`: you can enable the [`defmt`](https://defmt.ferrous-systems.com/) feature to get a `defmt::Format` implementation for all structs & enums and a `defmt::debug!` call for each command being parsed.
11
11
*`rgb`: if enabled, the `ColorEvent` implements `Into<RGB8>` for the [RGB crate](https://crates.io/crates/rgb).
12
+
* All events can be selected as individual features. By default, they are all selected,
13
+
but you can opt to only select the event(s) you are interested in which will result in a small binary size.
14
+
If other events are received, a `ProtocolParseError::DisabledControllerDataPackageType` will be returned.
Copy file name to clipboardExpand all lines: src/lib.rs
+83-9Lines changed: 83 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@
4
4
//! ## Optional features
5
5
//! * `defmt`: you can enable the `defmt` feature to get a `defmt::Format` implementation for all structs & enums and a `defmt::debug!` call for each command being parsed.
6
6
//! * `rgb`: if enabled, the `ColorEvent` implements `Into<RGB8>` for the [RGB crate](https://crates.io/crates/rgb).
7
+
//! * All events can be selected as individual features. By default, they are all selected,
8
+
//! but you can opt to only select the event(s) you are interested in which will result in a small binary size.
9
+
//! If other events are received, a [`ProtocolParseError::DisabledControllerDataPackageType`] will be returned.
7
10
8
11
#![forbid(unsafe_code)]
9
12
// use deny instead of forbid due to bogus warnings, see also https://github.com/rust-lang/rust/issues/81670
@@ -14,35 +17,67 @@
14
17
#![deny(unused)]
15
18
#![no_std]
16
19
20
+
#[cfg(not(any(
21
+
feature = "accelerometer_event",
22
+
feature = "button_event",
23
+
feature = "color_event",
24
+
feature = "gyro_event",
25
+
feature = "location_event",
26
+
feature = "magnetometer_event",
27
+
feature = "quaternion_event"
28
+
)))]
29
+
compile_error!("at least one event type must be selected in the features!");
30
+
31
+
#[cfg(feature = "accelerometer_event")]
17
32
pubmod accelerometer_event;
33
+
#[cfg(feature = "button_event")]
18
34
pubmod button_event;
35
+
#[cfg(feature = "color_event")]
19
36
pubmod color_event;
37
+
#[cfg(feature = "gyro_event")]
20
38
pubmod gyro_event;
39
+
#[cfg(feature = "location_event")]
21
40
pubmod location_event;
41
+
#[cfg(feature = "magnetometer_event")]
22
42
pubmod magnetometer_event;
43
+
#[cfg(feature = "quaternion_event")]
23
44
pubmod quaternion_event;
24
45
46
+
#[cfg(feature = "accelerometer_event")]
25
47
use accelerometer_event::AccelerometerEvent;
48
+
#[cfg(feature = "button_event")]
26
49
use button_event::{ButtonEvent,ButtonParseError};
50
+
#[cfg(feature = "color_event")]
27
51
use color_event::ColorEvent;
28
52
use core::cmp::min;
53
+
#[cfg(feature = "gyro_event")]
29
54
use gyro_event::GyroEvent;
30
55
use heapless::Vec;
56
+
#[cfg(feature = "location_event")]
31
57
use location_event::LocationEvent;
58
+
#[cfg(feature = "magnetometer_event")]
32
59
use magnetometer_event::MagnetometerEvent;
60
+
#[cfg(feature = "quaternion_event")]
33
61
use quaternion_event::QuaternionEvent;
34
62
35
63
/// Lists all (supported) events which can be sent by the controller. These come with the parsed event data and are the result of a [`parse`] call.
#[allow(missing_docs)]// the names are already obvious enough
39
67
pubenumControllerEvent{
68
+
#[cfg(feature = "button_event")]
40
69
ButtonEvent(ButtonEvent),
70
+
#[cfg(feature = "color_event")]
41
71
ColorEvent(ColorEvent),
72
+
#[cfg(feature = "quaternion_event")]
42
73
QuaternionEvent(QuaternionEvent),
74
+
#[cfg(feature = "accelerometer_event")]
43
75
AccelerometerEvent(AccelerometerEvent),
76
+
#[cfg(feature = "gyro_event")]
44
77
GyroEvent(GyroEvent),
78
+
#[cfg(feature = "magnetometer_event")]
45
79
MagnetometerEvent(MagnetometerEvent),
80
+
#[cfg(feature = "location_event")]
46
81
LocationEvent(LocationEvent),
47
82
}
48
83
@@ -52,7 +87,10 @@ pub enum ControllerEvent {
52
87
pubenumProtocolParseError{
53
88
/// The message contained an event which is not known to the current implementation. This can either mean that the message was malformed or that a newer protocol version has been used.
54
89
UnknownEvent(Option<u8>),
90
+
/// The message contained an event which is known to the library but has not been selected as a feature and can thus not be parsed. Select the feature when compiling the library to handle this message.
0 commit comments