Skip to content

Kindle: toggle cover events #10363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 3, 2023
Merged

Kindle: toggle cover events #10363

merged 2 commits into from
May 3, 2023

Conversation

yparitcher
Copy link
Member

@yparitcher yparitcher commented Apr 27, 2023

used on kindle but can be extended to other devices

Allow disabling the hall efect sensor via the sysfs knob, so the kindle system wont sleep & wake the device

for those of use that stay in koreader, are caseless and get spurious wakeups


This change is Reviewable

@yparitcher yparitcher added this to the 2023.05 milestone Apr 27, 2023
@yparitcher yparitcher requested a review from NiLuJe April 27, 2023 01:00
@NiLuJe
Copy link
Member

NiLuJe commented Apr 27, 2023

I don't quite recall how this works on Kindle, but, FWIW, on Kobo, we essentially get an EV_KEY with a specific keycode, so we can easily ignore the event (and go back to sleep if necessary).

It's handled over here for the UI side:

if Device:isKobo() then
common_settings.ignore_sleepcover = {
text = _("Ignore all sleepcover events"),
checked_func = function()
return G_reader_settings:isTrue("ignore_power_sleepcover")
end,
callback = function()
G_reader_settings:toggle("ignore_power_sleepcover")
G_reader_settings:makeFalse("ignore_open_sleepcover")
UIManager:askForRestart()
end
}
common_settings.ignore_open_sleepcover = {
text = _("Ignore sleepcover wakeup events"),
checked_func = function()
return G_reader_settings:isTrue("ignore_open_sleepcover")
end,
callback = function()
G_reader_settings:toggle("ignore_open_sleepcover")
G_reader_settings:makeFalse("ignore_power_sleepcover")
UIManager:askForRestart()
end
}
end

And sorted somewhere in Device:


TL;DR: Feel free to move the menu entry somewhere around there, too?

@poire-z
Copy link
Contributor

poire-z commented Apr 27, 2023

Oh, ok, it's just sleep cover handling ! :)
I guess a menu item "Hall sensor", even with your help_text, is too technical: just name it like the existing menu for handling the sleep cover on Kobo ?
Or better, I guess it should be abstracted low level so the same menu and same bit of code handle like like they do on a Kobo? (unless it's really too different, and we don't have to handle anything at all if it's the Kindle OS that do it all without us even knowing?)

@Frenzie
Copy link
Member

Frenzie commented Apr 27, 2023

We already have code at least in Kobo to deal with spurious wakeups, basically a reasonably quick go back to sleep if no input for a minute (or whatever). As for the menu item I think it should probably just reuse the Kobo "sleepcover event" message; the technical side you'd have to check what the best way is to abstract it away.

@yparitcher
Copy link
Member Author

As usual on kindle we cant get the events, we can only change the sysfs knob to enable / disable on a driver level

@yparitcher
Copy link
Member Author

Kindle also does not advertise as a sleep cover so kindle users might not be familiar with the term. Maybe cover events?

Also i need help with device_spec i am not sure how to convert its expecting us to use os.execute when we don't use it anymore

@Frenzie
Copy link
Member

Frenzie commented Apr 27, 2023

I think that maps fairly cleanly to "ignore all sleepcover events"? :-)

@Frenzie
Copy link
Member

Frenzie commented Apr 27, 2023

Kindle also does not advertise as a sleep cover so kindle users might not be familiar with the term. Maybe cover events?

What term does Kindle use?

@yparitcher
Copy link
Member Author

Kindle also does not advertise as a sleep cover so kindle users might not be familiar with the term. Maybe cover events?

What term does Kindle use?

Kindle {model} cover

Deep in product details it says wakes and sleeps kindle

@yparitcher yparitcher changed the title Hall sensor plugin Kindle: toggle cover events Apr 28, 2023
@NiLuJe
Copy link
Member

NiLuJe commented Apr 28, 2023

Random fun fact: I seem to recall that (on the PW5, at least) there's actually (at least?) two of them, one calibrated for the back, and one for the front. This is (I imagine) to help deal with tolerance issues to prevent false-positives from the back (when there's an actual cover involved, at least).

I don't recall how/where/why I even checked that, because I've never used a cover with a Kindle, but I remember thinking that it the implementation looked neat (especially given the amount of crap false positives like that have caused on kobo ;p).

if Device:isKindle() and PowerD:hasHallSensor() then
common_settings.cover_events = {
text = _("Cover events"),
help_text = _([[Enable or disable the hall effect sensor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The Hall-effect principle is named for physicist Edwin Hall. In 1879 he discovered that when a conductor or semiconductor with current flowing in one direction was introduced perpendicular to a magnetic field a voltage could be measured at right angles to the current path."
May be capitilize "hall"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incidentally, I've been considering buying a Gulikit KingKong 2, with Hall effect sensors.

But over here as I said I'm not sure how much sense it makes to talk about the underlying tech instead of what it does (i.e., detect covers).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I understand that the Kindle has it enabled by default ? And that you added that option to allow disabling it because it sucks ?
Then I would just name it [ ] Disable cover events (or [ ] Disable Kindle cover events if it's really clear to all it's Kindle system stuff outside of us).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the capitalization only.

@yparitcher
Copy link
Member Author

Random fun fact: I seem to recall that (on the PW5, at least) there's actually (at least?) two of them, one calibrated for the back, and one for the front. This is (I imagine) to help deal with tolerance issues to prevent false-positives from the back (when there's an actual cover involved, at least).

I don't recall how/where/why I even checked that, because I've never used a cover with a Kindle, but I remember thinking that it the implementation looked neat (especially given the amount of crap false positives like that have caused on kobo ;p).

Makes sense, as it is more difficult to trigger this on my pw5 then on older models

Allow disabling the hall efect sensor via the sysfs knob, so the kindle system wont sleep & wake the device

for those of use that stay in koreader, are caseless and have get spurious wakeups
@yparitcher
Copy link
Member Author

Ready to merge

@poire-z
Copy link
Contributor

poire-z commented May 3, 2023

Fine with the final wording. (Haven't looked at the lower level stuff.)

Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, left a small phrasing nit

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
@yparitcher yparitcher merged commit 1102c03 into koreader:master May 3, 2023
@yparitcher yparitcher deleted the hall branch May 3, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants