File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,23 @@ pub trait AdcChannel: ErrorType {
50
50
/// This should wait until data is ready and then read it.
51
51
/// If the ADC's precision is less than 32 bits, the value must be scaled accordingly.
52
52
fn read ( & mut self ) -> Result < u32 , Self :: Error > ;
53
+
54
+ /// Take an measurement in millivolts.
55
+ fn measure_mv ( & mut self ) -> Result < i32 , Self :: Error > {
56
+ Ok ( self . read ( ) ? as i32 )
57
+ }
58
+
59
+ /// Take an measurement in microvolts.
60
+ fn measure_uv ( & mut self ) -> Result < i32 , Self :: Error > {
61
+ let uv = self . measure_mv ( ) ?;
62
+ Ok ( uv. saturating_mul ( 1000 ) )
63
+ }
64
+
65
+ /// Take an measurement in nanovolts.
66
+ fn measure_nv ( & mut self ) -> Result < i32 , Self :: Error > {
67
+ let uv = self . measure_uv ( ) ?;
68
+ Ok ( uv. saturating_mul ( 1000 ) )
69
+ }
53
70
}
54
71
55
72
impl < T > AdcChannel for & mut T
You can’t perform that action at this time.
0 commit comments