From 1179fd7471bbd5e3c7f29274f9ec21772dbfdb09 Mon Sep 17 00:00:00 2001 From: Sandy Noble Date: Tue, 10 Nov 2015 22:53:47 +0000 Subject: [PATCH] Added a safety net for when the machine auto-fit-to-window goes wrong. --- Machine.pde | 8 ++++---- polargraphcontroller.pde | 14 +++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Machine.pde b/Machine.pde index 6e7b5bd..9737ae1 100644 --- a/Machine.pde +++ b/Machine.pde @@ -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); diff --git a/polargraphcontroller.pde b/polargraphcontroller.pde index 083c48d..6d799eb 100644 --- a/polargraphcontroller.pde +++ b/polargraphcontroller.pde @@ -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);