Shared header files for MagLoop stepper motor control projects.
- stepper_commands.h β Command definitions and Message struct for ESP-NOW communication
- stepper_helpers.h β Helper functions and utilities
- circular_buffer.h β Template-based circular buffer implementation
- StepperController β ESP32 stepper motor controller
- StepperGUI β ESP32 touchscreen GUI controller
This repository is designed to be used as a Git submodule in projects that need these shared definitions.
# Add as submodule
git submodule add https://github.com/mm5agm/MagLoop_Common_Files.git MagLoop_Common_Files
# For PlatformIO: add to [platformio.ini](http://_vscodecontentref_/1)
build_flags = -IMagLoop_Common_Files
# For Arduino IDE: copy files to your project or add to include path
Batch Scripts for Updating and Uploading Code
Use the following batch files in your main project folder to keep MagLoop_Common_Files and StepperGUI in sync:
download_latest_code.bat β Pulls the latest code from both StepperGUI and MagLoop_Common_Files from GitHub.
upload_code_if_changed.bat β Checks for changes (including README.md and all other files) in both repositories  
and pushes updates only if changes are detected.
Usage
Double-click or run download_latest_code.bat to update your local code from GitHub.
Double-click or run upload_code_if_changed.bat to push any local changes (including README.md) to GitHub.   
If there are no changes, the script will warn and do nothing.
These scripts automate the most common sync operations for development and ensure documentation changes are included.
π  Development Workflow
Making Changes to Common Files
Make changes in any project that uses these files as a submodule.
Navigate to the submodule directory:
cd MagLoop_Common_Files
Commit and push changes:
git add .
git commit -m "Description of changes"
git push origin main
Update other projects using the batch scripts above.
Best Practices
β
 Test changes in one project before updating others
β
 Use descriptive commit messages for common file changes
β
 Update all dependent projects after making changes
β
 Maintain backward compatibility when possible
β
 Document breaking changes in commit messages
π File Descriptions
stepper_commands.h
CommandType enum β All ESP-NOW command definitions
Message struct β Packed message format for wire communication
Constants β Position limits and parameter defaults
stepper_helpers.h
commandToString() β Convert command enum to readable string
Helper stubs β Placeholder for future utility functions
circular_buffer.h
CircularBuffer template β Thread-safe circular buffer implementation
Arduino compatible β Works with ESP32/Arduino framework
Generic template β Can store any data type
π§ Technical Details
Wire Format: Messages use packed structs with explicit sizes for consistency
Compatibility: Designed for ESP32 with Arduino framework
Thread Safety: CircularBuffer is interrupt-safe for ESP-NOW callbacks
Memory Usage: Minimal footprint, suitable for embedded systems
π License
This project is part of the MagLoop stepper control system.