Skip to content

UI: Create pH Sensor Calibration Modal #10

Description

@tazomatalax

Description
Provide a user-friendly interface for calibrating an EZO-pH sensor. This modal will allow the user to send specific calibration commands and see the sensor's response.

Tasks

  1. In data/index.html, add a "Calibrate" button to the sensor management UI for EZO-pH sensors. This button should open a new modal.
  2. Design the calibration modal with buttons for "Calibrate Mid (7.0)", "Calibrate Low (4.0)", "Calibrate High (10.0)", "Clear Calibration", and "Check Status".
  3. Add a display area in the modal for the sensor's last response.
  4. In data/script.js, create a sendCalibrateCommand(command) function that POSTs the command to the /api/sensor/command endpoint.
  5. Update the updateIOStatus function to continuously refresh the response text inside the calibration modal when it is open.

Example Code

In data/script.js:

function sendCalibrateCommand(command) {
    fetch('/api/sensor/command', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ index: currentSensorIndex, command: command })
    }).then(res => {
        if (res.ok) showToast("Command sent!", "info");
        else showToast("Failed to send command.", "error");
    });
}

// In updateIOStatus()
const calResponseSpan = document.getElementById('cal-response');
if (calResponseSpan) {
    calResponseSpan.innerText = data.sensors_data[currentSensorIndex].response;
}

Acceptance Criteria

  • The user can open the calibration modal for a pH sensor.
  • Clicking a calibration button sends the correct command to the device.
  • The response from the EZO circuit (e.g., *OK or an error code) is displayed in the modal in near real-time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions