aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--asm/jo_f_percent.asm29
-rw-r--r--src/jo_lowbat.h1
-rw-r--r--src/jo_main.c6
4 files changed, 36 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 27c8b92..206a3f7 100644
--- a/Makefile
+++ b/Makefile
@@ -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);
}