Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Using Diamond's Accelerometer


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 07-23-2008, 01:55 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,753
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Mr_Gee View Post
No there is nothing else
Wrong! There is a lot more information there. It shows how important it is to describe exactly and in detail rather than just saying an exception occurred.

I think that the dll might actually be working, it is your code that is trying to use the returned information incorrectly. From my earlier post
Quote:
Dim data(0)
...
HTCGSensor.New
...
data() = HTCGSensor.GetRawSensorData

In the unlikely event that it works the data is returned in a 20 byte array described in the struct at the start of the source file in the zip. You can reassemble the data the hard way by multiplying and adding bytes or by using my ByteConverter library
You have to assign the returned data to an array and pick it apart from there. The array will be an array of bytes that you have to transform to the required numbers. With my ByteConverter library it looks likes this (there may be typos/errors, I haven't actually tried the code).

Code:
TiltX = ByteConv.Int16FromBytes(data(), 0) ' From -1000 to 1000 (about), 0 is flats
TiltY = ByteConv.Int16FromBytes(data(), 2) ' From -1000 to 1000 (about), 0 is flatshort
TiltZ = ByteConv.Int16FromBytes(data(), 4) ' From -1000 to 1000 (about), 0 is flat
Unknown1 = ByteConv.Int16FromBytes(data(), 6) ' Always zero
AngleY = ByteConv.Int32FromBytes(data(), 8) 'From 0 to 359
AngleX = ByteConv.Int32FromBytes(data(), 12) 'From 0 to 359
Unknown2 = ByteConv.Int16FromBytes(data(), 16) ' Bitfield?
Reply With Quote
  #12 (permalink)  
Old 07-23-2008, 02:17 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
Wrong! There is a lot more information there. It shows how important it is to describe exactly and in detail rather than just saying an exception occurred.
Sorry you are right, I think I was just to eager to get started...

I started again from scratch
Code:
Sub Globals
	Dim data(0)
End Sub
Sub App_Start
	Form1.Show
End Sub
Sub Button1_Click
	HTCGSensor.New1
	data() = HTCGSensor.GetRawSensorData
	Msgbox(ArrayLen(data()))
End Sub
Error message is :

An error occured on sub button1_click
Line number : 15
data() = HTCGSensor.GetRawSensorData
Error description :
NotSupportedException

Last edited by Mr_Gee : 07-23-2008 at 02:21 PM.
Reply With Quote
  #13 (permalink)  
Old 07-23-2008, 04:34 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,753
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Mr_Gee View Post
NotSupportedException
Pity it doesn't tell us what is not supported

I can't see anything wrong with the code (it's only three lines long!), but I can't test it as I haven't an HTC device. I've done the same thing the long way round with this second attempt. If this doesn't work then I am afraid that I am out of ideas without having a device to play with.
Attached Files
File Type: zip Sensors2.zip (2.2 KB, 21 views)
Reply With Quote
  #14 (permalink)  
Old 07-23-2008, 06:03 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

:-)

guess what... i'm getting data back!

msgbox(ArrayLen(data())) is giving 20
and sending the data to a listbox is also working

Now for the hard part processing the data...

I have no idea where to start

I get a list of values, none of them are negative so the stuff you posted in post#4 cannot be used directly... but i'm pretty sure i'm missing something
is this something that can be deducted using your byteconverter lib?

edit added image
Attached Images
File Type: jpg Screen01.jpg (28.1 KB, 17 views)

Last edited by Mr_Gee : 07-23-2008 at 06:07 PM.
Reply With Quote
  #15 (permalink)  
Old 07-23-2008, 06:14 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,753
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Mr_Gee View Post
is this something that can be deducted using your byteconverter lib?
You will need to play. Add my ByteConverter library as a component, make an object called ByteConv and use the code I posted in #11 to take the data apart. You won't see those values I posted in #4 until you have parsed the data back into the correct format.
Reply With Quote
  #16 (permalink)  
Old 07-23-2008, 10:31 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Man..this is cool :-)

I got it working with the above code, but it's very jittery at the moment,
changes of 2 (on 2000)

I'll polish the code and post it, there must be other people wanting to use your lib :-)

Thanks for all your help on this
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:29 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0