CommanderMAM
Members-
Posts
15 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by CommanderMAM
-
Ok, been messing around here's what I've figured out. 1) My LCD uses i2c and is (a 20 by 4 character display) 2) My code works as long as all the portions involving the LCD are commented out 3) This means that the issue involves these lines of code: Under void setup in the main page (for the demo, the one titled Demo17, for me its titled KerbalCode): Serial.begin(9600); //LCD Connection lcd.init(); lcd.backlight(); //write to LCD lcd.clear(); lcd.setCursor(0,0); lcd.print("KerbalController"); lcd.setCursor(0,1); lcd.print("booting..."); Under void Indicators in the utilities tab: //MODE 0 : TakeOff Mode if(digitalRead(LCDPINA) == HIGH){ //Mode 1 Takeoff Mode lcd.clear(); //Vsurf lcd.setCursor(0,0); char bufferVsurf[17]; String strVsurf = "Vsurf: "; strVsurf += String(VData.Vsurf, 0); strVsurf += " m/s"; strVsurf.toCharArray(bufferVsurf,17); lcd.print(bufferVsurf); //Acceleration (G) lcd.setCursor(0,1); char bufferGee[17]; String strGee = "G-Force: "; strGee += String(VData.G, 0); strGee += " G"; strGee.toCharArray(bufferGee,17); lcd.print(bufferGee); //Altitude from Sea Level lcd.setCursor(0,2); char bufferAtl[17]; String strAlt = "Alt: "; strAlt += String(VData.Alt, 0); strAlt += " m"; strAlt.toCharArray(bufferAtl,17); lcd.print(bufferAtl); } if(digitalRead(LCDPINA) == LOW){ //MODE 2: Orbit Mode lcd.clear(); //VOrbit lcd.setCursor(0,0); char bufferVOrbit[17]; String strVOrbit = "VOrbit: "; strVOrbit += String(VData.VOrbit, 0); strVOrbit += " m/s"; strVOrbit.toCharArray(bufferVOrbit,17); lcd.print(bufferVOrbit); //Altitude from Sea Level lcd.setCursor(0,1); char bufferAtl[17]; String strAlt = "Alt: "; strAlt += String(VData.Alt, 0); strAlt += " m"; //Apoapsis lcd.setCursor(0,2); char bufferAP[17]; String strApo = "AP: "; if (VData.AP < 10000 && VData.AP > -10000) { strApo += String(VData.AP,0); strApo += "m "; } else if ((VData.AP >= 10000 && VData.AP < 10000000) || (VData.AP <= -10000 && VData.AP > -10000000)) { strApo += String((VData.AP / 1000),0); strApo += "km "; } else if ((VData.AP >= 10000000 && VData.AP < 10000000000) || (VData.AP <= -10000000 && VData.AP > -10000000000)) { strApo += String((VData.AP / 1000000),0); strApo += "Mm "; } else { strApo += String((VData.AP / 1000000000),0); strApo += "Gm "; } strApo += String(VData.TAp); //time to apoapsis strApo += "s"; strApo.toCharArray(bufferAP,17); lcd.print(bufferAP); //Periapsis lcd.setCursor(0,3); char bufferPE[17]; String strPeri = "PE: "; if (VData.PE < 10000 && VData.PE > -10000) { strPeri += String(VData.PE,0); strPeri += "m "; } else if ((VData.PE >= 10000 && VData.PE < 10000000) || (VData.PE <= -10000 && VData.PE > -10000000)) { strPeri += String((VData.PE / 1000.0),0); strPeri += "km "; } else if ((VData.PE >= 10000000 && VData.PE < 10000000000) || (VData.PE <= -10000000 && VData.PE > -10000000000)) { strPeri += String((VData.PE / 1000000.0),0); strPeri += "Mm "; } else { strPeri += String((VData.PE / 1000000000.0),0); strPeri += "Gm "; } strPeri += String(VData.TPe); //time to periapsis strPeri += "s"; strPeri.toCharArray(bufferPE,17); lcd.print(bufferPE); } Only other code relating to the LCD is just some basic defining stuff in the main page and the output page, and works without being commented out. Main page: #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 20 chars and 4 line display Under void controlsInit in the output page: pinMode(LCDPINA, INPUT); Not sure what could be messing things up, maybe something with the Serial connection? Any help or insight would be greatly appreciated.
-
I seem to be having an issue where the controller is taking a very long time to connect to the game once the flight has started. This started once I wired an LCD to my controller and started coding it. I'm not sure if it is a coding problem, an issue with the plugin, or possibly something to do with crossed wires, but after removing the LCD code the issue persists, and I am in the process of rewiring part of my controller but so far it hasn't fixed anything. Is there some way I can upload my code other than pasting it in a post? It is mostly based off of the KSPDemo_17 code but there is a lot of additions for various other functions scattered about.
-
Thanks for the help, I did get it to where the throttle could be manually disabled via a switch. I then went on to do the same thing for the axis controls as well using the same switch, which (after almost posting an issue here only to realize my ground wire had come unplugged) is now working perfectly. Here's the code I'm using: //throttle slide pot int THROTTLE = map(1018-analogRead(THROTTLEPIN),0,1018,0,1000); //switch if (!digitalRead(MASTERSWITCH)){ CPacket.Throttle = constrain(THROTTLE,0,1000); //joysticks rotational if(analogRead(pRX) >= 530){CPacket.Yaw = constrain(map(analogRead(pRX),660,530,-1000,0),-1000,0);} //calibrated else if(analogRead(pRX) <= 490){CPacket.Yaw = constrain(map(analogRead(pRX),490,360,0,1000),0,1000);} //calibrated else {CPacket.Yaw = 0;} if(analogRead(pRY) >= 530){CPacket.Pitch = constrain(map(analogRead(pRY),530,660,0,1000),0,1000);} //calibrated else if(analogRead(pRY) <= 490){CPacket.Pitch = constrain(map(analogRead(pRY),360,490,-1000,0),-1000,0);} //calibrated else {CPacket.Pitch = 0;} if(analogRead(pRZ) <= 490){CPacket.Roll = constrain(map(analogRead(pRZ),300,490,-1000,0),-1000,0);} //calibrated else if(analogRead(pRZ) >= 510){CPacket.Roll = constrain(map(analogRead(pRZ),510,700,0,1000),0,1000);} //calibrated else {CPacket.Roll = 0;} //joysticks translational if(analogRead(pTX) >= 530){CPacket.TX = constrain(map(analogRead(pTX),530,660,0,1000),0,1000);} //calibrated else if(analogRead(pTX) <= 490){CPacket.TX = constrain(map(analogRead(pTX),360,490,-1000,0),-1000,0);} //calibrated else {CPacket.TX = 0;} if(analogRead(pTY) >= 530){CPacket.TY = constrain(map(analogRead(pTY),660,530,-1000,0),-1000,0);} //calibrated else if(analogRead(pTY) <= 490){CPacket.TY = constrain(map(analogRead(pTY),490,360,0,1000),0,1000);} //calibrated else {CPacket.TY = 0;} if(analogRead(pTZ) <= 490){CPacket.TZ = constrain(map(analogRead(pTZ),300,490,-1000,0),-1000,0);} //calibrated else if(analogRead(pTZ) >= 510){CPacket.TZ = constrain(map(analogRead(pTZ),510,700,0,1000),0,1000);} //calibrated else {CPacket.TZ = 0;} Now all that's left is the abort and stage arm toggle switches, some specific action group buttons (gear, comms, solar, brakes, etc), a numpad (for action groups in general plus time warp if it gets added), joystick buttons (for SAS states), LCD and its accompanying control switches, and the LED bar graphs (to show fuel levels and for the gods to torture me with). Will post pics/vids of it when I'm done coding and have made a proper case for it (right now its a nice clear laser-engraved acrylic faceplate balanced on a cardboard box). Thanks again for the help!
-
Hi, I'm working on building my own Kerbal Controller (the physical side of it is nearly finished) and was trying to test this plugin on another Arduino using the light demo. Unfortunately, I haven't been able to get it to work. The first LED lights during the loading screen, but then my game briefly freezes (not responding) and the light goes off. It then stays off for the rest of the flight until I'm in the loading screen before launch again, after which the whole cycle repeats. I'm using the demo code exactly as is, running on Windows 10 with the latest KSP version. I do have a few mods installed (mod list below) through CKAN, however I installed KerbalSerialIO manually. Is there something I'm missing? Thanks for your help. Mod list: B9 Part Switch (B9PartSwitch v2.17.0) Breaking Ground (BreakingGround-DLC 1.5.1) Community Tech Tree (CommunityTechTree 1:3.4.2) Kerbal Engineer Redux (KerbalEngineerRedux 1.1.7.2) Kerbal Joint Reinforcement Continued (KerbalJointReinforcementContinued v3.5.1) Making History (MakingHistory-DLC 1.10.1) MechJeb 2 (MechJeb2 2.10.0.0) Module Manager (ModuleManager 4.1.4) Near Future IVA Props (NearFutureProps 1:0.6.3) Stockalike Mining Extension (StockalikeMiningExtension 1.1.6) Stockalike Station Parts Expansion Redux (StationPartsExpansionRedux 1.3.6)