Last post, I wrote about creating “Drive Lights” on Linux using GPIO pins on a Raspberry Pi. It was a fun project that used the kernel’s fanotify API to monitor disk activity and flash physical LEDs. But what if you’re on Windows? Or what if you’re using a modern desktop without native GPIO pins? Today, I’m excited to share a major update to the Drive_Lights project. It’s now cross-platform, supports USB GPIO hardware, and uses modern Python tooling! What’s New?1. Windows Support (ReadDirectoryChangesW)The biggest addition is a full Windows port (mainw.py). While Linux uses fanotify at the kernel level, Windows provides the ReadDirectoryChangesW API. I’ve implemented a recursive monitoring loop that captures file creations, deletions, renames, and modifications across an entire drive or directory. 2. USB GPIO Hardware (MCP2221A)You no longer need a Raspberry Pi to see your drive lights! By using a simple USB-to-GPIO adapter like the MCP2221A or FT232H, you can add physical LEDs to any Windows or Linux desktop. The project now supports Adafruit Blinka, which allows gpiozero and other libraries to talk to USB GPIO hardware as if it were a native Pi. 3. Modern Dependency Management with uvI’ve migrated the project to uv. This means you can get up and running with a single command: bash uv sync No more manual pip install or broken virtual environments! Technical Deep Dive: Fanotify vs. ReadDirectoryChangesWOne of the most interesting parts of this update was comparing how different operating systems handle file events:
Hardware SetupThe hardware remains simple. You just need two LEDs (one for Read, one for Write) and two resistors (around 220-330 ohms). If you’re using a Raspberry Pi, connect them to GPIO 20 and 21. If you’re using the MCP2221A, you can map the pins in the .env file: READ_LED=20WRITE_LED=21I’ve included updated Fritzing diagrams (Sketch.fzz) and schematics in the repository to help with the wiring. Get the CodeThe full project, including both the Linux and Windows scripts, is available on the GitHub repository. Check out the README.md for detailed installation instructions and the OVERVIEW.md for a deeper look at the code structure. Happy monitoring! |
From Heathkit vacuum tubes to first-gen Arduino LEDs, electronics has been my lifelong passion. Though not my profession, I've journeyed from analog circuits to microcontrollers, hacking Arduinos since they appeared. This blog shares that journey—the successes and struggles. If you're a fellow hobbyist, a curious beginner, or just love to tinker, you're in the right place. Welcome!
Sunday, April 19, 2026
Creating Drive Lights: Now for Linux and Windows!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment