-
Notifications
You must be signed in to change notification settings - Fork 85
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
added onyx note air 2 and onyx sdk light control #342
Conversation
Thanks for the patch. We cannot accept it because the minSdk bump. First try the controller used for other onyx devices. See koreader/koreader#8482 (comment). You'll need the last nightly to run the new test activity. If that doesn't work or works worse than this implementation you're welcome to submit a patch. Instead of using the sdk onyx provides you need to RE the calls used to get/set light levels and use these calls directly. |
I tried the tests in latest nightly before writing this up. The existing onyx controller does not work at all, unfortunately. I can override the minSDK change by setting I've never decompiled/reverse engineered on the android platform, so would like to avoid it if possible. |
Indeed. Please don't add the check within the controller class. Just wrap methods inside try-catch blocks. I would expect:
|
app/src/main/AndroidManifest.xml
Outdated
@@ -28,6 +28,7 @@ | |||
android:name=".MainApp" | |||
android:icon="@mipmap/icon" | |||
android:banner="@mipmap/banner" | |||
tools:replace="android:label,android:allowBackup" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to include the onyx-sdk as dependency at all. I already have it decompiled, so I can just look up the methods you need and we can use reflection to call them. That's what onyx-sdk does anyway. @bezmi Would that be acceptable for you? Also does the previous controller not work at all, or just not work in the way you want it? |
I've decompiled the SDK now as well (easier than I though) and they're just using reflection to call methods in The file locations are the same; |
I've removed the onyx sdk dependency and used reflection to call the api directly. The note air 2 falls under the |
@bezmi: could you add the new driver to https://github.com/koreader/android-luajit-launcher/blob/master/app/src/main/java/org/koreader/launcher/TestActivity.kt? |
app/src/main/AndroidManifest.xml
Outdated
@@ -34,7 +34,7 @@ | |||
android:usesCleartextTraffic="true" | |||
android:requestLegacyExternalStorage="true" | |||
android:supportsRtl="true" | |||
android:extractNativeLibs="true" > | |||
android:extractNativeLibs="true"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove. If you want to make style changes do it in a separate PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, this one just snuck in
@@ -50,13 +50,15 @@ object DeviceInfo { | |||
ONYX_C67, | |||
ONYX_KON_TIKI2, | |||
ONYX_NOVA2, | |||
ONYX_NOTEAIR2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: NOTE_AIR2
TOLINO | ||
} | ||
|
||
enum class LightsDevice { | ||
NONE, | ||
ONYX_C67, | ||
ONYX_NOVA2, | ||
ONYX_NOTEAIR2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^
nit: NOTE_AIR2
The new driver looks ok. It should be compatible with devices supported by our previous controller. If @Galunid wants to try and works for him we can have a single driver for all devices. If not we keep both and call it a day :) |
That's my thoughts as well. It should work, but I have some stuff to deal with. I'll test it in the evening/tomorrow, and if it's good, we'll get rid of the previous one. |
I tested it and it works on Nova 2, but it handles the brightness/warmth differently from what we do now. What I mean is that 100% brightness + 100% warmth sliders result in 100% warmth LEDs and none of the white ones. Reducing warmth (when brigntness is 100%) increases whiteness. This may work in unexpected ways with Autowarmth plugin. Personally I'm not a huge fan of the new behavior, because it's different from every other warmth device. I'd rather make it behave like the old one, but working on Note Air 2 too. |
@pazos I'll make all of the requested changes and add to @Galunid I personally don't like the brightness=cold/white and warmth=warm LED approach. Instead of manual mixing of two colours, it makes more sense for brightness to be related to the combined illuminance and warmth to be related to the colour temperature. Use of the autowarmth plugin is what drove me to write this as I wanted to change colour temperature without perceptual variation in brightness. Is the current default behaviour specific to onyx, or do the other e-reader devices also behave the same way? Nevertheless, I'm happy revert to the default brightness behaviour for this pull request and remove the |
It is the same behaviour on all devices in all platforms :) frontlight controls white leds. "natural light" controls orange leds (rgb leds in a few devices).
That would be awesome :)
It is doable but requires a few tweaks here and there. Currently epd and lights are hardcoded based on device properties. We need to add stuff to ignore detected drivers and let the users to push their own. It is actually useful to have it implemented but needs a few hours of free time. All starts here: Which leads to https://github.com/koreader/android-luajit-launcher/blob/master/app/src/main/java/org/koreader/launcher/device/Device.kt#L8-L9 All of this starts before we run the LuaJIT vm so there's no way to change that as-is. We might need to declare both drivers mutable and add setters for them. The EPD driver is a bit more tricky since there're a few constants that we retrieve once: https://github.com/koreader/koreader-base/blob/master/ffi/framebuffer_android.lua#L15 and those constants are tied to a specific driver. The lights driver should be way easier because it is self-contained. I would like to help you with the implementation as a mid-term task. I'm very busy and my to-do list keeps growing :/ |
I was thinking more along the lines of adjusting the functionality of The user will toggle a setting which will convert the behaviour from mixing of cold/warm LEDs to brightness=combined brightness of both LEDs and warmth=requested colour temperature. This will run an extra step in powerd.lua that changes the requested total brightness + colour temperature into the expected cold/warm values for the device driver. It will require some device specific information, such as the light output and colour temperature of the warm and cold LEDs for the math to ensure that brightness remains perceptually uniform as colour temperature is altered. Users should be able to tweak these values to get it just right for their device. Currently, the light output and colour temperatures are pretty much hard coded in the driver I wrote. The values work okay for the Note Air 2, but probably won't be perfect for other devices unless Onyx keeps their choice of warm/cold LEDs identical over the product lines. Do you think the approach I've outlined above is do-able? P.s. happy to be pinged whenever testing is required for my device. |
if But check first if it behaves as you expected. Actions, gestures and plugins use There's no easy way to fix that without: a) reverting back to the good-old frontlight widget, used on the rest of platforms, while keeping android's device abstraction in place. or b) writting your custom driver as part of this repo and enable it on runtime based on a flag Keep in mind device abstraction is a PITA and time is limited. |
|
Great, thanks! I haven't tested it yet, but I will do it later today. Could you try to fix the Codacy Static Code Analysis issues? Those are just styling changes. |
No problem, took me a couple of goes, but that's what squashing is for :). I'm not sure about the current naming, if you guys remove the old OnyxWarmthController then I guess this can take over the name.
@pazos, I was able to get this working with the alternative brightness implementation after some trivial changes. However, I don't think it's a change that anyone would enjoy. I certainly prefer the style of the native dialog. I think I'll put a pin in it for now and keep a patch for myself with the other (better!) driver. Don't really see anyone else complaining about the warmth implementation on these devices anyway. |
} | ||
|
||
object FrontLight { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant new line
|
||
object FrontLight { | ||
|
||
private val fLController = forName("android.onyx.hardware.DeviceController") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer flController
, since afaik we use Frontlight
, not FrontLight
I tested it and it works on Nova 2! Feel free to nuke the old one and replace it with this one. Not sure if @pazos has any comments, but it looks ready to merge, after fixing those nits I mentioned in the review. |
Apologies for the multiple commits, I missed a few changes when removing the OnyxSDMController references. OnyxWarmthController has been updated with the new driver code. |
@Galunid: please merge when ready. Looks quite good :) |
@Frenzie Please give me permission to merge ^_^ I'll build and test it in a few hours code is looking alright |
@bezmi: this PR got reverted because koreader/koreader#8584. Feel free to submit the PR again with the following changes:
sorry for the inconvenience |
* revert koreader/android-luajit-launcher#342 * store apks in private dir and remove them after update
I'm happy to rename it back to the old |
I've adapted code found at calin-darie/gentle-glow-onyx to create a
LightsInterface
using the onyx SDK. I've tested and confirmed that it is working for my Boox Note Air 2.The interface adapts (more intuitive) brightness/warmth values to the warm/cold values that onyx uses, whilst maintaining perceptually uniform brightness across the entire range. A caveat of this is that maximum brightness is limited.
I've also added the Note Air 2 to the
EPDFactory
as I have confirmed that full refresh works using theOnyxEPDController
.Had to bump
minSDK
to 19 for compatibility with the Onyx SDK packages.This change is