koreader / android-luajit-launcher

Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
MIT License
131 stars 85 forks source link

add waveform constants to drivers #341

Closed pazos closed 2 years ago

pazos commented 2 years ago

Makes easier to handle outliers. Required for https://github.com/koreader/koreader/issues/4551#issuecomment-931370121.

Untested. Pinging @zwim and @Galunid. Does the app work fine with this PR in?


This change is Reviewable

zwim commented 2 years ago

Hmm: I get a strange crash:

I/KOReader(10200):  framebuffer resolution: {
I/KOReader(10200):     ["w"] = 1072,
I/KOReader(10200):     ["h"] = 1448,
I/KOReader(10200): }
E/NativeThread(10200): Failed to run script: [string "android.lua"]:2265: cannot convert 'string' to 'int'
V/NativeGlue(10200): Pause: 0x62cfc530

Maybe I did something wrong?

pazos commented 2 years ago

Nah, it is my bad. Could you try with

diff --git a/assets/android.lua b/assets/android.lua
index 0ddb542..487f3fd 100644
--- a/assets/android.lua
+++ b/assets/android.lua
@@ -2350,8 +2350,14 @@ local function run(android_app_state)
                 "getEinkConstants",
                 "()Ljava/lang/String;"
             )
-            return string.match(jni:to_string(constants),
-                "(.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*)")
+
+            local full, partial, full_ui, partial_ui, fast, delay, delay_ui, delay_fast = string.match(
+                jni:to_string(constants),
+                "(.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*)"
+            )
+            return tonumber(full), tonumber(partial), tonumber(full_ui), tonumber(partial_ui),
+                tonumber(fast), tonumber(delay), tonumber(delay_ui), tonumber(delay_fast)
+
         end)
     end

???

zwim commented 2 years ago

No crash now ;) I don't see any drawbacks on the first view.

Galunid commented 2 years ago

I didn't look at the code but it works on Onyx Nova 2 too.

NiLuJe commented 2 years ago

Looks much better to an outsider now ;).