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
1 changed files with 2 additions and 10 deletions

View File

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