Skip to content

Commit

Permalink
Added a safety net for when the machine auto-fit-to-window goes wrong.
Browse files Browse the repository at this point in the history
  • Loading branch information
euphy committed Nov 10, 2015
1 parent a1bdca8 commit 1179fd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Machine.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);

Expand Down
14 changes: 9 additions & 5 deletions polargraphcontroller.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1179fd7

Please sign in to comment.