@@ -104,7 +104,11 @@ where
104
104
/// The initial state of the motors will be set to [stopped](DriveCommand::Stop).
105
105
/// The initial state of standby will be *disabled*.
106
106
///
107
- /// Usage example:
107
+ /// # Errors
108
+ /// If any of the underlying pin interactions fail these errors will be propagated up.
109
+ /// The errors are specific to your HAL.
110
+ ///
111
+ /// # Usage example
108
112
/// ```
109
113
/// # use embedded_hal_mock::eh1::digital::Mock as PinMock;
110
114
/// # use embedded_hal_mock::eh1::pwm::Mock as PwmMock;
@@ -189,18 +193,30 @@ where
189
193
///
190
194
/// Note that this does not change any commands on the motors, i.e. the PWM signal will continue
191
195
/// and once [`Tb6612fng::disable_standby`] is called the motor will pick up where it left off (unless the command was changed in-between).
196
+ ///
197
+ /// # Errors
198
+ /// If the underlying pin interaction fails this error will be propagated up.
199
+ /// The error is specific to your HAL.
192
200
pub fn enable_standby ( & mut self ) -> Result < ( ) , STBY :: Error > {
193
201
self . standby . set_low ( )
194
202
}
195
203
196
204
/// Disable standby. Note that the last active commands on the motors will resume.
205
+ ///
206
+ /// # Errors
207
+ /// If the underlying pin interaction fails this error will be propagated up.
208
+ /// The error is specific to your HAL.
197
209
pub fn disable_standby ( & mut self ) -> Result < ( ) , STBY :: Error > {
198
210
self . standby . set_high ( )
199
211
}
200
212
201
213
/// Returns whether the standby mode is enabled.
202
214
///
203
215
/// *NOTE* this does *not* read the electrical state of the pin, see [`StatefulOutputPin`]
216
+ ///
217
+ /// # Errors
218
+ /// If the underlying pin interaction fails this error will be propagated up.
219
+ /// The error is specific to your HAL.
204
220
pub fn current_standby ( & mut self ) -> Result < bool , STBY :: Error >
205
221
where
206
222
STBY : StatefulOutputPin ,
@@ -210,6 +226,7 @@ where
210
226
}
211
227
212
228
/// Represents a single motor (either motor A or motor B) hooked up to a TB6612FNG controller.
229
+ ///
213
230
/// This is unaware of the standby pin. If you plan on using both motors and the standby feature then use the [`Tb6612fng`] struct instead.
214
231
/// See the crate-level comment for further details on when to use what.
215
232
#[ derive( Debug ) ]
@@ -231,7 +248,11 @@ where
231
248
/// This also automatically enables the PWM pin.
232
249
/// The initial state of the motor will be set to [stopped](DriveCommand::Stop).
233
250
///
234
- /// Usage example:
251
+ /// # Errors
252
+ /// If any of the underlying pin interactions fail these errors will be propagated up.
253
+ /// The errors are specific to your HAL.
254
+ ///
255
+ /// # Usage example
235
256
/// ```
236
257
/// # use embedded_hal_mock::eh1::digital::Mock as PinMock;
237
258
/// # use embedded_hal_mock::eh1::pwm::Mock as PwmMock;
@@ -275,6 +296,13 @@ where
275
296
}
276
297
277
298
/// Drive with the defined speed (or brake or stop the motor).
299
+ ///
300
+ /// # Errors
301
+ /// If the underlying pin interaction fails this error will be propagated up.
302
+ /// The error is specific to your HAL.
303
+ ///
304
+ /// The specified speed must be between 0 and 100 (inclusive), otherwise you will get a
305
+ /// [`MotorError::InvalidSpeed`] error.
278
306
#[ allow( clippy:: type_complexity) ]
279
307
pub fn drive (
280
308
& mut self ,
@@ -330,7 +358,7 @@ where
330
358
/// Return the current speed of the motor (in percentage). Note that driving forward returns a positive number
331
359
/// while driving backward returns a negative number and both [`DriveCommand::Brake`] and [`DriveCommand::Stop`] return 0.
332
360
///
333
- /// If you need to know in more details what the current status is consider calling [`Motor::current_drive_command`] instead.
361
+ /// If you need to know in more details what the current status is, consider calling [`Motor::current_drive_command`] instead.
334
362
pub fn current_speed ( & self ) -> i8 {
335
363
match self . current_drive_command ( ) {
336
364
DriveCommand :: Forward ( s) => * s as i8 ,
0 commit comments