• Content Count

  • Joined

  • Last visited

Everything posted by zitronen

  1. The SAS thing unfortunately is the only way I can get axes to work. Not an optimal solution, I recommend using an arduino leo in USB HID joystick mode and directly bind them in KSP input options. This might also solve your second problem as well.
  2. Hi @OKB_Carba I figured out what's wrong. Changing SAS mode only works when SAS is already on! Completely forgot about this. It was designed to be used with more than one switches, one to turn SAS on, and others to change mode. So if you have two pins, you can do this: if (digitalRead(SASPIN)) { //--------- This is how you do main controls MainControls(SAS, HIGH); } else { MainControls(SAS, LOW); } if (digitalRead(CG1PIN)) setSASMode(SMPrograde); //setting SAS mode to prograde else setSASMode(SMSAS); //setting SAS mode to normal If you only want to use a single switch you will have to manually code something in the if statement like (not tested, but should work): if (inputpin == high) { MainControls(SAS, HIGH); if ((ControlStatus(AGSAS) == True) && (getSASMode() != SMPrograde)) //if control group SAS is on and not in prograde mode setSASMode(SMPrograde) else ... } else ... Sorry about the confusion. Unfortunately, because the fuel code I stole from mechjeb only works by traversing through connection nodes, surface attached engines don't work. I have no idea how to fix this, I had to copy stuff from more competent people just to get fuel working.
  3. Sorry guys, I have some other things to worry about right now, will have a look at this later, maybe this weekend. @OKB_Carba @Wurmi
  4. Ah I think it's because you are using MainControls(PROGRADE, HIGH); If you set MainControls(PROGRADE = 8) you are actually turning on action group 3. The list of things that can be controlled by MainControls() are //Action group statuses #define AGSAS 0 #define AGRCS 1 #define AGLight 2 #define AGGear 3 #define AGBrakes 4 #define AGAbort 5 #define AGCustom01 6 #define AGCustom02 7 #define AGCustom03 8 #define AGCustom04 9 #define AGCustom05 10 #define AGCustom06 11 #define AGCustom07 12 #define AGCustom08 13 #define AGCustom09 14 #define AGCustom10 15 What you should do is else if (digitalRead(PROGRADEPIN)){ //same estructure as above MainControls(SAS, HIGH); //Input enum for PROGRADE SAS Mode setSASMode(SMPrograde); //Setting SMPrograde }
  5. OK I fixed it! Update 0.19.2: Changes: Fixed very old bug of auto detection and connection with high number (>10) COM ports, thanks to detective work from @Jimbofarrar Plugin download link: https://sites.google.com/site/zitronfiles/KSPSerialIO_019_2.zip Arduino code dowload: https://sites.google.com/site/zitronfiles/KSPIODemo17.zip
  6. Sorry for the late reply, I'm having some issues with your code. It works fine the first time, but when you revert flight and go back to launch it stops working. I'm trying to figure out what's going on.
  7. @Jimbofarrar Good work! I never quite figured out what port number format the serial port dll wanted. Thanks for the research. I'm away at a conference this week, will update the plugin with your code when I come back next week.
  8. OK you do not want to put anything in "loop()", the loop needs to run very fast without being slowed down by slow LCD stuff. Put your LCD code in "input()" under the KSP receive data if statement like this: if (KSPBoardReceiveData()){ deadtimeOld = now; returnValue = id; switch(id) { case 0: //Handshake packet Handshake(); break; case 1: Indicators(); //LCD CODE HERE ************** lcd.setCursor(0,0); lcd.print((long)VData.AP); lcd.setCursor(0,1); lcd.print((long)VData.PE); break; } //We got some data, turn the green led on digitalWrite(GLED,HIGH); Connected = true; }
  9. Well done! When you guys get stuff working, it makes me happy. I would suggest adding time to AP, it's really useful to have to know if you are going to slow or to fast to orbit efficiently. More or less. The way it's written the command goes on when pin is connected to Vcc (3.3 or 5V) not ground, but it's the same principle. Also this is set up for a switch, not a button, unless the button is latching. In order to turn on RCS, a specific bit in the controls byte of the data packet needs to be set. The maincontrols() function just makes the code easier for people to read. Rather than having to remember which bit number is RCS, and doing the bit maths do set it, you just do maincontrols(RCS, HIGH).
  10. Haha nice. This is also why I'm not sharing the code I use for my personal display, it's a huge mess! No you put the folder in GameData, like all other mods, not in PluginData. You can also use CKAN to install it automatically, since it was updated recently. Also yes you can change the default port in the config file. If the plugin can't find the default port it will check other available ports on your PC.
  11. That means it's connected. If you plug in some LEDs as described in the first post, do they work? If your inputs don't work, it's because there are problems for things like switches and axis controls in Windows 10, which are related to serial port drivers. Some arduino boards work some don't, some people report cheap ones from China have better chance of working. You can try searching this thread for previous attempts. Uh.. floats have a variable number of decimal points, that's why they are called "floating" point. Mach number is a sent as a float. Arduinos only support 32bit floats, they have about 7 significant digits (M=1.235678, M=12.345678 M=123.45678, etc.), times are always in seconds, but some are signed (int) because they can be negative and some are unsigned (UInt). The only time related variable that is a float is "deltaTime" which is the time interval in seconds since last serial packet was sent from KSP, used for calculating derivatives.
  12. If you are new, I would suggest starting with something simple, follow the instructions on the first post. Start with a button and LED. If you are using code from someone else and you have a problem, I can't really help you. Also please post the debug log https://wiki.kerbalspaceprogram.com/wiki/Debug_Toolbar
  13. You can try the latest version plugin 0.19.1 and arduino demo 17 (I updated links in first post). They should be compatible with KSP 1.7-1.3. Please post the KSP debug log, and tell us which version of the plugin and arduino code you are using.
  14. There are 2 main loops, a input and output with separate tabs. Input() has a if statement that checks if a packet is received from KSP, so put you LEDs, displays stuff in here so they only executes when you receive something new. Output() function has a if statement that checks against a timer, put your switches, axis and other controls in the controls() function this is triggered every 25ms. Avoid running stuff constantly in the background so the code has enough time to process the serial data when not doing your stuff. Remember the arduino is single threaded, it can only do one thing at a time.
  15. I think it's a bit too early to say what we can do at this stage, but this is definitely something that interest me. I still remember when I first landed on the Mun , this was like KSP 0.07, without landing legs, manoeuvre nodes or even quick save! I paid $10 for KSP, got all expansions for free. Pretty good deal! I do wish Squad and the original crew was making KSP 2, but definitely exciting times.
  16. I wouldn't worry about if statements. If statements themselves take almost no time (maybe 1 or 2 CPU cycles at 62.5ns per cycle), the digitalRead/digitalWrite functions are the slow bit, they take a few micro seconds. By default the IO pins are only checked every 25ms, when a control packet is sent to KSP, not all the time. 25ms is enough to check many 1000s of IOs with if statements. Of course you can use interrupts, but it won't make much difference in speed. Printing to LCDs, floating point math, sending and receiving serial data take far more time.
  17. No reason, just lazy and forgot! I think it's working fine with the latest KSP, I use it myself. Hmm.. The joystick code has not been updated since KSP added SAS modes, might look into changing it in the future, it is kind of outdated. I suggest for now you can use a arduino leo or similar in USB joystick mode (google arduino usb joystick if you've not done it before), and just map your axis in KSP like a normal joystick. Frankly you will have a better experience since USB HID joysticks can have much faster refresh rates than my plugin, and you won't have any SAS problems.
  18. Hmm this is weird. Why would you want to know this value? If you just want to know how deep you are in the atmosphere why not just use altitude and remember atmo start height for each planet? That formula is also odd since IRL density ratio is exponential, not 4th root. Density by itself is useful, if density halves your drag and lift halves at the same true air speed, which is why I included it.
  19. Is it not just air density? Where sea level is 100% (1.225kg/m^3) and space is 0%?
  20. Hi I'm not so sure taking out the if statement is a good idea, will reply to you on github.