Move main program files to 'prog', add support for CLI-based interfaces (no boot file).
This commit is contained in:
43
prog/helicopter.ks
Normal file
43
prog/helicopter.ks
Normal file
@ -0,0 +1,43 @@
|
||||
// assumptions about helicopter builds:
|
||||
// * AG10 toggles the rotor engine power. (with appropriate RPM set by default)
|
||||
// * AG9 is unmapped.
|
||||
// * Main throttle controls collective.
|
||||
|
||||
runoncepath("lib/stabilize_helicopter").
|
||||
|
||||
global done is false.
|
||||
on AG9 {
|
||||
set done to true.
|
||||
return true.
|
||||
}
|
||||
|
||||
clearguis().
|
||||
|
||||
// Main UI.
|
||||
local interface is gui(250, 300).
|
||||
set interface:X to 200.
|
||||
set interface:Y to 700.
|
||||
|
||||
// Main menu elements in here.
|
||||
local y is interface:AddVLayout().
|
||||
local x is y:AddHLayout().
|
||||
|
||||
set x:AddButton("HOVER"):onClick to {
|
||||
Hover().
|
||||
}.
|
||||
|
||||
set x:AddButton("LAND"):onClick to {
|
||||
// todo: consider a more elaborate landing script that adjusts
|
||||
// velocity as a function of altitude.
|
||||
when SHIP:STATUS = "LANDED" then {
|
||||
set done to true.
|
||||
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.5.
|
||||
toggle AG10.
|
||||
BRAKES on.
|
||||
}
|
||||
Hover(-5).
|
||||
}.
|
||||
|
||||
interface:show().
|
||||
|
||||
wait until false.
|
165
prog/rocket.ks
Normal file
165
prog/rocket.ks
Normal file
@ -0,0 +1,165 @@
|
||||
@lazyglobal off.
|
||||
|
||||
runoncepath("/lib/ui").
|
||||
runoncepath("/lib/navigation").
|
||||
runoncepath("/lib/throttle").
|
||||
runoncepath("/lib/node").
|
||||
runoncepath("/lib/stabilize_rocket").
|
||||
runoncepath("/lib/launch_rocket").
|
||||
|
||||
clearguis().
|
||||
|
||||
global done is false.
|
||||
on AG9 {
|
||||
set done to true.
|
||||
return true.
|
||||
}
|
||||
|
||||
// Main UI.
|
||||
local iface is gui(250, 300).
|
||||
set iface:X to 200.
|
||||
set iface:Y to 700.
|
||||
|
||||
// Main menu elements in here.
|
||||
local top is iface:AddVLayout().
|
||||
local row is makeRow(top).
|
||||
|
||||
local btn is row:AddButton("TERM").
|
||||
set btn:TOGGLE to true.
|
||||
set btn:ONTOGGLE to {
|
||||
parameter d.
|
||||
|
||||
if d {
|
||||
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
|
||||
} else {
|
||||
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
||||
}
|
||||
}.
|
||||
|
||||
makeButton(row, "CONF", { stk:ShowOnly(panes["conf"]). }).
|
||||
|
||||
set row to makeRow(top).
|
||||
|
||||
makeButton(row, "HOVER", { Hover(). }).
|
||||
makeButton(row, "LAND", { Land(). }).
|
||||
|
||||
set row to makeRow(top).
|
||||
|
||||
makeButton(row, "LNCH", { stk:ShowOnly(panes["launch"]). }).
|
||||
|
||||
makeButton(row, "NODE", {
|
||||
if HASNODE {
|
||||
set nodeDV:TEXT to NEXTNODE:DELTAV:MAG:ToString.
|
||||
set nodeBT:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString.
|
||||
} else {
|
||||
set nodeDV:TEXT to "No Node".
|
||||
set nodeBT:TEXT to "No Node".
|
||||
}
|
||||
stk:ShowOnly(panes["node"]).
|
||||
}).
|
||||
|
||||
makeButton(row, "TWR", { stk:ShowOnly(panes["twr"]). }).
|
||||
|
||||
local stk is iface:AddStack().
|
||||
local panes is Lex().
|
||||
|
||||
// Build launch menu
|
||||
local top is stk:AddVLayout().
|
||||
panes:Add("launch", top).
|
||||
|
||||
local box is top:AddScrollBox().
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Target Apoapsis").
|
||||
local targetApo is row:AddTextField("80000"). // todo: config params should go into a nested lexicon
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Atmo TWR").
|
||||
local targetTWR is row:AddTextField("1.6").
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Initial Pitch").
|
||||
local initialPitch is row:AddTextField("85").
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Minimum Pitch").
|
||||
local minimumPitch is row:AddTextField("5").
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Gravity Turn Alt").
|
||||
local gravTurnStart is row:AddTextField("8000").
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Gravity Turn Pitch").
|
||||
local gravPitch is row:AddTextField("75").
|
||||
|
||||
makeButton(top, "Execute", {
|
||||
Launch(
|
||||
targetApo:TEXT:ToNumber(),
|
||||
gravTurnStart:TEXT:ToNumber(),
|
||||
gravPitch:TEXT:ToNumber(),
|
||||
initialPitch:TEXT:ToNumber(),
|
||||
minimumPitch:TEXT:ToNumber()
|
||||
).
|
||||
}).
|
||||
// End Launch Menu
|
||||
|
||||
// Build conf menu
|
||||
local top is stk:AddVLayout().
|
||||
panes:Add("conf", top).
|
||||
|
||||
set box to top:AddScrollbox().
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Torque Epsilon Max").
|
||||
local maxEpsilon is row:AddTextField("0.001").
|
||||
|
||||
set row to makeRow(box).
|
||||
row:AddLabel("Max Stopping Time").
|
||||
local maxStopTime is row:AddTextField("2.0").
|
||||
|
||||
makeButton(top, "Apply", {
|
||||
set STEERINGMANAGER:TORQUEEPSILONMAX to maxEpsilon:TEXT:ToNumber().
|
||||
set STEERINGMANAGER:MAXSTOPPINGTIME to maxStopTime:TEXT:ToNumber().
|
||||
}).
|
||||
// end conf menu
|
||||
|
||||
// twr menu
|
||||
local top is stk:AddVLayout().
|
||||
panes:Add("twr", top).
|
||||
|
||||
set row to makeRow(top).
|
||||
row:AddLabel("Target TWR").
|
||||
local twrLock is row:AddTextField("1.6").
|
||||
|
||||
makeButton(top, "Lock TWR", {
|
||||
local done is false.
|
||||
on AG9 {
|
||||
set done to true.
|
||||
}
|
||||
|
||||
print "Locking throttle to target TWR.".
|
||||
local tgt is twrLock:TEXT:ToNumber().
|
||||
lock THROTTLE to ThrottleToTWR(tgt).
|
||||
wait until done.
|
||||
print "Throttle unlocked.".
|
||||
}).
|
||||
// end twr menu
|
||||
|
||||
// node menu
|
||||
local top is stk:AddVLayout().
|
||||
panes:Add("node", top).
|
||||
|
||||
set row to makeRow(top).
|
||||
row:AddLabel("Node dV").
|
||||
local nodeDV is row:AddLabel().
|
||||
|
||||
set row to makeRow(top).
|
||||
row:AddLabel("Node Burn Time").
|
||||
local nodeBT is row:AddLabel().
|
||||
|
||||
makeButton(top, "Execute", { ExecNode(). }).
|
||||
// end node menu
|
||||
|
||||
iface:show().
|
||||
wait until false.
|
Reference in New Issue
Block a user