diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-16 19:45:51 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-16 19:45:51 +0200 |
commit | 29835759655b94e7f45b68489ee14e3b4308570d (patch) | |
tree | 556235c481c64209de6a743570fa6c427a8d7439 | |
parent | Hex, removed lowbat bin (diff) | |
download | lowbat-bsd-29835759655b94e7f45b68489ee14e3b4308570d.tar.gz lowbat-bsd-29835759655b94e7f45b68489ee14e3b4308570d.tar.bz2 lowbat-bsd-29835759655b94e7f45b68489ee14e3b4308570d.tar.xz lowbat-bsd-29835759655b94e7f45b68489ee14e3b4308570d.tar.zst lowbat-bsd-29835759655b94e7f45b68489ee14e3b4308570d.zip |
Now getting percent
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | asm/jo_f_percent.asm | 29 | ||||
-rw-r--r-- | src/jo_lowbat.h | 1 | ||||
-rw-r--r-- | src/jo_main.c | 6 |
4 files changed, 36 insertions, 1 deletions
@@ -10,6 +10,7 @@ C_SRCS = ${C_SRCS_DIR}/jo_main.c C_OBJS = ${C_SRCS:.c=.o} # ------------------------------------------------------------------------------------------------ # A_SRCS = ${A_SRCS_DIR}/jo_f_status.asm +A_SRCS = ${A_SRCS_DIR}/jo_f_percent.asm # ------------------------------------------------------------------------------------------------ # A_OBJS = ${A_SRCS:.asm=.o} # ========================================== COMPILER ============================================ # diff --git a/asm/jo_f_percent.asm b/asm/jo_f_percent.asm new file mode 100644 index 0000000..765ca99 --- /dev/null +++ b/asm/jo_f_percent.asm @@ -0,0 +1,29 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; File : jo_f_percent.asm /_________/ ;; +;; Author : Joe | ;; +;; Date : 04/2020 | ;; +;; Info : gets batt remaining capacity | ;; +;; / | ;; +;; \ / ;; +;; \_____/ ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +section .text + extern system + global jo_f_percent + +jo_f_percent: + mov rdi, f_cmd + call system + retq + +err: + mov rax, 0xff + retq + + +section .data + f_cmd: db "apm -l > /tmp/lowbat.percent", 0x0 + buff: db 0x0, 0x0, 0x0, 0x0 diff --git a/src/jo_lowbat.h b/src/jo_lowbat.h index b39243e..9a3b9e3 100644 --- a/src/jo_lowbat.h +++ b/src/jo_lowbat.h @@ -22,5 +22,6 @@ enum }; int8_t jo_f_status(void); +int8_t jo_f_percent(void); #endif diff --git a/src/jo_main.c b/src/jo_main.c index e5576b3..7ee0c83 100644 --- a/src/jo_main.c +++ b/src/jo_main.c @@ -22,10 +22,14 @@ int main(void) { int8_t status; + int8_t percent; if ((status = jo_f_status()) < 0) { return (JO_RET_RD_FAILED); } - printf("status: %d\n", status); + if ((percent = jo_f_percent()) < 0) { + return (JO_RET_RD_FAILED); + } + printf("status: %hhd, %hhd%%\n", status, percent); return (JO_RET_FINE); } |