-
Notifications
You must be signed in to change notification settings - Fork 24
Enhanced troubleshooting and reliability changes #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dpenney
wants to merge
8
commits into
jhoff:main
Choose a base branch
from
dpenney:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Major enhancements to improve module calibration and diagnostics:
New Features:
- Module calibration interface with real-time offset adjustment
- I2C connectivity testing endpoint
- Dynamic offset updates without restart
- Automatic restart on module count change
- Watchdog timer protection for long operations
- Add credentials.h for WiFi and MQTT defaults
- Create credentials.h.example template
- Update .gitignore to exclude credentials.h
Technical Changes:
- Add testI2CConnectivity and getAddress methods to SplitFlapModule
- Add getModules and updateOffsets to SplitFlapDisplay
- Modify testModule to home and display blank character
- Add watchdog feeding in motor control loops
- Add Module Calibration section to settings page
- Fix Alpine.js template issues and array initialization
API Endpoints:
- POST /api/module/{index}/test - Home and test module
- POST /api/module/{index}/offset - Update module offset
- GET /api/i2c/test - Test I2C connectivity
Documentation:
- Add ENHANCEMENTS.md with comprehensive feature documentation
- Add CLAUDE.md with project guidance
- Add CREDENTIALS.md documentation
MQTT messages were briefly displayed but immediately cleared by the display mode logic. The mode loop was overwriting MQTT messages because the web server's input/written state didn't match the MQTT text. Changes: - Add setWebServer() method to SplitFlapMqtt class - Update MQTT callback to sync web server state (inputString and writtenString) - Connect web server to MQTT in setup via splitflapMqtt.setWebServer() This ensures MQTT messages persist on the display by keeping the web server's state synchronized with what MQTT displays. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…r motors This commit significantly improves system reliability across network connectivity and motor control with intelligent reconnection strategies and idle motor handling. WiFi Reconnection Improvements: - Implement exponential backoff for reconnection attempts (5s → 180s max) - Add maximum retry limit (10 attempts) to prevent infinite loops - Track reconnection state to avoid spamming reconnect commands - Provide detailed logging with status codes and wait times - Automatic recovery detection and state reset on successful reconnection MQTT Reconnection Support: - Add automatic MQTT reconnection when WiFi is restored - Implement connection monitoring with 5-second retry interval - Detect and log connection state changes (lost/established/restored) - Publish offline status when disconnection is detected - Skip reconnection attempts when MQTT server is not configured Stepper Motor Reliability Enhancements: - Add idle motor detection (tracks last movement time) - Implement gentle 3-phase wake-up sequence for motors idle > 5 minutes: * Gradual coil energizing to overcome static friction * Small oscillation to break stiction * Full power holding before movement - Enhanced I2C error recovery: * Track consecutive errors per module * Automatic recovery attempt after 3 errors * Clear error flags when communication resumes * Detailed logging of module health status - Automatic wake-up integration in moveTo() function - Extra settling time for modules that were woken up Benefits: - Prevents endless WiFi reconnection loops - Ensures MQTT connectivity after network disruptions - Reduces missed steps from idle motors - Better diagnostics through comprehensive logging - Improved mechanical longevity through gentle motor handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Changed motor wake-up strategy from time-based detection to always executing before any movement. This is simpler, more reliable, and ensures consistent motor performance. Changes: - Remove time-based idle detection (needsWakeUp method) - Remove timestamp tracking (lastMovementTime, lastStopTime, isMotorStopped) - Always wake up all motors before moveTo() operations - Simplify wakeUp() to focus only on the gentle wake-up sequence Benefits: - Simpler code with less state to track - More consistent behavior - every movement is preceded by wake-up - Eliminates edge cases from time-based detection - Better reliability as motors are always properly energized - Removes complexity without sacrificing functionality The gentle 3-phase wake-up sequence (gradual energizing, oscillation, full power holding) is now performed on every movement, ensuring motors are always ready for precise positioning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Major code quality improvements to enhance maintainability, reliability,
and debuggability of the Split-Flap Display firmware.
Changes:
1. Extract Magic Numbers to Named Constants:
- Define stepper motor control patterns (STEPPER_PATTERN_0-3)
- Define PCF8575 I/O states (PCF8575_IO_INIT_STATE, PCF8575_MOTOR_STOP_STATE)
- Define timing constants (HALL_EFFECT_CHECK_INTERVAL_US,
MOTOR_START_STOP_DELAY_MS, WATCHDOG_FEED_INTERVAL_MS)
- Add MODULE_INIT_DELAY_MS for initialization timing
- Benefits: Easier to maintain, modify, and understand hardware interface
2. Add Input Validation and Error Handling:
- Validate targetPositions array is not null in moveTo()
- Check all target positions are within valid range (0 to stepsPerRot-1)
- Add default case in stepper pattern switch with error logging
- Log warnings when invalid characters are displayed (not in charset)
- Benefits: Prevents crashes, provides better debugging information
3. Refactor Duplicate Homing Code:
- Extract common homing logic into performHomingSequence() private method
- Simplify home(), homeToString(), and homeToChar() methods
- Remove 30+ lines of duplicate code
- Benefits: Single source of truth, easier to maintain and modify
4. Improve Error Messages:
- Add detailed printf-style logging for invalid characters
- Include charset size, hex values, and module addresses in errors
- Show which module and position caused validation failures
- Benefits: Faster troubleshooting and debugging
Code Metrics:
- Removed ~30 lines of duplicate code
- Added comprehensive input validation
- Improved code readability with named constants
- Enhanced error reporting for debugging
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Timing Fixes: - Fix stale currentTime in motor control loop - Fix sensor check timestamp - Reduce I2C error recovery delay from 10ms to 2ms - Add I2C timeout handling to prevent hangs MQTT Reliability: - Add busy flag to prevent concurrent operations - Queue MQTT messages when display is busy Documentation: - TIMING_ISSUES.md - timing analysis - MQTT_ACCURACY_FIX.md - MQTT fixes - ACCURACY_IMPROVEMENTS.md - future enhancements
Added documentation for recent enhancements: - Motor timing improvements for better accuracy - MQTT reliability with message queuing - Links to detailed analysis documents
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes address a number of issues I was having with the SplitFlap modules, mainly centered around reliability of the WiFi/MQTT connections and the repeatability of the moves, there are also additions to assist with the initial setup of the offsets.