From 28c9c681538308e126131f4b65ec2e793398cbd4 Mon Sep 17 00:00:00 2001 From: K Date: Thu, 20 Jul 2023 10:24:10 +0200 Subject: [PATCH] [ADD] 2023 barani meteo wind codec --- .gitignore | 3 +- barani-meteo-wind-2023.js | 122 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 barani-meteo-wind-2023.js diff --git a/.gitignore b/.gitignore index 723ef36..706fd07 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +.vscode diff --git a/barani-meteo-wind-2023.js b/barani-meteo-wind-2023.js new file mode 100644 index 0000000..7a66838 --- /dev/null +++ b/barani-meteo-wind-2023.js @@ -0,0 +1,122 @@ +var pos = 0; +var bindata = ""; + +var ConvertBase = function (num) { + return { + from : function (baseFrom) { + return { + to : function (baseTo) { + return parseInt(num, baseFrom).toString(baseTo); + } + }; + } + }; +}; + +function pad(num) { + var s = "0000000" + num; + return s.slice(-8); +} + +function windify(num) { + if (num > 0) { + return num * 0.6335 + 0.3582 + } else { + return 0 + } + + } + +ConvertBase.dec2bin = function (num) { + return pad(ConvertBase(num).from(10).to(2)); +}; + +ConvertBase.bin2dec = function (num) { + return ConvertBase(num).from(2).to(10); +}; + +function data2bits(data) { + var binary = ""; + for(var i=0; i