From 8a9e5c6f5baf59e04ea88cdd6d382216839c12df Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Tue, 5 Nov 2024 17:50:35 +0100 Subject: [PATCH] Read max spindle speed as double --- .../firmware/grbl/GrblFirmwareSettings.java | 4 +++- .../firmware/grbl/GrblFirmwareSettingsTest.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ugs-core/src/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettings.java b/ugs-core/src/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettings.java index fdd5e9d379..31e510ce78 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettings.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettings.java @@ -375,7 +375,9 @@ public double getMaximumRate(Axis axis) throws FirmwareSettingsException { public int getMaxSpindleSpeed() throws FirmwareSettingsException { return getSetting(KEY_MAX_SPINDLE_SPEED) .map(FirmwareSetting::getValue) - .map(Integer::valueOf) + .map(value -> value.replaceAll(",", ".")) + .map(Double::valueOf) + .map(Double::intValue) .orElse(0); } diff --git a/ugs-core/test/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettingsTest.java b/ugs-core/test/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettingsTest.java index 4c6da39a9c..64e8d36c03 100644 --- a/ugs-core/test/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettingsTest.java +++ b/ugs-core/test/com/willwinder/universalgcodesender/firmware/grbl/GrblFirmwareSettingsTest.java @@ -360,4 +360,19 @@ public void setInvertDirectionZShouldSetBit() throws FirmwareSettingsException, assertEquals("7", target.getSetting("$3").get().getValue()); } + + @Test + public void getMaxSpindleSpeedShouldReturnIntegerValue() throws FirmwareSettingsException { + target.rawResponseListener("$30=1000.0"); + assertEquals(1000, target.getMaxSpindleSpeed()); + + target.rawResponseListener("$30=1000"); + assertEquals(1000, target.getMaxSpindleSpeed()); + + target.rawResponseListener("$30=1000,00"); + assertEquals(1000, target.getMaxSpindleSpeed()); + + target.rawResponseListener("$30=1000.9"); + assertEquals(1000, target.getMaxSpindleSpeed()); + } }