-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBatteryLevelDigits_210_v1.pbp
82 lines (78 loc) · 1.87 KB
/
BatteryLevelDigits_210_v1.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
; Always display current battery level in statusbar.
;
; Note that this patch might slightly increase battery consumption
; (though not much more than regular watchface/app showing battery state).
#ver 210 219
00 BF ?4 ?4 @
1F B5 ?4 8D F8 00 00 C0 F3 07 23 C0 F3 07 40
8D F8 02 00 8D F8 01 30 00 9B 00 20 {
proc battery_state_service_peek
}
0C B4 7F B5 08 9A 05 46 {
proc snprintf
}
F8 B5 00 AF 04 46 {
proc fonts_get_system_font
}
82 B0 F0 B5 0E 46 91 B0 {
proc graphics_draw_text
}
"RESOURCE_ID_GOTHIC_14" 00 {
proc res_id_gothic_14
}
; This matches middle of status_bar_draw procedure,
; the part responsible for determining desired
; battery level icon and drawing it if needed.
;
; prev: launch custom drawing proc if needed
2B 68 73 B1 20 46 00 21 ?4 14 4B 20 46
19 68 06 22 8D 23 ?4 C0 F1 88 00
05 46 00 E0 8D 25
; next: BL is_vibro_disabled
{
B.W my_code
; Skip unneeded now code to position label correctly
DCB "SkipSkipSkipSkipSkipSkipSkipSkip"
global continue
}
; Place our code to floating block
{
proc my_code
BL battery_state_service_peek ; FIXME: doing this at every redraw might be power-consuming?
; now R0 contains a BatteryChargeState structure:
; 00 . is_plugged . is_charging . percent
UXTB R0, R0 ; just throw away charging info for now
MOV R3, R0
ADD R0, SP,16
MOV R1, 5 ; buffer size
ADR R2, format
BL snprintf
; now we have complete "nn%" string at [SP+12]
LDR R0, fontname
BL fonts_get_system_font
MOV R2, R0 ; font
MOV R0, 0
STR R0, [SP,4] ; overflow_mode
STR R0, [SP,8] ; alignment
STR R0, [SP,12] ; layout
MOV R0, R4 ; ctx
ADD R1, SP,16 ; text
LDR R3, rect_b
STR R3, [SP] ; box_2
LDR R3, rect_a ; box_1
BL graphics_draw_text
MOV R5, 128 ; hold that space from other icons
B.W continue
; data block
ALIGN 4
rect_a:
DCW 130 ; x
DCW 0xFFFF ; y
rect_b:
DCW 14 ; w
DCW 16 ; h
fontname:
DCD res_id_gothic_14
format:
DCB "%d" 00
}