Commit Graph

46 Commits (66e8087c66791e381feb59051a0f89660bd89628)

Author SHA1 Message Date
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
Qingping Hou 8b7658b8cd kobo: always keep intensity value and is_fl_on in sync 8 years ago
Qingping Hou 9afae91b13 chore: rename frontlight related variables to keep style consistent
flIntensity -> fl_intensity
flState -> is_fl_on
fallback_FrontLightLevel -> fallback_fl_level
8 years ago
NiLuJe f213fb6405 Bypass flState on suspend/wakeup
We pretty much always want to turn it off on suspend, and turn it on to
some measure on wakeup.

That, and nickel's FrontLightState is completely nonsensical on my device anyway...
8 years ago
NiLuJe 6c8bbfd470 Unbreak Kobo frontlight -> off when suspending.
If no-one touches anything, flState stays false...
And anyway, we should unconditionally disable the fl on sleep.
8 years ago
zijiehe a183c1c64b Slightly refector device & powerd component, remove some magic code 8 years ago
zijiehe e84093c414 Add a flState in Kobo, and KoboPowerD:toggleFrontlight uses flState to control the light instead of intensity. 8 years ago
Dimitrios Semitsoglou-Tsiapos eb47c5a39f Synchronise frontlight level with nickel config
* Drops support for mocking the frontlight setting internally which may
  cause incorrect in-memory values.

* Adds new supported value for `KOBO_LIGHT_ON_START` (-2), which sets
  'Kobo eReader.conf' as the source to update `settings.reader.lua`'s
  brightness setting on startup, thus using the value from it
  indirectly.

* Adds the `KOBO_SYNC_BRIGHTNESS_WITH_NICKEL` configuration variable
  which updates 'Kobo eReader.conf' every time the brightness setting is
  changed within koreader.

* Fixes missing call to save brightness when modifying via two-finger
  swipe.

Closes #1523.
8 years ago
Cosmin Gorgovan 41045dab99 Fix charging detection for Kobo devices
I've tested this on a N905C. I assume this implementation never
worked (since charge_now is supposed to show state of charge), but
it would be useful to get a confirmation.
9 years ago
Hans-Werner Hilse 3d73ff5ae7 only open frontlight device on Kobo devices that actually have light 10 years ago
Hans-Werner Hilse 3066c86e38 Refactoring hardware abstraction
This is a major overhaul of the hardware abstraction layer.
A few notes:

General platform distinction happens in
  frontend/device.lua
which will delegate everything else to
  frontend/device/<platform_name>/device.lua
which should extend
  frontend/device/generic/device.lua

Screen handling is implemented in
  frontend/device/screen.lua
which includes the *functionality* to support device specifics.
Actually setting up the device specific functionality, however,
is done in the device specific setup code in the relevant
device.lua file.

The same goes for input handling.
10 years ago