Is it possible to use TX2 (from second uart) from Lua Nodemcu or did somebody implemented successfully software, bitbang uart tx?
Thanks,
Patriko
Explore... Chat... Share...
#include "lualib.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#define Baudrate 2400
#define OneBitDelay (1000000/Baudrate)
#define DataBitCount 8
static int ICACHE_FLASH_ATTR rgbw_write(lua_State* L) {
const uint8_t pin = luaL_checkinteger(L, 1);
size_t length;
const char *buffer = luaL_checklstring(L, 2, &length);
char c = *buffer;
platform_gpio_mode(pin, PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT);
platform_gpio_write(pin, 0);
os_intr_lock();
os_delay_us(OneBitDelay);
uint8_t mask = 0;
unsigned char i = 0;
for(i = 0; i < DataBitCount; i++)
{
if((c>>i)&0x01)
{
platform_gpio_write(pin, 1);
}
else
{
platform_gpio_write(pin, 0);
}
os_delay_us(OneBitDelay);
}
//stop bit
platform_gpio_write(pin, 1);
os_delay_us(OneBitDelay);
os_intr_unlock();
return 0;
}
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
const LUA_REG_TYPE rgbw_map[] =
{
{ LSTRKEY( "write" ), LFUNCVAL( rgbw_write )},
{ LNILKEY, LNILVAL}
};
LUALIB_API int luaopen_rgbw(lua_State *L) {
LREGISTER(L, "rgbw", rgbw_map);
return 1;
}
// ----------------------------------------------------------------------------
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]