Skip to content

AutoWarmth: add option to toggle/set frontlight on day/night#9337

Merged
Frenzie merged 12 commits into
masterfrom
autowarmthToggleFl
Jul 28, 2022
Merged

AutoWarmth: add option to toggle/set frontlight on day/night#9337
Frenzie merged 12 commits into
masterfrom
autowarmthToggleFl

Conversation

@ghost

@ghost ghost commented Jul 15, 2022

Copy link
Copy Markdown

I was experimenting with a solution to dim the frontlight smoothly on sun set/rise.
Too long to explain: This does not work, as I don't want to find out how the intensity of devices maps to brightness felt by us humans. (maybe or next year, or the year after or in 2525).

So, this solution stupidly turns the frontlight on (toggle) between sunset and sunrise, and turns the frontlight off (toggle) during daytime, once (per day). The user can override the selection of the plugin, but on the next day/night change AutoWarmth toggles again (if necessary).
This should also work with autosuspend (which I really, really love from the users view, but from the developers point :/)

Draft by now, as some more test will follow, so no need to review as long this PR is in draft state.
But as always ( :) ), improvements on wording (menu) are welcomed.

grafik


This change is Reviewable

@ghost ghost force-pushed the autowarmthToggleFl branch from 7494a8b to d7601d0 Compare July 15, 2022 21:33
@ghost ghost marked this pull request as ready for review July 18, 2022 05:44
@ghost

ghost commented Jul 18, 2022

Copy link
Copy Markdown
Author

Strange, I got a crash. Can not reproduce :/

crash.log
07/18/22-07:59:12 DEBUG set up single/double tap timer
07/18/22-07:59:12 DEBUG in single/double tap timer, single tap: true
07/18/22-07:59:12 DEBUG single tap detected in slot 0 {
    ["x"] = 161,
    ["y"] = 1810,
    ["w"] = 0,
    ["h"] = 0,
}
07/18/22-07:59:12 DEBUG adjusted ges: tap
07/18/22-07:59:12 DEBUG AutoSuspend: onInputEvent
07/18/22-07:59:12 DEBUG AutoTurn: onInputEvent
07/18/22-07:59:12 DEBUG getLinkFromPosition link_xpointer:
07/18/22-07:59:12 DEBUG getLinkFromPosition a_xpointer:
error in subprocess:	frontend/device/kobo/powerd.lua:465: attempt to perform arithmetic on field 'fl_intensity' (a nil value)
stack traceback:
	frontend/device/kobo/powerd.lua:465: in function 'func'
	./ffi/util.lua:343: in function <./ffi/util.lua:314>
	[C]: in function 'xpcall'
	./ffi/util.lua:314: in function 'runInSubProcess'
	frontend/device/kobo/powerd.lua:463: in function 'turnOnFrontlightHW'
	frontend/device/generic/powerd.lua:127: in function 'toggleFrontlight'
	frontend/device/devicelistener.lua:205: in function 'handleEvent'
	frontend/ui/widget/container/widgetcontainer.lua:95: in function 'propagateEvent'
	frontend/ui/widget/container/widgetcontainer.lua:113: in function 'handleEvent'
	frontend/ui/uimanager.lua:1099: in function 'sendEvent'
	frontend/dispatcher.lua:748: in function 'execute'
	plugins/gestures.koplugin/main.lua:1078: in function 'handler'
	frontend/ui/widget/container/inputcontainer.lua:255: in function 'handleEvent'
	frontend/ui/uimanager.lua:1099: in function 'sendEvent'
	frontend/ui/uimanager.lua:222: in function '__default__'
	frontend/ui/uimanager.lua:1608: in function 'handleInputEvent'
	frontend/ui/uimanager.lua:1694: in function 'handleInput'
	frontend/ui/uimanager.lua:1744: in function 'run'
	./reader.lua:300: in main chunk
	[C]: at 0x000140bd
