Suggy Posted July 18, 2009 Report Posted July 18, 2009 I'm hoping someone can help me. I have spent a good day reading through the GFdisplay manual and have successfully assigned switches and lights on my GoFlight panels using GFdisplay over WideFS. However, there is just one thing that I can't get right. I want to display the current frame rate (FPS) on my GF45 display. The frame rate offset is 0274. However, the frame rate is calculated by 32768/this value. Dividing 32768 by the raw value of X0274 on my calculator does indeed equate to the correct FPS. The raw value is currently showing on my GF45 display: [GF45.0] D0.1=X0274 U16 How do I write the 'code' so that 32768 is divided by this value? Examples that are shown are the other way round - take the offset and then the extra calculations e.g. X7CC U16 *360/65536 (for the autopilot heading). It's so simple what I want to do but I just can't figure it out! :-0 Best wishes, Darren Sugden
Pete Dowson Posted July 19, 2009 Report Posted July 19, 2009 IHow do I write the 'code' so that 32768 is divided by this value? Examples that are shown are the other way round - take the offset and then the extra calculations e.g. X7CC U16 *360/65536 (for the autopilot heading). Sorry, but there isn't any way to do that using GFDisplay alone. The only way would be to write a little Lua plug-in: [EDITED TO CORRECT CODE THANKS TO Darren] while 1 do frate = 32768 / ipc.readUW(0x0274) ipc.writeUW(0x66C0, frate) ipc.sleep(500) end Save this in the Modules folder as ipcReady.lua, so it gets loaded and run automatically. Display the Word from offset 0x66C0 (a user-offset), without any computations. Regards Pete
Suggy Posted July 19, 2009 Author Report Posted July 19, 2009 Thank you, Peter. Very much appreciated. Just so that people don't get confused from Peter's example, the code for frames per second is: while 1 do frate = 32768 / ipc.readUW(0x0274) ipc.writeUW(0x66C0, frate) ipc.sleep(500) end Peter used a different offset as his example and missed off a bracket. Regards, Darren Sugden
Pete Dowson Posted July 19, 2009 Report Posted July 19, 2009 Peter used a different offset as his example and missed off a bracket. Oops.Sorry, and thanks! Should take more care. Was rushing off for a flight with friend Ray! ;-) I'll correct my original too ... Oh. one other thought. Really you should read 0274 separately and check that it isn't zero, before dividing it into 32768. If it ever is zero, then the overflow error would terminate the Lua plug-in with an error in the log. So: frate = ipc.readUW(0x0274) if frate ~= 0 then .... else .... end Pete
Suggy Posted July 19, 2009 Author Report Posted July 19, 2009 Thanks, Peter. Once again, I appreciate your time in providing an answer. Best wishes, Darren Sugden
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now