$ ./decode-adc.js
[
0.5, 1, 1.5, 2, 2.5, 3, 3.5,
4, 4.5, 5, 5.5, 6, 6.5, 7,
7.5, 8, 8.5, 9, 9.5, 10, 10.5,
11, 11.5, 12, 12.5, 13, 13.5, 14,
14.5, 15, 15.5, 16
]
Last active
November 10, 2021 04:01
-
-
Save jadonk/f6d759439fc3881caf674f1285ffa97d to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
var ascii85 = require('ascii85') | |
var b85_table = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '#', '$', '%', '&', '«', '»', '*', '+', '-', ';', '<', '=', '>', '?', '@', '^', '_', '`', '{', '|', '}', '~']; | |
var c = new ascii85.Ascii85({table:b85_table}); | |
function decodeFloat16(binary) { | |
var exponent = (binary & 0x7C00) >> 10, | |
fraction = binary & 0x03FF; | |
var output = (binary >> 15 ? -1 : 1) * ( | |
exponent ? | |
( | |
exponent === 0x1F ? | |
fraction ? NaN : Infinity : | |
Math.pow(2, exponent - 15) * (1 + fraction / 0x400) | |
) : | |
6.103515625e-5 * (fraction / 0x400)); | |
return(output); | |
}; | |
function decode(string) { | |
var buf = c.decode(string); | |
var output = []; | |
for(var i = 0; i < buf.length; i+=2) { | |
var v = decodeFloat16(buf.readUInt16LE(i)); | |
output.push(v); | |
} | |
return(output); | |
}; | |
console.log(decode("05||V06qXf06_pk07C#ofJ6XAfJFdCfJOjEfJXpGKuCZ{z«@c|KuLf}z»1i~KuUm0z»Ap1Kuds2z»Jv3")); |
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
{ | |
"name": "ascii85", | |
"lockfileVersion": 2, | |
"requires": true, | |
"packages": { | |
"": { | |
"dependencies": { | |
"ascii85": "^1.0.2" | |
} | |
}, | |
"node_modules/ascii85": { | |
"version": "1.0.2", | |
"resolved": "https://registry.npmjs.org/ascii85/-/ascii85-1.0.2.tgz", | |
"integrity": "sha1-YhJUPUI2lE3r5IJ+yuZCd25BVEg=", | |
"engines": { | |
"node": ">=0.12" | |
} | |
} | |
}, | |
"dependencies": { | |
"ascii85": { | |
"version": "1.0.2", | |
"resolved": "https://registry.npmjs.org/ascii85/-/ascii85-1.0.2.tgz", | |
"integrity": "sha1-YhJUPUI2lE3r5IJ+yuZCd25BVEg=" | |
} | |
} | |
} |
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
{ | |
"dependencies": { | |
"ascii85": "^1.0.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment