mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_Scripting: removed old servo output binding
This commit is contained in:
parent
d214e379a2
commit
b1977ca43d
@ -39,7 +39,7 @@ function update () -- periodic function that will be called
|
||||
if distance > 1000 then -- if more then 1000 meters away
|
||||
distance = 1000; -- clamp the distance to 1000 meters
|
||||
end
|
||||
servo.set_output_pwm(96, 1000 + distance) -- set the servo assigned function 96 (scripting3) to a proportional value
|
||||
SRV_Channels:set_output_pwm(96, 1000 + distance) -- set the servo assigned function 96 (scripting3) to a proportional value
|
||||
end
|
||||
|
||||
return update, 1000 -- request to be rerun again 1000 milliseconds (1 second) from now
|
||||
|
@ -24,24 +24,6 @@ int check_arguments(lua_State *L, int expected_arguments, const char *fn_name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// servo binding
|
||||
|
||||
static int lua_servo_set_output_pwm(lua_State *L) {
|
||||
check_arguments(L, 2, "set_output_pwm");
|
||||
|
||||
const SRV_Channel::Aux_servo_function_t servo_function = (SRV_Channel::Aux_servo_function_t)luaL_checkinteger(L, -2);
|
||||
luaL_argcheck(L, ((servo_function >= SRV_Channel::Aux_servo_function_t::k_scripting1) &&
|
||||
(servo_function <= SRV_Channel::Aux_servo_function_t::k_scripting16)),
|
||||
2, "function out of range");
|
||||
|
||||
const int output = luaL_checknumber(L, -1);
|
||||
luaL_argcheck(L, ((output >= 0) && (output <= UINT16_MAX)), 2, "output out of range");
|
||||
|
||||
SRV_Channels::set_output_pwm((SRV_Channel::Aux_servo_function_t)servo_function, output);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// millis
|
||||
static int lua_millis(lua_State *L) {
|
||||
check_arguments(L, 0, "millis");
|
||||
@ -58,17 +40,7 @@ static const luaL_Reg global_functions[] =
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static const luaL_Reg servo_functions[] =
|
||||
{
|
||||
{"set_output_pwm", lua_servo_set_output_pwm},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
void load_lua_bindings(lua_State *L) {
|
||||
lua_pushstring(L, "servo");
|
||||
luaL_newlib(L, servo_functions);
|
||||
lua_settable(L, -3);
|
||||
|
||||
luaL_setfuncs(L, global_functions, 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user