Flashlight V1.1 is a highly optimized, state-machine-based illumination utility for the M5Stack Cardputer ADV. It repurposes the device's TFT display and the built-in RGB LED as a synchronized multi-mode light source, featuring standard white light, tactical red light, and a high-frequency strobe.
Important
Source Code Status: This project is proprietary. The source code is private. Distribution: Binary only via M5Burner.
- Hardware RGB LED Sync: The built-in StampS3 WS2812 LED (GPIO 21) perfectly mirrors the screen state in real-time. It uses native ESP32 core functions (
neopixelWrite) to achieve instant color switching without relying on heavy third-party libraries. - Non-Blocking State Machine: The core architecture relies entirely on
millis()for timer management. Zerodelay()calls ensure instant responsiveness and prevent CPU blocking. - Custom Debounce & Click Detection Core: Features a custom-built event listener that accurately distinguishes between single clicks, double clicks, and prolonged holds using leading-edge and trailing-edge logic.
- Smart Color Memory: The system remembers your last active illumination mode (White or Red). Turning the flashlight off and on via a single click will restore the previous state.
- Deep Power Optimization: The ESP32-S3 CPU frequency is underclocked from the default 240MHz down to 80MHz during setup. This guarantees stable I2C/SPI bus operation for the keyboard and display while drastically reducing battery consumption and heat generation.
- Hardware-Level Display Control: When turned off, the firmware sets the TFT backlight brightness to
0and fills the VRAM withTFT_BLACKto completely halt power draw from the screen matrix.
- Open M5Burner.
- Search for
Flashlight ADVorZeloksa. - Select version V1.1.
- Burn to your M5Stack Cardputer ADV.
Interaction works by pressing ANY key on the Cardputer ADV's matrix keyboard.
- [ Single Click ]: Power Toggle. Turns the flashlight ON (restoring the last used color) or OFF.
- [ Double Click ]: Strobe Toggle. Instantly enters or exits a high-frequency (50ms interval) white/black flashing sequence. Exiting returns to the previous color state.
- [ Hold (>500ms) ]: Tactical Red Light Toggle. Switches between standard White Light and Red Light modes. Useful for preserving night vision.
| State | Brightness | Action |
|---|---|---|
STATE_WHITE |
255 | Solid TFT_WHITE fill. RGB LED set to White. |
STATE_RED |
255 | Solid TFT_RED fill for night vision preservation. RGB LED set to Red. |
STATE_STROBE |
255 | Alternating TFT_WHITE / TFT_BLACK every 50ms. RGB LED flashes in sync. |
STATE_OFF |
0 | Screen brightness killed, VRAM filled with TFT_BLACK. RGB LED turned off. |
If you find a bug or have a suggestion for the next version:
- Go to the [Issues] tab at the top of this page.
- Click [New Issue].
- Describe your problem or idea in detail.
If this tool has been useful for your EDC (Everyday Carry) or projects, consider supporting further development:
Created by Zeloksa. Optimized for Cardputer ADV.