Add the invert option for the ledc module (#3506)

This commit is contained in:
Philip Gladstone 2022-05-20 01:36:36 -04:00 committed by GitHub
parent ceb62993da
commit c03e7cffb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -43,6 +43,8 @@ static int lledc_new_channel( lua_State *L )
channel_config.gpio_num = opt_checkint_range(L, "gpio", -1, 0, GPIO_NUM_MAX-1);
channel_config.flags.output_invert = opt_checkbool(L, "invert", 0);
lua_settop(L, top);
esp_err_t timerErr = ledc_timer_config(&ledc_timer);

View File

@ -22,6 +22,7 @@ myChannel = ledc.newChannel({
timer=ledc.TIMER_0 || ledc.TIMER_1 || ledc.TIMER_2 || ledc.TIMER_3,
channel=ledc.CHANNEL_0 || ledc.CHANNEL_1 || ledc.CHANNEL_2 || ledc.CHANNEL_3 || ledc.CHANNEL_4 || ledc.CHANNEL_5 || ledc.CHANNEL_6 || ledc.CHANNEL_7,
frequency=x,
invert=false,
duty=x
});
```
@ -46,6 +47,7 @@ List of configuration tables:
- ...
- `ledc.CHANNEL_7`
- `frequency` Timer frequency(Hz)
- `invert` Inverts the output. False, with duty 0, is always low.
- `duty` Channel duty, the duty range is [0, (2**bit_num) - 1]. Example: if ledc.TIMER_13_BIT is used maximum value is 4096 x 2 -1 = 8091
#### Returns