Allow use of GPIO 0
This commit is contained in:
parent
39c95722e3
commit
a94fc1000e
|
@ -145,13 +145,13 @@ static int lrotary_setup( lua_State* L )
|
|||
d->longpress_delay_us = LONGPRESS_DELAY_US;
|
||||
|
||||
int phase_a = luaL_checkinteger(L, 1);
|
||||
luaL_argcheck(L, platform_gpio_exists(phase_a) && phase_a > 0, 1, "Invalid pin");
|
||||
luaL_argcheck(L, platform_gpio_exists(phase_a), 1, "Invalid pin");
|
||||
int phase_b = luaL_checkinteger(L, 2);
|
||||
luaL_argcheck(L, platform_gpio_exists(phase_b) && phase_b > 0, 2, "Invalid pin");
|
||||
luaL_argcheck(L, platform_gpio_exists(phase_b), 2, "Invalid pin");
|
||||
int press;
|
||||
if (nargs >= 3) {
|
||||
press = luaL_checkinteger(L, 3);
|
||||
luaL_argcheck(L, platform_gpio_exists(press) && press > 0, 3, "Invalid pin");
|
||||
luaL_argcheck(L, platform_gpio_exists(press), 3, "Invalid pin");
|
||||
} else {
|
||||
press = -1;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ Initialize the nodemcu to talk to a rotary encoder switch.
|
|||
`switch = rotary.setup(pina, pinb[, pinpress[, longpress_time_ms[, dblclick_time_ms]]])`
|
||||
|
||||
#### Parameters
|
||||
- `pina` This is a GPIO number (excluding 0) and connects to pin phase A on the rotary switch.
|
||||
- `pinb` This is a GPIO number (excluding 0) and connects to pin phase B on the rotary switch.
|
||||
- `pinpress` (optional) This is a GPIO number (excluding 0) and connects to the press switch.
|
||||
- `pina` This is a GPIO number and connects to pin phase A on the rotary switch.
|
||||
- `pinb` This is a GPIO number and connects to pin phase B on the rotary switch.
|
||||
- `pinpress` (optional) This is a GPIO number and connects to the press switch.
|
||||
- `longpress_time_ms` (optional) The number of milliseconds (default 500) of press to be considered a long press.
|
||||
- `dblclick_time_ms` (optional) The number of milliseconds (default 500) between a release and a press for the next release to be considered a double click.
|
||||
|
||||
|
@ -49,6 +49,10 @@ Nothing. If the arguments are in error, or the operation cannot be completed, th
|
|||
|
||||
switch = rotary.setup(5, 6, 7)
|
||||
|
||||
#### Notes
|
||||
|
||||
This module uses pullups on the GPIO pins to detect the key presses. However, not all GPIO pins support pullups and so, if one of those pins is used, then there needs to be a real external resistor pullup.
|
||||
|
||||
## switch:on()
|
||||
Sets a callback on specific events.
|
||||
|
||||
|
|
Loading…
Reference in New Issue