Skip to content

KingDuane/Moonshot-M5GLASS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

                    @         @                 @@@@@       @         @@@@@@@@@@
                  @@@       @@@             @@@@@@@@@@@@@   @@@       @@@@@@@@@@
               @@@@@@    @@@@@@           @@@@@@@@@@@@@@@@@ @@@@@@    @@@@@@@@@@
             @@@@@@@@  @@@@@@@@          @@@@@@@@@@@@@@@@@@@@@@@@@@@  @@@@@@@@@@
          @@@@@@@@@@@@@@@@@@@@@   @@@   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
        @@@@@@@@@@@@@@@@@@@@@@X@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@
   @@@@@@@@@@@@@@@@@@@@@@@@@@@X@@@@@@@@@    @@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @@@           @@@@@       @@@@@@@@@@@@@@@@@@@@

                  @@@@@@      @@@@@@@@@@@@@@@@@@@@          @@@@@@@@@@@@@@@@@@@@
              @@@@@@@@@@@@@   @@@@@@@@@@@@@@@@@@@@          @@@@@@@@@@@@@@@@@@@@
            @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@    @@@   @@@@@@@@@@@@@@@@@@@@
           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@         @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@     @@@@@@@@@@     
 @@@@@@@@@@@@@@@@@@@          @@@@@@@@@@@@@@@@@@@@ @@@@@@@@@     @@@@@@@@@@     
   @@@@@@@@@@@@@@@            @@@@@@@@@@@@@@@@@@@@    @@@        @@@@@@@@@@     
      @@@@@@@@                @@@@@@@@@@@@@@@@@@@@               @@@@@@@@@@     

Moonshot M5GLASS

A dual-screen bouncing logo screensaver for M5Stack Cardputer and GLASS2 display, featuring synchronized LED flash and sound effects.

Features

  • Dual Display Support - Synchronized bouncing logos on both Cardputer LCD and GLASS2 OLED
  • Color-Matched Design - Carefully tuned cyan (0x06FF) across all displays and LED
  • Hardware-Accelerated Rendering - Sprite-based rendering with double buffering for butter-smooth animation
  • LED Flash Feedback - Cyan LED flash on wall collision
  • Subtle Sound Effects - High-pitched tick sound on collision
  • Sound Toggle - Press G0 button to enable/disable sound
  • Anti-Flicker Technology - Double buffering eliminates OLED flicker and LCD artifacts
  • OLED Burn-in Protection - Constant movement prevents static image retention

Hardware Requirements

Software Requirements

Arduino IDE Setup

  1. Install Arduino IDE (1.8.x or 2.x)

  2. Add ESP32 Board Support:

    • File → Preferences → Additional Board Manager URLs
    • Add: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
    • Tools → Board → Boards Manager → Search "ESP32" → Install
  3. Install Required Libraries (via Library Manager):

    • M5Unified by M5Stack
    • M5UnitGLASS2 by M5Stack
    • Adafruit NeoPixel by Adafruit
  4. Board Settings:

    • Board: "ESP32S3 Dev Module"
    • USB CDC On Boot: "Enabled"
    • Flash Size: "16MB (128Mb)"
    • Partition Scheme: "16M Flash (3MB APP/9.9MB FATFS)"

Installation

  1. Clone this repository:

    git clone https://github.com/KingDuane/Moonshot-M5GLASS.git
    cd Moonshot-M5GLASS
  2. Open Moonshot-M5GLASS.ino in Arduino IDE

  3. Connect your Cardputer via USB-C

  4. Select the correct COM port: Tools → Port → (your Cardputer port)

  5. Click Upload

Usage

Controls

  • G0 Button (top button on Cardputer) - Toggle sound on/off
  • Sound is enabled by default

Customization

Adjust Animation Speed

static const uint32_t FRAME_MS = 50;  // Lower = faster (milliseconds per frame)

Change Bounce Velocity

int glass_vx = 1, glass_vy = 1;  // GLASS2 velocity (pixels per frame)
int card_vx = 1, card_vy = 1;   // Cardputer velocity

Adjust Colors

// Cardputer logo color (RGB565)
createSpriteFromBitmap(spriteCard, LOGO_LARGE_W, LOGO_LARGE_H, getPixelLarge, 0x06FF);

// Options:
// 0x07FF - Pure bright cyan
// 0x06FF - Saturated cyan (default)
// 0x05FF - Rich teal-cyan
// 0x04FF - Dark teal

Modify Sound

M5.Speaker.setVolume(20);       // Volume: 0-255
M5.Speaker.tone(3000, 10);      // Frequency (Hz), Duration (ms)

// Sound options:
// tone(3000, 10)  - High tick (default)
// tone(1500, 30)  - Retro game blip
// tone(880, 100)  - DVD bounce sound
// tone(440, 80)   - Mellow boop

Adjust LED Brightness

led.setBrightness(50);  // LED brightness: 0-255

Technical Details

Display Configuration

  • GLASS2 OLED: 128×64 pixels, white on black, ROW-packed bitmap format
  • Cardputer LCD: 240×135 pixels, color display with backlight

Performance Optimizations

  • Sprite Pre-rendering: Logo bitmap converted to sprite once during setup
  • Double Buffering: Off-screen rendering eliminates flicker on OLED and artifacts on LCD
  • Hardware DMA Transfers: pushSprite() uses DMA for fast screen updates
  • Frame Rate: ~60 FPS capability, configured to 20 FPS (50ms) for chill vibe

Memory Usage

  • GLASS2 buffer: ~16KB (128×64×2 bytes)
  • Cardputer buffer: ~64KB (240×135×2 bytes)
  • Logo sprites: <1KB each

Development Journey

This project evolved through several iterations:

  1. Initial Bitmap Conversion - PNG → Arduino bitmap format
  2. Format Discovery - Found ROW-packed format works on M5 GLASS2
  3. Sprite Optimization - 10-20× performance boost with hardware acceleration
  4. Double Buffering - Eliminated OLED flicker and LCD artifacts
  5. Multi-sensory Feedback - Added LED flash and sound effects
  6. Color Tuning - Matched cyan across OLED, LCD, and RGB LED displays

Special thanks to Claude (Anthropic) for the development assistance!

Troubleshooting

GLASS2 Shows Scrambled Pixels

  • Ensure USE_PAGE_PACKED is set to 0 (ROW-packed format)
  • Verify GLASS2 is properly connected via Grove port

LED Not Flashing

  • Check GPIO21 is not used by other peripherals
  • Verify Adafruit_NeoPixel library is installed
  • Try different brightness: led.setBrightness(128);

No Sound

  • Press G0 button to enable sound
  • Check volume: M5.Speaker.setVolume(50);
  • Verify speaker is not muted in hardware

Compilation Errors

  • Update M5Unified to latest version
  • Ensure all required libraries are installed
  • Check ESP32 board package is up to date

License

MIT License - feel free to modify and share!

Contributing

Contributions welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests
  • Share your customizations

Made with ❤️ for the M5Stack community

About

A dual-screen bouncing logo screensaver for M5Stack Cardputer and GLASS2 display, featuring synchronized LED flash and sound effects.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages