From 8c5ddcf440038539c0e1a39718922bba89b9c406 Mon Sep 17 00:00:00 2001 From: Sandy Noble Date: Sun, 24 Mar 2013 00:13:00 +0000 Subject: [PATCH] Added pen lift position stuff. This means by default, using the penlift buttons sets the positions too. Hitting "send pen width" sends the low and the high values, with the expectation that they will be saved in EEPROM. --- Machine.pde | 7 +++++++ controlsActions.pde | 17 +++++++++++++++-- controlsSetup.pde | 26 ++++++++++++++++++++++++++ drawing.pde | 2 ++ polargraphcontroller.pde | 5 +++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Machine.pde b/Machine.pde index 1788b7f..02d9518 100644 --- a/Machine.pde +++ b/Machine.pde @@ -430,6 +430,10 @@ class Machine PVector framePos = new PVector(getIntProperty("controller.pictureframe.position.x", 200), getIntProperty("controller.pictureframe.position.y", 200)); Rectangle frame = new Rectangle(inSteps(framePos), inSteps(frameSize)); setPictureFrame(frame); + + // penlift positions + penLiftDownPosition = getIntProperty("machine.penlift.down", 90); + penLiftUpPosition = getIntProperty("machine.penlift.up", 180); } @@ -502,6 +506,9 @@ class Machine // picture frame position props.setProperty("controller.pictureframe.position.x", Integer.toString((int) inMM(framePosX))); props.setProperty("controller.pictureframe.position.y", Integer.toString((int) inMM(framePosY))); + + props.setProperty("machine.penlift.down", Integer.toString((int) penLiftDownPosition)); + props.setProperty("machine.penlift.up", Integer.toString((int) penLiftUpPosition)); // println("framesize: " + inMM(frameSizeX)); diff --git a/controlsActions.pde b/controlsActions.pde index 225b680..e51e1ca 100644 --- a/controlsActions.pde +++ b/controlsActions.pde @@ -89,12 +89,25 @@ void unsetOtherToggles(String except) } void button_mode_penUp() { - addToCommandQueue(CMD_PENUP + "END"); + addToCommandQueue(CMD_PENUP + penLiftUpPosition +",END"); } void button_mode_penDown() { - addToCommandQueue(CMD_PENDOWN + "END"); + addToCommandQueue(CMD_PENDOWN + penLiftDownPosition +",END"); } +void numberbox_mode_penUpPos(int value) +{ + penLiftUpPosition = value; +} +void numberbox_mode_penDownPos(int value) +{ + penLiftDownPosition = value; +} +void button_mode_sendPenliftRange() +{ + addToCommandQueue(CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END"); +} + void toggle_mode_inputBoxTopLeft(boolean flag) { if (flag) diff --git a/controlsSetup.pde b/controlsSetup.pde index 3068ae1..74901f1 100644 --- a/controlsSetup.pde +++ b/controlsSetup.pde @@ -441,6 +441,22 @@ Map initialiseNumberboxValues(Map map) { n.setValue(minimumVectorLineLength); n.setMin(0); + n.setMultiplier(1); + } + else if (MODE_PEN_LIFT_POS_UP.equals(key)) + { + n.setDecimalPrecision(1); + n.setValue(penLiftUpPosition); + n.setMin(0); + n.setMax(360); + n.setMultiplier(1); + } + else if (MODE_PEN_LIFT_POS_DOWN.equals(key)) + { + n.setDecimalPrecision(1); + n.setValue(penLiftDownPosition); + n.setMin(0); + n.setMax(360); n.setMultiplier(0.1); } } @@ -673,6 +689,10 @@ List getControlNamesForDetailPanel() controlNames.add(MODE_CHANGE_PEN_TEST_INCREMENT_SIZE); controlNames.add(MODE_DRAW_TEST_PENWIDTH); + controlNames.add(MODE_PEN_LIFT_POS_UP); + controlNames.add(MODE_PEN_LIFT_POS_DOWN); + controlNames.add(MODE_SEND_PEN_LIFT_RANGE); + controlNames.add(MODE_CHANGE_MACHINE_MAX_SPEED); controlNames.add(MODE_CHANGE_MACHINE_ACCELERATION); controlNames.add(MODE_SEND_MACHINE_SPEED); @@ -818,6 +838,9 @@ Map buildControlLabels() result.put(MODE_PEN_LIFT_UP, "Pen lift"); result.put(MODE_PEN_LIFT_DOWN, "Pen drop"); + result.put(MODE_PEN_LIFT_POS_UP, "Pen up position"); + result.put(MODE_PEN_LIFT_POS_DOWN, "Pen down position"); + result.put(MODE_SEND_PEN_LIFT_RANGE, "Send lift range"); result.put(MODE_SEND_ROVE_AREA, "Send Roving Area"); result.put(MODE_SEND_START_TEXT, "Start text at point"); @@ -940,6 +963,9 @@ Set buildControlNames() result.add(MODE_CHANGE_PIXEL_SCALING); result.add(MODE_PEN_LIFT_UP); result.add(MODE_PEN_LIFT_DOWN); + result.add(MODE_PEN_LIFT_POS_UP); + result.add(MODE_PEN_LIFT_POS_DOWN); + result.add(MODE_SEND_PEN_LIFT_RANGE); result.add(MODE_SEND_ROVE_AREA); result.add(MODE_SEND_START_TEXT); diff --git a/drawing.pde b/drawing.pde index 02ff446..97f80fe 100644 --- a/drawing.pde +++ b/drawing.pde @@ -120,6 +120,8 @@ void sendMachineSpec() addToCommandQueue(command); command = CMD_SETMACHINESTEPMULTIPLIER+machineStepMultiplier+",END"; addToCommandQueue(command); + command = CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END"; + addToCommandQueue(command); } public PVector getMouseVector() diff --git a/polargraphcontroller.pde b/polargraphcontroller.pde index ea2c012..dea32ea 100644 --- a/polargraphcontroller.pde +++ b/polargraphcontroller.pde @@ -114,6 +114,8 @@ float gridSize = 75.0; float currentPenWidth = 0.8; float penIncrement = 0.05; +int penLiftDownPosition = 90; +int penLiftUpPosition = 180; // this variable controls how big the pixels are scaled when drawn. // 1.0 represents full size, 2.0 would be twice as big as the grid size, // 0.5 would be half the grid size. @@ -281,6 +283,9 @@ static final String MODE_CHOOSE_CHROMA_KEY_COLOUR = "toggle_mode_chooseChromaKey static final String MODE_CHANGE_PIXEL_SCALING = "numberbox_mode_changePixelScaling"; static final String MODE_PEN_LIFT_UP = "button_mode_penUp"; static final String MODE_PEN_LIFT_DOWN = "button_mode_penDown"; +static final String MODE_PEN_LIFT_POS_UP = "numberbox_mode_penUpPos"; +static final String MODE_PEN_LIFT_POS_DOWN = "numberbox_mode_penDownPos"; +static final String MODE_SEND_PEN_LIFT_RANGE = "button_mode_sendPenliftRange"; static final String MODE_SEND_ROVE_AREA = "button_mode_sendRoveArea"; static final String MODE_SEND_START_TEXT = "toggle_mode_sendStartText";