Skip to content

Commit d9da807

Browse files
committed
remove defmt dependency & feature
based on the discussion on GitHub we don't need this dependency. it's the only 0.x dependency currently present in the crate and doesn't provide a lot of value since consuming code can use `defmt::Debug2Format` when needed. the single `defmt::debug!` statement in `Motor::drive` was not very helpful anyway if two motors were connected as it did not differentiate between the motors in the message. since this was the only optional feature there's no need anymore to test with `--all-features` in the CI. this has been removed from the build matrix (but the possibility to add it later has been kept as it doesn't make the build script unnecessarily complicated).
1 parent bbdd9b4 commit d9da807

File tree

5 files changed

+4
-21
lines changed

5 files changed

+4
-21
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
rust: [1.63.0, stable]
17-
features: ['', '--all-features']
18-
exclude:
19-
- rust: 1.63.0
20-
features: '--all-features'
17+
features: ['']
2118
runs-on: ubuntu-latest
2219
steps:
2320
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
* Removed the `drive_forward`, `drive_backward`, `stop` and `brake`
2727
functions as they are duplicates to the `drive` function with the
2828
different enum variants and make the API surface larger
29+
* Removed the `defmt` feature: it was only used for debugging and since the `enum`s & `struct`s implement `Debug`
30+
consuming code can use `defmt::Debug2Format` when needed. The single `defmt::debug!` statement in `Motor::drive` was
31+
not very helpful anyway if two motors were connected
2932

3033
## [0.2.0] - 2023-11-28
3134

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ license = "MIT OR Apache-2.0"
1212
authors = ["Ralph Ursprung <[email protected]>", "ripytide <[email protected]>"]
1313

1414
[features]
15-
defmt-03 = ["dep:defmt"]
1615

1716
[dependencies]
1817
embedded-hal = "1.0"

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ See the documentation for usage examples.
2020
* You plan on using a single motor with the standby feature: use `Motor` and control the standby pin manually
2121
* You plan on using a single motor without the standby feature: use `Motor`
2222

23-
## Optional features
24-
* `defmt-03`: you can enable this feature to get a `defmt::Format` implementation for all structs & enums in this crate and a `defmt::debug` call for every speed change.
25-
2623
## Examples
2724
A simple example for the STM32F4 microcontrollers is [available](examples/stm32f4-single-motor-example/README.md).
2825

src/lib.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
//! * You plan on using both motors without the standby feature: use two separate [`Motor`]s
1010
//! * You plan on using a single motor with the standby feature: use [`Motor`] and control the standby pin manually
1111
//! * You plan on using a single motor without the standby feature: use [`Motor`]
12-
//!
13-
//! ## Optional features
14-
//! * `defmt-03`: you can enable this feature to get a `defmt::Format` implementation for all structs & enums in this crate and a `defmt::debug` call for every speed change.
1512
1613
#![forbid(unsafe_code)]
1714
#![deny(warnings)]
@@ -20,14 +17,11 @@
2017
#![deny(unused)]
2118
#![no_std]
2219

23-
#[cfg(feature = "defmt-03")]
24-
use defmt::Format;
2520
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
2621
use embedded_hal::pwm::SetDutyCycle;
2722

2823
/// Defines errors which can happen when calling [`Motor::drive()`].
2924
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
30-
#[cfg_attr(feature = "defmt-03", derive(Format))]
3125
pub enum MotorError<IN1Error, IN2Error, PWMError> {
3226
/// An invalid speed has been defined. The speed must be given as a percentage value between 0 and 100 to be valid.
3327
InvalidSpeed,
@@ -41,15 +35,13 @@ pub enum MotorError<IN1Error, IN2Error, PWMError> {
4135

4236
/// Defines errors which can happen when calling [`Tb6612fng::new()`].
4337
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
44-
#[cfg_attr(feature = "defmt-03", derive(Format))]
4538
pub enum Tb6612fngError<STBYError> {
4639
/// An error in setting the initial output of the standby pin
4740
Standby(STBYError),
4841
}
4942

5043
/// Defines the possible drive commands.
5144
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
52-
#[cfg_attr(feature = "defmt-03", derive(Format))]
5345
pub enum DriveCommand {
5446
/// Drive forward with the defined speed (in percentage)
5547
Forward(u8),
@@ -66,7 +58,6 @@ pub enum DriveCommand {
6658
/// Use the [`Motor`] struct directly if you only have one motor.
6759
/// See the crate-level comment for further details on when to use what.
6860
#[derive(Debug)]
69-
#[cfg_attr(feature = "defmt-03", derive(Format))]
7061
pub struct Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY> {
7162
/// The first motor, labelled as 'A' on the chip
7263
pub motor_a: Motor<MAIN1, MAIN2, MAPWM>,
@@ -200,7 +191,6 @@ where
200191
/// This is unaware of the standby pin. If you plan on using both motors and the standby feature then use the [`Tb6612fng`] struct instead.
201192
/// See the crate-level comment for further details on when to use what.
202193
#[derive(Debug)]
203-
#[cfg_attr(feature = "defmt-03", derive(Format))]
204194
pub struct Motor<IN1, IN2, PWM> {
205195
in1: IN1,
206196
in2: IN2,
@@ -306,9 +296,6 @@ where
306296
}
307297
}
308298

309-
#[cfg(feature = "defmt-03")]
310-
defmt::debug!("driving {} with speed {}", drive_command, speed);
311-
312299
self.pwm
313300
.set_duty_cycle_percent(speed)
314301
.map_err(MotorError::PwmError)?;

0 commit comments

Comments
 (0)