get rid of rainfall filtering

This commit is contained in:
Evert Prants 2023-10-03 20:37:54 +03:00
parent 7e112a78e6
commit 18423bec72
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -1,6 +1,5 @@
import { getDeviceList, Device, Interface, InEndpoint } from 'usb';
const MAX_RAIN_JUMP = 10;
const WIND_DIRS = [
'N',
'NNE',
@ -236,7 +235,7 @@ class WS1080 {
// Bytes 14 and 15 when combined create an unsigned short int
// that we multiply by 0.3 to find the total rain
let totalRain = currentBlock.subarray(13, 15).readUint16LE() * 0.3;
const totalRain = currentBlock.subarray(13, 15).readUint16LE() * 0.3;
// Calculate wind speeds
const windSpeed = (wind + ((windExtra & 0x0f) << 8)) * 0.38; // Was 0.1
@ -251,14 +250,7 @@ class WS1080 {
// Calculate rainfall rates
if (this.previousRain === 0) this.previousRain = totalRain;
let rainDiff = totalRain - this.previousRain;
if (rainDiff > MAX_RAIN_JUMP) {
// Filter rainfall spikes
rainDiff = 0;
totalRain = this.previousRain;
}
const rainDiff = totalRain - this.previousRain;
this.previousRain = totalRain;
// Compile the data