Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 17, 2025

This PR provides a comprehensive implementation of the ESP32InfoScreen controller, transforming it from a skeleton with TODO placeholders into a fully functional bidirectional communication system between ImSwitch and ESP32 devices with attached displays.

Key Features Implemented

🔄 Rate-Limited Communication System

Implemented a sophisticated rate limiting mechanism to prevent ESP32 serial communication issues:

  • 0.5-second minimum intervals between updates to ESP32
  • Pending update queue with Timer-based delayed sending
  • Prevents communication overload while maintaining responsiveness

🎯 Enhanced Motor Control

Complete motor control implementation supporting multiple movement modes:

  • Speed-based control: Continuous movement with moveForever for joystick interactions
  • Position-based control: Precise relative movements in ImSwitch units
  • Stop functionality: Zero speed properly stops motors using positioner.stop()
  • Multi-axis support: Handles X, Y, Z, A axis mapping with fallback mechanisms

⚡ Smart Laser Management

Automatic laser state management with PWM control:

  • Auto-enables lasers when setting positive PWM values
  • Auto-disables lasers when PWM reaches zero
  • Proper value range conversion (0-1024 ESP32 ↔ ImSwitch ranges)
  • Bidirectional synchronization of laser states

🔒 Recursion-Safe Signal Handling

Implemented robust signal management to prevent infinite loops:

  • Objective slot changes use direct manager calls when possible
  • Recursion prevention flags for signal-based updates
  • Safe fallback mechanisms for different hardware configurations

📡 Complete Bidirectional Integration

ESP32 → ImSwitch Control:

  • Joystick movements control stage positioning
  • LED color picker controls LED matrix
  • PWM sliders adjust laser intensity
  • Objective buttons switch between slots
  • Snap button triggers image capture

ImSwitch → ESP32 Status Updates:

  • Motor position changes reflected on sample position map
  • Captured images sent to display with timestamps
  • Laser intensity and enable state synchronization
  • LED matrix color updates
  • Objective slot status updates

🛡️ Enhanced Error Handling & Safety

  • Graceful handling when hardware components are unavailable
  • Comprehensive logging throughout all operations
  • Proper cleanup in finalize() method with timer management
  • Safe fallbacks for unsupported positioner features

Hardware Integration

The controller seamlessly integrates with existing ImSwitch managers:

  • ESP32StageManager for motor control
  • ESP32LEDMatrixManager for LED matrix control
  • ESP32LEDLaserManager for laser control
  • Auto-detection and connection to available ESP32 devices

Code Quality Improvements

  • Removed all 11 TODO comments with complete implementations
  • Enhanced error handling and logging throughout
  • Improved code organization and documentation
  • All syntax validation passes ✅

Usage

Simply add "ESP32InfoScreen" to your setup's availableWidgets list. The controller automatically detects and connects to ESP32 devices, providing immediate bidirectional control with robust communication management.

Fixes #134.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 17, 2025 06:33
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Integrate ESP32 InfoScreen into controller system Integrate ESP32 InfoScreen into controller system with bidirectional communication Aug 17, 2025
@Copilot Copilot AI requested a review from beniroquai August 17, 2025 06:36
Copilot finished work on behalf of beniroquai August 17, 2025 06:36
Deleted ESP32InfoScreenWidget.py and its import from widgets/__init__.py. Refactored ESP32InfoScreenController to remove direct widget interactions and UI signal connections, focusing on controller logic only. This change decouples the controller from the UI, likely in preparation for headless operation or a new UI approach.
@beniroquai
Copy link
Collaborator

@copilot can you fix the TODOs in the code please?

…, enhanced motor control, laser management, and signal handling

Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 18, 2025

@copilot can you fix the TODOs in the code please?

Fixed all TODOs in the ESP32InfoScreen controller (commit b8bf90f).

Key improvements:

  • ✅ Rate limiting (0.5s intervals) for ESP32 serial communication
  • ✅ Enhanced motor control with speed/position handling and stop functionality
  • ✅ Recursion prevention for objective toggle signals
  • ✅ Automatic laser enable/disable with PWM commands
  • ✅ Complete bidirectional signal integration for laser/LED status updates
  • ✅ Cleaned up all commented code and improved error handling

The controller now provides robust bidirectional communication with proper rate limiting and comprehensive hardware integration.

@Copilot Copilot AI changed the title Integrate ESP32 InfoScreen into controller system with bidirectional communication Complete ESP32InfoScreen controller implementation with enhanced hardware control and rate-limited communication Aug 18, 2025
Copilot finished work on behalf of beniroquai August 18, 2025 05:08
Introduces setSingleShot() to the Timer abstract base and implements it in the noqt backend. This allows timers to be configured to fire only once per start or to repeat, improving flexibility for timer usage.
Added bidirectional mapping between lasers and ESP32 PWM channels, improved handling of laser value updates, and implemented support for absolute position commands from ESP32. Introduced new signals and API methods for reconnecting and checking ESP32 connection status. Removed SQUIDLaserManager and SQUIDLedManager files, and made related updates to controllers and serial communication logic.
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.

Integrate ESP32 InfoScreen into controller system

2 participants