Commit Graph

60 Commits (217a73f3c0be5832d2ccd289eb0f1d8528e3cd75)

Author SHA1 Message Date
NiLuJe 217a73f3c0
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 ;).
2 years ago
NiLuJe eb0c2bfc93 Kobo: Handle a few PowerCover quirks...
* The first few capacity reads after connecting to the cover may fail

* The PowerCover may trigger spurious move/add usb_plug uevent,
which translate into Charging events for us.
Instead of blindly lighting up the charging LED on those,
check if the device is actually charging, first.
2 years ago
NiLuJe dc98384177 PowerD: Add a framework to report the status of auxiliary batteries
Implement it on the Kobo Sage, for the PowerCover

TouchMenu: Display auxiliary battery status

Kobo: More accurately report the PowerCover's charging status

i.e., try to actually figure out if the auxiliary battery is charging
instead of just checking the reader's battery (because that one will
often swap between the charging and discharging state as it drains the
aux battery...).

PowerD: Use a cached timestamp when doing battery pull checks
2 years ago
zwim 0c7d174cd7
[frontlight, kobo, cervantes] Remove auto_warmth (#8154)
The feature is now provided by the "Auto warmth
and night mode" plugin (#8129).
3 years ago
zwim debf5dc550
Footer: add Warmth as footer item (#8060) 3 years ago
NiLuJe ae35e898fb
Kobo Elipsa support (#7986)
Includes a few minor cleanups along the way ;).
3 years ago
NiLuJe fba0b8eec7 Kobo: Refresh the system clock on resume.
Mimics Nickel's behavior, should fix #7092

Thanks to @gtalusan for the pointers ;).

Bump base

(https://github.com/koreader/koreader-base/pull/1322)
3 years ago
Rex Kerr 2510ff4847
Reversing commit 2348cd, changes to warmth values (#7296) 3 years ago
Rex Kerr 2348cdb066
Improved ramp-down of warm-light after max hour (#7272)
previously: warm light stays at 100% for 3 hours and then drops by 50% per hour
now: warm light stays at 100% for 4 hours and then drops by 15% per hour
3 years ago
NiLuJe dffe86dfe9
Cleanup eye-gouging madness around io.read calls (#7149)
* Don't reinvent the wheel when reading a one-line int or string from sysfs

* Simplify a whole other bunch of read calls
3 years ago
yparitcher 3e063498fc
FrontLight: fix footer update on FL on/off toggle (#6664)
move state change event to higher level function so it will be called after powerd.is_fl_on is updated.

makes _setIntensity redundant so get rid of it

obsoletes #6667
4 years ago
NiLuJe f1918cdfbb
[Kobo] Don't send a flood a FrontlightStateChanged events during the FL ramps (#6667)
* Only send a single FrontlightStateChanged event on toggle

Prevents the ReaderFooter refresh from going wonky
4 years ago
NiLuJe 99045b4311
Minor util & ffi/util cleanups (#6657) 4 years ago
poire-z 962fd02c98
Tame BackgroundRunner: stop running when no more job (#6605)
A BackgroundRunner plugin instance will stop running
(rescheduling a check every 2 seconds) when there is no
(or no more) job to run.
Clients of this service now have to emit an event after
adding a job into PluginShare.backgroundJobs, so an
already loaded but stopped BackgroundRunner can notice
it and start running again.
4 years ago
zwim 66e8087c66
[android]: fix backlight toggle (#6520)
* check on startup if frontlight can be changed.
* Init fl_min if necessary not to use intensity==0
4 years ago
NiLuJe 9f4ba77fab [Kobo] Always set the warmth on the KA1 (#5468)
It might be possible to instead only set the white led, but I don't
have the hardware to test that theory, se, eh.

Fix #5465 (probably.)
5 years ago
NiLuJe abc86323fc [Kobo/Cervantes] Always use setBrightness to set the brightness (#5429)
sysfs_light handles every case sanely already, no need to be cute ;).

This prevents always setting the warmth when setting the FL on NL
devices with a mixer, because, besides being useless, it's also slow
(lua does mmap'ed io, so every handle requires an fstat + mmap).

It was subtly affecting the fluidity of the toggle ramp, and much less
subtly wreaking havoc on #5373 ;).

KA1 owners might want to investigate keeping the fds around one way or
another, like we do for the fl ioctl, to alleviate the overhead of doing
that for not one but three or four fds...
I won't be doing that, since I lack the hardware to test it, and FL+NL
stuff is pain.

* Do the same on Cervantes

* Bump base to pickup related ioctl tweaks
5 years ago
NiLuJe e7cfc65780 [Kobo] Unbreak the FL ramp-up/down (#5421)
I got my wires crossed.

It's fast on Mk. 5, slow on Mk. 7.
So, slow it down on Mk. 5 so we actually get a ramp and not a jump.
5 years ago
NiLuJe 1c2c471c5f
[Kobo/Cervantes] Prefer using the ioctl over sysfs when setting the FL. (#5407)
* Prefer using the ioctl over sysfs when setting the FL.
It's much lower latency (re #5373).

We can do so on NL devices with a mixer.
5 years ago
Frans de Jonge 0dad707e2e
[fix, Kobo] Don't crash trying to sync frontlight with Nickel. (#5361)
When reasonably possible, the program should only crash in debug mode.

Adds a couple of extra unit tests to prevent regressions and adds docs.

Fixes <https://github.com/koreader/koreader/issues/5356>.
5 years ago
Frans de Jonge 1b17ce8ba0
[fix, Kobo] Save frontlight state on shutdown after suspend (#5305)
Fixes <https://github.com/koreader/koreader/issues/5292>.
5 years ago
Frans de Jonge a2dcfe9aec
[doc] Tag @todo, @fixme and @warning (#5244)
This commit standardizes the various todos around the code a bit in a manner recognized by LDoc.

Besides drawing more attention by being displayed in the developer docs, they're also extractable with LDoc on the command line:

```sh
ldoc --tags todo,fixme *.lua
```

However, whether that particular usage offers any advantage over other search tools is questionable at best.

* and some random beautification
5 years ago
NiLuJe 4ba7f984bf Sync powerd.fl brightness with powerd when toggling the FL (#4999)
Possibly helps with some more edge cases related to interaction with
autowarmth & the KA1...

re: #4925
5 years ago
NiLuJe d9ab5d2f43 Make sure the AutoWarmth feature will never try to turn the light back (#4953)
on if it's off.
Because, on the KA1, since wetting the warmth *has* to set the
brightness, it could ;).

Patch only actually needed on Kobo, as all Cervantes devices with warmth
support have a mixer, which mean they *can* set the warmth without
affecting the brightness ;).
5 years ago
NiLuJe 717db55566
Some more FL fixes when we start with the FL off (#4924)
* Don't override hw_intensity when we start with the FL off
* And add an insane workaround to make the first toggle behave sanely in this case.
* And also handle the sneakier case where the first toggle happening would not be manual, but triggered by a suspend/resume cycle.
5 years ago
NiLuJe 33946aa732
Some FL regression fixes after #4901 (#4921)
* Make hasNaturalLight* caps safe to call without a device check. (fix #4919)
Make it clear that it's expecting the NTX implementation, though.
* Don't turn the FL on on resume if it was off on suspend
* Make sure turnOn/turnOff actually updates hw_intensity in the process where it matters, instead of just in a short lived fork ;). (fix #4923)
5 years ago
NiLuJe f63ca005c6 [fix] Update AutoWarmth state on resume (#4901)
Regression since #4871
Fix #4895

* Hide the "Configure" button in the FL/NL widget on devices where it
won't do anything

(i.e., those w/ a NL mixer).
5 years ago
NiLuJe 4005bf69aa
Slightly less crappy Nightmode (#4871)
Companion PR to https://github.com/koreader/koreader-base/pull/884
* Basically flags devices known to be stable when using PxP inversion.
* Plus, random fix for #4870 ;).
* A few FrontLight tweaks & cleanups on Kobo:
  * Moved the Kobo-specific startup status insanity to Kobo-specific init
  * Made turnOff/turnOn frontlight do a smooth ramp down/up
  * On Kobo, use turnOff/turnOn for suspend/resume, to get that smooth toggle
  * On Kobo, for NaturalLight w/ a mixer, only set warmth for setWarmth, and only set Brightness for setBrightness, otherwise, it tried to set both with not in-sync values, which made the FL widget jittery.
5 years ago
NiLuJe f6743a45db
Proper Forma support (#4414)
* Enforce a known rotation on startup, to make sure we handle touch input coordinates properly.
* Proper FrontLight warmth support (thanks to @cairnsh & @pazos in #4291)!
* Fix the PageTurn buttons mapping to match Nickel's defaults
* Properly remap PageTurn buttons depending on the current rotation.
* Actually enable the Mk.7 screen refresh codepath on *all* Mk.7 devices (I'd messed up the device check...).
* Full accelerometer handling (includes a touch of refactoring regarding orientation handling in general).
* Fix insidiously broken USBMS behavior in Nickel after we exit on FW >4.8.

Fix #4291
Fix #3002
5 years ago
Martín Fernández 29835b3072 [chore] Refactor sysfs_light (#4283) 6 years ago
David Engster 7c527aa5dd [chg] kobo/powerd: Keep max. warmth 2h after bedtime (issue #3825)
Keep max. warmth for 2h after bedtime, and then start reducing for 2h,
so that 4h after bedtime we have reached zero warmth.
6 years ago
David Engster e80951413d [feat] kobo/powerd, kobo/nickel_conf: Saving of auto-warmth settings
Add support in nickel_conf to save/retrieve setting of
'autoColorEnabled', which is the automatic warmth feature in
Nickel. We do not support reading of 'BedTime', because it is encoded
as a QVariant. This setting is hence saved/loaded solely in/from
G_reader_settings.
6 years ago
David Engster 596e20e588 [feat] kobo/powerd: Support for automatic warmth
This is the first step to support "automatic warmth", meaning that
warmth will be set according to the current time. The user can set a
"bedtime" at which warmth should be maximal. Warmth will increase
towards approaching bedtime and decrease afterwards.

Add new members 'auto_warmth' and 'max_warmth_hour' which tell if this
feature is enabled and the "bedtime", resp. Add a method
'calculateAutoWarmth' which will set the current warmth according to
the current time. The progression is linear but not symmetrical: we
start 5h before "bedtime", but turn back warmth to '0' 2h after it, to
make sure that warmth is '0' in the morning.

For automatically setting warmth in the background we use the
backgroundrunner plugin, because not only is it more comfortable to
use, but we also cannot require 'uimanager' during device
initialization.
6 years ago
David Engster bfd55c76c2 device/kobo/powerd: Read natural light configuration
Define 'frontlight_settings' table for all Kobo devices, and read
configuration from settings file.
6 years ago
Frans de Jonge 68e63df442
[feat] Add H2O2 natural light (#3709)
See https://www.mobileread.com/forums/showpost.php?p=3664352&postcount=66
6 years ago
David Engster f77ce9bf7c kobo/powerd, kobo/nickel_conf: Support reading/setting natural light
Nickel stores the 'warmth' values as 'ColorSetting' in a linear
mapping from '1500' to '6400'.
6 years ago
David Engster 5c1f97eeb3 kobo/powerd: Use sysfs interface for natural light support
If the device has natural light support (currently only KA1), use the
sysfs interface instead of the ioctl-based one. It might also be
usable on other Kobo devices for setting brightness without natural
light, but since I cannot test this, this is currently restricted to
the KA1.
6 years ago
poire-z 0122c086f2 Fix crash on exit on Kobo devices with no frontlight (#3221) 7 years ago
poire-z d4fd0b9428 frontlight on kobo: a few fixes (#3163)
* frontlight on kobo: a few fixes

Rewritten to not update NickelConf on every change, and never
if KOBO_SYNC_BRIGHTNESS_WITH_NICKEL = false.
Reintroduce global settings frontlight_intensity and
is_frontlight_on to keep level and state across koreader
sessions.
Fix a few of the remaining issues on kobo light.
Ensure settings are saved when rebooting/powering off from
File browser.

* Ensure untoggle works when starting with light off
7 years ago
poire-z c6cfed92d7 Fix kobo fl_min and frontlightwidget (#3143)
* Put back fl_min=0 as it is for all other devices (the idea
fl_min should be 1 and toggling managed some other way is
not implemented in current code).
* Fix a few frontlightwidget issues
7 years ago
Hzj_jie a4d5165f7a Several fixes in frontlight logic (#2991)
* Use PluginShare to exchange data between plugins

* Remove legacy code in reader.lua and kobo/device.lua, and move KOBO_LIGHT_ON_START to kobo/powerd.lua

* A better sync config logic

* Consider kobo without hardware frontlight toggle

* update frontlight widget once toggle is tapped.
7 years ago
Hzj_jie c8be27481c Fix synchronizing issue of Kobo front light between KOReader and nickel (#2977) 7 years ago
Hzj_jie b5c77af15c Typo in last change. (BasePowerD -> KoboPowerD) 7 years ago
Hzj_jie 05769872c7 Allow Kobo to entirely turn off the front light. 7 years ago
Hzj_jie 63f2284f21 Fix several crash errors triggered by legacy code (#2962) 7 years ago
Hzj_jie 53eb4dee50 AutoFrontlight plugin (#2941)
* Add AutoFrontlight plugin

* Add configuration to control autofrontlight feature
7 years ago
Hzj_jie 0b29e73e2e BatteryStat plugin and instruction of KoboLight plugin (#2643)
* Start battery stat plugin

* BatteryStat & kobolight

* Several minor improvements

* Remove a useless function

* flush settings

* Some review feedbacks

* Resolve review comments

* Remaining Minutes -> Remaining Hours

* Add dump_file

* typo

* realpath

* realpath on folder

* Remove useless os.time()

* Resolve review comments

* warning

* Add BatteryStat.debugging flag

* treat log as txt

* Minor improvement

* Charging hour should be positive

* Use warn instead of info

* onSuspend in Kobo

* Charging events for kobo and kindle

* More events

* dumpOrLog

* Warnings

* Typo

* More space

* Singleton

* slightly format change

* BatteryStat singleton

* Init

* Remove debugging flag

* sleeping percentage is still negative

* Read settings

* Do not need to change was_suspending and was_charging

* Typo

* Remove debugging flag

* Not charging should happen before suspend

* Resolve review comments

* was_suspend and was_charging should be updated each time in onCallback()
7 years ago
Qingping Hou e812f7d0d6 kobo: fix typo during refactoring, luacheck is the best check 8 years ago
Qingping Hou cf70e86552 kobo: move reader setting outside of nicke_conf module 8 years ago
Qingping Hou 4751aba46c kobo: rewording, turns out has_toggle_btn != has_state_cfg :( 8 years ago