Last active
September 13, 2017 20:02
-
-
Save johnty/4f65dd6eba91caff71f37abe784efb04 to your computer and use it in GitHub Desktop.
node-red mqtt roundtrip updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "c67af34f.cfd1", | |
| "type": "function", | |
| "z": "9b7d2645.a72f18", | |
| "name": "deltaT", | |
| "func": "\nvar prev = flow.get('prev')||0;\n\nvar d = new Date();\nvar n = d.getMilliseconds();\n\nif (msg.topic == \"timestamp\"){\n flow.set('prev', n);\n}\n \nelse {\n if (n<prev) {\n //console.log(\"OVERFLOW!\");\n n=n+1000;\n }\n //console.log(\"tDiff = \",n,\"-\",prev,\"=\",n-prev);\n console.log(n-prev);\n}\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 382.5, | |
| "y": 241, | |
| "wires": [ | |
| [ | |
| "da5c6847.6b87f8" | |
| ] | |
| ] | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment