@@ -110,8 +110,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
110
110
log_e ("Attaching pin to already used channel failed!" );
111
111
return false;
112
112
}
113
- }
114
- else {
113
+ } else {
115
114
ledc_timer_config_t ledc_timer = {.speed_mode = group , .timer_num = timer , .duty_resolution = resolution , .freq_hz = freq , .clk_cfg = LEDC_DEFAULT_CLK };
116
115
if (ledc_timer_config (& ledc_timer ) != ESP_OK ) {
117
116
log_e ("ledc setup failed!" );
@@ -139,8 +138,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
139
138
ledc_ll_get_duty_resolution (LEDC_LL_GET_HW (), group , timer , & channel_resolution );
140
139
log_i ("Channel %u frequency: %u, resolution: %u" , channel , ledc_get_freq (group , timer ), channel_resolution );
141
140
handle -> channel_resolution = (uint8_t )channel_resolution ;
142
- }
143
- else {
141
+ } else {
144
142
handle -> channel_resolution = resolution ;
145
143
ledc_handle .used_channels |= 1UL << channel ;
146
144
}
@@ -186,7 +184,7 @@ bool ledcWrite(uint8_t pin, uint32_t duty) {
186
184
return false;
187
185
}
188
186
189
- bool ledcWriteChannel (uint8_t channel , uint32_t duty ){
187
+ bool ledcWriteChannel (uint8_t channel , uint32_t duty ) {
190
188
//check if channel is valid and used
191
189
if (channel >= LEDC_CHANNELS || !(ledc_handle .used_channels & (1UL << channel ))) {
192
190
log_e ("Channel %u is not available (maximum %u) or not used!" , channel , LEDC_CHANNELS );
@@ -197,7 +195,7 @@ bool ledcWriteChannel(uint8_t channel, uint32_t duty){
197
195
//Fixing if all bits in resolution is set = LEDC FULL ON
198
196
uint32_t resolution = 0 ;
199
197
ledc_ll_get_duty_resolution (LEDC_LL_GET_HW (), group , timer , & resolution );
200
-
198
+
201
199
uint32_t max_duty = (1 << resolution ) - 1 ;
202
200
203
201
if ((duty == max_duty ) && (max_duty != 1 )) {
0 commit comments