Skip to content

Commit

Permalink
ci(pre-commit): Apply automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Jul 16, 2024
1 parent bc694ce commit 4dbde96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions cores/esp32/esp32-hal-ledc.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
log_e("Attaching pin to already used channel failed!");
return false;
}
}
else {
} else {
ledc_timer_config_t ledc_timer = {.speed_mode = group, .timer_num = timer, .duty_resolution = resolution, .freq_hz = freq, .clk_cfg = LEDC_DEFAULT_CLK};
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
log_e("ledc setup failed!");
Expand Down Expand Up @@ -139,8 +138,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
ledc_ll_get_duty_resolution(LEDC_LL_GET_HW(), group, timer, &channel_resolution);
log_i("Channel %u frequency: %u, resolution: %u", channel, ledc_get_freq(group, timer), channel_resolution);
handle->channel_resolution = (uint8_t)channel_resolution;
}
else {
} else {
handle->channel_resolution = resolution;
ledc_handle.used_channels |= 1UL << channel;
}
Expand Down Expand Up @@ -186,7 +184,7 @@ bool ledcWrite(uint8_t pin, uint32_t duty) {
return false;
}

bool ledcWriteChannel(uint8_t channel, uint32_t duty){
bool ledcWriteChannel(uint8_t channel, uint32_t duty) {
//check if channel is valid and used
if (channel >= LEDC_CHANNELS || !(ledc_handle.used_channels & (1UL << channel))) {
log_e("Channel %u is not available (maximum %u) or not used!", channel, LEDC_CHANNELS);
Expand All @@ -197,7 +195,7 @@ bool ledcWriteChannel(uint8_t channel, uint32_t duty){
//Fixing if all bits in resolution is set = LEDC FULL ON
uint32_t resolution = 0;
ledc_ll_get_duty_resolution(LEDC_LL_GET_HW(), group, timer, &resolution);

uint32_t max_duty = (1 << resolution) - 1;

if ((duty == max_duty) && (max_duty != 1)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example shows how to software fade LED
using the ledcWriteChannel function on multiple pins.
This example is useful if you need to control synchronously
This example is useful if you need to control synchronously
multiple LEDs on different pins.
Code adapted from original Arduino Fade example:
Expand Down

0 comments on commit 4dbde96

Please sign in to comment.