Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add direct mode #6

Closed
wants to merge 1 commit into from

Conversation

cyrinux
Copy link

@cyrinux cyrinux commented Jul 30, 2023

Hi,

Thanks for the project.

This allow to switch to the wanted value without smooth transition when using the flag --direct

We need this specially when using wluma project then. To quick learning desired values.

Thanks !

@geekylthyosaur
Copy link
Owner

Wow, didn't think someone would ever need this feature, cool! Glad to see you find this project useful especially for wluma :).

To make this code better I would suggest using struct Flags instead of Mode::Direct.
Also, using r.max().unwrap() is double footgun because input.iter_with(r):

  1. returns either ascending or descending iterator, so it would be better to use last() instead of max().
  2. can return empty iterator when user wants to set current brightness so unwrap() should be handled.

Then duplicating of Device::set* is unnecessary when there is std::iter::once to create iterator from single element.

Thanks for contributing!

@maximbaz
Copy link
Contributor

We weren't sure if we aren't being blind while looking for how to set the value directly, it's good that you confirm this feature didn't exist until now 😅

@maximbaz maximbaz mentioned this pull request Jul 30, 2023
19 tasks
@cyrinux cyrinux closed this Jul 31, 2023
@cyrinux
Copy link
Author

cyrinux commented Jul 31, 2023

After chatting with @maximbaz we maybe don't need it. If needed, will re-open and rewrite in the good way with your recommendations. Thanks

@maximbaz
Copy link
Contributor

maximbaz commented Jul 31, 2023

To give you some context, wluma is trained by watching when brightness value is changed by a human, and using the new brightness value together with current environment (ambient light around you, current screen content) to remember a new user preference. Initially when we were testing, the transitions seemed to be quite slow (especially due to #8), which meant a lot of false training data points. With +5% (what we'd normally use in real life), the transition seems only 0.2s, which is almost indistinguishable from being instant, so we don't really need a whole new code path just to make it even faster.

My personal perception is still that starting from 0, +50% is quite slow, takes more than 2s, and I feel like it's worth experimenting if it could complete in half a second, would it still feel smooth and at the same time not so "laggy"?

There is still the case, if say I was in a dark room looking in a dark-themed text editor, my brightness would be at 60%, and then I switch to a browser to open a bright Google, I want to quickly reduce brightness to say 10% (so -50%) and let wluma remember as fast as possible the conditions, at which I reduced the brightness. If the transition takes too much time, the recorded conditions might already be wrong, resulting in a "bad" training data point (for example maybe I couldn't wait for these 2 seconds, and I intuitively switched back to dark text editor, while the transition was still ongoing...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants