Remove deprecated rc module
It has long been superseded by the rfswitch module
This commit is contained in:
parent
35a266e2c2
commit
61b540757a
|
@ -46,7 +46,6 @@
|
|||
//#define LUA_USE_MODULES_PIPE
|
||||
//#define LUA_USE_MODULES_PWM
|
||||
//#define LUA_USE_MODULES_PWM2
|
||||
//#define LUA_USE_MODULES_RC
|
||||
//#define LUA_USE_MODULES_RFSWITCH
|
||||
//#define LUA_USE_MODULES_ROTARY
|
||||
//#define LUA_USE_MODULES_RTCFIFO
|
||||
|
|
100
app/modules/rc.c
100
app/modules/rc.c
|
@ -1,100 +0,0 @@
|
|||
#include "module.h"
|
||||
#include "lauxlib.h"
|
||||
#include "platform.h"
|
||||
#include "user_interface.h"
|
||||
#include "rom.h"
|
||||
|
||||
//#include "driver/easygpio.h"
|
||||
//static Ping_Data pingA;
|
||||
#define defPulseLen 185
|
||||
#define defProtocol 1
|
||||
#define defRepeat 10
|
||||
#define defBits 24
|
||||
static void ICACHE_FLASH_ATTR transmit(int pin, int pulseLen, int nHighPulses, int nLowPulses) {
|
||||
platform_gpio_write(pin, 1);
|
||||
os_delay_us(pulseLen*nHighPulses);
|
||||
platform_gpio_write(pin, 0);
|
||||
os_delay_us(pulseLen*nLowPulses);
|
||||
}
|
||||
//rc.send(4,267715,24,185,1,10) --GPIO, code, bits, pulselen, protocol, repeat
|
||||
static int ICACHE_FLASH_ATTR rc_send(lua_State* L) {
|
||||
const uint8_t pin = luaL_checkinteger(L, 1);
|
||||
platform_gpio_mode(pin, PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT);
|
||||
//platform_gpio_mode(pin, PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_PULLUP);
|
||||
//platform_gpio_mode(pin, PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_PULLDOWN);
|
||||
platform_gpio_write(pin, 0);
|
||||
long code = luaL_checklong(L, 2);
|
||||
//const uint8_t bits = luaL_checkinteger(L, 3);
|
||||
uint8_t bits = luaL_checkinteger(L, 3);
|
||||
const uint8_t pulseLen = luaL_checkinteger(L, 4);
|
||||
const uint8_t Protocol = luaL_checkinteger(L, 5);
|
||||
const uint8_t repeat = luaL_checkinteger(L, 6);
|
||||
NODE_ERR("pulseLen:%d\n",pulseLen);
|
||||
NODE_ERR("Protocol:%d\n",Protocol);
|
||||
NODE_ERR("repeat:%d\n",repeat);
|
||||
NODE_ERR("send:");
|
||||
|
||||
platform_print_deprecation_note("rc",
|
||||
"in the next release. Use rfswitch module instead.");
|
||||
|
||||
int c,k,nRepeat;
|
||||
bits = bits-1;
|
||||
for (c = bits; c >= 0; c--)
|
||||
{
|
||||
k = code >> c;
|
||||
if (k & 1)
|
||||
NODE_ERR("1");
|
||||
else
|
||||
NODE_ERR("0");
|
||||
}
|
||||
NODE_ERR("\n");
|
||||
for (nRepeat=0; nRepeat<repeat; nRepeat++) {
|
||||
for (c = bits; c >= 0; c--)
|
||||
{
|
||||
k = code >> c;
|
||||
if (k & 1){
|
||||
//send1
|
||||
if(Protocol==1){
|
||||
transmit(pin,pulseLen,3,1);
|
||||
}else if(Protocol==2){
|
||||
transmit(pin,pulseLen,2,1);
|
||||
}else if(Protocol==3){
|
||||
transmit(pin,pulseLen,9,6);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//send0
|
||||
if(Protocol==1){
|
||||
transmit(pin,pulseLen,1,3);
|
||||
}else if(Protocol==2){
|
||||
transmit(pin,pulseLen,1,2);
|
||||
}else if(Protocol==3){
|
||||
transmit(pin,pulseLen,4,11);
|
||||
}
|
||||
}
|
||||
}
|
||||
//sendSync();
|
||||
if(Protocol==1){
|
||||
transmit(pin,pulseLen,1,31);
|
||||
}else if(Protocol==2){
|
||||
transmit(pin,pulseLen,1,10);
|
||||
}else if(Protocol==3){
|
||||
transmit(pin,pulseLen,1,71);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Module function map
|
||||
LROT_BEGIN(rc, NULL, 0)
|
||||
LROT_FUNCENTRY( send, rc_send )
|
||||
LROT_END(rc, NULL, 0)
|
||||
|
||||
|
||||
int luaopen_rc(lua_State *L) {
|
||||
// TODO: Make sure that the GPIO system is initialized
|
||||
return 0;
|
||||
}
|
||||
|
||||
NODEMCU_MODULE(RC, "rc", rc, luaopen_rc);
|
|
@ -1,50 +0,0 @@
|
|||
# RC Module
|
||||
| Since | Origin / Contributor | Maintainer | Source |
|
||||
| :----- | :-------------------- | :---------- | :------ |
|
||||
| 2015-06-12 | [Mike Wen](https://github.com/mikewen) | - | [rc.c](../../app/modules/rc.c)|
|
||||
|
||||
Module to generate series of impulses for remote control via 433/315Mhz radio transmitter.
|
||||
Superseded by **[rfswitch](./rfswitch.md)** module which have same functionality, and supports more transmission protocols.
|
||||
|
||||
For more detailed description see [rfswitch module documentation](./rfswitch.md).
|
||||
|
||||
!!! caution
|
||||
|
||||
This module is deprecated and will be removed in favor of the **[rfswitch](./rfswitch.md)** module.
|
||||
|
||||
## rc.send()
|
||||
Sends series of impulses
|
||||
|
||||
#### Syntax
|
||||
`rc.send(pin, value, length, pulse_length, protocol_id, repeat)`
|
||||
|
||||
which is similar to:
|
||||
`rfswitch.send(protocol_id, pulse_length, repeat, pin, value, length)`
|
||||
|
||||
|
||||
#### Parameters
|
||||
- `pin` 0~12, I/O index of pin, example 6 is for GPIO12, see [details](../modules/gpio/)
|
||||
- `value` positive integer value, this is the primary data which will be sent
|
||||
- `length` bit length of value, if value length is 3 bytes, then length is 24
|
||||
- `pulse_length` length of one pulse in microseconds, usually from 100 to 650
|
||||
- `protocol_id` positive integer value, from 1-3
|
||||
- `repeat` repeat value, usually from 1 to 5. This is a synchronous task. Setting the repeat count to a large value will cause problems.
|
||||
The recommended limit is about 1-4.
|
||||
|
||||
#### Returns
|
||||
`1` always 1
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
-- Lua transmit radio code using protocol #1
|
||||
-- pulse_length 300 microseconds
|
||||
-- repeat 5 times
|
||||
-- use pin #7 (GPIO13)
|
||||
-- value to send is 560777
|
||||
-- value length is 24 bits (3 bytes)
|
||||
rc.send(7, 560777, 24, 300, 1, 5)
|
||||
```
|
||||
which is similar to:
|
||||
```lua
|
||||
rfswitch.send(1, 300, 5, 7, 560777, 24)
|
||||
```
|
Loading…
Reference in New Issue