mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-01-08 19:24:25 +01:00
EISF test version of the controller.
This commit is contained in:
parent
51c34e65d2
commit
f23a5a15a4
@ -350,9 +350,9 @@ void button_mode_clearQueue()
|
||||
{
|
||||
resetQueue();
|
||||
}
|
||||
void button_mode_setPositionHome()
|
||||
void button_mode_autoCalibrate()
|
||||
{
|
||||
sendSetHomePosition();
|
||||
sendCalibrate();
|
||||
}
|
||||
void button_mode_drawTestPenWidth()
|
||||
{
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
void button_mode_serialPortDialog()
|
||||
{
|
||||
ControlWindow serialPortWindow = cp5.addControlWindow("changeSerialPortWindow",100,100,150,150);
|
||||
ControlWindow serialPortWindow = cp5.addControlWindow("changeSerialPortWindow",100,100,150,350);
|
||||
serialPortWindow.hideCoordinates();
|
||||
|
||||
serialPortWindow.setBackground(getBackgroundColour());
|
||||
|
@ -656,7 +656,7 @@ List<String> getControlNamesForInputPanel()
|
||||
{
|
||||
List<String> controlNames = new ArrayList<String>();
|
||||
controlNames.add(MODE_CLEAR_QUEUE);
|
||||
controlNames.add(MODE_SET_POSITION_HOME);
|
||||
controlNames.add(MODE_AUTO_CALIBRATE);
|
||||
controlNames.add(MODE_SET_POSITION);
|
||||
controlNames.add(MODE_DRAW_TO_POSITION);
|
||||
controlNames.add(MODE_DRAW_DIRECT);
|
||||
@ -838,7 +838,7 @@ Map<String, String> buildControlLabels()
|
||||
result.put(MODE_DRAW_TESTPATTERN, "test pattern");
|
||||
result.put(MODE_PLACE_IMAGE, "place image");
|
||||
result.put(MODE_LOAD_IMAGE, "Load image file");
|
||||
result.put(MODE_SET_POSITION_HOME, "Set home");
|
||||
result.put(MODE_AUTO_CALIBRATE, "Calibrate");
|
||||
result.put(MODE_RETURN_TO_HOME, "Return to home");
|
||||
result.put(MODE_INPUT_SINGLE_PIXEL, "Choose pixel");
|
||||
result.put(MODE_DRAW_TEST_PENWIDTH, "Test pen widths");
|
||||
@ -954,8 +954,6 @@ Map<String, String> buildControlLabels()
|
||||
result.put(MODE_FLIP_WEBCAM_INPUT, "Flip video");
|
||||
result.put(MODE_ROTATE_WEBCAM_INPUT, "Rotate webcam");
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -984,7 +982,7 @@ Set<String> buildControlNames()
|
||||
result.add(MODE_DRAW_TESTPATTERN);
|
||||
result.add(MODE_PLACE_IMAGE);
|
||||
result.add(MODE_LOAD_IMAGE);
|
||||
result.add(MODE_SET_POSITION_HOME);
|
||||
result.add(MODE_AUTO_CALIBRATE);
|
||||
result.add(MODE_RETURN_TO_HOME);
|
||||
result.add(MODE_INPUT_SINGLE_PIXEL);
|
||||
result.add(MODE_DRAW_TEST_PENWIDTH);
|
||||
@ -1094,7 +1092,6 @@ Set<String> buildControlNames()
|
||||
result.add(MODE_SHOW_WEBCAM_RAW_VIDEO);
|
||||
result.add(MODE_FLIP_WEBCAM_INPUT);
|
||||
result.add(MODE_ROTATE_WEBCAM_INPUT);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
33
drawing.pde
33
drawing.pde
@ -72,6 +72,7 @@ static final String CMD_DRAW_NORWEGIAN_OUTLINE = "C44,";
|
||||
static final String CMD_SETPENLIFTRANGE = "C45,";
|
||||
static final String CMD_SELECT_ROVE_SOURCE_IMAGE = "C46";
|
||||
static final String CMD_RENDER_ROVE = "C47";
|
||||
static final String CMD_AUTO_CALIBRATE = "C48";
|
||||
|
||||
static final int PATH_SORT_NONE = 0;
|
||||
static final int PATH_SORT_MOST_POINTS_FIRST = 1;
|
||||
@ -160,8 +161,10 @@ void sendMoveToPosition(boolean direct, PVector position)
|
||||
{
|
||||
String command = null;
|
||||
PVector p = getDisplayMachine().scaleToDisplayMachine(position);
|
||||
p = getDisplayMachine().inSteps(p);
|
||||
p = getDisplayMachine().asNativeCoords(p);
|
||||
if (!cartesianOutput) {
|
||||
p = getDisplayMachine().inSteps(p);
|
||||
p = getDisplayMachine().asNativeCoords(p);
|
||||
}
|
||||
sendMoveToNativePosition(direct, p);
|
||||
}
|
||||
|
||||
@ -184,7 +187,10 @@ int getMaxSegmentLength()
|
||||
|
||||
void sendTestPattern()
|
||||
{
|
||||
String command = CMD_DRAWDIRECTIONTEST+int(gridSize)+",6,END";
|
||||
float gSize = gridSize;
|
||||
if (cartesianOutput)
|
||||
gSize = getDisplayMachine().inMM(int(gridSize));
|
||||
String command = CMD_DRAWDIRECTIONTEST+int(gSize)+",6,END";
|
||||
addToCommandQueue(command);
|
||||
}
|
||||
|
||||
@ -209,8 +215,11 @@ void sendTestPenWidth()
|
||||
void sendSetPosition()
|
||||
{
|
||||
PVector p = getDisplayMachine().scaleToDisplayMachine(getMouseVector());
|
||||
p = getDisplayMachine().convertToNative(p);
|
||||
p = getDisplayMachine().inSteps(p);
|
||||
if (!cartesianOutput) {
|
||||
p = getDisplayMachine().convertToNative(p);
|
||||
p = getDisplayMachine().inSteps(p);
|
||||
}
|
||||
print(p);
|
||||
|
||||
String command = CMD_SETPOSITION+int(p.x+0.5)+","+int(p.y+0.5)+",END";
|
||||
addToCommandQueue(command);
|
||||
@ -228,11 +237,17 @@ void sendStartTextAtPoint()
|
||||
|
||||
void sendSetHomePosition()
|
||||
{
|
||||
PVector pgCoords = getDisplayMachine().asNativeCoords(getHomePoint());
|
||||
PVector pgCoords;
|
||||
if (cartesianOutput) pgCoords = getDisplayMachine().inMM(getHomePoint());
|
||||
else pgCoords = getDisplayMachine().asNativeCoords(getHomePoint());
|
||||
|
||||
String command = CMD_SETPOSITION+int(pgCoords.x+0.5)+","+int(pgCoords.y+0.5)+",END";
|
||||
addToCommandQueue(command);
|
||||
}
|
||||
void sendCalibrate()
|
||||
{
|
||||
addToCommandQueue(CMD_AUTO_CALIBRATE+",END");
|
||||
}
|
||||
|
||||
int scaleDensity(int inDens, int inMax, int outMax)
|
||||
{
|
||||
@ -892,10 +907,10 @@ List<PVector> filterPointsLowPass(RPoint[] points, long filterParam, float scali
|
||||
PVector p = new PVector(firstPoint.x, firstPoint.y);
|
||||
p = PVector.mult(p, scaling);
|
||||
p = PVector.add(p, position);
|
||||
p = getDisplayMachine().inSteps(p);
|
||||
if (getDisplayMachine().getPage().surrounds(p))
|
||||
// p = getDisplayMachine().inSteps(p);
|
||||
if (getDisplayMachine().getPage().surrounds(getDisplayMachine().inSteps(p)))
|
||||
{
|
||||
p = getDisplayMachine().asNativeCoords(p);
|
||||
// p = getDisplayMachine().asNativeCoords(p);
|
||||
scaled.add(p);
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ ControlP5 cp5;
|
||||
boolean drawbotReady = false;
|
||||
boolean drawbotConnected = false;
|
||||
|
||||
boolean cartesianOutput = true;
|
||||
static final int HARDWARE_VER_UNO = 1;
|
||||
static final int HARDWARE_VER_MEGA = 100;
|
||||
static final int HARDWARE_VER_MEGA_POLARSHIELD = 200;
|
||||
@ -200,7 +201,7 @@ static final String MODE_PLACE_IMAGE = "button_mode_placeImage";
|
||||
static final String MODE_LOAD_IMAGE = "button_mode_loadImage";
|
||||
static final String MODE_PAUSE_QUEUE = "button_mode_pauseQueue";
|
||||
static final String MODE_RUN_QUEUE = "button_mode_runQueue";
|
||||
static final String MODE_SET_POSITION_HOME = "button_mode_setPositionHome";
|
||||
static final String MODE_AUTO_CALIBRATE = "button_mode_autoCalibrate";
|
||||
static final String MODE_RETURN_TO_HOME = "button_mode_returnToHome";
|
||||
static final String MODE_INPUT_SINGLE_PIXEL = "button_mode_inputSinglePixel";
|
||||
static final String MODE_DRAW_TEST_PENWIDTH = "button_mode_drawTestPenWidth";
|
||||
@ -324,7 +325,6 @@ static final String MODE_SHOW_WEBCAM_RAW_VIDEO = "toggle_mode_showWebcamRawVideo
|
||||
static final String MODE_FLIP_WEBCAM_INPUT = "toggle_mode_flipWebcam";
|
||||
static final String MODE_ROTATE_WEBCAM_INPUT = "toggle_mode_rotateWebcam";
|
||||
|
||||
|
||||
PVector statusTextPosition = new PVector(300.0, 12.0);
|
||||
|
||||
static String currentMode = MODE_BEGIN;
|
||||
@ -575,6 +575,7 @@ void setup()
|
||||
|
||||
addEventListeners();
|
||||
|
||||
noLoop();
|
||||
//gamepad_init();
|
||||
}
|
||||
void addEventListeners()
|
||||
@ -603,9 +604,7 @@ void addEventListeners()
|
||||
|
||||
void preLoadCommandQueue()
|
||||
{
|
||||
addToCommandQueue(CMD_CHANGEPENWIDTH+currentPenWidth+",END");
|
||||
addToCommandQueue(CMD_SETMOTORSPEED+currentMachineMaxSpeed+",END");
|
||||
addToCommandQueue(CMD_SETMOTORACCEL+currentMachineAccel+",END");
|
||||
addToCommandQueue(CMD_AUTO_CALIBRATE+",END");
|
||||
}
|
||||
|
||||
void windowResized()
|
||||
@ -949,13 +948,9 @@ void drawMoveImageOutline()
|
||||
void showCurrentMachinePosition()
|
||||
{
|
||||
noStroke();
|
||||
fill(255,0,255,150);
|
||||
PVector pgCoord = getDisplayMachine().scaleToScreen(currentMachinePos);
|
||||
ellipse(pgCoord.x, pgCoord.y, 20, 20);
|
||||
|
||||
// also show cartesian position if reported
|
||||
fill(255,255,0,150);
|
||||
ellipse(currentCartesianMachinePos.x, currentCartesianMachinePos.y, 15, 15);
|
||||
PVector pgCoord = getDisplayMachine().scaleToScreen(currentCartesianMachinePos);
|
||||
ellipse(pgCoord.x, pgCoord.y, 20, 20);
|
||||
|
||||
noFill();
|
||||
}
|
||||
@ -2612,7 +2607,8 @@ void dispatchCommandQueue()
|
||||
}
|
||||
Checksum crc = new CRC32();
|
||||
crc.update(lastCommand.getBytes(), 0, lastCommand.length());
|
||||
lastCommand = lastCommand+":"+crc.getValue();
|
||||
lastCommand = lastCommand+";";
|
||||
// lastCommand = lastCommand+":"+crc.getValue();
|
||||
println("Last command:" + lastCommand);
|
||||
myPort.write(lastCommand);
|
||||
drawbotReady = false;
|
Loading…
Reference in New Issue
Block a user