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

Android: Gestures for Warmth makes it zero #8070

Closed
mergen3107 opened this issue Aug 13, 2021 · 20 comments · Fixed by #8104
Closed

Android: Gestures for Warmth makes it zero #8070

mergen3107 opened this issue Aug 13, 2021 · 20 comments · Fixed by #8104

Comments

@mergen3107
Copy link
Contributor

  • KOReader version: test apk (because current stable doesn't have my device properly included yet)
  • Device: Onyx Boox Kon-Tiki 2 (Android 10, rooted)

Issue

In the test apk, which uses Onyx driver for e-ink screen, if I control Brightness and Warmth from the Top Menu - Frontlight, everything works as intended. pidcat also reports proper values from 0 to 255 for both.

However, if I use default Gestures "swipe up/down along the right edge", Warmth is immediately set to zero. This is also confirmed by pidcat. Brightness is fine though.

I tried to manually set other increments for gesture than default, like 1, 2 - does not matter.

@NiLuJe NiLuJe added the Android label Aug 13, 2021
@pazos
Copy link
Member

pazos commented Aug 13, 2021

Pinging @Galunid

@pazos pazos added the firmware label Aug 13, 2021
@Galunid
Copy link
Member

Galunid commented Aug 14, 2021

I'll see what I can do, but no promises, since it's not really fault with my lights controller (I run into this when I was making it, and gestures/frontlight code passed "0" as a value to set). I looked into this back then, but nothing jumped out

@pazos
Copy link
Member

pazos commented Aug 16, 2021

I'll see what I can do, but no promises, since it's not really fault with my lights controller

I wasn't implying that. Just pinged you since I thought you would be able to reproduce on your device.

Also pinging @zwim to know if he can reproduce on a Tolino. I guess he won't as the first driver for custom lights controller was written by him for its own device and he's very nit-picker about these kind of features 😄

Maybe makes sense to have a fakeController enabled on the android x86 emulator to be able to test integration with the frontend?. Otherwise I won't be able to test the behaviour.

@zwim
Copy link
Contributor

zwim commented Aug 16, 2021

On my Tolinos the right swipe works as expected.

@Galunid
Copy link
Member

Galunid commented Aug 17, 2021

diff --git a/frontend/device/android/powerd.lua b/frontend/device/android/powerd.lua
index 475636aa..fd368595 100644
--- a/frontend/device/android/powerd.lua
+++ b/frontend/device/android/powerd.lua
@@ -1,3 +1,4 @@
+local logger = require("logger")
 local BasePowerD = require("device/generic/powerd")
 local _, android = pcall(require, "android")
 
@@ -48,7 +49,7 @@ end
 
 function AndroidPowerD:setWarmth(warmth)
     self.fl_warmth = warmth
-    android.setScreenWarmth(warmth / self.warm_diff)
+    android.setScreenWarmth(warmth * self.warm_diff / 100)
 end

Works as expected, and I believe it makes sense. I'm a bit lost why it used to work on tolino though, so I'll investigate a bit more to not break it there ^^

@mergen3107
Copy link
Contributor Author

@Galunid
Thank you for your time!
I tested this patch. It reports correct values 0-255 this time around, however, the actual brightness is at 0 anyway.
Maybe I should double check something else? Looks like something is different on my platform.

@Galunid
Copy link
Member

Galunid commented Aug 17, 2021

@mergen3107 Can you try this file? Remove whatever version you have installed first

@mergen3107
Copy link
Contributor Author

@Galunid
Thank you for the file!
Results are following:

  1. e-ink driver was not recognized at all
  2. left-edge swipes do not change Brightness and show values 0-100, whereas pidcat correspondingly shows 0-255.
  3. right-edge swipes do nothing. Upon further look, Warmth is not even listed among gestures. I think this is because (1).

@mergen3107
Copy link
Contributor Author

I think this is because 2021.05 didn't have Kon-Tiki 2 added to the list of devices, which happened in this commit: 2222f25

@Galunid
Copy link
Member

Galunid commented Aug 18, 2021

@mergen3107 Sorry about that, try this one. For the record, I added the device config, but forgot to set it to use the onyx light controller in place of the default one. This one should run the latest master and android-luajit. It also added some logging and rounding to int, which may help with light not being applied. Let me know if it does the trick. Remove any previous version, before installing this. Thanks for your time trying those.

@mergen3107
Copy link
Contributor Author

@Galunid
Thank you very much!
I can confirm that everything now works as expected!
The driver was detected and Brightness and Warmth both change on their respective edges.

P.S. I don't know whether this is intended or not, but both Brightness and Warmth in KOReader have absolutely no connection to System Brightness and Warmth. I did this:

  • Before opening newly reinstalled KOReader, setup System lights to some levels.
  • entered KOReader and started to adjust them with edge gestures
  • both started initially from 0, however the actual controls worked.
  • KOReader remembers it own values for lights. So if I then toggle System brightness with Onyx Glowlight control - the light leves will be set to System ones (which are different). If I use KOReader's gestures again, it will override to what was in KOReader again. So at least it is consistent with itself.

This is not an issue per se, but it jumped out on me because AFAIK in Kindle the system brightness was in sync with KOReader's brightness.

@mergen3107
Copy link
Contributor Author

Also, the gesture "Toggle Frontlight" toggles only KOReader's Brightness, while Warmth stays the same. Shouldn't it toggle both at the same time?

@pazos
Copy link
Member

pazos commented Aug 18, 2021

I don't know whether this is intended or not, but both Brightness and Warmth in KOReader have absolutely no connection to System Brightness and Warmth.

Is not intended but not our bug. We read and write directly from/to sysfs nodes. If your vendor provides a broken environment and some of the most hacked android roms is not something easily fixable, at least for us.

OTOH android devices with the generic controller should work this way: in app brightness is an override of system brightness that only applies to the app when it is on the foreground. Restarting the app should pick the (updated or not) values of the system. That's the intended behaviour that will apply to 99'999999999% of android devices. Devices outside the norm have no intended behaviour so we can consider ourselves lucky if basic brightness/warmth controls work fine in-app 😄

Also, the gesture "Toggle Frontlight" toggles only KOReader's Brightness, while Warmth stays the same. Shouldn't it toggle both at the same time?

That was an undocumented behaviour based on how most devices work: on a kobo/cervantes et al is not possible to turn off the frontlight without turning off warmth lights. If that's not the case on your device you need to fix it your specific device implementation.

If that's not the case on your device you need to fix it your specific device

This sentence also applies to any setting that works fine on a sane device (kobo/cervantes or compliant android device) but not on hacked up AOSP devices. Patches welcome but won't fix by default :)

@mergen3107
Copy link
Contributor Author

@pazos Thank you for details :)

