Skip to content

Add 100% authentic CMatrix implementation for Raspberry Pi 5#1

Open
bobster316 wants to merge 4 commits intomainfrom
claude/matrix-rain-raspberry-pi-011CUryrKmPLec1WgefY5hTu
Open

Add 100% authentic CMatrix implementation for Raspberry Pi 5#1
bobster316 wants to merge 4 commits intomainfrom
claude/matrix-rain-raspberry-pi-011CUryrKmPLec1WgefY5hTu

Conversation

@bobster316
Copy link
Owner

This commit adds a complete, algorithm-accurate replication of the original cmatrix terminal screensaver, ported for ST7789V3 240x280 displays on Raspberry Pi 5.

Key features:

  • 100% accurate implementation matching original cmatrix C code
  • All character sets: ASCII (movie-accurate), Katakana, Console mode
  • All visual modes: Bold (none/even/all), 8 colors, rainbow mode
  • Original scrolling algorithms: new-style and old-style with head markers
  • Special effects: Lambda mode, character randomization (8%), speed control (0-10)
  • Movie-accurate preset matching "The Matrix" film appearance

New files:

  • cmatrix_authentic.py: Core implementation with complete feature parity
  • CMATRIX_AUTHENTIC.md: Comprehensive documentation with algorithm details
  • test_cmatrix.py: Full test suite with 10 test scenarios
  • examples/: 5 example scripts demonstrating different modes
    • simple_matrix.py: Movie-accurate mode
    • rainbow_matrix.py: Rainbow colors with character randomization
    • katakana_matrix.py: Traditional Japanese characters
    • lambda_matrix.py: Lambda mode for programmers
    • interactive_matrix.py: Runtime control demonstration

Updated files:

  • display.py: Now uses CMatrixDisplay instead of legacy MatrixDisplay
  • README.md: Updated with CMatrix documentation and usage examples

Technical implementation:

  • Exact column algorithm with head markers and length tracking
  • Authentic character selection and randomization
  • Original bold detection (even-valued characters)
  • All 8 color schemes plus rainbow mode
  • Speed control matching original napms(update * 10) timing
  • Both synchronous and asynchronous column scrolling

Based on: https://github.com/abishekvashok/cmatrix
Original author: Chris Allegretta
Current maintainer: Abishek V Ashok

This commit adds a complete, algorithm-accurate replication of the
original cmatrix terminal screensaver, ported for ST7789V3 240x280
displays on Raspberry Pi 5.

Key features:
- 100% accurate implementation matching original cmatrix C code
- All character sets: ASCII (movie-accurate), Katakana, Console mode
- All visual modes: Bold (none/even/all), 8 colors, rainbow mode
- Original scrolling algorithms: new-style and old-style with head markers
- Special effects: Lambda mode, character randomization (8%), speed control (0-10)
- Movie-accurate preset matching "The Matrix" film appearance

New files:
- cmatrix_authentic.py: Core implementation with complete feature parity
- CMATRIX_AUTHENTIC.md: Comprehensive documentation with algorithm details
- test_cmatrix.py: Full test suite with 10 test scenarios
- examples/: 5 example scripts demonstrating different modes
  - simple_matrix.py: Movie-accurate mode
  - rainbow_matrix.py: Rainbow colors with character randomization
  - katakana_matrix.py: Traditional Japanese characters
  - lambda_matrix.py: Lambda mode for programmers
  - interactive_matrix.py: Runtime control demonstration

Updated files:
- display.py: Now uses CMatrixDisplay instead of legacy MatrixDisplay
- README.md: Updated with CMatrix documentation and usage examples

Technical implementation:
- Exact column algorithm with head markers and length tracking
- Authentic character selection and randomization
- Original bold detection (even-valued characters)
- All 8 color schemes plus rainbow mode
- Speed control matching original napms(update * 10) timing
- Both synchronous and asynchronous column scrolling

Based on: https://github.com/abishekvashok/cmatrix
Original author: Chris Allegretta
Current maintainer: Abishek V Ashok
Added three installation resources to make setup on Raspberry Pi 5 easy:

1. QUICKSTART.md
   - 5-minute quick start guide
   - Essential commands only
   - Perfect for getting started fast

2. INSTALL_GUIDE.md
   - Complete step-by-step installation instructions
   - Hardware wiring reference
   - Comprehensive troubleshooting section
   - Auto-start configuration
   - Performance tuning tips

3. quick_install.sh
   - Automated installation script
   - Checks SPI status
   - Installs all dependencies
   - Clones LCD driver if needed
   - Updates paths in all scripts
   - Tests display connection
   - Makes scripts executable

Users can now simply:
  1. Clone the repo
  2. Enable SPI
  3. Run ./quick_install.sh
  4. Run python3 examples/simple_matrix.py

The installer handles everything automatically.
This reorganization ensures existing working files remain untouched while
providing clear separation between original and new implementations.

Key Changes:
============

SAFE TESTING APPROACH:
- Restored original display.py (user's working version - UNTOUCHED)
- Created display_cmatrix.py (new version with authentic CMatrix)
- Users can test standalone examples without affecting their working setup

FILE ORGANIZATION:
Renamed with clear prefixes to avoid confusion:
- cmatrix_examples/ (was examples/)
- cmatrix_test.py (was test_cmatrix.py)
- cmatrix_install.sh (was quick_install.sh)
- CMATRIX_DOCS.md (was CMATRIX_AUTHENTIC.md)
- CMATRIX_INSTALL.md (was INSTALL_GUIDE.md)

ARCHIVE:
- Created _archive/ folder
- Moved old/legacy files (matrix.py, install.sh, etc.)
- Preserved for reference but not actively used

NEW DOCUMENTATION:
- TESTING_GUIDE.md - Comprehensive safe testing and integration guide
  - Phase 1: Test standalone (no integration)
  - Phase 2: Test integrated version (optional)
  - Phase 3: Permanent integration (optional)
  - Rollback instructions

UPDATED ALL REFERENCES:
- Updated all file paths in scripts
- Updated all documentation references
- Added safety warnings to README
- Clear indication of original vs new files

Final Structure:
===============
display.py                 ✅ Original working version (preserved)
display_cmatrix.py         🆕 New version with authentic CMatrix
cmatrix_authentic.py       🆕 Core implementation
cmatrix_examples/          🆕 Standalone examples (test first!)
cmatrix_test.py           🆕 Test suite
cmatrix_install.sh        🆕 Installer
TESTING_GUIDE.md          🆕 Safe testing instructions
_archive/                  📦 Old files

User Benefits:
=============
1. Existing working display is completely safe
2. Can test new matrix without any risk
3. Clear separation between original and new code
4. Easy rollback if needed
5. Optional integration only after successful testing

This allows users to:
- Keep their current setup running
- Test the authentic CMatrix separately
- Integrate only when ready
- Rollback instantly if issues occur
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.

2 participants