Jump to content

LEDJeb [0.90][WIP] A Physical and Virtual LED Readout


heaton84

Recommended Posts

Update 1/11/2015: Version 0.2 Beta is out.

Releases are now posted on the Add-on Releases forum. Post is here: http://forum.kerbalspaceprogram.com/threads/107006-0-90-LEDJeb-Flight-Data-Readout-0-2-Beta-2015-01-11

Update 1/10/2015: Version 0.1 Alpha is out for KSP 0.90! Link is below.

LEDJeb provides an interface for a physical LED readout based on MAX7219 display modules. It also provides a virtual panel to both facilitate testing, and to be used by those who don't care to invest in the physical display but do have a second monitor to spare.

The plugin will be configurable and scalable. You can have one display, or you could have 100 displays.

Source and binaries are all available HERE. Be sure to check out the readme file!

Version 0.1 Alpha - Known Bugs

  • The virtual readout program must be started before you launch KSP, or it won't work.
  • There is no time to intercept or estimated burn time yet. I am still sorting out how MechJeb calculates these to emulate it.
  • Currently, no decimal points are sent down to the readout client. This means that velocity and inclination both are displayed as "times 10", it's really just missing the decimal.
  • The plugin WILL CRASH KSP when KSP is closed. I am still trying to figure out why this happens.
  • Distances are auto-scaled to KM and MM, but there is currently no indication as to which scaling is present. Open to ideas on how this would be done on a physical panel.
  • Relative inclination (ascending node) seems to be wrong at the moment.

uE15Mxp.png

Edited by heaton84
First release of plugin
Link to comment
Share on other sites

I don't have a project set up to get all the details right now, but I can get you started in the right direction !

vessel.patchedConicSolver.maneuverNodes[0] is the next node, and it has properties for time, direction, and deltav. I don't remember exactly what those properties are... or what math I had to do to get them into useful numbers... but that's the start. If it's not obvious (and, in my experience, not much in the KSP API IS obvious) shout at me and I'll dig out an old project that dealt with this to see if I can be of more help.

If you're not already doing it, the best way I've found to figure out anything in KSP coding is to dig through the source code for mechjeb. It's a big project so figuring out where they grab or calculate anything takes a little time, but they've figured out how to get just about every useful bit of info out of KSP... so when I'm trying to figure something out, that's my go to source!

Which method are you using to get the data out of KSP? I've played with doing it via HTTP, both using the telemachus plugin as a server inside KSP, and using my own plugin to do HTTP Post messages out of KSP to a server in the remote application.

Art

Link to comment
Share on other sites

I don't have a project set up to get all the details right now, but I can get you started in the right direction !

vessel.patchedConicSolver.maneuverNodes[0] is the next node, and it has properties for time, direction, and deltav. I don't remember exactly what those properties are... or what math I had to do to get them into useful numbers... but that's the start. If it's not obvious (and, in my experience, not much in the KSP API IS obvious) shout at me and I'll dig out an old project that dealt with this to see if I can be of more help.

If you're not already doing it, the best way I've found to figure out anything in KSP coding is to dig through the source code for mechjeb. It's a big project so figuring out where they grab or calculate anything takes a little time, but they've figured out how to get just about every useful bit of info out of KSP... so when I'm trying to figure something out, that's my go to source!

Which method are you using to get the data out of KSP? I've played with doing it via HTTP, both using the telemachus plugin as a server inside KSP, and using my own plugin to do HTTP Post messages out of KSP to a server in the remote application.

Art

Thanks! I was starting to look into MechJeb, but you are right, it's a large project. I at least have a starting point of what to look for... will report back if I can't figure it out.

I am using sockets. The ultimate goal is to feed the data out via a serial port to drive a real display, so this was the closest mechanism I could find that I could boil down to an interface quickly.

You mis-spelled Inclination...

Sorry to be "that guy"

This looks rather useful for folks who, like me, have 2 monitors.

Oh, you. Heh, yeah I'll fix that. Thanks for the feedback!

Link to comment
Share on other sites

If memory serves... getting the time of the next node is easy, it's .UT or something similar. Getting deltaV took a conversion. Another good place to look for examples of grabbing data is the RPM source - the core/propmonitorcomputer file is where most of that magic happens... They're getting deltav with .GetBurnVector(vessel.orbit).magnitude Again, it's been a while, so I'm not sure if that will compile or if you'll have to resolve any alias's or methods that's calling.

One of these days I'm going to sit down and learn something about IPC for Linux and Mac and make a plugin that just rapidly gets ALL of the data out of KSP, so third party plugins and apps can use it. For Windows it seems like a memory mapped file would be perfect - as you could write all the flight data to it every frame and multiple apps could read from it and use the data any way they want... and they could even write instructions to it that could get spotted by the KSP plugin. That way everyone who wants to display data, or pass it to an arduino, or make a navball, or make a webservice, or build a control panel wouldn't have to reinvent the wheel. But I'd want it to work on all three platforms, and I don't know if there's a good fast method of IPC that they all handle well. There are a lot of things ahead of this on my 'one of these days' list though.

Another cute thing I played with that could help you when you get to the hardware stage... I fiddled with a tm4c1294 connected launchpad ($25 dev board, with ethernet jack) and managed to get it talking both ways with Telemachus. Haven't done anything with it yet other than demonstrating that it worked, but it was stupid simple to make it light an led when SAS was enabled... and I used the hardware buttons to toggle Mechjeb SMARTASS on and off. It's got enough IO that I may someday hook a whole cockpit to it. It's, of course, not as simple as your serial port solution, but if you find yourself needing more io, it's a cool, cheap board that can communicate directly on the network with KSP, if it needs to and with Energia, it runs Arduino code. :)

Link to comment
Share on other sites

Ok, I have everything except time to intercept and burn time remaining.

The MechJeb stuff on burn time remaining is rather... involved. I have to either rely on MechJeb or extract it all out piece by piece.

For "relative inclination" (ascending node), I literally added together the current vessel's obit.inclination and the target vessel's orbit.inclination, and it appears to match the game's ascending node value pretty closely. This seems counter-intuitive, but if it works, it works I guess.

Still a bit of cleanup to get things less... Kerbal.... and I want to get decimal points working. Then, I think I'm ready to share an early release.

For hardware, I'm looking at a Microchip PIC 16F628A. Since I am designing with daisy-chained MAX7219's in mind, the protocol is a bit wonky but it definitely works.

Link to comment
Share on other sites

If you're not already doing it, the best way I've found to figure out anything in KSP coding is to dig through the source code for mechjeb. It's a big project so figuring out where they grab or calculate anything takes a little time, but they've figured out how to get just about every useful bit of info out of KSP... so when I'm trying to figure something out, that's my go to source!

Feel free to pop on IRC and ask me question if you need info about some MJ stuff. I'm there most evening and weekend (GMT+1)

Link to comment
Share on other sites

Release 0.1 alpha is out! Heads up: it crashes KSP when you close the game. Is anyone familiar with InternalGetGameObject throwing a NullReferenceException?

NullReferenceException

at (wrapper managed-to-native) UnityEngine.Component:InternalGetGameObject ()

at UnityEngine.Component.get_gameObject () [0x00000] in <filename unknown>:0

at ApplicationLauncher.ScaleModList () [0x00000] in <filename unknown>:0

at ApplicationLauncher.RemoveApplication (.ApplicationLauncherButton button) [0x00000] in <filename unknown>:0

at ResourceDisplay.OnDestroy () [0x00000] in <filename unknown>:0

Link to comment
Share on other sites

  • 2 weeks later...

Update, release 0.25 is out. Thread here.

One thought on the readout scaling.... I could place the decimal point based on UOM. For example:

0000000.0 M

000000.00 KM

00000.000 MM

0000.0000 GM

This would let me get away with simple labels on the physical panel, and the virtual panel could infer scaling from this convention. It's either this, or allow for a separate controller to illuminate scaling on the final panel (more $$$).

On the physical side of things, I have a rough proof of concept working in MPLAB's simulator. Once I get a few more parts in, I should be able to breadboard up a physical readout!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...