-
Notifications
You must be signed in to change notification settings - Fork 1
/
LaunchBank14_250.pbp
101 lines (84 loc) · 2.69 KB
/
LaunchBank14_250.pbp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
; This patch changes behaviour of the Back button
; in watchfaces:
; If you (from any watchface)
; press Back button and shortly after then any button,
; it will launch an app installed in bank N,
; where N is a button ID (Back=0, Up=1, Select=2, Down=3).
; I.e. you can turn on backlight with Back button alone,
; launch app0 with Back-Back,
; launch app1 with Back-Up, app2 with Back-Select
; and app3 with Back-Down.
; You may choose which app is installed in which bank
; by uninstalling and reinstalling apps in desired order.
; This is greatly simplified since 2.0 app with Locker.
;
; This version works with 2.2.0, any HW version.
#ver 220
; just a simple mask to find named proc
07 4b 10 b5 04 46 18 68 48 b1 {
proc app_manager_get_bank_info
}
1f b5 04 46 30 b9 0a 48 40 f2 59 11 {
proc app_manager_launch
}
37 B5 0D 46 04 46 0D F1 02 01 01 A8 {
proc time_ms
}
; This matches some SerialConsole-related proc
; which references memory address used for serial console read buffer.
; We will use this address to store timer value.
08 B5 05 4B 1B 78 13 B9 3E 20 ?4 03 4B
00 22 C3 F8 84 20 08 BD ?4 @ {
val counter_ptr
}
; This matches beginning of watchface_button_handler proc.
; We replace "CMP R3, 4 // BEQ ret" with our code:
38 B5 43 7a 04 46 @ 04 2B 2d D0 {
B.W my_code
global continue ; and will return here if we wouldn't like to consume button :)
}
; and append our code
{
proc my_code
CMP R3, 4 ; reexecute replaced code
BEQ ret; we don't need button_up events
; R0 already saved in R4. Was: MOV R5, R0 ; save R0 as we want to use it
; check if this is first or subsequent btn press
LDR R0, counter
LDR R5, [R0] ; get old counter value
MOV R1, 0
BL time_ms
LDR R2, counter
LDR R1, [R2]
MOV.W R3, 1000
MUL R1, R3 ; convert seconds to millis
ADD R1, R0 ; now R1 contains full timestamp
; check current button
LDRB R0, [R4]
CBNZ R0, notupdate
; update counter only if this was Back btn
STR R1, [R2] ; update counter value
; check diff
notupdate:
SUB R1, R1, R5 ; calculate diff
MOV.W R3, 500 ; delay in millis
CMP R1, R3
BHI cont ; if diff is too large, pass this button to original proc
; now launch app: get its info -
; R0 holds button id, which we use as bank id,
; i.e. launch app from bank 0..3 depending on button
BL app_manager_get_bank_info
CBZ R0, ret ; if no such app, just return
LDR R0, [R0,0x10] ; get app id from bank info
BL app_manager_launch
ret: ; terminate proc
db 38 BD ; POP {R3-R5,PC}
cont: ; return to original proc and let it handle this button
MOV R0, R4 ; restore R0
B.W continue
; ---------------------------
; data block
ALIGN 4
counter: ; memory location for click counter.
DCD counter_ptr ; this should be a serial console's read buffer
}