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

nearly

parent 98433ab8
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ export default function LeastSquares() { ...@@ -28,7 +28,7 @@ export default function LeastSquares() {
// 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', '25, 14854, 29649, 44453, 74061, 103695') let xStateArray = new State('string', 'csv: readings: x', '25, 14854, 29649, 44453, 74061, 103695')
let yStateArray = new State('string', 'csv: readings: y', '0, 100, 200, 300, 500, 700') let yStateArray = new State('string', 'csv: readings: y', '0, -0.100, -0.200, -0.300, -0.500, -0.700')
// state! // state!
let m, b = 0 let m, b = 0
let writeCalExpression = () => { let writeCalExpression = () => {
...@@ -47,11 +47,12 @@ export default function LeastSquares() { ...@@ -47,11 +47,12 @@ export default function LeastSquares() {
m = lsqr.m m = lsqr.m
b = lsqr.b b = lsqr.b
isOkToCalc = true isOkToCalc = true
console.log(`m, ${m}, b, ${b}`)
// we round 'em out a bit ... local values are full width; // we round 'em out a bit ... local values are full width;
if (b >= 0) { if (b >= 0) {
return `${Math.round(m*1000)/1000}x + ${Math.round(b*1000)/1000}` return `${m.toExponential(2)} x + ${b.toExponential(2)}`
} else { } else {
return `${Math.round(m*1000)/1000}x ${Math.round(b*1000)/1000}` return `${m.toExponential(2)} x ${b.toExponential(2)}`
} }
} else { } else {
isOkToCalc = false isOkToCalc = false
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"interpreterName": "cuttlefish",
"interpreterVersion": "v0.1",
"hunks": [
{
"type": "manager",
"name": "nrol",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "1",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "view",
"name": "tlview",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "0",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "pipes/vfptc",
"name": "pipes/vfptc_2",
"inputs": [
{
"name": "data",
"type": "byteArray"
}
],
"outputs": [
{
"name": "data",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "3",
"inHunkInput": "0"
}
]
}
],
"states": [
{
"name": "pipe status",
"type": "string",
"value": "open"
},
{
"name": "websocket port",
"type": "string",
"value": "2042"
},
{
"name": "usb product id",
"type": "string",
"value": "8022"
},
{
"name": "pipe reset",
"type": "boolean",
"value": "false"
},
{
"name": "serialport status",
"type": "string",
"value": "open"
}
]
},
{
"type": "link",
"name": "link_3",
"inputs": [
{
"name": "data",
"type": "byteArray"
},
{
"name": "mgrMsgs",
"type": "byteArray"
},
{
"name": "inc",
"type": "int32"
}
],
"outputs": [
{
"name": "data",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "2",
"inHunkInput": "0"
}
]
},
{
"name": "mgrMsgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "4",
"inHunkInput": "0"
}
]
}
],
"states": [
{
"name": "isActive",
"type": "boolean",
"value": "true"
},
{
"name": "otherLink",
"type": "uint16",
"value": "1"
},
{
"name": "inputList",
"type": "string",
"value": "mgrMsgs (byteArray), inc (int32)"
},
{
"name": "outputList",
"type": "string",
"value": "mgrMsgs (byteArray)"
}
],
"contains": {
"interpreterName": "ponyo",
"interpreterVersion": "v0.1",
"hunks": [
{
"type": "manager",
"name": "ponyo_one",
"inputs": [
{
"name": "mgrMsgs_1024",
"type": "byteArray"
}
],
"outputs": [
{
"name": "mgrMsgs_1024",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "1",
"inHunkInput": "1"
}
]
}
]
},
{
"type": "link",
"name": "link_1",
"inputs": [
{
"name": "data_1024",
"type": "byteArray"
},
{
"name": "mgrMsgs_1024",
"type": "byteArray"
}
],
"outputs": [
{
"name": "data_1024",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "2",
"inHunkInput": "0"
}
]
},
{
"name": "mgrMsgs_1024",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "0",
"inHunkInput": "0"
}
]
},
{
"name": "inc",
"type": "int32",
"connections": [
{
"inHunkIndex": "3",
"inHunkInput": "0"
}
]
}
],
"states": [
{
"name": "isActive",
"type": "boolean",
"value": "true"
},
{
"name": "otherLink",
"type": "uint16",
"value": "3"
},
{
"name": "inputList",
"type": "string",
"value": "mgrMsgs (byteArray)"
},
{
"name": "outputList",
"type": "string",
"value": "mgrMsgs (byteArray), inc (int32)"
}
]
},
{
"type": "comm/COBSerialUSB",
"name": "comm/COBSerialUSB_2",
"inputs": [
{
"name": "data_1024",
"type": "byteArray"
}
],
"outputs": [
{
"name": "data_1024",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "1",
"inHunkInput": "0"
}
]
}
]
},
{
"type": "stepper",
"name": "step_driver",
"inputs": [
{
"name": "increment",
"type": "int32"
},
{
"name": "enable",
"type": "boolean"
}
],
"outputs": [
{
"name": "increment",
"type": "int32"
},
{
"name": "stallGuard",
"type": "uint32"
}
],
"states": [
{
"name": "current (6-24)",
"type": "uint16",
"value": "16"
},
{
"name": "enable",
"type": "boolean",
"value": "true"
}
]
}
]
}
},
{
"type": "view",
"name": "view_4",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": "3",
"inHunkInput": "1"
}
]
}
]
},
{
"type": "flowcontrol/syncpressure",
"name": "flowcontrol/syncpressure_5",
"outputs": [
{
"name": "number",
"type": "number",
"connections": [
{
"inHunkIndex": "6",
"inHunkInput": "0"
},
{
"inHunkIndex": "3",
"inHunkInput": "2"
}
]
}
],
"states": [
{
"name": "run",
"type": "boolean",
"value": "false"
},
{
"name": "types",
"type": "string",
"value": "type, value sets OK"
},
{
"name": "types",
"type": "string",
"value": "number"
},
{
"name": "values",
"type": "string",
"value": "10"
}
]
},
{
"type": "data/log_numbers",
"name": "data/log_numbers_6",
"inputs": [
{
"name": "tolog",
"type": "number"
}
],
"states": [
{
"name": "console",
"type": "boolean",
"value": "false"
}
]
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment