Skip to content

Commit e274104

Browse files
committed
rename defmt feature to defmt-03
this follows the pattern from other crates (e.g. `heapless`) which allows to add e.g. an upcoming `defmt` v1.0 support as a non-breaking feature.
1 parent 6faea7b commit e274104

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ categories = ["embedded", "hardware-support", "no-std", "no-std::no-alloc"]
1010
keywords = ["tb6612fng", "driver", "motor", "controller", "embedded-hal-driver"]
1111
license = "MIT OR Apache-2.0"
1212

13+
[features]
14+
defmt-03 = ["dep:defmt"]
15+
1316
[dependencies]
1417
embedded-hal = "1.0"
1518

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See the documentation for usage examples.
2121
* You plan on using a single motor without the standby feature: use `Motor`
2222

2323
## Optional features
24-
* `defmt`: you can enable the [`defmt`](https://defmt.ferrous-systems.com/) feature to get a `defmt::debug!` call for every speed change.
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.
2525

2626
## Examples
2727
A simple example for the STM32F4 microcontrollers is [available](examples/stm32f4-single-motor-example/README.md).

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! * You plan on using a single motor without the standby feature: use [`Motor`]
1212
//!
1313
//! ## Optional features
14-
//! * `defmt`: you can enable the `defmt` feature to get a `defmt::Format` implementation for all structs & enums in this crate and a `defmt::debug` call for every speed change.
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.
1515
1616
#![forbid(unsafe_code)]
1717
#![deny(warnings)]
@@ -20,14 +20,14 @@
2020
#![deny(unused)]
2121
#![no_std]
2222

23-
#[cfg(feature = "defmt")]
23+
#[cfg(feature = "defmt-03")]
2424
use defmt::Format;
2525
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
2626
use embedded_hal::pwm::SetDutyCycle;
2727

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

4242
/// Defines errors which can happen when calling [`Tb6612fng::new()`].
4343
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
44-
#[cfg_attr(feature = "defmt", derive(Format))]
44+
#[cfg_attr(feature = "defmt-03", derive(Format))]
4545
pub enum Tb6612fngError<
4646
MAIN1Error,
4747
MAIN2Error,
@@ -61,7 +61,7 @@ pub enum Tb6612fngError<
6161

6262
/// Defines the possible drive commands.
6363
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
64-
#[cfg_attr(feature = "defmt", derive(Format))]
64+
#[cfg_attr(feature = "defmt-03", derive(Format))]
6565
pub enum DriveCommand {
6666
/// Drive forward with the defined speed (in percentage)
6767
Forward(u8),
@@ -78,7 +78,7 @@ pub enum DriveCommand {
7878
/// Use the [`Motor`] struct directly if you only have one motor.
7979
/// See the crate-level comment for further details on when to use what.
8080
#[derive(Debug)]
81-
#[cfg_attr(feature = "defmt", derive(Format))]
81+
#[cfg_attr(feature = "defmt-03", derive(Format))]
8282
pub struct Tb6612fng<MAIN1, MAIN2, MAPWM, MBIN1, MBIN2, MBPWM, STBY> {
8383
/// The first motor, labelled as 'A' on the chip
8484
pub motor_a: Motor<MAIN1, MAIN2, MAPWM>,
@@ -213,7 +213,7 @@ where
213213
/// This is unaware of the standby pin. If you plan on using both motors and the standby feature then use the [`Tb6612fng`] struct instead.
214214
/// See the crate-level comment for further details on when to use what.
215215
#[derive(Debug)]
216-
#[cfg_attr(feature = "defmt", derive(Format))]
216+
#[cfg_attr(feature = "defmt-03", derive(Format))]
217217
pub struct Motor<IN1, IN2, PWM> {
218218
in1: IN1,
219219
in2: IN2,
@@ -308,7 +308,7 @@ where
308308
}
309309
}
310310

311-
#[cfg(feature = "defmt")]
311+
#[cfg(feature = "defmt-03")]
312312
defmt::debug!("driving {} with speed {}", drive_command, speed);
313313

314314
self.pwm

0 commit comments

Comments
 (0)