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
  #1 (permalink)  
Old 07-10-2008, 01:40 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default Using Diamond's Accelerometer

It would be real cool to be able to use this in B4PPC,
Is there any way of using what this guy made?
Apparently he wrote a "managed wrapper" for the Sensor API,
I opened the file, but i think it is currently meant for VS (e.g. i couldn't find a DLL)
Reply With Quote
  #2 (permalink)  
Old 07-10-2008, 03:31 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,757
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

You try this AT YOUR OWN RISK I've no idea if it will work. Best case it will work, probably it will fail benignly, at worst you will need to hard reset your device and reinstall everything!

The original code required VS2008 and the WM6.0 SDK, neither of which I have. However I stripped out the device orientation bits of code, which won't compile with my system ,and and compiled the rest under VS2005 for WM5.0 devices. I can't test the code but it is pretty simple.

Make a HTCGSensor object and New it. Then call GetRawSensorData whenever you want to get the data. The data is returned relative to the screen face.

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 ByteConverter library
Attached Files
File Type: zip HTCSensor.zip (3.4 KB, 43 views)
Reply With Quote
  #3 (permalink)  
Old 07-10-2008, 05:05 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks agraham, that was quick

I don't have a Diamond yet, I'm waiting for the stock,
should be end of next week if everything goes well

after shoving the data through your ByteConverter Lib, will it
give me an orientation or the X,Y,Z axis?
Reply With Quote
  #4 (permalink)  
Old 07-10-2008, 06:03 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,757
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

IF it works you'll have to play, I don't really know myself. From the source
Code:
public short TiltX;   // From -1000 to 1000 (about), 0 is flat
public short TiltY;   // From -1000 to 1000 (about), 0 is flat
public short TiltZ;   // From -1000 to 1000 (about), 0 = Straight up, -1000 = Flat, 1000 = Upside down
public short Unknown1;  // Always zero
public int AngleY;  // From 0 to 359
 public int AngleX;  // From 0 to 359
public int Unknown2; // Bit field?
Reply With Quote
  #5 (permalink)  
Old 07-10-2008, 11:27 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

looks interesting...

I'll give it a go when i have one, and report back here

Thanks for your help on this
Reply With Quote
  #6 (permalink)  
Old 07-23-2008, 09:52 AM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi agraham,

Just got my t-Mobilized Diamond so I though i'd give this a go.

In the IDE I made a form and included the HTCSensor.dll
when hitting F5 i get the following error
- unable to find an entry point named HTCSendorOpen in DLL HTCSensorSDK
next I copy pasted Sensor.DLL and renamed it to HTCSensorSDK.DLL
That didn't help...

Reply With Quote
  #7 (permalink)  
Old 07-23-2008, 10:59 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,757
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Mr_Gee View Post
- unable to find an entry point named HTCSendorOpen in DLL HTCSensorSDK
I assume you mean "HTCSensorOpen". Do you have an HTCSensorSDK.dll file on the device? That message might mean the dll was found but lacked the required entry point.

Googling I found this "But HTCSensorSDK.dll is on ROM (I think) and not removeable" which implies that it should be on the device. I am afraid that I can't be of further help. The code requires that entry point in that dll.
Reply With Quote
  #8 (permalink)  
Old 07-23-2008, 11:30 AM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 205
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Yes I did, sorry..

I found the HTCSensorSDK.DLL on my device, so I copied it to the same dir as the sbp file.
next I change the sbp file to :
Code:
Sub App_Start
	Form1.Show
	sen.New1
	'TextBox1.Text = sen.GetRawSensorData
	Msgbox(sen.ToString)
End Sub
and it states "WindowsMobile.Sensor.HTCGSensor" in the popupbox

when I use the GetRawSensorData I get a "NotSupportedException"

Does that help you in any way?
Reply With Quote
  #9 (permalink)  
Old 07-23-2008, 11:49 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,757
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Ih has found the dll and the intialisation entry point or it wouldn't have got that far.
Quote:
Originally Posted by Mr_Gee View Post
when I use the GetRawSensorData I get a "NotSupportedException"
Any further information with that exception? That message is the exception type, I would have expected an additional message as well.
Reply With Quote
  #10 (permalink)  
Old 07-23-2008, 01:36 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
Ih has found the dll and the intialisation entry point or it wouldn't have got that far.
Any further information with that exception? That message is the exception type, I would have expected an additional message as well.
No there is nothing else.. I've attached a screenshot

I've used "TextBox1.Text = sen.ToString(sen.GetRawSensorData)" in this case
but to be sure i also did TextBox1.Text = sen.GetRawSensorData

same result
Attached Images
File Type: jpg tmp1.jpg (14.4 KB, 23 views)
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 02:40 PM.


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