From 9fabc76c9c29b14e27fcc6c2cbfb8cb08a3d54a4 Mon Sep 17 00:00:00 2001 From: SantamRC Date: Fri, 5 Apr 2024 22:54:13 +0530 Subject: [PATCH] Added GPS Sections --- HardwareReport/HardwareReport.js | 56 +++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/HardwareReport/HardwareReport.js b/HardwareReport/HardwareReport.js index b1d177a2..345e6db5 100644 --- a/HardwareReport/HardwareReport.js +++ b/HardwareReport/HardwareReport.js @@ -1166,10 +1166,10 @@ function load_airspeed(log) { } // Load GPS -let gps const max_num_gps = 2 let num_gps = 0 function load_gps(log) { + let gps = [] // for (let i = 0; i < max_num_gps; i++) { // let index = String(i+1) @@ -1192,37 +1192,61 @@ function load_gps(log) { let section = document.getElementById("GPS") let gps_num = 0 - let regex = /as (\w+)/i; + let regex = /(?<=as\s)(\S+)/i; for (let i = 0; i < messages.length; i++) { if (messages[i].startsWith("GPS")) { - let gps_device = messages[i].match(regex); + let gps_device = messages[i].match(regex)[0]; gps[gps_num++] = { gps: gps_device } } } console.log(gps) + function print_gps(inst, params) { + let fieldset = document.createElement("fieldset") + + let heading = document.createElement("legend") + heading.innerHTML = "GPS " + inst + fieldset.appendChild(heading) + + // const id = decode_devid(params.id, DEVICE_TYPE_BARO) + // print_device(fieldset, id) + + fieldset.appendChild(document.createTextNode(params.gps)) + fieldset.appendChild(document.createElement("br")) + + // fieldset.appendChild(document.createElement("br")) + // fieldset.appendChild(document.createTextNode("Wind compensation: " + (params.wind_cmp ? "\u2705" : "\u274C"))) + + // if ("all_healthy" in params) { + // fieldset.appendChild(document.createElement("br")) + // fieldset.appendChild(document.createTextNode("Health: " + (params.all_healthy ? "\u2705" : "\u274C"))) + // } + + return fieldset + } + // let primary = params["BARO_PRIMARY"] // section.appendChild(document.createTextNode("Primary: " + (primary+1))) // section.appendChild(document.createElement("br")) // section.appendChild(document.createElement("br")) - // let table = document.createElement("table") - // section.appendChild(table) + let table = document.createElement("table") + section.appendChild(table) - // let have_section = false - // for (let i = 0; i < baro.length; i++) { - // if (baro[i] != null) { - // have_section = true - // let colum = document.createElement("td") + let have_section = false + for (let i = 0; i < gps.length; i++) { + if (gps[i] != null) { + have_section = true + let colum = document.createElement("td") - // colum.appendChild(print_baro(i+1, baro[i])) - // table.appendChild(colum) - // } - // } + colum.appendChild(print_gps(i + 1, gps[i])) + table.appendChild(colum) + } + } - section.previousElementSibling.hidden = false - section.hidden = false + section.previousElementSibling.hidden = !have_section + section.hidden = !have_section }