./luajit: frontend/device/kobo/powerd.lua:367: attempt to compare number with nil
stack traceback:
	frontend/device/kobo/powerd.lua:367: in function 'isFrontlightOnHW'
	frontend/device/generic/powerd.lua:85: in function '_decideFrontlightState'
	frontend/device/kobo/powerd.lua:483: in function 'turnOnFrontlightHW'
	frontend/device/generic/powerd.lua:127: in function 'toggleFrontlight'
	frontend/device/devicelistener.lua:205: in function 'handleEvent'
	frontend/ui/widget/container/widgetcontainer.lua:95: in function 'propagateEvent'
	frontend/ui/widget/container/widgetcontainer.lua:113: in function 'handleEvent'
	frontend/ui/uimanager.lua:1099: in function 'sendEvent'
	frontend/dispatcher.lua:748: in function 'execute'
	plugins/gestures.koplugin/main.lua:1078: in function 'handler'
	frontend/ui/widget/container/inputcontainer.lua:255: in function 'handleEvent'
	frontend/ui/uimanager.lua:1099: in function 'sendEvent'
	frontend/ui/uimanager.lua:222: in function '__default__'
	frontend/ui/uimanager.lua:1608: in function 'handleInputEvent'
	frontend/ui/uimanager.lua:1694: in function 'handleInput'
	frontend/ui/uimanager.lua:1744: in function 'run'
	./reader.lua:300: in main chunk
	[C]: at 0x000140bd
!!!!
Uh oh, something went awry... (Crash n°1: 07/18/22 @ 07:59:13)
Running FW 4.32.19501 on Linux 4.9.56 (#18 SMP PREEMPT Thu Apr 14 13:26:51 CST 2022)
Attempting to restart KOReader . . .

Comment thread plugins/autodim.koplugin/main.lua Outdated
@ghost ghost force-pushed the autowarmthToggleFl branch from 9055fcb to 297d668 Compare July 18, 2022 08:37
@NiLuJe

NiLuJe commented Jul 18, 2022

Copy link
Copy Markdown
Member

The line numbers in the stacktrace look wonky as hell, are you running a patched kobo powerd?

@ghost

ghost commented Jul 18, 2022

Copy link
Copy Markdown
Author

Yes, I am running with #8934, which is unrelated to this PR.

@ghost

ghost commented Jul 19, 2022

Copy link
Copy Markdown
Author

I think I know what the cause of the crash was. Most probably I had run an outdated code. If I remove those two lines which where corrected by the last commit, I can reproduce the crash.

In the current state of this PR, I can not reproduce any crashes.

@JJTech0130 JJTech0130 mentioned this pull request Jul 20, 2022
@ghost

ghost commented Jul 21, 2022

Copy link
Copy Markdown
Author

From my side this is ready.

@ghost

ghost commented Jul 27, 2022

Copy link
Copy Markdown
Author

Any objections to merge this?

@NiLuJe

NiLuJe commented Jul 27, 2022

Copy link
Copy Markdown
Member

Sounds good to me, but I barely glanced at it ;).

@Frenzie Frenzie added this to the 2022.07 milestone Jul 28, 2022
@Frenzie Frenzie merged commit 9d71333 into master Jul 28, 2022
@Frenzie Frenzie deleted the autowarmthToggleFl branch July 28, 2022 04:22
@carmelocotonto

Copy link
Copy Markdown

Hi. I have tried this plugin and I think the line 75 should be
self.fl_off_during_day = G_reader_settings:readSetting("autowarmth_fl_off_during_day")

instead of
self.fl_off_during_day = G_reader_settings:saveSetting("autowarmth_fl_off_during_day")

Regards

@ghost

ghost commented Jul 28, 2022

Copy link
Copy Markdown
Author

@carmelocotonto Thank you.

@ghost ghost mentioned this pull request Jul 28, 2022
Frenzie pushed a commit that referenced this pull request Jul 28, 2022
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants