Jump to content
The simFlight Network Forums

Hope you can help


Recommended Posts

Guys,

This probablly isn't a good place to ask on this forum. or yet... I couldn't think any of help regarding to what I have encountered and is trying to solve. Its been a week struggling for me. So I hope I can get help from you based on your experience, or from what you know.

Now what I was doing is trying to get OIL PSI gauges needle to display corectly out from the picture box using VB6. Let say, I have succeed getting that to work, It shows needle changing based on values from offset, but a glitch here is, The needle duplicates when the values iscreased over 21 psi or Values decreased less than 21psi. Not only that, I dont get it a smooth fluxuating..it just skipped from one point to other. To give a clear explaination here, What Happen is that once PSI out from FS2002 given 0-21 psi, needles sits at one place (7 0'clock) and whateve given over 21 psi to max it skipped over to other point (9'o'C;ock) and stay there til I until I close my application.

What appears to me thinking it has something to do with AutoRedraw.. IOr there is something else... Here is the code, (Thank to Richard for his help) mayne take a look and see what has been missing or what you can do to solve the issues that I have encountered

Dim OilPress As Long
Dim OilPressAngle As Long
Dim dwResult As Long

Call FSUIPC_Read(&H8BA, 2 , VarPtr(OilPress),dwResult)
Call FSUIPC_Process(dwResult)

If OilPress < 60 Then 

    OilPressAngle = 0 - ((60 - OilPress) * 0.75) 

Else 

    OilPressAngle = ((OilPress - 60) * 0.75) 

End If 

' On the gauge, 60 psi is a needle angle of zero, or horizontal. The 0.75 
' is a factor to make the angle of the needle match the markings on the 
' gauge face. This will be different for every gauge. 

OilPressAngle = OilPressAngle * (3.1412 / 180)    
' Converts the angle from Radians to Degrees 
picOil.CurrentX = 1500 
picOil.CurrentY = 750 
' Sets the center of the needle to the center of the gauge.' picOil is 
' the picturebox that has the image of the gauge as its background 

picOil.Line Step(0 - (500 * Cos(OilPressAngle)), (0 - (500 * Sin(OilPressAngle))))-Step(0 - (250 * Cos(OilPressAngle)), (0 - (250 * Sin(OilPressAngle)))) 
' Uses trig to calculate the start and end points of a line at an angle of 
' OilPressAngle from 250 twips from the center of the gauge to 500 
' twips from the center of the gauge

Let me know if you can help Thanks in advance

Link to comment
Share on other sites

You seem to assume that the oil pressure reading is in psi units. It is not. From the offset list I saw that in fact a value of 16384 is 55 psi. So you must probably add:

OilPressAngle=OilPress * 55 / 16384 to your code.

but this again may go wrong because you defined OilPressAngle as a long integer.

Better change OilPressAngle to a floating point number (Dim Float ?) and use:

OilPressAngle=OilPress * 55.0 / 16384.0

Better still, use FSUIPC offset 3B60, which gives you a nice double precision lbs/sq in. number. Scale this by 1/144.0 to get psi.

J.

Link to comment
Share on other sites

I gave you that factor of 55/16384 (or 298) in an earlier post. That's why the needle seems to skip around - it only displays when a value of 289 x the pressure happens to fall within the displayed range.

The reason the needle duplicates is in the code I sent you - you need a '.cls' command before every time you draw the needle.

After drawing the needle, you need to get rid of it again before you redraw it, otherwise you'll end up with a white arc - every position the needles ever been in, all showing at once.

Richard

Link to comment
Share on other sites

VBKeyBus and Rickalty,

Actuakky, I forgot to include codes from the previous topic. And this code:

OilPress = OilPress / 298
OilPressAngle = OilPress

Sorry about that, Bear with me, I'm still a VB/FSUIPC 'Dummy'.

VBKeyBus, I have tried once on your methods with offset 3B60', it worked as well with offset '08BA'. But, Specifically I was looking for some help on elimiating multiple needles displaying at once. But Thank you anyway.

Rickalty, Yes you did give that equation out to me from other topic. Its just that I forgot to include the code on this posted topic So its not like I ingore you or anything :) .

I am familar with 'CLS' Command, that was the first attempt I've tried. And result I get is a blank displays. I had to delete it and try again on every place on my app. .

So today, I went to Barnes and Noble book retailer, I read a book called Visual Basic Code Tips. One of these chapeter explaining on using CLS command. *Snap all like this, I got this popped in my head knowing where to place 'CLS' Commands.

What I realize is that I had that 'CLS; command at the wrong place. I put that at the end (before End Sub). The last attempt I did was :

If OilPress < 60 Then
    OilPressAngle  = 0 - ((60 - OilPress) * 0.75)
    PicOil.CLS
Else
    OilPressAngle = ((OilPress - 60) * 0.75)
    PicOil.CLS
End If

So finally, that come in end of stuggle for me. So before I want to close this topic. I want to thank you for you all of your help, I truly appreicate this.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.