From 603dd3bd054bc6902a42a778b204e6e862879fb0 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 17:22:36 +0200 Subject: [PATCH 1/9] Some Kidle refresh mode experiments... Emulate (as best we can) the refresh behavior of the Kindle Touch reader --- frontend/ui/uimanager.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 81079bbe2..a7381c9a1 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -353,6 +353,19 @@ function UIManager:run() elseif force_full_refresh or self.refresh_count == self.FULL_REFRESH_COUNT - 1 then refresh_type = 1 end + -- Emulate the Kindle behavior... + if Device:isKindle() then + -- NOTE: For ref, on a Touch (debugPaint is my new best friend): + -- UI: gc16_fast + -- Reader: When flash: if to/from img: gc16, else gc16_fast; when non-flash: auto (seems to prefer gl16_fast); Waiting for marker only on flash + if refresh_type == 1 then + -- We don't really have an easy way to know if we're refreshing the UI, or a page, or if said page contains an image, so go with the best q. + waveform_mode = WAVEFORM_MODE_GC16 + else + -- We spend much more time in the reader than the UI, and our UI isn't very graphic anyway, so go with the reader behavior + waveform_mode = WAVEFORM_MODE_GL16_FAST + end + end if force_fast_refresh then waveform_mode = self.fast_waveform_mode end From 64566e0f3a57b3660336f21320ba39cf8465f9fb Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:02:58 +0200 Subject: [PATCH 2/9] Try to use reagl on the PW2... That doesn't seem to work as nicely as the stock reader... :/ --- frontend/ui/uimanager.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index a7381c9a1..316307a9d 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -19,6 +19,9 @@ local WAVEFORM_MODE_GC16_FAST = 0x3 -- Medium fidelity local WAVEFORM_MODE_A2 = 0x4 -- Faster but even lower fidelity local WAVEFORM_MODE_GL16 = 0x5 -- High fidelity from white transition local WAVEFORM_MODE_GL16_FAST = 0x6 -- Medium fidelity from white transition +local WAVEFORM_MODE_DU4 = 0x7 -- Medium fidelity 4 level of gray direct update +local WAVEFORM_MODE_REAGL = 0x8 -- Ghost compensation waveform +local WAVEFORM_MODE_REAGLD = 0x9 -- Ghost compensation waveform with dithering local WAVEFORM_MODE_AUTO = 0x101 -- there is only one instance of this @@ -358,12 +361,18 @@ function UIManager:run() -- NOTE: For ref, on a Touch (debugPaint is my new best friend): -- UI: gc16_fast -- Reader: When flash: if to/from img: gc16, else gc16_fast; when non-flash: auto (seems to prefer gl16_fast); Waiting for marker only on flash + -- On a PW2: + -- Same as Touch, except reader uses reagl on non-flash, non-flash lasts longer; Always waits for marker if refresh_type == 1 then -- We don't really have an easy way to know if we're refreshing the UI, or a page, or if said page contains an image, so go with the best q. waveform_mode = WAVEFORM_MODE_GC16 else -- We spend much more time in the reader than the UI, and our UI isn't very graphic anyway, so go with the reader behavior - waveform_mode = WAVEFORM_MODE_GL16_FAST + if Device:getModel() == "KindlePaperWhite2" then + waveform_mode = WAVEFORM_MODE_REAGL + else + waveform_mode = WAVEFORM_MODE_GL16_FAST + end end end if force_fast_refresh then From 25a4fc01eacbfd83749ed6e42255d93acf7eb57b Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 18:43:50 +0200 Subject: [PATCH 3/9] Clear up some comments... --- frontend/ui/uimanager.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 316307a9d..c7dd68c74 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -19,9 +19,12 @@ local WAVEFORM_MODE_GC16_FAST = 0x3 -- Medium fidelity local WAVEFORM_MODE_A2 = 0x4 -- Faster but even lower fidelity local WAVEFORM_MODE_GL16 = 0x5 -- High fidelity from white transition local WAVEFORM_MODE_GL16_FAST = 0x6 -- Medium fidelity from white transition +-- Kindle FW >= 5.3 local WAVEFORM_MODE_DU4 = 0x7 -- Medium fidelity 4 level of gray direct update +-- Kindle PW2 local WAVEFORM_MODE_REAGL = 0x8 -- Ghost compensation waveform local WAVEFORM_MODE_REAGLD = 0x9 -- Ghost compensation waveform with dithering + local WAVEFORM_MODE_AUTO = 0x101 -- there is only one instance of this @@ -362,7 +365,7 @@ function UIManager:run() -- UI: gc16_fast -- Reader: When flash: if to/from img: gc16, else gc16_fast; when non-flash: auto (seems to prefer gl16_fast); Waiting for marker only on flash -- On a PW2: - -- Same as Touch, except reader uses reagl on non-flash, non-flash lasts longer; Always waits for marker + -- Same as Touch, except reader uses reagl on non-flash, non-flash lasts longer (12 pgs); Always waits for marker if refresh_type == 1 then -- We don't really have an easy way to know if we're refreshing the UI, or a page, or if said page contains an image, so go with the best q. waveform_mode = WAVEFORM_MODE_GC16 From 806c2ffc00f1b034303d6ffecbcb77ba0a47d103 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 6 Jul 2014 21:38:13 +0200 Subject: [PATCH 4/9] Another hugely important commit! --- frontend/ui/uimanager.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index c7dd68c74..7cbe2de32 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -38,9 +38,9 @@ local UIManager = { -- force to do full refresh, will be reset to false -- after each ui loop full_refresh = false, - -- force to do patial refresh, will be reset to false + -- force to do partial refresh, will be reset to false -- after each ui loop - patial_refresh = false, + partial_refresh = false, -- trigger a full refresh when counter reaches FULL_REFRESH_COUNT FULL_REFRESH_COUNT = DRCOUNTMAX, refresh_count = 0, @@ -311,7 +311,7 @@ function UIManager:run() local dirty = false local request_full_refresh = false local force_full_refresh = false - local force_patial_refresh = false + local force_partial_refresh = false local force_fast_refresh = false for _, widget in ipairs(self._window_stack) do if self.repaint_all or self._dirty[widget.widget] then @@ -325,7 +325,7 @@ function UIManager:run() force_full_refresh = true end if self._dirty[widget.widget] == "partial" then - force_patial_refresh = true + force_partial_refresh = true end if self._dirty[widget.widget] == "fast" then force_fast_refresh = true @@ -342,19 +342,19 @@ function UIManager:run() force_full_refresh = true end - if self.patial_refresh then + if self.partial_refresh then dirty = true - force_patial_refresh = true + force_partial_refresh = true end self.repaint_all = false self.full_refresh = false - self.patial_refresh = false + self.partial_refresh = false local refresh_type = self.default_refresh_type local waveform_mode = self.default_waveform_mode if dirty then - if force_patial_refresh or force_fast_refresh then + if force_partial_refresh or force_fast_refresh then refresh_type = 0 elseif force_full_refresh or self.refresh_count == self.FULL_REFRESH_COUNT - 1 then refresh_type = 1 @@ -392,7 +392,7 @@ function UIManager:run() end if self.refresh_type == 1 then self.refresh_count = 0 - elseif not force_patial_refresh and not force_full_refresh then + elseif not force_partial_refresh and not force_full_refresh then self.refresh_count = (self.refresh_count + 1)%self.FULL_REFRESH_COUNT end self.update_region_func = nil From 19295cc0275738a0afce34b4df3cece4b39737d3 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 00:11:45 +0200 Subject: [PATCH 5/9] One more comment... --- frontend/ui/uimanager.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 7cbe2de32..294c29a66 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -375,6 +375,8 @@ function UIManager:run() waveform_mode = WAVEFORM_MODE_REAGL else waveform_mode = WAVEFORM_MODE_GL16_FAST + -- NOTE: Or we could go back to what KOReader did before fa55acc in koreader-base, which was also use WAVEFORM_MODE_AUTO ;). I have *no* idea how the driver makes its choice though... + --waveform_mode = WAVEFORM_MODE_AUTO end end end From 9e6dd11b0e3aa943827d5a7351b67b903cc1c889 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 00:12:37 +0200 Subject: [PATCH 6/9] Keystrokes aren't that cheap. --- frontend/ui/uimanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 294c29a66..f9ec13a0d 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -367,7 +367,7 @@ function UIManager:run() -- On a PW2: -- Same as Touch, except reader uses reagl on non-flash, non-flash lasts longer (12 pgs); Always waits for marker if refresh_type == 1 then - -- We don't really have an easy way to know if we're refreshing the UI, or a page, or if said page contains an image, so go with the best q. + -- We don't really have an easy way to know if we're refreshing the UI, or a page, or if said page contains an image, so go with the highest fidelity option waveform_mode = WAVEFORM_MODE_GC16 else -- We spend much more time in the reader than the UI, and our UI isn't very graphic anyway, so go with the reader behavior From eed4e3b9ff63c98d97f2bf24196f4ef676bd7f17 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 02:24:57 +0200 Subject: [PATCH 7/9] Update koreader-base. For the backend changes related to #704 --- koreader-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koreader-base b/koreader-base index a6bdb7cd7..2ba492e57 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit a6bdb7cd75fa58d5073b522aa4d8de7a3273c68b +Subproject commit 2ba492e57d7ae1924f4de9c94b65f70b982ff527 From a6ff78e5d8503e5a2f18d220aa8b532f71693f04 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 04:50:16 +0200 Subject: [PATCH 8/9] Fix the battery checks. I have *no* idea how that even seemed to work, but in fact didn't. Also no idea where the hell is the battery status supposed to appear in the menu, because it's currently not there. --- frontend/ui/device/basepowerd.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/ui/device/basepowerd.lua b/frontend/ui/device/basepowerd.lua index af36cbdf6..34ca6c5f3 100644 --- a/frontend/ui/device/basepowerd.lua +++ b/frontend/ui/device/basepowerd.lua @@ -4,7 +4,7 @@ local BasePowerD = { flIntensity = nil, -- frontlight intensity battCapacity = nil, -- battery capacity model = nil, -- device model - + capacity_pulled_count = 0, capacity_cached_count = 10, } @@ -49,11 +49,11 @@ end function BasePowerD:getCapacity() - if capacity_pulled_count == capacity_cached_count then - capacity_pulled_count = 0 + if self.capacity_pulled_count == self.capacity_cached_count then + self.capacity_pulled_count = 0 return self:getCapacityHW() else - capacity_pulled_count = capacity_pulled_count + 1 + self.capacity_pulled_count = self.capacity_pulled_count + 1 return self.battCapacity or self:getCapacityHW() end end From d45efd81d806601866adc23b9c2497c5604e69d5 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 7 Jul 2014 05:37:16 +0200 Subject: [PATCH 9/9] Add a battery indicator to the menu. Very quick'n dirty hack, doesn't seem to blow up horribly. re: #679 --- frontend/ui/widget/touchmenu.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index fa109e956..bd6a52ce2 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -7,6 +7,7 @@ local Font = require("ui/font") local TextWidget = require("ui/widget/textwidget") local LineWidget = require("ui/widget/linewidget") local Screen = require("ui/screen") +local Device = require("ui/device") local GestureRange = require("ui/gesturerange") local HorizontalGroup = require("ui/widget/horizontalgroup") local VerticalGroup = require("ui/widget/verticalgroup") @@ -428,7 +429,7 @@ function TouchMenu:updateItems() self.page_info_right_chev:showHide(self.page_num > 1) self.page_info_left_chev:enableDisable(self.page > 1) self.page_info_right_chev:enableDisable(self.page < self.page_num) - self.time_info.text = os.date("%H:%M") + self.time_info.text = os.date("%H:%M").." @ "..Device:getPowerDevice():getCapacity().."%" -- FIXME: this is a dirty hack to clear previous menus -- refert to issue #664 UIManager.repaint_all = true