Skip to content

Commit f2b1df7

Browse files
committed
Fixed merge
2 parents 9307c4e + f32f22a commit f2b1df7

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

SerialPortWindow.pde

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ControlFrameSimple addSerialPortControlFrame(String theName, int theWidth, int t
3333
.setPosition(10, 10)
3434
.setSize(150, 450)
3535
.setBarHeight(20)
36-
.setItemHeight(20)
36+
.setItemHeight(16)
3737
.plugTo(this, "dropdown_serialPort");
3838

3939
sl.addItem("No serial connection", -1);
@@ -61,9 +61,11 @@ ControlFrameSimple addSerialPortControlFrame(String theName, int theWidth, int t
6161
void dropdown_serialPort(int newSerialPort)
6262
{
6363
println("In dropdown_serialPort, newSerialPort: " + newSerialPort);
64+
65+
// No serial in list is slot 0 in code because of list index
66+
// So shift port index by one
6467
newSerialPort -= 1;
6568

66-
6769
if (newSerialPort == -2)
6870
{
6971
}

polargraphcontroller.pde

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import java.lang.reflect.Method;
5858

5959
int majorVersionNo = 2;
6060
int minorVersionNo = 5;
61-
int buildNo = 0;
61+
int buildNo = 1;
6262

6363
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
6464
ControlP5 cp5;
@@ -1331,6 +1331,7 @@ RShape loadShapeFromGCodeFile(String filename) {
13311331
boolean reportStatus = true;
13321332
while ((line = reader.readLine ()) != null) {
13331333
lineNo++;
1334+
// println("Line: " + line);
13341335

13351336
if (reportStatus) {
13361337
float percent = ((float)lineNo / (float)countLines) * 100.0;
@@ -1354,10 +1355,8 @@ RShape loadShapeFromGCodeFile(String filename) {
13541355
println(e.toString());
13551356
continue;
13561357
}
1358+
// println("Ins: " + ins);
13571359
Integer code = Math.round(ins.get("G"));
1358-
if (code >= 2) {
1359-
continue;
1360-
}
13611360

13621361
Float z = ins.get("Z");
13631362
if (z != null) {
@@ -1400,19 +1399,6 @@ RShape loadShapeFromGCodeFile(String filename) {
14001399
parent.addMoveTo(x, y);
14011400
}
14021401
}
1403-
// RPoint[][] points = parent.getPointsInPaths();
1404-
// totalPoints = 0;
1405-
// if (points != null) {
1406-
// for (int i = 0; i<points.length; i++) {
1407-
// if (points[i] != null) {
1408-
// for (int j = 0; j<points[i].length; j++) {
1409-
// totalPoints++;
1410-
// }
1411-
// }
1412-
// }
1413-
// }
1414-
// points = null;
1415-
// println("" + totalPoints + " points.");
14161402
}
14171403
else {
14181404

@@ -1433,15 +1419,15 @@ RShape loadShapeFromGCodeFile(String filename) {
14331419
}
14341420
}
14351421
catch (IOException e) {
1436-
println("Execption reading lines from the gcode file " + filename);
1422+
println("IOExecption reading lines from the gcode file " + filename);
14371423
e.printStackTrace();
14381424
}
14391425
finally {
14401426
try {
14411427
reader.close();
14421428
}
14431429
catch (IOException e) {
1444-
println("Exception closing the gcode file " + filename);
1430+
println("IOException closing the gcode file " + filename);
14451431
e.printStackTrace();
14461432
}
14471433
}
@@ -1478,18 +1464,23 @@ Map<String, Float> unpackGCodeInstruction(String line) throws Exception {
14781464
// remove ; character
14791465
splitted[i] = splitted[i].replace(";", "");
14801466
String axis = splitted[i].substring(0, 1);
1481-
Float value = Float.parseFloat(splitted[i].substring(1));
1482-
1467+
String sanitisedValue = splitted[i].substring(1);
1468+
sanitisedValue = sanitisedValue.replace(",", ".");
1469+
Float value = Float.parseFloat(sanitisedValue);
14831470
if ("X".equalsIgnoreCase(axis) || "Y".equalsIgnoreCase(axis) || "Z".equalsIgnoreCase(axis) || "G".equalsIgnoreCase(axis)) {
1484-
instruction.put(axis, value);
1471+
instruction.put(axis.toUpperCase(), value);
14851472
}
14861473
}
14871474
// println("instruction: " + instruction);
14881475
if (instruction.isEmpty()) {
1489-
throw new Exception();
1476+
throw new Exception("Empty instruction");
14901477
}
1491-
}
1478+
}
1479+
catch (NumberFormatException nfe) {
1480+
println("Number format exception: " + nfe.getMessage());
1481+
}
14921482
catch (Exception e) {
1483+
println("e: " + e);
14931484
throw new Exception("Exception while reading the lines from a gcode file: " + line + ", " + e.getMessage());
14941485
}
14951486

0 commit comments

Comments
 (0)