From 31ea8165b235c9df00fdc5ad4f1010591c2d0ca8 Mon Sep 17 00:00:00 2001 From: trombonebuster Date: Sat, 15 Jul 2023 13:03:58 -0500 Subject: [PATCH] add support for ohaus scout 123 --- powderomatic-step.ino | 46 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/powderomatic-step.ino b/powderomatic-step.ino index d2808e1..9dfec3a 100644 --- a/powderomatic-step.ino +++ b/powderomatic-step.ino @@ -246,6 +246,7 @@ CHOOSE(configData.balanceType, scaleMenu, "Scale", doNothing, noEvent, noStyle , VALUE("Kern PCB 100-3", 1, doNothing, noEvent) , VALUE("A&D FX120i", 2, doNothing, noEvent) , VALUE("Sartorius", 3, doNothing, noEvent) + , VALUE("Ohaus Scout 123", 4, doNothing, noEvent) ); SELECT(configData.motaMsteps, motamstepMenu, "Trickler MSteps", doNothing, noEvent, noStyle @@ -576,7 +577,7 @@ int readScale(float *returnValue) { if (debug > 39) Serial.println("no data from scale"); return -1; } - } else { // Sartorius + } else if (configData.balanceType == 3) { // Sartorius if (Serial1.available()) { //Serial.println("data available"); bool negative = false; @@ -618,6 +619,49 @@ int readScale(float *returnValue) { } + } else { // Ohaus + if (Serial1.available()) { + //Serial.println("data available"); + bool negative = false; + bool stable = false; + String scaleOutput = Serial1.readStringUntil('\n'); + if (debug > 29) { + Serial.print("SCALE OUTPUT:"); + Serial.println(scaleOutput); + Serial.println(scaleOutput.indexOf(".")); + } + if ((scaleOutput.indexOf('.') == 8) || (scaleOutput.indexOf('.') == 9)) { + + if (scaleOutput.indexOf('?') == -1) { // ? is present when unstable + //Serial.println("stable"); + stable = true; + } + if (scaleOutput.indexOf('-') != -1) { + negative = true; + } + + String valueString = scaleOutput.substring(0, 11).trim(); + if (debug > 39) { + Serial.println(valueString); + + } + float value = valueString.toFloat(); + if (negative) value = value * -1; + if (debug > 29) Serial.print("Float: "); + if (debug > 29) Serial.println(value, 3); + *returnValue = value; + if (stable) return 1; + return 0; + } else { + return -1; + } + + } else { + if (debug > 39) Serial.println("no data from scale"); + return -1; + } + + } // wrong scale configuration return -1;