Commit 62ab1198 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Add coordinates parameters to loiter function

Add latitude, longitude and altitude parameters to loiter function as this
functionality is required to land safely.
parent 6bc7a3ca
......@@ -464,11 +464,22 @@ static JSValue js_triggerParachute(JSContext *ctx, JSValueConst thisVal,
static JSValue js_loiter(JSContext *ctx, JSValueConst thisVal,
int argc, JSValueConst *argv)
{
double la_arg_double;
double lo_arg_double;
double a_arg_double;
double radius;
if (JS_ToFloat64(ctx, &radius, argv[0]))
if (JS_ToFloat64(ctx, &la_arg_double, argv[0]))
return JS_EXCEPTION;
if (JS_ToFloat64(ctx, &lo_arg_double, argv[1]))
return JS_EXCEPTION;
if (JS_ToFloat64(ctx, &a_arg_double, argv[2]))
return JS_EXCEPTION;
if (JS_ToFloat64(ctx, &radius, argv[3]))
return JS_EXCEPTION;
return JS_NewInt32(ctx, loiter((float)radius));
return JS_NewInt32(ctx, loiter(la_arg_double, lo_arg_double,
(float)a_arg_double, (float)radius));
}
static JSValue js_setAirspeed(JSContext *ctx, JSValueConst thisVal,
......@@ -591,7 +602,7 @@ static const JSCFunctionListEntry js_funcs[] = {
JS_CFUNC_DEF("takeOff", 0, js_takeOff ),
JS_CFUNC_DEF("takeOffAndWait", 0, js_takeOffAndWait ),
JS_CFUNC_DEF("triggerParachute", 0, js_triggerParachute ),
JS_CFUNC_DEF("loiter", 1, js_loiter ),
JS_CFUNC_DEF("loiter", 4, js_loiter ),
JS_CFUNC_DEF("setAirspeed", 1, js_setAirspeed ),
JS_CFUNC_DEF("setTargetCoordinates", 3, js_setTargetCoordinates ),
JS_CFUNC_DEF("getAltitude", 0, js_getAltitude ),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment