displaylight_rs
This Rust workspace is a rewrite of my DisplayLight project. It colors leds mounted behind the monitor with the colors shown on the display at that location, this is known as bias lighting, sometimes refered to as Ambilight
.
Steps are still the same as in the original project:
- Screen capture takes a snapshot of the screen and keeps it in shared memory.
- Uses X11's shared memory extension Xshm on Linux.
- Uses the Desktop Duplication API on Windows (with help of windows-rs).
- Black border detection is performed to find the interesting region on the screen.
- Zones are created from this region of interest, each zone will map to one led.
- Zones are sampled, sampled colors averaged to determine zone value.
- Led string is updated with the obtained values.
Usage
Usage requires some hardware, most specifically a microcontroller running the firmware. If using something else, the lights crate will need some changing to ensure communication with the hardware is correct.
Running on either Windows and on Linux is a matter of cargo run --release
. Configuration lives in config and is selected based on the operating system. Performance is identical to the C++ version, running at ~3% of an i7-4770TE core when sampling a 1920x1080 image at 60 Hz.
The screen_capture crate used to obtain the screen captures is completely stand alone and could be used outside of this project.
License
License is MIT OR Apache-2.0
.