V 1.1.0 Senden von Winddie in Grad, Log mehrere Werte

This commit is contained in:
2026-04-14 15:41:01 +02:00
parent a7d82d31ab
commit fc8c7071f8
5 changed files with 12 additions and 21 deletions

View File

@@ -55,18 +55,8 @@ const fTenthToC = (raw) => raw === -32768 ? null : +((raw / 10 - 32) * 5 / 9).to
const mphToKmh = (raw) => raw === 255 ? null : +(raw * 1.60934).toFixed(1);
const inHgToHPa = (raw) => raw === 0 ? null : +(raw / 1000 * 33.8639).toFixed(1);
// Windrichtung aus Archiv-Byte (015 Index)
const WIND_DIR = ["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];
const windDirStr = (raw) => raw === 255 ? null : (WIND_DIR[raw] ?? null);
// Windrichtung aus LOOP1-Gradangabe (1360, 0 = kein Wind)
const WIND_STEPS = [22.5,45,67.5,90,112.5,135,157.5,180,202.5,225,247.5,270,292.5,315,337.5,360];
const WIND_ABBR = ["NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"];
const degToDir = (deg) => {
if (!deg) return null;
for (let i = 0; i < WIND_STEPS.length; i++) if (deg <= WIND_STEPS[i]) return WIND_ABBR[i];
return "N";
};
// Windrichtung aus Archiv-Byte (015 Index à 22,5°), 255 = kein Wert
const archiveWindDir = (raw) => raw === 255 ? null : raw * 22.5;
// ── Raw-Port-Helfer ────────────────────────────────────────────────────────
@@ -177,8 +167,8 @@ function parseLOOP1(pkt) {
humOut: hum(pkt[33]),
humIn: hum(pkt[11]),
windAvg: mph(pkt[14]),
windGust: null,
windDir: degToDir(pkt.readUInt16LE(16)),
windGust: mph(pkt[15]),
windDir: pkt.readUInt16LE(16) || null,
forecast: pkt[89],
pressure: press === 0 ? null : r1(press * 33.8639 / 1000),
barTrend: barTrend === 80 ? null : barTrend,
@@ -220,7 +210,7 @@ function parseRecord(buf) {
humIn: buf[22] === 255 ? null : buf[22],
windAvg: mphToKmh(buf[24]),
windGust: mphToKmh(buf[25]),
windDir: windDirStr(buf[27]),
windDir: archiveWindDir(buf[27]),
pressure: inHgToHPa(buf.readUInt16LE(14)),
rain: +(buf.readUInt16LE(10) * RAIN_CLICK).toFixed(1),
rainRate: +(buf.readUInt16LE(12) * RAIN_CLICK).toFixed(1),