@Frenzie Frenzie added this to the 2021.08 milestone Aug 19, 2021
@hius07
Copy link
Member

hius07 commented Aug 19, 2021

@mergen3107, can you turn on flash_ui and press Auto checkbutton in the frontlight dialog.
I doubt if its width is okay after Checkbutton multilines PR (I have no device with warmlight to check).

max_width = math.floor(self.screen_width * 0.3),

@mergen3107
Copy link
Contributor Author

mergen3107 commented Aug 20, 2021

@hius07
It looks like I don't have Auto checkbox in the front light dialog.
flash_ui is the Top Menu - Gear - Screen - E-ink settings - Flash buttons and menu items, right?

@hius07
Copy link
Member

hius07 commented Aug 20, 2021

Yes, flash_ui it is.
Okay, thanks, waitng for somebody to complain about incorrect width of the Auto button.

@mergen3107
Copy link
Contributor Author

If your vendor provides a broken environment and some of the most hacked android roms is not something easily fixable, at least for us.

I found Onyx SDK that has Frontlight Controller example:
https://github.com/onyx-intl/OnyxAndroidDemo/blob/master/app/src/main/java/com/onyx/android/demo/FrontLightDemoActivity.java

Can this help to make a better controller?

@pazos
Copy link
Member

pazos commented Aug 22, 2021

If your vendor provides a broken environment and some of the most hacked android roms is not something easily fixable, at least for us.

I found Onyx SDK that has Frontlight Controller example:
https://github.com/onyx-intl/OnyxAndroidDemo/blob/master/app/src/main/java/com/onyx/android/demo/FrontLightDemoActivity.java

Can this help to make a better controller?

Nope

@mergen3107
Copy link
Contributor Author

OK :(

Thank you!

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

Successfully merging a pull request may close this issue.

7 participants