Example of OnGyroscope/OnAccelerometrr

Find quick help here to get you started with Hollywood
Post Reply
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Example of OnGyroscope/OnAccelerometrr

Post by plouf »

Hello
Had anyone any working sniper using gyroscope/accelerometer ?
Christos
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: Example of OnGyroscope/OnAccelerometrr

Post by xabierpayet »

i try sometimes with the gyroscope, but i don´t can understand how this is working
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Example of OnGyroscope/OnAccelerometrr

Post 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.
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Example of OnGyroscope/OnAccelerometrr

Post by plouf »

My point is to make hollywood return ..somethink.. after that i will interprent these values..
Christos
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Example of OnGyroscope/OnAccelerometrr

Post 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
Christos
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: Example of OnGyroscope/OnAccelerometrr

Post by xabierpayet »

Wow, thank you, i must test it ASAP!
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: Example of OnGyroscope/OnAccelerometrr

Post 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.
Post Reply