android
  #1  
Old 02-19-2010, 08:10 PM
Tetrajak Tetrajak is offline
Member
 
Join Date: Feb 2010
Location: Oceania
Posts: 124
Default [ Tool ] Accelerometer Output display

This tool outputs the Orientation, X, Y, and Z readings from the accelerometer to the screen. It may be useful to programmers who want to know how the accelerometer works, the relationships between the axis', and how the axis readings relate to the orientation of the device.

Attached are versions for firmware 1.11.X and 1.12.X., respectively listed.

Special thanks to ThievingSix and Legostein
Attached Files
File Type: zip Accel Output.zip (1.3 KB, 286 views)
File Type: zip accel_output1_2.zip (1.2 KB, 182 views)

Last edited by Tetrajak; 03-24-2010 at 09:54 PM. Reason: Update for new firmware
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 02-19-2010, 10:15 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

I couldn't get the orientation to work either. Might be something creative typo'd.(Not the first time either).
__________________
Only ONE more functions in the Wiki need addressing!
Zen X-Fi2 LUA Wiki
Want to protect your applications? Click Here!
Tower Defense Thread
Zen Lock - Protect Your Zen!
Reply With Quote

  #3  
Old 03-24-2010, 07:47 PM
Tetrajak Tetrajak is offline
Member
 
Join Date: Feb 2010
Location: Oceania
Posts: 124
Default

Ah ok, thanks for letting me know. I'll put this on Xeroo then as it is as complete as it can be with the current script available.

EDIT: Included are versions for the new firmware and old firmware. If you have updated, please download the new version. I am pleased to report that orientation now works in the new firmware (1.12.X)
Reply With Quote

  #4  
Old 03-24-2010, 08:15 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Great, you already adjusted it to work with firmware 1.12.

But I don't see a real difference in the code. Can you explain what the difference is in the use of the accelerometer?

I think it would help a lot of people adjusting their code for the new firmware.

I also noticed that you assign four variables, while asking for just three (x,y,z):
Code:
x_acc,y_acc,z_acc,orient = accelerometer.getdata("xyz")
But it seems to work.. what am I missing?
Reply With Quote

  #5  
Old 03-24-2010, 08:22 PM
Tetrajak Tetrajak is offline
Member
 
Join Date: Feb 2010
Location: Oceania
Posts: 124
Default

I disposed of the piece that was in the water level app, which determined whether accelerometer.set_datatype worked or not, and if not, used the accelerometer.set_senddatatype, which worked in the old firmware. It appears that the new firmware doesn't like this small set of if statements, so I disposed of them and left the set_datatype statement on its own.

As for why accelerometer.getdata gets the orientation even when I only ask it for xyz, that's because the string you put in getdata is trumped by the set_datatype statement, and will return a 4th value (the orientation) even when not asked for it. I'll adjust the code and re-upload it to make it a little cleaner.

EDIT2:Turns out "xyz" now returns orientation as well, even when set_datatype is given "xyz" beforehand.

EDIT: changes have been made and the new version has been uploaded. Give the forum a few minutes to update before trying to redownload.

Last edited by Tetrajak; 03-24-2010 at 08:50 PM.
Reply With Quote

  #6  
Old 03-24-2010, 08:35 PM
ThievingSix ThievingSix is offline
Member
 
Join Date: Aug 2008
Posts: 218
Default

My wha? The water level app was not mine =P
__________________
Only ONE more functions in the Wiki need addressing!
Zen X-Fi2 LUA Wiki
Want to protect your applications? Click Here!
Tower Defense Thread
Zen Lock - Protect Your Zen!
Reply With Quote

  #7  
Old 03-24-2010, 08:50 PM
Tetrajak Tetrajak is offline
Member
 
Join Date: Feb 2010
Location: Oceania
Posts: 124
Default

Quote:
Originally Posted by ThievingSix View Post
My wha? The water level app was not mine =P
My bad, post edited.
Reply With Quote

  #8  
Old 07-16-2010, 04:31 PM
HappyMeal HappyMeal is offline
Junior Member
 
Join Date: Jul 2010
Posts: 6
Default

would it be possible to make the app write a log-file of the acceleration?
Reply With Quote

  #9  
Old 07-17-2010, 04:00 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Quote:
Originally Posted by HappyMeal View Post
would it be possible to make the app write a log-file of the acceleration?
Tetrajak left us.. I don't know if he still checks his threads.

But yeah it would be possible I guess, but I have the feeling it will be quite buggy, and I don't have time to play around with it right now.
Reply With Quote

  #10  
Old 07-17-2010, 04:54 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

I think it is very much possible. If you can type it out on the screen then you can type it to a file which is then saved. You just have to decide on an interval to log it and add that into the code. I don't think Tetra checks his threads since he doesn't own the device anymore. I might take a look at it once I get more free time, but I'm busy until the end of July and then I have my own big project to work on. But I might squeeze this in if I hit a dead end somewhere and need to take a break.

Brett, could you just tell me quickly how to save a file as a .txt from the Zen? I believe it's possible in your notepad but I don't remember exactly how it was done.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #11  
Old 07-18-2010, 10:06 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Quote:
Originally Posted by Habhome View Post
Brett, could you just tell me quickly how to save a file as a .txt from the Zen? I believe it's possible in your notepad but I don't remember exactly how it was done.
datawrite = io.open("log.txt", "a+")
datawrite:write(os.date() .. "\t" .."data" .. "\r\n")
datawrite:close()


a+ is update mode, see the lua wiki for more.
Reply With Quote

  #12  
Old 12-20-2010, 06:18 PM
Jerryherz Jerryherz is offline
Junior Member
 
Join Date: Jul 2010
Posts: 2
Default

Using the code for firmware version 1.11.01, the program works fine for a while, (except for orientation), but then locks up the Zen. Why, is it just my unit?

Thanks for the code, very useful for a nobie in Lua programming.

Jerry
Reply With Quote

Reply

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 03:08 AM.