@@ -58,67 +58,71 @@ impl<T: ErrorType> ErrorType for &mut T {
5858}
5959
6060/// Single PWM channel / pin
61- pub trait SetDuty : ErrorType {
61+ pub trait SetDutyCycle : ErrorType {
6262 /// Get the maximum duty cycle value.
6363 ///
6464 /// This value corresponds to a 100% duty cycle.
65- fn get_max_duty ( & self ) -> u16 ;
65+ fn get_max_duty_cycle ( & self ) -> u16 ;
6666
6767 /// Set the duty cycle to `duty / max_duty`.
6868 ///
6969 /// The caller is responsible for ensuring that the duty cycle value is less than or equal to the maximum duty cycle value,
7070 /// 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 > ;
7272
7373 /// Set the duty cycle to 0%, or always inactive.
7474 #[ 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 )
7777 }
7878
7979 /// Set the duty cycle to 100%, or always active.
8080 #[ 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 ( ) )
8383 }
8484
8585 /// Set the duty cycle to `num / denom`.
8686 ///
8787 /// The caller is responsible for ensuring that `num` is less than or equal to `denom`,
8888 /// and that `denom` is not zero.
8989 #[ 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 )
9393 }
9494
9595 /// Set the duty cycle to `percent / 100`
9696 ///
9797 /// The caller is responsible for ensuring that `percent` is less than or equal to 100.
9898 #[ 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 )
101101 }
102102}
103103
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 )
107107 }
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)
110111 }
111112
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 )
114115 }
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 )
117119 }
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)
120123 }
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)
123127 }
124128}
0 commit comments