diff --git a/gcs/package.json b/gcs/package.json index 823f1e1ed..a5b8df612 100644 --- a/gcs/package.json +++ b/gcs/package.json @@ -31,7 +31,7 @@ "@mantine/hooks": "^7.17.3", "@mantine/notifications": "^7.4.0", "@mantine/spotlight": "^7.15.3", - "@mantine/tiptap": "^7.17.3", + "@mantine/tiptap": "^7.17.4", "@reduxjs/toolkit": "^2.2.7", "@robloche/chartjs-plugin-streaming": "^3.1.0", "@tabler/icons-react": "^2.44.0", diff --git a/gcs/src/components/fla/graph.jsx b/gcs/src/components/fla/graph.jsx index cddc94c4e..1e7e37ea9 100644 --- a/gcs/src/components/fla/graph.jsx +++ b/gcs/src/components/fla/graph.jsx @@ -286,9 +286,6 @@ export default function Graph({ ] const scales = {} - // Capture current scales if they exist - const currentScales = chartRef.current?.scales - if (yAxisIDs.length === 0) { scales.y = { grid: { color: tailwindColors.gray[500] }, @@ -309,27 +306,9 @@ export default function Graph({ text: yAxisID, }, } - // Only add min/max if we have existing scales and they're not undefined - if ( - data.datasets.length > 0 && - currentScales[yAxisID]?.min !== undefined - ) { - scales[yAxisID].min = currentScales[yAxisID].min - scales[yAxisID].max = currentScales[yAxisID].max - } else { - scales[yAxisID].min = undefined - scales[yAxisID].max = undefined - } }) scales.x = { ...config.scales.x } - if (data.datasets.length > 0 && currentScales.x?.min !== undefined) { - scales.x.min = currentScales.x.min - scales.x.max = currentScales.x.max - } else { - scales.x.min = undefined - scales.x.max = undefined - } setConfig({ ...config, diff --git a/gcs/src/components/fla/presetCategories.js b/gcs/src/components/fla/presetCategories.js index a2af3e5d4..2a11485e6 100644 --- a/gcs/src/components/fla/presetCategories.js +++ b/gcs/src/components/fla/presetCategories.js @@ -55,11 +55,26 @@ const dataflashPresetCategories = [ ], }, { - name: "Battery", + name: "Batteries", filters: [ { - name: "Battery Voltage vs Current", - filters: { BAT: ["Volt", "Curr"] }, + name: "Battery 1 Voltage vs Current", + filters: { BAT1: ["Volt", "Curr"] }, + aircraftType: ["copter", "plane", "quadplane"], + }, + { + name: "Battery 2 Voltage vs Current", + filters: { BAT2: ["Volt", "Curr"] }, + aircraftType: ["copter", "plane", "quadplane"], + }, + { + name: "Battery 3 Voltage vs Current", + filters: { BAT3: ["Volt", "Curr"] }, + aircraftType: ["copter", "plane", "quadplane"], + }, + { + name: "Battery 4 Voltage vs Current", + filters: { BAT4: ["Volt", "Curr"] }, aircraftType: ["copter", "plane", "quadplane"], }, ], diff --git a/gcs/src/fla.jsx b/gcs/src/fla.jsx index ec84f7ddc..a5b2780bb 100644 --- a/gcs/src/fla.jsx +++ b/gcs/src/fla.jsx @@ -268,6 +268,50 @@ export default function FLA() { delete logMessageFilterDefaultState["ESC"] } + if (loadedLogMessages["BAT"]) { + let tempLoadedLogMessages = { ...loadedLogMessages } + let tempMsgFormat = { ...loadedLogMessages["format"] } + + // Load each BATT data into its own array + loadedLogMessages["BAT"].map((battData) => { + // Check for both "Inst" and "Instance" keys + const instanceValue = battData["Instance"] ?? battData["Inst"] + const battName = `BAT${(instanceValue ?? 0) + 1}` + + // Initialize the array if it doesn't exist + if (!tempLoadedLogMessages[battName]) { + tempLoadedLogMessages[battName] = [] + } + + tempLoadedLogMessages[battName].push({ + ...battData, + name: battName, + }) + + // Add filter state for new BATT + if (!logMessageFilterDefaultState[battName]) + logMessageFilterDefaultState[battName] = { + ...logMessageFilterDefaultState["BAT"], + } + + // Add format state for new BATT + if (!tempMsgFormat[battName]) + tempMsgFormat[battName] = { + ...tempMsgFormat["BAT"], + name: battName, + } + + tempLoadedLogMessages["format"] = tempMsgFormat + }) + + // Remove old BATT motor data + delete tempLoadedLogMessages["BAT"] + delete tempLoadedLogMessages["format"]["BAT"] + delete logMessageFilterDefaultState["BAT"] + updateLogMessages(tempLoadedLogMessages) + updateFormatMessages(tempLoadedLogMessages["format"]) + } + // Sort new filters const sortedLogMessageFilterState = Object.keys( logMessageFilterDefaultState, @@ -817,11 +861,30 @@ export default function FLA() { )} {/* Default Presets */} {presetCategories[logType]?.map((category) => { + // Filter out presets with unavailable keys or fields + const filteredCategory = { + ...category, + filters: category.filters.filter((filter) => + Object.keys(filter.filters).every((key) => { + // Check if the key exists in logMessages + if (!logMessages[key]) return false + + // Check if the required fields exist in logMessages["format"][key].fields + const requiredFields = filter.filters[key] + const availableFields = + logMessages["format"]?.[key]?.fields || [] + return requiredFields.every((field) => + availableFields.includes(field), + ) + }), + ), + } + return ( diff --git a/gcs/src/helpers/logMessageDescriptions.js b/gcs/src/helpers/logMessageDescriptions.js index 139b05175..7708ed810 100644 --- a/gcs/src/helpers/logMessageDescriptions.js +++ b/gcs/src/helpers/logMessageDescriptions.js @@ -28,7 +28,18 @@ const dataflashLogMessageDescriptions = { AUXF: "Auxiliary function invocation information", BARD: "Barometer dynamic data", BARO: "Gathered Barometer data", - BAT: "Gathered battery data", + BAT1: "Gathered battery data for battery 1", + BAT2: "Gathered battery data for battery 2", + BAT3: "Gathered battery data for battery 3", + BAT4: "Gathered battery data for battery 4", + BAT5: "Gathered battery data for battery 5", + BAT6: "Gathered battery data for battery 6", + BAT7: "Gathered battery data for battery 7", + BAT8: "Gathered battery data for battery 8", + BAT9: "Gathered battery data for battery 9", + BAT10: "Gathered battery data for battery 10", + BAT11: "Gathered battery data for battery 11", + BAT12: "Gathered battery data for battery 12", BCL: "Battery cell voltage information", BCL2: "Battery cell voltage information", BCN: "Beacon information",