-
Notifications
You must be signed in to change notification settings - Fork 22
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
Earlier start time for Comfortlight #36
Comments
I'll take a look at it later today, and do the patch if it is straightforward (i.e. under 10 minutes to do). I'd also be interested in this myself once I get a Clara (I'm waiting for it to go on sale). |
@jackiew1, do the hours 7, 18, and 5 mean anything to you (possibly shifted, so also consider the intervals in between)? If so, this will be a really simple patch, if not, I'll have to look further later. 00a499de 3046 mov r0, r6 ; CODE XREF=_ZN14BedtimeManager17adjustTemperatureEv+72
00a499e0 7AF6E8E2 blx _ZN14BedtimeManager18daytimeTemperatureEv@PLT ; BedtimeManager::daytimeTemperature()
00a499e4 3861 str r0, [r7, #0x10]
00a499e6 3046 mov r0, r6
00a499e8 64F68CE0 blx _ZN14BedtimeManager18bedtimeTemperatureEv@PLT ; BedtimeManager::bedtimeTemperature()
00a499ec 4346 mov r3, r8
00a499ee 7860 str r0, [r7, #0x4]
00a499f0 4246 mov r2, r8
00a499f2 0721 movs r1, #7
00a499f4 2046 mov r0, r4
00a499f6 CDF80080 str.w r8, [sp, #0x70 + var_70]
00a499fa 61F68AE3 blx _ZN5QTimeC1Eiiii@PLT ; QTime::QTime(int, int, int, int)
00a499fe D7F82C90 ldr.w sb, [r7, #0x2c]
00a49a02 4346 mov r3, r8
00a49a04 4246 mov r2, r8
00a49a06 1221 movs r1, #18
00a49a08 CDF80080 str.w r8, [sp, #0x70 + var_70]
00a49a0c 2046 mov r0, r4
00a49a0e B9F1FF3F cmp.w sb, #0xffffffff
00a49a12 08BF it eq
00a49a14 4FF00009 mov.weq sb, #0x0
00a49a18 61F67AE3 blx _ZN5QTimeC1Eiiii@PLT ; QTime::QTime(int, int, int, int)
00a49a1c D7F82CB0 ldr.w fp, [r7, #0x2c]
00a49a20 4346 mov r3, r8
00a49a22 CDF80080 str.w r8, [sp, #0x70 + var_70]
00a49a26 4246 mov r2, r8
00a49a28 0521 movs r1, #5
00a49a2a 2046 mov r0, r4
00a49a2c BBF1FF3F cmp.w fp, #0xffffffff
00a49a30 08BF it eq
00a49a32 4FF0000B mov.weq fp, #0x0
00a49a36 61F66CE3 blx _ZN5QTimeC1Eiiii@PLT ; QTime::QTime(int, int, int, int)
00a49a3a FB6A ldr r3, [r7, #0x2c]
00a49a3c 7B61 str r3, [r7, #0x14]
00a49a3e 0133 adds r3, #0x1
00a49a40 00F05881 beq.w loc_a49cf4 |
That's a bit cryptic for me 😄 Here's the only actual info I can see, none of which answers your question. The config setting for "Bedtime" is a drop-down menu with 13 entries: I have my Clara and Forma set at the minimum of 21:00 which is stored in the Kobo .conf file's [PowerOptions] section with a value |
OK, thanks, that helps. BTW, I'm going to release v54 in the next few minutes. All the missing patches are now updated. |
... I typed that @variant with a capital 'V' but it's displaying as small 'v' |
That's because GitHub's interpreting that as a mention to the user |
Well then, lets hope user variant can answer your question if he reads it 😄 |
A bit more info I missed ... |
I found the relevant code multiple layers into functions which had their names optimized out by going back from references to QTime::addSecs (since the values aren't hard-coded, I guessed they would be generated this way). I just have to figure out where to patch it. 00a50e28 2DE9F04F push.w {r4, r5, r6, r7, r8, sb, sl, fp, lr} ; CODE XREF=sub_a51c98+1216 00a50e2c A3B0 sub sp, #0x8c 00a50e2e 06AF add r7, sp, #0x18 00a50e30 0024 movs r4, #0x0 00a50e32 07F11006 add.w r6, r7, #0x10 00a50e36 2346 mov r3, r4 00a50e38 2246 mov r2, r4 00a50e3a 0094 str r4, [sp, #0xb0 + var_B0] 00a50e3c 8246 mov sl, r0 00a50e3e 1521 movs r1, #0x15 00a50e40 3046 mov r0, r6 00a50e42 5AF666E1 blx _ZN5QTimeC1Eiiii@PLT ; QTime::QTime(int, int, int, int) 00a50e46 C34B ldr r3, =0x6526bc ; 0x6526bc,0xa51154 00a50e48 7B44 add r3, pc ; dword_10a3508 00a50e4a 1A46 mov r2, r3 00a50e4c 7B60 str r3, [r7, #0x4] 00a50e4e C24B ldr r3, =dword_14ef8 ; dword_14ef8,0xa51158 00a50e50 D258 ldr r2, [r2, r3] ; dword_10b8400 00a50e52 9368 ldr r3, [r2, #0x8] 00a50e54 7A61 str r2, [r7, #0x14] 00a50e56 C3F31E03 ubfx r3, r3, #0x0, #0x1f 00a50e5a 0C2B cmp r3, #0xc 00a50e5c C2BF ittt gt 00a50e5e 07F11403 add.wgt r3, r7, #0x14 00a50e62 1446 movgt r4, r2 00a50e64 BB60 strgt r3, [r7, #0x8] 00a50e66 40F33581 ble.w loc_a510d4 |
@jackiew1, can you tell me the earliest and latest time in the list? Edit: nevermind, found it at https://youtu.be/XIaN5TlbJJQ?t=120 - [9PM ... 3AM] step 30m (12 steps total). This confirms what I found in the firmware (init: 0xa50e76 => i=13, while: 0xa50f38 => i--;i>0, start: 0xa50e3e => 21h, increment: 0xa50ea2 => 1800). |
@jackiew1, can you try this: Change ComfortLight bedtime range:
- Enabled: yes
- Description: Change the times available in the ComfortLight bedtime dropdown.
# In an unnamed subroutine two layers into FrontLightPopupController::loadView
# (find it by going back from QTime::addSecs), the times for the dropdown are
# generated into a QVector<QPair<QString, QTime>> with a simple loop.
#
# The abbreviated structure of the loop:
#
# r0 = new QTime(r1 = 21, 0, 0)
# QVector<QPair<QString, QTime>>::reallocData(int, r2 = 13, QFlags<QArrayData::AllocationOption>) ; https://code.woboq.org/qt5/qtbase/src/corelib/tools/qvector.h.html#_ZN7QVector11reallocDataEii6QFlagsIN10QArrayData16AllocationOptionEE
# r5 = 13
# do {
# QLocale::toString(QTime const&, QLocale::FormatType)
# QVector<QPair<QString, QTime>>::append(QPair<QString, QTime> const&)
# QTime::addSecs(r1 = 1800)
# r5--
# } while (r5 > 0)
#
# Change the starting hour passed to the QTime constructor (mov r1, #21):
- ReplaceInt: {Offset: 0xA50E3E, Find: 21, Replace: 17} # 21:00 (9PM) -> 17:00 (5PM)
# Optional: Change the second increment passed to QTime::addSecs:
- ReplaceBytes: {Offset: 0xA50EA2, FindH: 4F F4 E1 61, ReplaceH: 4F F4 E1 61} # mov.w r1, #1800: 30m
# Change the number of increments (movs r5, #13):
- ReplaceInt: {Offset: 0xA50E76, Find: 13, Replace: 21} # 13 [9PM..3AM]+30m -> 21 [5PM..3AM]+30m
# Change the number of elements pre-allocated (I don't think this is actually
# required, as Qt will realloc as necessary, but we might as well do this just
# in case):
- ReplaceInt: {Offset: 0xA510DE, Find: 13, Replace: 21} # same as prev replacement I've tested this with the following patch to confirm the dropdown items and config entries work properly: Show natural light menu on all devices:
- Enabled: yes
- Description: |
Just for testing the previous patch, will show the slider and dropdown,
but won't actually do anything other than change the config file.
# Show slider in FrontLightPopupController::loadView:
- ReplaceBytes: {Offset: 0xA51E8A, FindBLX: 0x4C8984, ReplaceH: 4F F0 01 00}
- ReplaceBytes: {Offset: 0xA51FC8, FindBLX: 0x4C8984, ReplaceH: 4F F0 01 00} Everything seems to work. The only thing I can't test is the schedule itself, as I don't currently have a device with natural light. |
Testing now. Sorry for delay, it's been a busy morning. |
I installed the patch as-is on a KA1. It gave me the expected range of Bedtimes 17:00-03:00, 21 entries at 30min intervals. It's only 14:50 here so I need to customise the patch to force an earlier colour-changing. I re-applied the patch with a customised minimum Bedtime of 15:00 and commented out all other find/replace. After installation, as expected, the drop-down has 13 entries at 30min intervals 15:00-21:00. I've selected 15:00 from the drop-down and made sure the Natural light Auto switch is on. I would expect the colour to start changing immediately so it would gradually get to "full orange" by 15:00 . So far it's remained on "full blue". 😕 When you were digging around did you notice the algorithm for how the colour-change is meant to happen? |
I did take note of where the color change was handled (BedTimeManager::adjustTemperature), but I didn't bother to try to understand it. I was just focusing on the menu and config file yesterday. Does the color change happen if you set the time even further back? One suspicion I have is that those times I saw earlier also need to be adjusted (my patch doesn't touch anything to do with a wake-up time). Do you know when the auto color change ends (i.e. goes back to normal)? |
I haven't changed the patch on the KA1 but it's 15:12 now and the KA1 is still full blue. So passing the Bedtime value didn't kickstart anything.
I don't know for sure when orange starts to move back to blue. When I've finished reading for the night (early morning) the device will be full orange. If I open the book next morning it will be full blue, although I have a feeling that the immediate colour will be wherever it was when I closed the cover and re-opening it immediately starts to auto-decrease the orange. It's gradual but fast-gradual. |
Follow-up on the KA1 ...
So there's definitely more to it than we have so far. |
Follow-up 2 ... I've now installed the patch on my Clara. Bedtime 21 entries 15:00-01:00 set at 16:00. I plan to do some normal reading now and note at what time the orange starts to kick in (if it ever does). I've left this page open on screen so if you have more ideas I should see them quite quickly. |
Both KA1 and Clara started to move at 18:00. Both auto-stepped from min to max in under a minute. I have to admit that I've never paid attention to how long it normally takes to move from min to max. My Forma remains unpatched and has Bedtime set at the default min of 21:00. It's at full blue at the moment, so the patch has obviously made some kind of difference. I'll now continue reading on the unpatched Forma and pay more attention to when the colour-change kicks in and how fast it moves. |
Can you enable all light-related logging categories in developer options (search devmodeon, go to device info)? |
I've turned on dev mode and ticked every box in Logging Category. |
I've just checked the colour-slider. It's started to move. It's about 1cm from min. I wouldn't have noticed the change if I hadn't gone looking. |
These are the calculations "before day time start": 00a49d1e 7B69 ldr r3, [r7, #0x14] ; CODE XREF=dword_a4a6c4+1492, dword_a4a6c4+1538, dword_a4a6c4+2376, sub_a4b086+112
00a49d20 7A68 ldr r2, [r7, #0x4]
00a49d22 3969 ldr r1, [r7, #0x10]
00a49d24 ED1A subs r5, r5, r3
00a49d26 C3EB0909 rsb sb, r3, sb
00a49d2a 07EE902A vmov s15, r2
00a49d2e 8B1A subs r3, r1, r2
00a49d30 F8EEE71B vcvt.f64.s32 d17, s15
00a49d34 07EE905A vmov s15, r5
00a49d38 F8EEE70B vcvt.f64.s32 d16, s15
00a49d3c 07EE909A vmov s15, sb
00a49d40 F8EEE73B vcvt.f64.s32 d19, s15
00a49d44 07EE903A vmov s15, r3
00a49d48 F8EEE72B vcvt.f64.s32 d18, s15
00a49d4c C0EEA30B vdiv.f64 d16, d16, d19
00a49d50 42EEA01B vmla.f64 d17, d18, d16
00a49d54 FDEEE17B vcvt.s32.f64 s15, d17
00a49d58 C7ED047A vstr s15, [r7, #0x10]
00a49d5c C9E6 b loc_a49af2 These are "after sunset but not bed time yet": 00a4a54e 3A69 ldr r2, [r7, #0x10] ; CODE XREF=dword_a4a6c4+1894, dword_a4a6c4+1944, dword_a4a6c4+2406
00a4a550 CBEB0505 rsb r5, fp, r5
00a4a554 CBEB0808 rsb r8, fp, r8
00a4a558 7968 ldr r1, [r7, #0x4]
00a4a55a 07EE902A vmov s15, r2
00a4a55e 531A subs r3, r2, r1
00a4a560 F8EEE72B vcvt.f64.s32 d18, s15
00a4a564 07EE905A vmov s15, r5
00a4a568 F8EEE71B vcvt.f64.s32 d17, s15
00a4a56c 07EE908A vmov s15, r8
00a4a570 F8EEE70B vcvt.f64.s32 d16, s15
00a4a574 07EE903A vmov s15, r3
00a4a578 F8EEE73B vcvt.f64.s32 d19, s15
00a4a57c C1EEA00B vdiv.f64 d16, d17, d16
00a4a580 43EEE02B vmls.f64 d18, d19, d16
00a4a584 FDEEE27B vcvt.s32.f64 s15, d18
00a4a588 C7ED047A vstr s15, [r7, #0x10]
00a4a58c FFF7B1BA b.w loc_a49af2 And this calculation is used for something else: 00a49b5e 801A subs r0, r0, r2
00a49b60 9FEDB86A vldr s12, =0x458ca000 ; 0xa49e44
00a49b64 0028 cmp r0, #0x0
00a49b66 DFEDB87A vldr s15, =0x4270 ; 0xa49e4a
00a49b6a B8BF it lt
00a49b6c 4042 rsbslt r0, r0, #0x0
00a49b6e DFEDB76A vldr s13, =0x9b8e447a ; 0xa49e4e
00a49b72 1146 mov r1, r2
00a49b74 0122 movs r2, #0x1
00a49b76 07EE100A vmov s14, r0
00a49b7a 2846 mov r0, r5
00a49b7c B8EEC77A vcvt.f32.s32 s14, s14
00a49b80 87EE067A vdiv.f32 s14, s14, s12
00a49b84 67EE277A vmul.f32 s15, s14, s15
00a49b88 67EEA67A vmul.f32 s15, s15, s13
00a49b8c FDEEE77A vcvt.s32.f32 s15, s15
00a49b90 17EE903A vmov r3, s15
00a49b94 61F6F8E4 blx _ZN10FrontLight14setTemperatureEibi@PLT ; FrontLight::setTemperature(int, bool, int)
00a49b98 BAF1000F cmp.w sl, #0x0
00a49b9c BED1 bne loc_a49b1c (these are mainly for my own reference, I'll need to work out the math when I get around to it) |
I hope all that makes more sense to you than it does to me. I won't be particularly surprised if I see a slider jump every 30mins rather than a constant gradual creep. |
It does. It's easier than it seems at first, as quite a few of those instructions are just variants of a few simple ones (blx to call functions, v... for floating point numbers, etc, ...lt for executing only if less-than, {mul,div} for math operations, ldr to load from a memory address, etc). For example, the last part (after the vldr) of the last one basically says I won't be doing much with this today, though. Once you have the logs, can you post them or PM them to me (specifically the lines about adjustTemperature)? |
How long do you want me to let it run before connecting to access the logs? Is it one big log or lots of little ones? |
It saves whenever you connect USB. And it'd be nice to have the logs at the beginning and end of the change (remember to keep track of what bedtime you used). |
So, it seems the majority of my guesses are correct. Do you think it would be sufficient (with regards to this patch) to also set the sunset time earlier, or should I see if it is possible to make it transition over a fixed period before bedtime (this may be possible if I can find enough room to put it in)? One last thing you could try is to change the int at 0x00a49a28 from 5 to 0 (and 0x00a499f2 from 7 to 1) and see if it starts getting cooler again (sunrise). |
I applied the 2 new find/replaces with the device time set correctly. I couldn't immediately conclude anything. So I've advanced the time from 00:00 to 00:30, i.e. 30mins until sunrise ... and yes, the colour has moved down from full (almost) orange to about 50% orange. If your theory is true it should reach zero-orange within another 30 mins. I'll let it do this naturally with no more artificial time changes and post again in 30 mins. |
... it's now 01:00 on this Kobo and colour is at full blue, i.e zero-orange.
Hmmm. Need to think about this a bit. These are initial personal thoughts, not what I think every other user will necessarily want. I don't really care very much about what the transition duration from blue to orange is. And I care zero about transition duration from orange to blue because I'm never reading at sunrise. And even if I was I wouldn't care about colour. My personal wish for this patch is for the light to be orange when it actually dark rather than at my bedtime (which is very variable). As such, Kobo's idea of sunset being at 18:00 all year round doesn't work for me. In the UK darkness falls (roughly) anywhere between 15:00 in winter to 21:00 in summer. I'm very happy to change the on-device Bedtime setting, as required, as the seasons change. Based on today's experiments that suggests we need the patch to
|
How does this look for the final patch: Change ComfortLight bedtime range:
- Enabled: no
- Description: |
Change the times available in the ComfortLight bedtime dropdown and the
start/end times for the color change. All values in this patch are
customizable.
The default values for this patch give you 21 options between 5PM and 3AM
at 30 minute intervals, with the colour change starting at 4PM, and the
change back to blue between 5AM and 7AM. The firmware default is 13 options
between 9PM-3AM at 30 minute intervals, with the transition starting at 6PM.
#
# In an unnamed subroutine two layers into FrontLightPopupController::loadView
# (find it by going back from QTime::addSecs), the times for the dropdown are
# generated into a QVector<QPair<QString, QTime>> with a simple loop.
#
# Change the starting hour passed to the QTime constructor (mov r1, #21):
- ReplaceInt: {Offset: 0xA50E3E, Find: 21, Replace: 17} # 21:00 (9PM) -> 17:00 (5PM)
# Optional: Change the increment passed to QTime::addSecs (you need to use an
# ARM assembler to change this value):
- ReplaceBytes: {Offset: 0xA50EA2, FindH: 4F F4 E1 61, ReplaceH: 4F F4 E1 61} # mov.w r1, #1800: 30m
# Change the number of increments (movs r5, #13):
- ReplaceInt: {Offset: 0xA50E76, Find: 13, Replace: 21} # 13 [9PM..3AM]+30m -> 21 [5PM..3AM]+30m
# Change the number of pre-allocated elements (I don't think this is actually
# required, as Qt will realloc as necessary, but we might as well do this just
# in case) (mov r1, #21):
- ReplaceInt: {Offset: 0xA510DE, Find: 13, Replace: 21} # same as prev replacement
#
# The actual color adjustment is done in BedtimeManager::adjustTemperature.
# The color temperature is based on the current time, the bedtime, the hardcoded
# sunset, the hardcoded sunrise start, the hardcoded sunrise end, the daytime
# temperature, and the nighttime temperature.
#
# Change the sunset time (the transition to a warmer temperature starts here
# and transitions until the bedtime chosen) (this should be 1-3 hours before
# the minimum bedtime from the first replacement above) (mov r1, #18):
- ReplaceInt: {Offset: 0xA49A06, Find: 18, Replace: 16} # 18:00 (9PM-3=6PM) -> 16:00 (5PM-1=4PM)
# Optional: Change the sunrise start time (the transition back to a cooler
# temperature starts here) (this should be sometime after the last bedtime,
# but before the sunset time) (mov r1, #5):
- ReplaceInt: {Offset: 0xA49A28, Find: 5, Replace: 5} # 5AM
# Optional: Change the sunrise end time (the transition back to a cooler
# temperature ends here) (this should be 1-3 hours after the sunrise start but
# before the sunset time or bad things will happen with negative values) (mov r1, #7):
- ReplaceInt: {Offset: 0xA499F2, Find: 7, Replace: 7} # 5AM+2=7AM
|
It can do a job but If you want my honest opinion it's too dense with too much technical detail that detracts from what the average user needs to know to customise it. I do understand that a lot of it is there to document what you've done and acts as a permanent reminder of the details of the processes involved. But do the users need to know all that? In addition:
Also, the patch name needs to be more generic e.g. As your last post arrived I was just about to write to say that for my purposes the patch could be reduced to 2 find/replaces:
... or have I oversimplified this? |
I agree with that completely.
Yes, that's why I put it there, but edited out some of the denser parts. I've settled on that style for my patches, especially the complex ones like this one, as it provides enough information for me to quickly recreate it if I need to (unlike things like the 24 line spacing values patch), and it also provides enough information for somebody without much experience to learn how to update it in case I ever stop updating the patches for whatever reason. Before each section of replacements, I describe which function it's in (for context), how to find that function (in case it loses it's function name due to optimization), and what the defining characteristic of it is (in case the code ever gets moved around, like with the new reader stuff). Before each replacement, I describe what it is replacing, the possible side effects, and the user-facing description and constraints. With each replacement, I show the previous and new values along with the assembly instruction (so someone interested doesn't have to decompile each instruction manually to read it -- this was one of the most time consuming parts of learning to update the patches a few years ago). So, yes, quite a bit of this info is extra for users, but this info is the minimum I can put to save a lot of time and effort in the future if it needs to be rewritten or if someone else updates it.
My rationale was that there isn't any harm in putting them all there, and that a patch shouldn't remove functionality if possible.
I'd be using it myself once I have a Clara, and it's also there for reference about the 5 and 7 times.
Yep, will fix that. Thanks!
Yes, that should work. And, did you try that to make sure the array reallocation isn't needed (I didn't think it was, but if it turned out to be, it would segfault or cause unusual bugs when building the array). |
I did it this way to try to minimise the mods required (for me). Do you think I may be creating problems for myself that I haven't fully understood? In theory, it gives me 13 selectable Bedtimes from 16:00 to 21:00 and a constant start transition of 15:00 (sunset). I've now applied it to a Clara (Bedtime=16:00) and a Forma (Bedtime=21:00) for a proper test today. The theory is that:
Based on my (rather haphazard and accidental) observations so far I think the following may also be true:
Now, back to the full patch ... I'm not sure what changes you've already made but the following confused me so may confuse others:
How about # Change the starting hour for the Bedtime drop-down menu
|
I was thinking you missed this part: # Change the number of pre-allocated elements (I don't think this is actually
# required, as Qt will realloc as necessary, but we might as well do this just
# in case) (mov r1, #21):
- ReplaceInt: {Offset: 0xA510DE, Find: 13, Replace: 21} # same as prev replacement But now I realize you only wanted to change the time, not the number of values. So yes, your patch is fine.
That looks like I might have to patch the timer code too.
Yep, missed that one (you can see the current version in my kobopatch-config repo.
That's for optionally changing the increment of 1800s, but if what I said about needing to change the timer is true, I'll probably remove this option. |
I was right about missing the timer. Thanks for catching that! Here is one timer. That is probably all you need: 00a49b1c 0025 movs r5, #0x0 ; CODE XREF=_ZN14BedtimeManager17adjustTemperatureEv+564
00a49b1e 1221 movs r1, #18
00a49b20 2B46 mov r3, r5
00a49b22 2A46 mov r2, r5
00a49b24 0095 str r5, [sp, #0x70 + var_70]
00a49b26 2046 mov r0, r4
00a49b28 61F6F2E2 blx _ZN5QTimeC1Eiiii@PLT ; QTime::QTime(int, int, int, int)
00a49b2c 2A46 mov r2, r5
00a49b2e 2146 mov r1, r4
00a49b30 06F12800 add.w r0, r6, #0x28
00a49b34 82F66AE6 blx _ZN10PowerTimer6fireAtERK5QTimeN2Qt8TimeSpecE@PLT ; PowerTimer::fireAt(QTime const&, Qt::TimeSpec)
00a49b38 4437 adds r7, #0x44
00a49b3a BD46 mov sp, r7
00a49b3c BDE8F08F pop.w {r4, r5, r6, r7, r8, sb, sl, fp, pc} Add the following: - ReplaceInt: {Offset: 0xA49B1E, Find: 18, Replace: 15} # should match sunset time |
And just as a note for myself, here's the other timer (which is for the next step of the change, and is calculated from the other times): 00a49bc6 6CF676E0 blx _ZNK5QTime6minuteEv@PLT ; QTime::minute() const
00a49bca 0546 mov r5, r0
00a49bcc 4946 mov r1, sb
00a49bce 85FB0889 smull r8, sb, r5, r8
00a49bd2 EA17 asrs r2, r5, #0x1f
00a49bd4 5346 mov r3, sl
00a49bd6 CDF800A0 str.w sl, [sp, #0x70 + var_70]
00a49bda 2046 mov r0, r4
00a49bdc 4D44 add r5, sb
00a49bde C2EB2515 rsb r5, r2, r5, asr #4
00a49be2 6A01 lsls r2, r5, #0x5
00a49be4 A2EB4502 sub.w r2, r2, r5, lsl #1
00a49be8 61F692E2 blx _ZN5QTimeC1Eiiii@PLT ; QTime::QTime(int, int, int, int)
00a49bec 2146 mov r1, r4
00a49bee 5846 mov r0, fp
00a49bf0 4FF620E6 blx _ZNK5QTime7msecsToERKS_@PLT ; QTime::msecsTo(QTime const&) const
00a49bf4 011E subs r1, r0, #0x0
00a49bf6 06F12800 add.w r0, r6, #0x28
00a49bfa BEBF ittt lt
00a49bfc 01F1A461 add.wlt r1, r1, #0x5200000
00a49c00 01F5CB21 add.wlt r1, r1, #0x65800
00a49c04 01F58061 add.wlt r1, r1, #0x400
00a49c08 75F69EE3 blx _ZN10PowerTimer6fireInEi@PLT ; PowerTimer::fireIn(int)
00a49c0c 4437 adds r7, #0x44
00a49c0e BD46 mov sp, r7
00a49c10 BDE8F08F pop.w {r4, r5, r6, r7, r8, sb, sl, fp, pc} |
I wasn't actually reporting it as an error, just an observation 😃 but if you think this new find/replace will improve things, all well and good.
I've now applied it to both my Clara/Forma test devices ready for "Sunset" to happen at 15:00 (45mins from now). What different behaviour should I be looking for, exactly, as a result of having added this extra patch line? |
It should start changing automatically at a sunset time before 6PM without needing to put it to sleep and wake it up again. |
It did. I was reading the Clara at 15:00 when there was the tiniest shift off zero-orange. The slider hasn't moved again in the last 12mins of reading. I've now just done a manual sleep/wake cycle and the slider moved quite a lot. To be expected given the full transition should be completed in 1hour start-to-finish. |
OK, so that one worked. I might need to change the other timer too if it doesn't keep moving by itself. |
The Clara moved on its own at 15:30. |
So, it seems to work then. Do you think this patch is ready and bug-free now? Customize ComfortLight settings:
- Enabled: no
- Description: |
Change the times available in the ComfortLight bedtime dropdown and the
start/end times for the color changes. All values in this patch are
customizable.
The default values for this patch give you 21 options between 5PM and 3AM
at 30 minute intervals, with the colour change starting at 4PM, and the
change back to blue between 5AM and 7AM. The firmware default is 13 options
between 9PM-3AM at 30 minute intervals, with the transition starting at 6PM.
#
# In an unnamed subroutine two layers into FrontLightPopupController::loadView
# (find it by going back from QTime::addSecs), the times for the dropdown are
# generated into a QVector<QPair<QString, QTime>> with a simple loop.
#
# Change the initial hour / first dropdown item passed to the QTime constructor
# (mov r1, #21):
- ReplaceInt: {Offset: 0xA50E3E, Find: 21, Replace: 17} # 21:00 (9PM) -> 17:00 (5PM)
# Optional: Change the increment passed to QTime::addSecs (you need to use an
# ARM assembler to change this value):
- ReplaceBytes: {Offset: 0xA50EA2, FindH: 4F F4 E1 61, ReplaceH: 4F F4 E1 61} # mov.w r1, #1800: 30m
# Change the number of increments / dropdown items (movs r5, #13):
- ReplaceInt: {Offset: 0xA50E76, Find: 13, Replace: 21} # 13 [9PM..3AM]+30m -> 21 [5PM..3AM]+30m
# Change the number of pre-allocated elements (I don't think this is actually
# required, as Qt will realloc as necessary, but we might as well do this just
# in case) (mov r1, #21):
- ReplaceInt: {Offset: 0xA510DE, Find: 13, Replace: 21} # same as prev replacement
#
# The actual color adjustment is done in BedtimeManager::adjustTemperature.
# The color temperature is based on the current time, the bedtime, the hardcoded
# sunset, the hardcoded sunrise start, the hardcoded sunrise end, the daytime
# temperature, and the nighttime temperature.
#
# Change the sunset time (the transition to a warmer temperature starts here
# and transitions until the bedtime chosen) (this should be 1-3 hours before
# the minimum bedtime from the first replacement above) (mov r1, #18):
- ReplaceInt: {Offset: 0xA49A06, Find: 18, Replace: 16} # 18:00 (9PM-3=6PM) -> 16:00 (5PM-1=4PM)
# Change the time for the sunset timer to fire at (this is passed to a QTime
# constructor which is passed to PowerTime::fireAt) (mov r1, #18):
- ReplaceInt: {Offset: 0xA49B1E, Find: 18, Replace: 16} # should match sunset time above
# Optional: Change the sunrise start time (the transition back to a cooler
# temperature starts here) (this should be sometime after the last bedtime,
# but before the sunset time) (mov r1, #5):
- ReplaceInt: {Offset: 0xA49A28, Find: 5, Replace: 5} # 5AM
# Optional: Change the sunrise end time (the transition back to a cooler
# temperature ends here) (this should be 1-3 hours after the sunrise start but
# before the sunset time or bad things will happen with negative values) (mov r1, #7):
- ReplaceInt: {Offset: 0xA499F2, Find: 7, Replace: 7} # 5AM+2=7AM And here's another version using a lesser-known YAML feature: Customize ComfortLight settings:
- Enabled: no
- Description: |
Change the times available in the ComfortLight bedtime dropdown and the
start/end times for the color changes. All values in this patch are
customizable.
The default values for this patch give you 21 options between 5PM and 3AM
at 30 minute intervals, with the colour change starting at 4PM, and the
change back to blue between 5AM and 7AM. The firmware default is 13 options
between 9PM-3AM at 30 minute intervals, with the transition starting at 6PM.
#
# In an unnamed subroutine two layers into FrontLightPopupController::loadView
# (find it by going back from QTime::addSecs), the times for the dropdown are
# generated into a QVector<QPair<QString, QTime>> with a simple loop.
#
# Change the initial hour / first dropdown item passed to the QTime constructor
# (mov r1, #21):
- ReplaceInt: {Offset: 0xA50E3E, Find: 21, Replace: 17} # 21:00 (9PM) -> 17:00 (5PM)
# Optional: Change the increment passed to QTime::addSecs (you need to use an
# ARM assembler to change this value):
- ReplaceBytes: {Offset: 0xA50EA2, FindH: 4F F4 E1 61, ReplaceH: 4F F4 E1 61} # mov.w r1, #1800: 30m
# Change the number of increments / dropdown items (movs r5, #13):
- ReplaceInt: {Offset: 0xA50E76, Find: 13, Replace: &increments 21} # 13 [9PM..3AM]+30m -> 21 [5PM..3AM]+30m
# Change the number of pre-allocated elements (I don't think this is actually
# required, as Qt will realloc as necessary, but we might as well do this just
# in case) (mov r1, #21):
- ReplaceInt: {Offset: 0xA510DE, Find: 13, Replace: *increments} # same as prev replacement
#
# The actual color adjustment is done in BedtimeManager::adjustTemperature.
# The color temperature is based on the current time, the bedtime, the hardcoded
# sunset, the hardcoded sunrise start, the hardcoded sunrise end, the daytime
# temperature, and the nighttime temperature.
#
# Change the sunset time (the transition to a warmer temperature starts here
# and transitions until the bedtime chosen) (this should be 1-3 hours before
# the minimum bedtime from the first replacement above) (mov r1, #18):
- ReplaceInt: {Offset: 0xA49A06, Find: 18, Replace: &sunset 16} # 18:00 (9PM-3=6PM) -> 16:00 (5PM-1=4PM)
# Change the time for the sunset timer to fire at (this is passed to a QTime
# constructor which is passed to PowerTime::fireAt) (mov r1, #18):
- ReplaceInt: {Offset: 0xA49B1E, Find: 18, Replace: *sunset} # should match sunset time above
# Optional: Change the sunrise start time (the transition back to a cooler
# temperature starts here) (this should be sometime after the last bedtime,
# but before the sunset time) (mov r1, #5):
- ReplaceInt: {Offset: 0xA49A28, Find: 5, Replace: 5} # 5AM
# Optional: Change the sunrise end time (the transition back to a cooler
# temperature ends here) (this should be 1-3 hours after the sunrise start but
# before the sunset time or bad things will happen with negative values) (mov r1, #7):
- ReplaceInt: {Offset: 0xA499F2, Find: 7, Replace: 7} # 5AM+2=7AM |
The Clara just completed its transition to orange at 16:00 with no manual intervention whilst I was reading normally. So a 1 hour full transition works as expected. There's nothing more to be learned from the Clara today. I'd say it's working correctly, but I want to let the Forma's transition play out to the end before giving a final opinion. This should have a 6-hour transition which will complete at 21:00. I need to go and do something (unrelated) now. I'll comment on your revised patch shortly when I come back. |
As a completely useless data point, the Kindle uses geolocation to request sunset/sunrise times at the user's location ;). |
Comments:
|
Does that require wi-fi to be on or does it just use the device's timezone setting? Anything which absolutely requires wi-fi to be on is the devil's work as far as I'm concerned. 😃 |
Yes, although the use is quite limited. The value must have already been defined as a property of another element (i.e. you can't have things like config vars), the variable is global (I'd rather not use them too much), and it's all or nothing (i.e. you can't concatenate strings or that kind of thing). I'd rather not document it, as it's not something I want to officially endorse using for these reasons.
👍
You can replace it with something like armconverter.com.
I'll add some more notes about that. |
Of course it does, it's Amazon, after all ;). Kindle are, by design, getting more and more hobbled when they're in airplane mode... |
It sounds like we ought to pretend that there's only one version of the patch, namely the one without varnames.
Are we having a serious conversation? How many users are going to do that? I must say that I look forward to reading your extensive user help notes. 😄 |
... and still so many users won't consider buying anything else. I wonder if there will ever be a "straw that breaks the camel's back" moment. Their KFX format abomination marketed as "enhanced reading experience" was mine. |
Yes, I'll probably keep the version without variables.
I expect the people who don't know or care how to do it leave it alone, the people who want a specific value to ask me if needed, and the more resourceful people to know how to figure it out. I think I'll push the patch once I do the improvements mentioned previously. |
If you're going to do a full patch release you may want to have a closer look at libnickel patches It's almost 21:00 and I'm pretty confident my patched Forma is working as expected. |
I'm probably not doing a full patch release for at least a week so I can give the current one time to settle, and because this is a relatively niche patch as of right now (if people are interested, they can get it directly from the linked commit on the request thread).
Look closer 😄. The difference is
That's good to hear. |
OK, you've got me there. My mistake 😃 |
@geek1011 For your consideration once you feel like looking at patches again.
There was a request in the MR 'Kobo future firmware feature request thread' MR:post-3913806 regarding having the ability to set Comfortlight start time earlier than 21:00.
Naturally I'm bringing it to your attention because it's one I'd be interested in myself.😁 It can be dark by 15:00 in the UK in winter. Absolutely no urgency.
The text was updated successfully, but these errors were encountered: