Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
c03e7cff
Unverified
Commit
c03e7cff
authored
May 20, 2022
by
Philip Gladstone
Committed by
GitHub
May 20, 2022
Browse files
Add the invert option for the ledc module (#3506)
parent
ceb62993
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/modules/ledc.c
View file @
c03e7cff
...
@@ -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
);
...
...
docs/modules/ledc.md
View file @
c03e7cff
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment