Page 1 of 1

Example of OnGyroscope/OnAccelerometrr

Posted: Mon Aug 15, 2022 10:00 am
by plouf
Hello
Had anyone any working sniper using gyroscope/accelerometer ?

Re: Example of OnGyroscope/OnAccelerometrr

Posted: Mon Aug 15, 2022 8:52 pm
by xabierpayet
i try sometimes with the gyroscope, but i donĀ“t can understand how this is working

Re: Example of OnGyroscope/OnAccelerometrr

Posted: Mon Aug 29, 2022 10:47 pm
by airsoftsoftwair
Just use Google and look at the Android examples. Hollywood directly maps what Android returns here so there should be plenty of documentation on how to interpret these values.

Re: Example of OnGyroscope/OnAccelerometrr

Posted: Mon Aug 29, 2022 11:12 pm
by plouf
My point is to make hollywood return ..somethink.. after that i will interprent these values..

Re: Example of OnGyroscope/OnAccelerometrr

Posted: Sun Sep 11, 2022 6:30 pm
by plouf
was simpel after all.. dunno what i did wrong
here is a working example showing data and a simple LEVEL for future refence..

Code: Select all

@DISPLAY {Title = "Gyroscope and Accelerometer Test",Mode = "AutoFullScreen", X = #LEFT, Y = #TOP, Width = 414,
    Height = 896, Color = #BLACK}

Accx=1
accy=1
accz=1

gyrox=1
gyroy=1
gyroz=1

Function p_OnAccelerometer(msg)
	accx=msg.x*10
	accy=msg.y*10
	accz=msg.z*10
EndFunction

Function p_OnGyroscope(msg)
	gyrox=msg.x*10
	gyroy=msg.y*10
	gyroz=msg.z*10
EndFunction

InstallEventHandler({OnAccelerometer = p_OnAccelerometer,OnGyroscope = p_OnGyroscope})


Repeat
  	CheckEvents()
	Wait(5)
	Cls()
	Locate(0,0)
	NPrint("Acc  X = "..accX)
	NPrint("Acc  Y = "..accY)
	NPrint("Acc  X = "..accZ)
	NPrint("")
	NPrint("Gyro X = "..accx)
	NPrint("Gyro Y = "..accy)
	NPrint("Gyro Z = "..accz)

	SetFillStyle(#FILLCOLOR)
	Circle(180,180,40,#YELLOW)
	Circle(200+accx,200-accy,20,#GREEN)
	SetFillStyle(#FILLNONE)
	Circle(200,200,20,#BLACK)
	
	
Forever

Re: Example of OnGyroscope/OnAccelerometrr

Posted: Tue Sep 13, 2022 6:10 pm
by xabierpayet
Wow, thank you, i must test it ASAP!

Re: Example of OnGyroscope/OnAccelerometrr

Posted: Thu Sep 15, 2022 2:54 pm
by amyren
Tested and it works here, thank you.
Just added Orientation = #ORIENTATION_PORTRAIT to the Display command to avoid the screen rotation when testing.