EISF test version of the controller.

This commit is contained in:
Sandy Noble 2014-03-20 01:11:37 +00:00
parent 51c34e65d2
commit f23a5a15a4
5 changed files with 38 additions and 30 deletions

View File

@ -350,9 +350,9 @@ void button_mode_clearQueue()
{ {
resetQueue(); resetQueue();
} }
void button_mode_setPositionHome() void button_mode_autoCalibrate()
{ {
sendSetHomePosition(); sendCalibrate();
} }
void button_mode_drawTestPenWidth() void button_mode_drawTestPenWidth()
{ {

View File

@ -34,7 +34,7 @@
void button_mode_serialPortDialog() 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.hideCoordinates();
serialPortWindow.setBackground(getBackgroundColour()); serialPortWindow.setBackground(getBackgroundColour());

View File

@ -656,7 +656,7 @@ List<String> getControlNamesForInputPanel()
{ {
List<String> controlNames = new ArrayList<String>(); List<String> controlNames = new ArrayList<String>();
controlNames.add(MODE_CLEAR_QUEUE); controlNames.add(MODE_CLEAR_QUEUE);
controlNames.add(MODE_SET_POSITION_HOME); controlNames.add(MODE_AUTO_CALIBRATE);
controlNames.add(MODE_SET_POSITION); controlNames.add(MODE_SET_POSITION);
controlNames.add(MODE_DRAW_TO_POSITION); controlNames.add(MODE_DRAW_TO_POSITION);
controlNames.add(MODE_DRAW_DIRECT); controlNames.add(MODE_DRAW_DIRECT);
@ -838,7 +838,7 @@ Map<String, String> buildControlLabels()
result.put(MODE_DRAW_TESTPATTERN, "test pattern"); result.put(MODE_DRAW_TESTPATTERN, "test pattern");
result.put(MODE_PLACE_IMAGE, "place image"); result.put(MODE_PLACE_IMAGE, "place image");
result.put(MODE_LOAD_IMAGE, "Load image file"); 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_RETURN_TO_HOME, "Return to home");
result.put(MODE_INPUT_SINGLE_PIXEL, "Choose pixel"); result.put(MODE_INPUT_SINGLE_PIXEL, "Choose pixel");
result.put(MODE_DRAW_TEST_PENWIDTH, "Test pen widths"); 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_FLIP_WEBCAM_INPUT, "Flip video");
result.put(MODE_ROTATE_WEBCAM_INPUT, "Rotate webcam"); result.put(MODE_ROTATE_WEBCAM_INPUT, "Rotate webcam");
return result; return result;
} }
@ -984,7 +982,7 @@ Set<String> buildControlNames()
result.add(MODE_DRAW_TESTPATTERN); result.add(MODE_DRAW_TESTPATTERN);
result.add(MODE_PLACE_IMAGE); result.add(MODE_PLACE_IMAGE);
result.add(MODE_LOAD_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_RETURN_TO_HOME);
result.add(MODE_INPUT_SINGLE_PIXEL); result.add(MODE_INPUT_SINGLE_PIXEL);
result.add(MODE_DRAW_TEST_PENWIDTH); result.add(MODE_DRAW_TEST_PENWIDTH);
@ -1094,7 +1092,6 @@ Set<String> buildControlNames()
result.add(MODE_SHOW_WEBCAM_RAW_VIDEO); result.add(MODE_SHOW_WEBCAM_RAW_VIDEO);
result.add(MODE_FLIP_WEBCAM_INPUT); result.add(MODE_FLIP_WEBCAM_INPUT);
result.add(MODE_ROTATE_WEBCAM_INPUT); result.add(MODE_ROTATE_WEBCAM_INPUT);
return result; return result;
} }

View File

