sensor de proximidad

39 views
Skip to first unread message

Nahomi Estrada

unread,
Mar 5, 2019, 7:55:19 PM3/5/19
to DroidScript
Hola....

Disculpen alguien me podría apoyar con la codificación de una aplicación utilizando el sensor de proximidad.
Quiero que cuando se pase la mano por el mismo encienda y apague la pantalla.
Les agradecería bastante,espero y me puedan apoyar.
mi para un trabajo escolar. 

Steve Garman

unread,
Mar 6, 2019, 12:28:57 AM3/6/19
to androi...@googlegroups.com
I suggest you start with something like the code below to see what effect bringing your hand very close to the sensor has.

Then you can add code to the sns_OnChange function to perform whatever actions you need to.

// code -------------------------

function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

txt = app.CreateText( "Waiting", 0.8, 0.3, "multiLine,left" );
lay.AddChild( txt );
app.AddLayout( lay );

sns = app.CreateSensor( "Proximity");
sns.SetOnChange( sns_OnChange );
sns.Start();

}

function sns_OnChange( distance ,p2, p3,time)
{
txt.SetText( "Distance = " + distance +
"\ntime=" + time);
}

Reply all
Reply to author
Forward
0 new messages