Skip to content

Conversation

@mikeller
Copy link
Member

@mikeller mikeller commented Jun 8, 2025

Don't show the O2 sensor calibration settings in 'Extra Info' when the
dive is not a rebreather dive.

@mikeller mikeller requested a review from Copilot June 8, 2025 06:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the sensor calibration handling logic in the Shearwater Predator parser to hide O₂ sensor calibration data for open circuit dives.

  • Introduces a conditional retrieval of dive mode when the log version is 8 or higher.
  • Caches sensor calibration only if the dive mode indicates a rebreather dive (M_CC, M_CC2, or M_SC).
  • Removes a redundant block of code that previously extracted the dive mode later in the function.
Comments suppressed due to low confidence (1)

src/shearwater_predator_parser.c:779

  • Consider adding a comment to clarify the significance of the constants 6 and 86 when computing the base index for sensor calibration.
unsigned int base = parser->opening[3] + (pnf ? 6 : 86);

parser->calibrated = data[base];
// Get the dive mode from the header (if available).
if (logversion >= 8) {
divemode = data[parser->opening[4] + (pnf ? 1 : 112)];
Copy link

Copilot AI Jun 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment to explain the rationale behind the constant 112 (and 1) offset used to retrieve the dive mode from the header.

Suggested change
divemode = data[parser->opening[4] + (pnf ? 1 : 112)];
// The offset 112 is used to retrieve the dive mode from the header for non-PNF logs.
// For PNF logs, the offset is 1. These offsets are determined by the log format specifications.
const unsigned int DIVE_MODE_OFFSET_NON_PNF = 112;
const unsigned int DIVE_MODE_OFFSET_PNF = 1;
divemode = data[parser->opening[4] + (pnf ? DIVE_MODE_OFFSET_PNF : DIVE_MODE_OFFSET_NON_PNF)];

Copilot uses AI. Check for mistakes.
Don't show the O2 sensor calibration settings in 'Extra Info' when the
dive is not a rebreather dive.

Signed-off-by: Michael Keller <[email protected]>
@mikeller mikeller force-pushed the shearwater_hide_sensor_calibration_on_oc branch from 96ef0ca to 59350fd Compare June 14, 2025 07:25
@mikeller mikeller merged commit 4a20e1e into subsurface:Subsurface-DS9 Jun 14, 2025
8 checks passed
theCarlG pushed a commit to theCarlG/libdc that referenced this pull request Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant