psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.57k stars 188 forks source link

Protocol modification to handle screen auto-brightness #478

Open diaconesq opened 3 years ago

diaconesq commented 3 years ago

I'm successfully running Prismatik for my monitor via an Arduino connected by USB. All working well, thanks for your efforts! :)

I'd like some guidance for an extra-feature I'd like to do.

I want to add a light sensor to the Arduino and use that to automatically increase/decrease the brightness of the screen (it's near a window, so needs high brightness when the sun hits, and low brightness at night or my eyes hurt).

Ideally I'd like to remove Prismatik completely from this equation, but since it keeps the USB-Serial port occupied, no other process can talk to the Arduino board directly (is there any way around this?).

I'm thinking of enhancing the serial protocol such that the microcontroller can also send data (ambient light level in this case). Prismatik could then do one of the following:

My question is: given the current capabilities of Prismatik, what's the easiest way to get this going with the minimal amount of changes to Prismatik itself?

FWIW: There are generic Windows APIs that work for setting the brightness of any screen produced in the last 15 years or so. See e.g. here: https://github.com/diaconesq/SyncMonitorBrightness/blob/master/PhysicalMonitorBrightnessController.cs

psieg commented 3 years ago

I guess the easiest thing is to add a command to the protocol to retrieve the brightness sensor value. Prismatik would then poll this and adjust its internal LED brightness and possibly the screen brightness accordingly. Not as nice as having the device push it but easier to do.

I don't know about multiple processes talking to the same serial device.

If you're going to mess with the protocol on the serial port, you already need to do changes in Prismatik - you might as well do the other changes inside Prismatik as well, I don't think exposing some IPC would be easier.

ScruffR commented 3 years ago

I want to add a light sensor to the Arduino

Since you already intend to have the Arduino take the brightness measurement, why not let the Arduino adjust the received data according to that reading? This way you'd need no change on the Prismatik side at all.

diaconesq commented 3 years ago

@ScruffR I don't want to change the brightness of the LED strips (or it's a secondary goal), but that of the actual screen.