@@ -58,67 +58,71 @@ impl<T: ErrorType> ErrorType for &mut T {
58
58
}
59
59
60
60
/// Single PWM channel / pin
61
- pub trait SetDuty : ErrorType {
61
+ pub trait SetDutyCycle : ErrorType {
62
62
/// Get the maximum duty cycle value.
63
63
///
64
64
/// This value corresponds to a 100% duty cycle.
65
- fn get_max_duty ( & self ) -> u16 ;
65
+ fn get_max_duty_cycle ( & self ) -> u16 ;
66
66
67
67
/// Set the duty cycle to `duty / max_duty`.
68
68
///
69
69
/// The caller is responsible for ensuring that the duty cycle value is less than or equal to the maximum duty cycle value,
70
70
/// as reported by `get_max_duty`.
71
- fn set_duty ( & mut self , duty : u16 ) -> Result < ( ) , Self :: Error > ;
71
+ fn set_duty_cycle ( & mut self , duty : u16 ) -> Result < ( ) , Self :: Error > ;
72
72
73
73
/// Set the duty cycle to 0%, or always inactive.
74
74
#[ inline]
75
- fn set_off ( & mut self ) -> Result < ( ) , Self :: Error > {
76
- self . set_duty ( 0 )
75
+ fn set_duty_cycle_fully_off ( & mut self ) -> Result < ( ) , Self :: Error > {
76
+ self . set_duty_cycle ( 0 )
77
77
}
78
78
79
79
/// Set the duty cycle to 100%, or always active.
80
80
#[ inline]
81
- fn set_on ( & mut self ) -> Result < ( ) , Self :: Error > {
82
- self . set_duty ( self . get_max_duty ( ) )
81
+ fn set_duty_cycle_fully_on ( & mut self ) -> Result < ( ) , Self :: Error > {
82
+ self . set_duty_cycle ( self . get_max_duty_cycle ( ) )
83
83
}
84
84
85
85
/// Set the duty cycle to `num / denom`.
86
86
///
87
87
/// The caller is responsible for ensuring that `num` is less than or equal to `denom`,
88
88
/// and that `denom` is not zero.
89
89
#[ inline]
90
- fn set_fraction ( & mut self , num : u16 , denom : u16 ) -> Result < ( ) , Self :: Error > {
91
- let duty = num as u32 * self . get_max_duty ( ) as u32 / denom as u32 ;
92
- self . set_duty ( duty as u16 )
90
+ fn set_duty_cycle_fraction ( & mut self , num : u16 , denom : u16 ) -> Result < ( ) , Self :: Error > {
91
+ let duty = num as u32 * self . get_max_duty_cycle ( ) as u32 / denom as u32 ;
92
+ self . set_duty_cycle ( duty as u16 )
93
93
}
94
94
95
95
/// Set the duty cycle to `percent / 100`
96
96
///
97
97
/// The caller is responsible for ensuring that `percent` is less than or equal to 100.
98
98
#[ inline]
99
- fn set_percent ( & mut self , percent : u8 ) -> Result < ( ) , Self :: Error > {
100
- self . set_fraction ( percent as u16 , 100 )
99
+ fn set_duty_cycle_percent ( & mut self , percent : u8 ) -> Result < ( ) , Self :: Error > {
100
+ self . set_duty_cycle_fraction ( percent as u16 , 100 )
101
101
}
102
102
}
103
103
104
- impl < T : SetDuty > SetDuty for & mut T {
105
- fn get_max_duty ( & self ) -> u16 {
106
- T :: get_max_duty ( self )
104
+ impl < T : SetDutyCycle > SetDutyCycle for & mut T {
105
+ fn get_max_duty_cycle ( & self ) -> u16 {
106
+ T :: get_max_duty_cycle ( self )
107
107
}
108
- fn set_duty ( & mut self , duty : u16 ) -> Result < ( ) , Self :: Error > {
109
- T :: set_duty ( self , duty)
108
+
109
+ fn set_duty_cycle ( & mut self , duty : u16 ) -> Result < ( ) , Self :: Error > {
110
+ T :: set_duty_cycle ( self , duty)
110
111
}
111
112
112
- fn set_off ( & mut self ) -> Result < ( ) , Self :: Error > {
113
- T :: set_off ( self )
113
+ fn set_duty_cycle_fully_off ( & mut self ) -> Result < ( ) , Self :: Error > {
114
+ T :: set_duty_cycle_fully_off ( self )
114
115
}
115
- fn set_on ( & mut self ) -> Result < ( ) , Self :: Error > {
116
- T :: set_on ( self )
116
+
117
+ fn set_duty_cycle_fully_on ( & mut self ) -> Result < ( ) , Self :: Error > {
118
+ T :: set_duty_cycle_fully_on ( self )
117
119
}
118
- fn set_fraction ( & mut self , num : u16 , denom : u16 ) -> Result < ( ) , Self :: Error > {
119
- T :: set_fraction ( self , num, denom)
120
+
121
+ fn set_duty_cycle_fraction ( & mut self , num : u16 , denom : u16 ) -> Result < ( ) , Self :: Error > {
122
+ T :: set_duty_cycle_fraction ( self , num, denom)
120
123
}
121
- fn set_percent ( & mut self , percent : u8 ) -> Result < ( ) , Self :: Error > {
122
- T :: set_percent ( self , percent)
124
+
125
+ fn set_duty_cycle_percent ( & mut self , percent : u8 ) -> Result < ( ) , Self :: Error > {
126
+ T :: set_duty_cycle_percent ( self , percent)
123
127
}
124
128
}
0 commit comments