@@ -42,19 +42,7 @@ pub enum MotorError<IN1Error, IN2Error, PWMError> {
42
42
/// Defines errors which can happen when calling [`Tb6612fng::new()`].
43
43
#[ derive( PartialEq , Eq , Debug , Copy , Clone ) ]
44
44
#[ cfg_attr( feature = "defmt-03" , derive( Format ) ) ]
45
- pub enum Tb6612fngError <
46
- MAIN1Error ,
47
- MAIN2Error ,
48
- MAPWMError ,
49
- MBIN1Error ,
50
- MBIN2Error ,
51
- MBPWMError ,
52
- STBYError ,
53
- > {
54
- /// An error in setting the initial `drive()` of `motor_a`
55
- MotorA ( MotorError < MAIN1Error , MAIN2Error , MAPWMError > ) ,
56
- /// An error in setting the initial `drive()` of `motor_b`
57
- MotorB ( MotorError < MBIN1Error , MBIN2Error , MBPWMError > ) ,
45
+ pub enum Tb6612fngError < STBYError > {
58
46
/// An error in setting the initial output of the standby pin
59
47
Standby ( STBYError ) ,
60
48
}
@@ -133,15 +121,11 @@ where
133
121
/// # let standby = PinMock::new(&[PinTransaction::set(High)]);
134
122
/// # let mut standby_ = standby.clone();
135
123
///
136
- /// use tb6612fng::Tb6612fng;
124
+ /// use tb6612fng::{Motor, Tb6612fng} ;
137
125
///
138
126
/// let controller = Tb6612fng::new(
139
- /// motor_a_in1,
140
- /// motor_a_in2,
141
- /// motor_a_pwm,
142
- /// motor_b_in1,
143
- /// motor_b_in2,
144
- /// motor_b_pwm,
127
+ /// Motor::new(motor_a_in1, motor_a_in2, motor_a_pwm).unwrap(),
128
+ /// Motor::new(motor_b_in1, motor_b_in2, motor_b_pwm).unwrap(),
145
129
/// standby,
146
130
/// );
147
131
///
@@ -155,30 +139,16 @@ where
155
139
/// ```
156
140
#[ allow( clippy:: type_complexity) ]
157
141
pub fn new (
158
- motor_a_in1 : MAIN1 ,
159
- motor_a_in2 : MAIN2 ,
160
- motor_a_pwm : MAPWM ,
161
- motor_b_in1 : MBIN1 ,
162
- motor_b_in2 : MBIN2 ,
163
- motor_b_pwm : MBPWM ,
142
+ motor_a : Motor < MAIN1 , MAIN2 , MAPWM > ,
143
+ motor_b : Motor < MBIN1 , MBIN2 , MBPWM > ,
164
144
standby : STBY ,
165
145
) -> Result <
166
146
Tb6612fng < MAIN1 , MAIN2 , MAPWM , MBIN1 , MBIN2 , MBPWM , STBY > ,
167
- Tb6612fngError <
168
- MAIN1 :: Error ,
169
- MAIN2 :: Error ,
170
- MAPWM :: Error ,
171
- MBIN1 :: Error ,
172
- MBIN2 :: Error ,
173
- MBPWM :: Error ,
174
- STBY :: Error ,
175
- > ,
147
+ Tb6612fngError < STBY :: Error > ,
176
148
> {
177
149
let mut controller = Tb6612fng {
178
- motor_a : Motor :: new ( motor_a_in1, motor_a_in2, motor_a_pwm)
179
- . map_err ( Tb6612fngError :: MotorA ) ?,
180
- motor_b : Motor :: new ( motor_b_in1, motor_b_in2, motor_b_pwm)
181
- . map_err ( Tb6612fngError :: MotorB ) ?,
150
+ motor_a,
151
+ motor_b,
182
152
standby,
183
153
} ;
184
154
0 commit comments