Skip to content

Zeloksa/Cardputer-Flashlight-ADV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Version Hardware Platform License Boosty

πŸ”¦ M5Stack Cardputer ADV Flashlight (V1.1)

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.


⚑ Technical Highlights

  • 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. Zero delay() 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 0 and fills the VRAM with TFT_BLACK to completely halt power draw from the screen matrix.

πŸ›  Installation

  1. Open M5Burner.
  2. Search for Flashlight ADV or Zeloksa.
  3. Select version V1.1.
  4. Burn to your M5Stack Cardputer ADV.

πŸ•Ή Controls & Usage

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.

βš™οΈ Core States Overview

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.

πŸ’¬ Feedback & Suggestions

If you find a bug or have a suggestion for the next version:

  1. Go to the [Issues] tab at the top of this page.
  2. Click [New Issue].
  3. Describe your problem or idea in detail.

β˜• Support the Project

If this tool has been useful for your EDC (Everyday Carry) or projects, consider supporting further development:


Created by Zeloksa. Optimized for Cardputer ADV.