Skip to content

Commit c996d03

Browse files
committed
remove device-specific code, leave only the protocol handling
1 parent dacaaab commit c996d03

File tree

10 files changed

+233
-306
lines changed

10 files changed

+233
-306
lines changed

Cargo.toml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
10-
cortex-m-rtic = "1.1.3"
9+
defmt = { version = "0.3", optional = true }
10+
heapless = { version = "0.7" }
1111

12-
stm32f4xx-hal = { version = "0.13.2", features = ["stm32f401"] }
13-
14-
fugit = "0.3"
15-
16-
defmt = "0.3.2"
17-
defmt-rtt = "0.4"
18-
19-
heapless = { version = "0.7", features = ["defmt-impl"] }
12+
[features]
13+
defmt = ["dep:defmt", "heapless/defmt-impl"]

src/bluefruit_protocol/accelerometer_event.rs renamed to src/accelerometer_event.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use super::{try_f32_from_le_bytes, ProtocolParseError};
22

33
/// Represents an accelerometer event from the protocol.
4-
#[derive(Debug, defmt::Format)]
4+
#[derive(PartialEq, Debug)]
5+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56
pub struct AccelerometerEvent {
67
x: f32,
78
y: f32,

src/bluefruit_protocol/mod.rs

Lines changed: 0 additions & 218 deletions
This file was deleted.

src/bluefruit_protocol/button_event.rs renamed to src/button_event.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use super::ProtocolParseError;
22

33
/// Errors which can be raised while parsing a button event.
4-
#[derive(Debug, defmt::Format)]
4+
#[derive(PartialEq, Eq, Debug)]
5+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56
pub enum ButtonParseError {
67
UnknownButton(u8),
78
UnknownButtonState(u8),
89
}
910

1011
/// Lists all possible buttons which can be sent in the event.
11-
#[derive(Debug, defmt::Format)]
12+
#[derive(PartialEq, Eq, Debug)]
13+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1214
pub enum Button {
1315
Button1,
1416
Button2,
@@ -38,7 +40,8 @@ impl Button {
3840
}
3941

4042
/// The state of the button.
41-
#[derive(Debug, defmt::Format)]
43+
#[derive(PartialEq, Eq, Debug)]
44+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4245
pub enum ButtonState {
4346
Released,
4447
Pressed,
@@ -56,7 +59,8 @@ impl ButtonState {
5659
}
5760

5861
/// Represents a button event from the protocol.
59-
#[derive(Debug, defmt::Format)]
62+
#[derive(PartialEq, Eq, Debug)]
63+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6064
pub struct ButtonEvent {
6165
button: Button,
6266
state: ButtonState,

src/bluefruit_protocol/color_event.rs renamed to src/color_event.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use super::ProtocolParseError;
22

33
/// Represents a color event from the protocol.
4-
#[derive(Debug, defmt::Format)]
4+
#[derive(PartialEq, Eq, Debug)]
5+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56
pub struct ColorEvent {
67
red: u8,
78
green: u8,

src/bluefruit_protocol/gyro_event.rs renamed to src/gyro_event.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use super::{try_f32_from_le_bytes, ProtocolParseError};
22

33
/// Represents a gyro event from the protocol.
4-
#[derive(Debug, defmt::Format)]
4+
#[derive(PartialEq, Debug)]
5+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56
pub struct GyroEvent {
67
x: f32,
78
y: f32,

0 commit comments

Comments
 (0)