Added a safety net for when the machine auto-fit-to-window goes wrong.

This commit is contained in:
Sandy Noble 2015-11-10 22:53:47 +00:00
parent a1bdca895f
commit 1179fd7471
2 changed files with 13 additions and 9 deletions

View File

@ -364,7 +364,7 @@ class Machine
public void loadDefinitionFromProperties(Properties props)
{
// get these first because they are important to convert the rest of them
setStepsPerRev(getFloatProperty("machine.motors.stepsPerRev", 800.0));
setStepsPerRev(getFloatProperty("machine.motors.stepsPerRev", 200.0));
setMMPerRev(getFloatProperty("machine.motors.mmPerRev", 95.0));
// now stepsPerMM and mmPerStep should have been calculated. It's safe to get the rest.
@ -383,12 +383,12 @@ class Machine
String pos = getStringProperty("controller.page.position.x", "CENTRE");
float px = 0.0;
println("machine size: " + getSize().x + ", " + inSteps(pageSize.x));
if (pos.equalsIgnoreCase("CENTRE"))
{
if (pos.equalsIgnoreCase("CENTRE")) {
px = inMM((getSize().x - pageSize.x) / 2.0);
}
else
else {
px = getFloatProperty("controller.page.position.x", (int) getDisplayMachine().getPageCentrePosition(pageSize.x));
}
float py = getFloatProperty("controller.page.position.y", 120);

View File

@ -58,7 +58,7 @@ import java.lang.reflect.Method;
int majorVersionNo = 2;
int minorVersionNo = 1;
int buildNo = 0;
int buildNo = 1;
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
ControlP5 cp5;
@ -190,7 +190,7 @@ float testPenWidthStartSize = 0.5;
float testPenWidthEndSize = 2.0;
float testPenWidthIncrementSize = 0.5;
int machineStepMultiplier = 1;
int machineStepMultiplier = 8;
int maxSegmentLength = 2;
@ -619,6 +619,10 @@ void fitDisplayMachineToWindow() {
machineScaling = (targetHeight / machineHeight);
println(machineScaling);
if (machineScaling < 0) {
machineScaling = 1.0;
}
getDisplayMachine().getOffset().x = ((gr.getRight() > ir.getRight()) ? gr.getRight() : ir.getRight()) + CONTROL_SPACING.x;
getDisplayMachine().getOffset().y = gr.getTop();
@ -2953,9 +2957,9 @@ void loadFromPropertiesFile()
this.currentPenWidth = getFloatProperty("machine.pen.size", 0.8);
// motor settings
this.currentMachineMaxSpeed = getFloatProperty("machine.motors.maxSpeed", 600.0);
this.currentMachineAccel = getFloatProperty("machine.motors.accel", 400.0);
this.machineStepMultiplier = getIntProperty("machine.step.multiplier", 1);
this.currentMachineMaxSpeed = getFloatProperty("machine.motors.maxSpeed", 2000.0);
this.currentMachineAccel = getFloatProperty("machine.motors.accel", 2000.0);
this.machineStepMultiplier = getIntProperty("machine.step.multiplier", 8);
// serial port
this.serialPortNumber = getIntProperty("controller.machine.serialport", 0);