android
Prev Previous Post   Next Post Next
  #1  
Old 01-21-2011, 12:55 PM
Saponificio Saponificio is offline
Junior Member
 
Join Date: Jan 2011
Posts: 2
Default Accelerometer app

Hi! I'm trying to understand how accelerometer works so I made an easy app to display accel. x y z and orientation but it doesn't work... It's my first app so I'm not sure if everything is correct. Help!

Accelerometer test:

Code:
height=screen.height()
width=screen.width()

black=color.new(0,0,0)

strx="acc. x value: "
stry="acc. y value: "
strz="acc. z value: "
stro="acc. orientation: "
err="ERROR OPENING ACC."
all="all"

accok=accelerometer.open()
os.sleep(10)

if accok==0 then
	accelerometer.set_datatype(all)
	while 1 do
		screen.fillrect(0,0,width,height,black)
		x,y,z,o=accelerometer.getdata(all)
		text.draw(5,20,strx..x,"center",width)
		text.draw(5,60,stry..y,"center",width)
		text.draw(5,100,strz..z,"center",width)
		text.draw(5,140,stro..o,"center",width)
		screen.update()
		if control.read()==1 then
			if control.IsButton()==1 then
				if button.home()==1 then
					accelerometer.close()
					break
				end
			end
		end
	end
else
	screen.fillrect(0,0,width,height,black)
	text.draw(5,20,"center",width)
	screen.update()
end
Reply With Quote

Advertisement [Remove Advertisement]

 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:58 PM.