Sensor

45 views
Skip to first unread message

Fatih Elitas

unread,
Dec 2, 2025, 2:24:36 AM (yesterday) Dec 2
to DroidScript
Hello;
I'm creating a sensor object to create a compass app. However, the direction in degrees isn't working. Azimuth 0 value
Is it the same for you?

DS v.3
Android 12

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

    txt = app.CreateText( "", 0.8, 0.3, "Multiline" );
    lay.AddChild( txt );
    app.AddLayout( lay );

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

}

function sns_OnChange( azimuth, pitch, roll, time )
{
    var msg = " azimuth = " + azimuth.toFixed(1);
    msg += "\n pitch = " + pitch.toFixed(1);
    msg += "\n roll = " + roll.toFixed(1);
    txt.SetText( msg );
}

Alan Hendry

unread,
Dec 2, 2025, 6:51:46 AM (yesterday) Dec 2
to DroidScript
HI,
I get the same on 2.79.1, Androud 15 (pitch and roll are OK)
V3 is still in initial testing.
I'd check what sensors are available
(see example GetNames for CreateSensor)
and perhaps try MagneticField or GeoMagneticRotation, etc.
I've posted about problems before, 
usually seem to be ascribed to individual hardware
Regards, ah


Fatih Elitas

unread,
Dec 2, 2025, 8:38:55 AM (yesterday) Dec 2
to DroidScript
My phone was fine with Android 11. 
After upgrading to Android 12, it stopped working. 
Redmi Note 9 Pro. Global version. Official version

2 Aralık 2025 Salı tarihinde saat 14:51:46 UTC+3 itibarıyla hendr...@gmail.com şunları yazdı:
Reply all
Reply to author
Forward
0 new messages