mirror of https://github.com/ArduPilot/ardupilot
AP_Scripting: Swap reschedule to be callback, delay
This commit is contained in:
parent
ecb1a433b1
commit
2afe72d79f
|
@ -31,8 +31,6 @@ int lua_servo_set_output_pwm(lua_State *state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRV_Channels::set_output_pwm((SRV_Channel::Aux_servo_function_t)servo_function, output_value);
|
SRV_Channels::set_output_pwm((SRV_Channel::Aux_servo_function_t)servo_function, output_value);
|
||||||
|
|
||||||
gcs().send_text(MAV_SEVERITY_INFO, "Set to %d", output_value);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,25 +184,25 @@ void lua_scripts::run_next_script(lua_State *L) {
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// sanity check the return types
|
// sanity check the return types
|
||||||
if (lua_type(L, -2) != LUA_TNUMBER) {
|
if (lua_type(L, -1) != LUA_TNUMBER) {
|
||||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "Lua: %s did not return a delay (0x%d)", script->name, lua_type(L, -2));
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "Lua: %s did not return a delay (0x%d)", script->name, lua_type(L, -1));
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
remove_script(L, script);
|
remove_script(L, script);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lua_type(L, -1) != LUA_TFUNCTION) {
|
if (lua_type(L, -2) != LUA_TFUNCTION) {
|
||||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "Lua: %s did not return a function (0x%d)", script->name, lua_type(L, -1));
|
gcs().send_text(MAV_SEVERITY_CRITICAL, "Lua: %s did not return a function (0x%d)", script->name, lua_type(L, -2));
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
remove_script(L, script);
|
remove_script(L, script);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// types match the expectations, go ahead and reschedule
|
// types match the expectations, go ahead and reschedule
|
||||||
|
script->next_run_ms = AP_HAL::millis64() + (uint64_t)luaL_checknumber(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
int old_ref = script->lua_ref;
|
int old_ref = script->lua_ref;
|
||||||
script->lua_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
script->lua_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, old_ref);
|
luaL_unref(L, LUA_REGISTRYINDEX, old_ref);
|
||||||
script->next_run_ms = AP_HAL::millis64() + (uint64_t)luaL_checknumber(L, -1);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
reschedule_script(script);
|
reschedule_script(script);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue