Skip to content
Snippets Groups Projects
Commit 1c23a613 authored by Jake Read's avatar Jake Read
Browse files

lsq update cycles

parent 2d9131c4
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ export default function LoadcellCalibration() { ...@@ -23,6 +23,7 @@ export default function LoadcellCalibration() {
let loadReading = new Output('number', 'prediction', this) let loadReading = new Output('number', 'prediction', this)
this.outputs.push(loadReading) this.outputs.push(loadReading)
let isOkToCalc = false
// admit unwillingness to write nice array wrappers, // admit unwillingness to write nice array wrappers,
// do that locally .. // do that locally ..
let xStateArray = new State('string', 'csv: readings: x', '0, 250, 500') let xStateArray = new State('string', 'csv: readings: x', '0, 250, 500')
...@@ -44,19 +45,27 @@ export default function LoadcellCalibration() { ...@@ -44,19 +45,27 @@ export default function LoadcellCalibration() {
let lsqr = smallmath.lsq(exes, whys) let lsqr = smallmath.lsq(exes, whys)
m = lsqr.m m = lsqr.m
b = lsqr.b b = lsqr.b
isOkToCalc = true
if (b >= 0) { if (b >= 0) {
return `${m}x + ${b}` return `${m}x + ${b}`
} else { } else {
return `${m}x ${b}` return `${m}x ${b}`
} }
} else { } else {
isOkToCalc = false
return 'bad inputs ...' return 'bad inputs ...'
} }
} }
let result = new State('string', 'calibration result', writeCalExpression()) let result = new State('string', 'calibration result', writeCalExpression())
this.states.push(xStateArray, yStateArray, result) this.states.push(xStateArray, yStateArray, result)
xStateArray.onChange = (value) => {
let isOkToCalc = false xStateArray.set(value)
result.set(writeCalExpression())
}
yStateArray.onChange = (value) => {
yStateArray.set(value)
result.set(writeCalExpression())
}
this.init = () => { this.init = () => {
result.set(writeCalExpression()) result.set(writeCalExpression())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment