1
1
#![ no_std]
2
2
#![ no_main]
3
+ #![ allow( clippy:: uninlined_format_args) ]
3
4
4
5
// Requires a jumper from A1<->A2 (arduino naming) aka PA1<->PA4
5
6
6
7
#[ path = "../examples/utils/mod.rs" ]
7
8
mod utils;
8
9
10
+ use utils:: logger:: println;
11
+
9
12
mod common;
10
13
11
14
use stm32g4xx_hal:: adc:: { self , AdcClaim , AdcCommonExt } ;
@@ -83,9 +86,7 @@ mod tests {
83
86
let reading = adc. convert ( & opamp, sample_time) ;
84
87
assert ! (
85
88
reading. abs_diff( setpoint) < 10 ,
86
- "reading: {}, setpoint {}" ,
87
- reading,
88
- setpoint
89
+ "reading: {reading}, setpoint {setpoint}"
89
90
) ;
90
91
}
91
92
}
@@ -114,9 +115,7 @@ mod tests {
114
115
let reading = adc. convert ( & pa2, sample_time) ;
115
116
assert ! (
116
117
reading. abs_diff( setpoint) < 10 ,
117
- "reading: {}, setpoint {}" ,
118
- reading,
119
- setpoint
118
+ "reading: {reading}, setpoint {setpoint}"
120
119
) ;
121
120
}
122
121
}
@@ -141,9 +140,7 @@ mod tests {
141
140
let reading = adc. convert ( & opamp, sample_time) ;
142
141
assert ! (
143
142
reading. abs_diff( ( setpoint * 2 ) . min( 4095 ) ) < 20 ,
144
- "reading: {}, setpoint {}" ,
145
- reading,
146
- setpoint
143
+ "reading: {reading}, setpoint {setpoint}"
147
144
) ;
148
145
}
149
146
}
@@ -180,8 +177,7 @@ mod tests {
180
177
let out = comp. output ( ) ;
181
178
assert ! (
182
179
comp. output( ) == ( value_setpoint > ref_setpoint) ,
183
- "setpoint: {}, expected: '{}', got '{}'" ,
184
- value_setpoint,
180
+ "setpoint: {value_setpoint}, expected: '{}', got '{}'" ,
185
181
if value_setpoint > ref_setpoint {
186
182
"HI"
187
183
} else {
@@ -224,8 +220,7 @@ mod tests {
224
220
let out = comp. output ( ) ;
225
221
assert ! (
226
222
comp. output( ) == ( value_setpoint > ref_setpoint) ,
227
- "setpoint: {}, expected: '{}', got '{}'" ,
228
- value_setpoint,
223
+ "setpoint: {value_setpoint}, expected: '{}', got '{}'" ,
229
224
if value_setpoint > ref_setpoint {
230
225
"HI"
231
226
} else {
@@ -246,6 +241,7 @@ mod tests {
246
241
///
247
242
#[ test]
248
243
fn comp_dac_dac ( ) {
244
+ use super :: * ;
249
245
let super :: Peripherals {
250
246
comp,
251
247
mut value_dac,
@@ -264,7 +260,7 @@ mod tests {
264
260
for s_ref in 4 ..=255 {
265
261
let s_ref = s_ref << 4 ; // Convert from 8 to 12 bits
266
262
if s_ref & 0xFF == 0 {
267
- defmt :: println!( "{}/{} ..." , s_ref, 4095 ) ;
263
+ println ! ( "{}/4095 ..." , s_ref) ;
268
264
}
269
265
ref_dac. set_value ( s_ref) ;
270
266
for s_value in 0 ..=255 {
@@ -275,10 +271,7 @@ mod tests {
275
271
if s_value. abs_diff ( s_ref) > 20 {
276
272
assert ! (
277
273
out == ( s_value > s_ref) ,
278
- "s_value: {}, s_ref: {}, out: {}" ,
279
- s_value,
280
- s_ref,
281
- out
274
+ "s_value: {s_value}, s_ref: {s_ref}, out: {out}"
282
275
) ;
283
276
}
284
277
}
0 commit comments