Unverified Commit c03e7cff authored by Philip Gladstone's avatar Philip Gladstone Committed by GitHub
Browse files

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

parent ceb62993
...@@ -43,6 +43,8 @@ static int lledc_new_channel( lua_State *L ) ...@@ -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.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); lua_settop(L, top);
esp_err_t timerErr = ledc_timer_config(&ledc_timer); esp_err_t timerErr = ledc_timer_config(&ledc_timer);
......
...@@ -22,6 +22,7 @@ myChannel = ledc.newChannel({ ...@@ -22,6 +22,7 @@ myChannel = ledc.newChannel({
timer=ledc.TIMER_0 || ledc.TIMER_1 || ledc.TIMER_2 || ledc.TIMER_3, 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, 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, frequency=x,
invert=false,
duty=x duty=x
}); });
``` ```
...@@ -46,6 +47,7 @@ List of configuration tables: ...@@ -46,6 +47,7 @@ List of configuration tables:
- ... - ...
- `ledc.CHANNEL_7` - `ledc.CHANNEL_7`
- `frequency` Timer frequency(Hz) - `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 - `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 #### Returns
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment