mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Initial Kindle PW5 support (#8856)
* Rejig frontlight warmth API to more closely match the existing API, and, hopefully, clarify some of its quirks, and reduce boilerplate and duplicate code in platform implementations. * Tweak Kindle:setDateTime to prefer using the platform's custom script, as in interacts better with the stock UI. And make the fallbacks handle old busybox versions better. * Add Kindle PW5 support ;). * Add warmth support to the Kindle platform. * Random TextBoxWidget cleanups: make sure we immediately free destroyed instances. * FrontLightWidget: Refactor to make it slightly less obnoxious to grok and update; i.e., separate layout from update, and properly separate brightness from warmth handling. Move to simpler widgets instead of reinventing the wheel. * TextBoxWidgets: Implement `setText` to match TextWidget's API, as some callers may be using the two interchangeably (i.e., Button). * NaturalLightWidget: Make sure we pass a string to InputText * InputText: Add debug guards to catch bad callers not passing strings ;).
This commit is contained in:
@@ -53,6 +53,7 @@ dbg:guard(SysfsLight, 'setWarmth',
|
||||
"Wrong warmth value given!")
|
||||
end)
|
||||
|
||||
--- @note: warmth is already in the *native* scale!
|
||||
function SysfsLight:setNaturalBrightness(brightness, warmth)
|
||||
local set_brightness = true
|
||||
local set_warmth = true
|
||||
@@ -67,8 +68,6 @@ function SysfsLight:setNaturalBrightness(brightness, warmth)
|
||||
|
||||
-- Newer devices use a mixer instead of writting values per color.
|
||||
if self.frontlight_mixer then
|
||||
-- Honor the device's scale, which may not be [0...100] (e.g., it's [0...10] on the Forma) ;).
|
||||
warmth = math.floor(warmth / self.nl_max)
|
||||
if set_brightness then
|
||||
-- Prefer the ioctl, as it's much lower latency.
|
||||
if self.frontlight_ioctl then
|
||||
@@ -77,7 +76,7 @@ function SysfsLight:setNaturalBrightness(brightness, warmth)
|
||||
self:_write_value(self.frontlight_white, brightness)
|
||||
end
|
||||
end
|
||||
-- And it may be inverted... (cold is nl_max, warm is nl_min)
|
||||
-- The mixer might be using inverted values... (cold is nl_max, warm is nl_min)
|
||||
if set_warmth then
|
||||
if self.nl_inverted then
|
||||
self:_write_value(self.frontlight_mixer, self.nl_max - warmth)
|
||||
|
||||
Reference in New Issue
Block a user