aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-18 19:02:15 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-18 19:02:15 +0200
commitc6ec965f46c5c322c9cf5a0d3369241a24cca92a (patch)
treef16669c37c348288b9f0dc9e8e3c8c1ae137bf50
parentBetter (diff)
downloadlowbat-bsd-c6ec965f46c5c322c9cf5a0d3369241a24cca92a.tar.gz
lowbat-bsd-c6ec965f46c5c322c9cf5a0d3369241a24cca92a.tar.bz2
lowbat-bsd-c6ec965f46c5c322c9cf5a0d3369241a24cca92a.tar.xz
lowbat-bsd-c6ec965f46c5c322c9cf5a0d3369241a24cca92a.tar.zst
lowbat-bsd-c6ec965f46c5c322c9cf5a0d3369241a24cca92a.zip
Something is not quite right
-rw-r--r--asm/jo_r_loop.asm41
1 files changed, 32 insertions, 9 deletions
diff --git a/asm/jo_r_loop.asm b/asm/jo_r_loop.asm
index a917f2f..43cbc8a 100644
--- a/asm/jo_r_loop.asm
+++ b/asm/jo_r_loop.asm
@@ -15,7 +15,9 @@
section .text
extern sleep
+ extern memset
extern sprintf
+ extern dprintf
extern jo_f_percent
extern jo_f_status
extern jo_n_speak
@@ -28,27 +30,36 @@ jo_r_loop:
mov rbx, rsi
mov ebp, edi
jmp bigloop
-
bigloop:
call jo_f_status
+ cmp rax, 0xfe ; in case we couldn't read
+ je err
cmp rax, 0x3
je sleepalot
call jo_f_percent
- cmp rax, 0xf ; 15%
+ cmp rax, 0xfe ; in case we couldn't read
+ je err
+ ;; cmp rax, 0xf ; 15%
+ cmp rax, 60; 15%
jge sleepalot
- xor rdi, rdi
- mov rsi, n_head
+ mov rdi, buff
+ mov rsi, 0x0
+ mov rdx, 17
+ call memset
+ lea rsi, [rel n_head]
mov rdx, rax
- call sprintf
- mov rdi, rsi ; notification head sprintfed
+ call sprintf ; get notification head via sprintf
+ mov rsi, rdi
+ mov rdi, 0x1
+ call dprintf
mov rsi, n_body ; notification body
mov rdx, 0x3 ; ciritcal notification
mov rcx, 0x3a98 ; 15000ms notification timeout
call jo_n_notify ; jo_n_notify(rdi, rsi, rdx, rcx)
speak:
- cmp ebp, 1
+ cmp ebp, 0x1
jne sleepabit
mov rdi, [rbx + 0x8 * 0x2]
call jo_n_speak
@@ -59,7 +70,8 @@ sleepabit:
jmp bigloop
sleepalot:
- mov rdi, 0xf0 ; 240s
+ ;; mov rdi, 0xf0 ; 240s
+ mov rdi, 40 ; 240s
call sleep
jmp bigloop
@@ -67,6 +79,17 @@ return:
xor rax, rax
retq
+err:
+ mov rdi, 0x2 ; stderr
+ lea rsi, [rel errmsg]
+ call dprintf
+ mov rax, 0x1
+ retq
+
section .data
- n_head: db "Low battery: %d", 0x0
+ n_head: db "Low battery: %d%%", 0x0
n_body: db "Please plug in computer", 0x0
+ errmsg: db "Failed to read battery informations", 0xa, 0x0
+
+section .bss
+ buff: resb 17