|
|
@ -149,38 +149,6 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
-- Setup device
|
|
|
|
-- Setup device
|
|
|
|
local Device = require("device")
|
|
|
|
local Device = require("device")
|
|
|
|
-- DPI
|
|
|
|
|
|
|
|
local dpi_override = G_reader_settings:readSetting("screen_dpi")
|
|
|
|
|
|
|
|
if dpi_override ~= nil then
|
|
|
|
|
|
|
|
Device:setScreenDPI(dpi_override)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Night mode
|
|
|
|
|
|
|
|
local hw_nightmode = Device.screen:getHWNightmode()
|
|
|
|
|
|
|
|
if G_reader_settings:isTrue("night_mode") then
|
|
|
|
|
|
|
|
Device.screen:toggleNightMode()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Ensure the proper rotation on startup.
|
|
|
|
|
|
|
|
-- We default to the rotation KOReader closed with.
|
|
|
|
|
|
|
|
-- If the rotation is not locked it will be overridden by a book or the FM when opened.
|
|
|
|
|
|
|
|
local rotation_mode = G_reader_settings:readSetting("closed_rotation_mode")
|
|
|
|
|
|
|
|
if rotation_mode and rotation_mode ~= Device.screen:getRotationMode() then
|
|
|
|
|
|
|
|
Device.screen:setRotationMode(rotation_mode)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Dithering
|
|
|
|
|
|
|
|
if Device:hasEinkScreen() then
|
|
|
|
|
|
|
|
Device.screen:setupDithering()
|
|
|
|
|
|
|
|
if Device.screen.hw_dithering and G_reader_settings:isTrue("dev_no_hw_dither") then
|
|
|
|
|
|
|
|
Device.screen:toggleHWDithering(false)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if Device.screen.sw_dithering and G_reader_settings:isTrue("dev_no_sw_dither") then
|
|
|
|
|
|
|
|
Device.screen:toggleSWDithering(false)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- NOTE: If device can HW dither (i.e., after setupDithering(), hw_dithering is true, but sw_dithering is false),
|
|
|
|
|
|
|
|
-- but HW dither is explicitly disabled, and SW dither enabled, don't leave SW dither disabled (i.e., re-enable sw_dithering)!
|
|
|
|
|
|
|
|
if Device:canHWDither() and G_reader_settings:isTrue("dev_no_hw_dither") and G_reader_settings:nilOrFalse("dev_no_sw_dither") then
|
|
|
|
|
|
|
|
Device.screen:toggleSWDithering(true)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Document renderers canvas
|
|
|
|
-- Document renderers canvas
|
|
|
|
local CanvasContext = require("document/canvascontext")
|
|
|
|
local CanvasContext = require("document/canvascontext")
|
|
|
@ -324,19 +292,12 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
-- Exit
|
|
|
|
-- Exit
|
|
|
|
local function exitReader()
|
|
|
|
local function exitReader()
|
|
|
|
-- Save any device settings before closing G_reader_settings
|
|
|
|
|
|
|
|
Device:saveSettings()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Save current rotation (or the original rotation if ScreenSaver temporarily modified it) to remember it for next startup
|
|
|
|
|
|
|
|
G_reader_settings:saveSetting("closed_rotation_mode", Device.orig_rotation_mode or Device.screen:getRotationMode())
|
|
|
|
|
|
|
|
G_reader_settings:close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Restore initial inversion state
|
|
|
|
|
|
|
|
Device.screen:setHWNightmode(hw_nightmode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Shutdown hardware abstraction
|
|
|
|
-- Shutdown hardware abstraction
|
|
|
|
Device:exit()
|
|
|
|
Device:exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Flush settings to disk
|
|
|
|
|
|
|
|
G_reader_settings:close()
|
|
|
|
|
|
|
|
|
|
|
|
if Profiler then Profiler.stop() end
|
|
|
|
if Profiler then Profiler.stop() end
|
|
|
|
|
|
|
|
|
|
|
|
if type(exit_code) == "number" then
|
|
|
|
if type(exit_code) == "number" then
|
|
|
|