@ -72,6 +72,7 @@ static final String CMD_DRAW_NORWEGIAN_OUTLINE = "C44,";
static final String CMD_SETPENLIFTRANGE = "C45,"; static final String CMD_SETPENLIFTRANGE = "C45,";
static final String CMD_SELECT_ROVE_SOURCE_IMAGE = "C46"; static final String CMD_SELECT_ROVE_SOURCE_IMAGE = "C46";
static final String CMD_RENDER_ROVE = "C47"; 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_NONE = 0;
static final int PATH_SORT_MOST_POINTS_FIRST = 1; static final int PATH_SORT_MOST_POINTS_FIRST = 1;
@ -160,8 +161,10 @@ void sendMoveToPosition(boolean direct, PVector position)
{ {
String command = null; String command = null;
PVector p = getDisplayMachine().scaleToDisplayMachine(position); PVector p = getDisplayMachine().scaleToDisplayMachine(position);
p = getDisplayMachine().inSteps(p); if (!cartesianOutput) {
p = getDisplayMachine().asNativeCoords(p); p = getDisplayMachine().inSteps(p);
p = getDisplayMachine().asNativeCoords(p);
}
sendMoveToNativePosition(direct, p); sendMoveToNativePosition(direct, p);
} }
@ -184,7 +187,10 @@ int getMaxSegmentLength()
void sendTestPattern() 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); addToCommandQueue(command);
} }
@ -209,8 +215,11 @@ void sendTestPenWidth()
void sendSetPosition() void sendSetPosition()
{ {
PVector p = getDisplayMachine().scaleToDisplayMachine(getMouseVector()); PVector p = getDisplayMachine().scaleToDisplayMachine(getMouseVector());
p = getDisplayMachine().convertToNative(p); if (!cartesianOutput) {
p = getDisplayMachine().inSteps(p); 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"; String command = CMD_SETPOSITION+int(p.x+0.5)+","+int(p.y+0.5)+",END";
addToCommandQueue(command); addToCommandQueue(command);
@ -228,11 +237,17 @@ void sendStartTextAtPoint()
void sendSetHomePosition() 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"; String command = CMD_SETPOSITION+int(pgCoords.x+0.5)+","+int(pgCoords.y+0.5)+",END";
addToCommandQueue(command); addToCommandQueue(command);
} }
void sendCalibrate()
{
addToCommandQueue(CMD_AUTO_CALIBRATE+",END");
}
int scaleDensity(int inDens, int inMax, int outMax) 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); PVector p = new PVector(firstPoint.x, firstPoint.y);
p = PVector.mult(p, scaling); p = PVector.mult(p, scaling);
p = PVector.add(p, position); p = PVector.add(p, position);
p = getDisplayMachine().inSteps(p); // p = getDisplayMachine().inSteps(p);
if (getDisplayMachine().getPage().surrounds(p)) if (getDisplayMachine().getPage().surrounds(getDisplayMachine().inSteps(p)))
{ {
p = getDisplayMachine().asNativeCoords(p); // p = getDisplayMachine().asNativeCoords(p);
scaled.add(p); scaled.add(p);
} }
} }

View File

@ -60,6 +60,7 @@ ControlP5 cp5;
boolean drawbotReady = false; boolean drawbotReady = false;
boolean drawbotConnected = false; boolean drawbotConnected = false;
boolean cartesianOutput = true;
static final int HARDWARE_VER_UNO = 1; static final int HARDWARE_VER_UNO = 1;
static final int HARDWARE_VER_MEGA = 100; static final int HARDWARE_VER_MEGA = 100;
static final int HARDWARE_VER_MEGA_POLARSHIELD = 200; 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_LOAD_IMAGE = "button_mode_loadImage";
static final String MODE_PAUSE_QUEUE = "button_mode_pauseQueue"; static final String MODE_PAUSE_QUEUE = "button_mode_pauseQueue";
static final String MODE_RUN_QUEUE = "button_mode_runQueue"; 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_RETURN_TO_HOME = "button_mode_returnToHome";
static final String MODE_INPUT_SINGLE_PIXEL = "button_mode_inputSinglePixel"; static final String MODE_INPUT_SINGLE_PIXEL = "button_mode_inputSinglePixel";
static final String MODE_DRAW_TEST_PENWIDTH = "button_mode_drawTestPenWidth"; 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_FLIP_WEBCAM_INPUT = "toggle_mode_flipWebcam";
static final String MODE_ROTATE_WEBCAM_INPUT = "toggle_mode_rotateWebcam"; static final String MODE_ROTATE_WEBCAM_INPUT = "toggle_mode_rotateWebcam";
PVector statusTextPosition = new PVector(300.0, 12.0); PVector statusTextPosition = new PVector(300.0, 12.0);
static String currentMode = MODE_BEGIN; static String currentMode = MODE_BEGIN;
@ -575,6 +575,7 @@ void setup()
addEventListeners(); addEventListeners();
noLoop();
//gamepad_init(); //gamepad_init();
} }
void addEventListeners() void addEventListeners()
@ -603,9 +604,7 @@ void addEventListeners()
void preLoadCommandQueue() void preLoadCommandQueue()
{ {
addToCommandQueue(CMD_CHANGEPENWIDTH+currentPenWidth+",END"); addToCommandQueue(CMD_AUTO_CALIBRATE+",END");
addToCommandQueue(CMD_SETMOTORSPEED+currentMachineMaxSpeed+",END");
addToCommandQueue(CMD_SETMOTORACCEL+currentMachineAccel+",END");
} }
void windowResized() void windowResized()
@ -949,13 +948,9 @@ void drawMoveImageOutline()
void showCurrentMachinePosition() void showCurrentMachinePosition()
{ {
noStroke(); 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); 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(); noFill();
} }
@ -2612,7 +2607,8 @@ void dispatchCommandQueue()
} }
Checksum crc = new CRC32(); Checksum crc = new CRC32();
crc.update(lastCommand.getBytes(), 0, lastCommand.length()); crc.update(lastCommand.getBytes(), 0, lastCommand.length());
lastCommand = lastCommand+":"+crc.getValue(); lastCommand = lastCommand+";";
// lastCommand = lastCommand+":"+crc.getValue();
println("Last command:" + lastCommand); println("Last command:" + lastCommand);
myPort.write(lastCommand); myPort.write(lastCommand);
drawbotReady = false; drawbotReady = false;