this is new function in tmr.c
// Lua: servo_pulse( us , pin )
static int tmr_servo_pulse( lua_State* L )
{
s32 us;
unsigned pin;
us = luaL_checkinteger( L, 1 );
pin = luaL_checkinteger( L, 2 );
MOD_CHECK_ID( gpio, pin );
if ( us <= 0 )
return luaL_error( L, "wrong arg range" );
if ( us >= 1000000 )
return luaL_error( L, "too long delay" );
//noInterrupts();
DIRECT_WRITE_HIGH(pin); // drive output high
delayMicroseconds(us);
DIRECT_WRITE_LOW(pin);
//interrupts();
return 0;
}
you must write it to tmr_map[]
and this is code in lua to generate pulse
pin_servo = 3
servo_pulse_lenght = 1500
tmr.alarm(0, 20, 1, function()
tmr.servo_pulse(servo_pulse_lenght,pin_servo)
end)