RadiaCode-Spectrometer/ESP32-S3-Touch/_archive_previous_project/FIXES_DOCUMENTATION.md

3.4 KiB

ESP32-S3-Touch Project Fixes Documentation

Overview

This document describes the fixes applied to the ESP32-S3-Touch project to address various issues with API endpoints, touch handling, memory corruption, and UI organization.

1. API Endpoint Authentication Issues

Problem: The /apply and /save API endpoints were reported as unavailable in the Web UI.

Solution:

  • Enhanced error logging in requireAuth() function to provide detailed information about authentication failures.
  • Added better error handling to the Web UI's fetch logic for improved error reporting.
  • Updated the error messages to be more descriptive.

2. Touch Handling Issues

Problem: The Controls page was not responding properly to touch inputs.

Solution:

  • Improved the touch_poll() function with enhanced gesture detection.
  • Added visual feedback when touching the Controls page.
  • Fixed swipe detection parameters to make page navigation more reliable.
  • Ensured Controls page gets redrawn when touch events occur.

3. Memory Corruption (Weird Symbols)

Problem: Strange symbols were appearing on LCD pages, potentially due to memory corruption.

Solution:

  • Added a comprehensive check_memory_health() function to detect memory issues.
  • Implemented validation for all string lengths and numeric values to prevent overflow.
  • Added checks for invalid configuration values with automatic correction.
  • Added diagnostic logging to help identify the source of corruption.

4. Category to Page Mapping

Problem: The structure appeared messy with widgets not organized by their categories.

Solution:

  • Implemented the update_category_to_page_mapping() function to ensure widgets are displayed on the correct screens.
  • Added support for the new category system (Weather, Device, Control, System).
  • Ensured the Controls page shows Control widgets, Home shows Weather widgets, etc.
  • Added visual indicators to show widget categories on each page.

5. Template API Endpoints

Problem: Template data verification and API endpoints needed improvement.

Solution:

  • Enhanced the /template/data endpoint to provide comprehensive data for all categories.
  • Improved the /template/verify endpoint to better validate data paths.
  • Added data type information to template verification.
  • Added category name information to make template usage clearer.
  • Added additional dummy data for fields not yet in the AppConfig.

How to Apply These Fixes

  1. All the fixes are integrated into the main codebase.

  2. Run the provided build script to compile and upload the updated firmware:

    # PowerShell
    .\build_script.ps1
    

Verifying the Fixes

  1. API Endpoints: Check the serial monitor for detailed authentication logs when using the Web UI.
  2. Touch Handling: The Controls page should now respond properly to touch inputs with visual feedback.
  3. Memory Issues: The system now monitors and logs potential memory issues in the serial output.
  4. Category Mapping: Widgets should appear on the correct screens based on their categories.
  5. Template API: Use the improved template verification in the Web UI for better widget creation.

Additional Information

These fixes maintain backward compatibility with the existing configuration while adding new functionality. The memory diagnostics will run at startup to detect any potential issues early.