changelog New Features#2
Open
vicliu624 wants to merge 18 commits into
Open
Conversation
This commit represents a comprehensive refactoring effort to improve code organization, maintainability, and performance. The monolithic M5mp3.cpp has been broken down into well-organized modules with clear responsibilities. ## Module Structure ### Core Modules Created: - **config.hpp/cpp**: Centralized configuration constants (UI layout, hardware pins, timing intervals) - **app_state.hpp**: Centralized application state structure (AppState) aggregating all global variables - **input_handler.hpp/cpp**: Keyboard input handling abstraction - **ui_renderer.hpp/cpp**: UI rendering logic (main view and ID3 page) - **audio_manager.hpp/cpp**: Audio playback control and callback management - **board_init.hpp/cpp**: Hardware initialization and variant detection - **file_manager.hpp/cpp**: File operations (list, delete, screenshot) - **image_utils.hpp/cpp**: Image scanning and dimension parsing utilities ## Key Improvements ### Code Organization: - Reduced M5mp3.cpp from ~1800 lines to ~420 lines (76% reduction) - Separated concerns: UI, audio, file operations, hardware init - Clear module boundaries with well-defined interfaces - Eliminated code duplication ### Performance Optimizations: - Replaced String concatenation with snprintf for better performance - Optimized screenshot capture with row-by-row pixel reading/writing - Removed unused functions and variables - Centralized constants to reduce magic numbers ### Code Quality: - Unified logging system with compile-time switches (LOG, DEBUG_PRINTF) - Consistent error handling and resource management - Better type safety (proper includes instead of forward declarations) - Improved code documentation and comments ### Memory Management: - Stream-only album cover handling (no RAM caching) - Optimized screenshot memory usage - Better resource cleanup ## Technical Details - All hardware constants moved to config.hpp - All application state consolidated in AppState struct - Audio operations unified through AudioManager interface - File operations abstracted via FileManager module - UI rendering separated into UiRenderer module - Input handling centralized in InputHandler module ## Files Changed - M5mp3.cpp: Reduced from ~1800 to ~420 lines - Added 8 new module files (headers + implementations) - Removed history/main.cpp (no longer needed) ## Testing All functionality verified and tested. The refactored code maintains 100% feature parity with the original implementation while significantly improving code maintainability and organization.
- Add VERSION file for version tracking - Add CHANGELOG.md following Keep a Changelog format - Add version macros to config.hpp - Add release scripts (release.sh and release.ps1) - Add GitHub Actions workflow for automated releases - Update .gitignore for build artifacts
- Remove Changelog section from README (moved to CHANGELOG.md) - Expand Features section with comprehensive feature descriptions - Add Version History section with link to CHANGELOG.md - Update release scripts with correct GitHub username (vicliu624) - Update CHANGELOG.md with actual release dates
…nced - Use M5Cardputer.Power.getBatteryLevel() API (uses AXP2101 PMIC internal gauge) - Add fallback to ADC reading for compatibility with Standard version - Add detailed comments explaining: - AXP2101 PMIC provides accurate battery level via internal gauge - Battery capacity (1750mAh) is handled by PMIC, not voltage mapping - Voltage-to-percentage mapping is a linear approximation - Voltage range (3.3V-4.2V) is determined by battery chemistry, not capacity
Main fixes:
1. Fix cover image scaling issue
- Properly calculate image dimensions and compute appropriate scale ratio
- Pass scaleX/scaleY parameters to M5GFX drawJpg/drawPng functions
- Use fit-to-size mode (scale=0) when dimensions cannot be determined
2. Fix crash when switching tracks in ID3 page
- Save local copies at start of drawId3Page to avoid accessing shared state
that may be modified during rendering
- Add double-check to verify buffer validity (pointer and size)
- Add index validation to prevent accessing invalid audioFiles array indices
- Early return when stale data is detected to avoid accessing freed memory
3. Improve error handling in streaming read branch
- Check getImageSize return value
- Use scaleX=0.0f (fit-to-size) instead of fixed 0.5f scaling
These fixes resolve LoadProhibited crashes that could occur when switching
tracks while viewing the ID3 information page.
…2.2.0) - Added current playback time display (MM:SS format, smaller font) - Added minimalist progress bar (1-pixel high, green, at bottom) - Added control icons (Previous: |◀, Play/Pause: ▶/⏸, Next: ▶|) with rounded square backgrounds - Added ContentType metadata display (conditional) - Improved ID3 page layout with dynamic text positioning to prevent overlap - Fixed screenshot color conversion issue (removed redundant byte swap) - Fixed album name text clipping when scrolling - Fixed scroll trigger logic (only scrolls when text exceeds width) - Added interface screenshots to README.md - Updated version to 2.2.0
…if firmware exists
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
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.
Version 2.0 - Major Feature Additions and Improvements
New Features
Multi-Language Character Support
efontKR_12(Hangul syllables)efontJA_12(Hiragana, Katakana, Kanji)efontCN_12(CJK Unified Ideographs)Screen Power Management
Song Deletion Feature
Playback Mode System
Fine Volume Control
-key for decreasing volume (step 1)=key for increasing volume (step 1)Smart Scrolling for Selected Songs
Dual Index System
n) from playing index (currentPlayingIndex)Enhanced Features
File Organization
/mp3sto/musicUser Interface Improvements
List Navigation
Performance Optimizations
Volume Control Enhancement
155 + (volume * 60 / 21)instead of step-based(volume / 5) * 17Code Quality
Removed Features
Technical Changes
deleteCurrentFile()function with smart index managementaudio_eof_mp3()to support different playback modesdraw()function with Chinese font support and improved rendering logicNotes
/musicdirectory