diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-17 17:15:51 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-17 17:15:51 +0200 |
commit | d78062b1643006c59e325d4821361e56d9bd3b71 (patch) | |
tree | 79b233e0ab801b7bb9d64be526157d27b7abe301 | |
parent | Using libespeak and libnotify (diff) | |
download | lowbat-bsd-d78062b1643006c59e325d4821361e56d9bd3b71.tar.gz lowbat-bsd-d78062b1643006c59e325d4821361e56d9bd3b71.tar.bz2 lowbat-bsd-d78062b1643006c59e325d4821361e56d9bd3b71.tar.xz lowbat-bsd-d78062b1643006c59e325d4821361e56d9bd3b71.tar.zst lowbat-bsd-d78062b1643006c59e325d4821361e56d9bd3b71.zip |
Starting the main program, bus error somehow
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | asm/jo_f_percent.asm | 2 | ||||
-rw-r--r-- | asm/jo_f_status.asm | 2 | ||||
-rw-r--r-- | asm/jo_r_lowbat.asm | 27 | ||||
-rw-r--r-- | src/jo_lowbat.c | 22 | ||||
-rw-r--r-- | src/jo_lowbat.h | 4 | ||||
-rw-r--r-- | src/jo_n_notify.h | 10 | ||||
-rw-r--r-- | src/jo_n_speak.c | 6 | ||||
-rw-r--r-- | src/jo_n_speak.h | 1 |
9 files changed, 50 insertions, 30 deletions
@@ -21,7 +21,8 @@ C_SRCS += ${C_SRCS_DIR}/jo_n_notify.c # -------------------------------------------------------------------------------------- # C_OBJS = ${C_SRCS:.c=.o} # -------------------------------------------------------------------------------------- # -A_SRCS = ${A_SRCS_DIR}/jo_f_status.asm +A_SRCS = ${A_SRCS_DIR}/jo_r_lowbat.asm +A_SRCS += ${A_SRCS_DIR}/jo_f_status.asm A_SRCS += ${A_SRCS_DIR}/jo_f_percent.asm # -------------------------------------------------------------------------------------- # A_OBJS = ${A_SRCS:.asm=.o} @@ -53,6 +54,7 @@ CINCS += -I/usr/local/lib/glib-2.0/include CINCS += -I/usr/local/include/gdk-pixbuf-2.0 # -------------------------------------------------------------------------------------- # LINK = -L/usr/local/lib +LINK += -L/usr/lib LINK += -lnotify LINK += -lespeak LINK += -lc @@ -80,7 +82,7 @@ SED = sed ${CC} -c ${CFLAGS} ${CINCS} -o ${.TARGET} ${.IMPSRC} # -------------------------------------------------------------------------------------- # ${TARGET}: ${A_OBJS} ${C_OBJS} - ${CC} ${CFLAGS} ${CINCS} -o ${.TARGET} ${.ALLSRC} ${LINK} + ${CC} ${CFLAGS} ${CINCS} -o ${.TARGET} ${A_OBJS} ${C_OBJS} ${LINK} # -------------------------------------------------------------------------------------- # depend: ${CC} ${CINCS} -E -MM ${C_SRCS} > .depend diff --git a/asm/jo_f_percent.asm b/asm/jo_f_percent.asm index 76d792b..6ce918b 100644 --- a/asm/jo_f_percent.asm +++ b/asm/jo_f_percent.asm @@ -3,7 +3,7 @@ ;; File : jo_f_percent.asm /_________/ ;; ;; Author : Joe | ;; ;; Date : 04/2020 | ;; -;; Info : gets batt remaining capacity | ;; +;; Info : Gets batt remaining capacity | ;; ;; / | ;; ;; \ / ;; ;; \_____/ ;; diff --git a/asm/jo_f_status.asm b/asm/jo_f_status.asm index 326f58e..723df0b 100644 --- a/asm/jo_f_status.asm +++ b/asm/jo_f_status.asm @@ -3,7 +3,7 @@ ;; File : jo_f_status.asm /_________/ ;; ;; Author : Joe | ;; ;; Date : 04/2020 | ;; -;; Info : gets batt status | ;; +;; Info : Gets batt status | ;; ;; / | ;; ;; \ / ;; ;; \_____/ ;; diff --git a/asm/jo_r_lowbat.asm b/asm/jo_r_lowbat.asm new file mode 100644 index 0000000..42863b4 --- /dev/null +++ b/asm/jo_r_lowbat.asm @@ -0,0 +1,27 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; File : jo_r_lowbat.asm /_________/ ;; +;; Author : Joe | ;; +;; Date : 04/2020 | ;; +;; Info : The main program | ;; +;; / | ;; +;; \ / ;; +;; \_____/ ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +section .text + extern sleep + extern jo_n_speak + global jo_r_lowbat + +jo_r_lowbat: + mov rdi, 0x2 + call sleep + mov rdi, msg + call jo_n_speak + xor rax, rax + retq + +section .data + msg: db "Welcome back, partner", 0x0 diff --git a/src/jo_lowbat.c b/src/jo_lowbat.c index da7c575..b6ee68c 100644 --- a/src/jo_lowbat.c +++ b/src/jo_lowbat.c @@ -18,28 +18,14 @@ ** -------------- ** f: fetch ** n: notify +** r: run */ int main( - int argc, - const char *argv[] + int argc, + char *argv[] ) { - int8_t status; - int8_t percent; - - (void)argc; - (void)argv; - if ((status = jo_f_status()) == -2) { - return (JO_RET_RD_FAILED); - } - if ((percent = jo_f_percent()) == -3) { - return (JO_RET_RD_FAILED); - } - printf("status: %hhd, %hhd%%\n", status, percent); - /* NOTIFY-SEND */ - jo_n_notify("VEGA: Yo", "Welcome", NOTIFY_URGENCY_LOW, 5000); - jo_n_speak("Heya!"); - return (JO_RET_FINE); + return (jo_r_lowbat(argc, argv)); } diff --git a/src/jo_lowbat.h b/src/jo_lowbat.h index 9e1fa7f..c4f3c37 100644 --- a/src/jo_lowbat.h +++ b/src/jo_lowbat.h @@ -27,6 +27,10 @@ enum JO_RET_RD_FAILED }; +int8_t jo_r_lowbat( + int, + char** + ); int8_t jo_f_status(void); int8_t jo_f_percent(void); diff --git a/src/jo_n_notify.h b/src/jo_n_notify.h index 7011baa..0bf7ca1 100644 --- a/src/jo_n_notify.h +++ b/src/jo_n_notify.h @@ -18,10 +18,10 @@ #include <stdint.h> void jo_n_notify( - const char[], - const char[], - NotifyUrgency, - int32_t - ); + const char[], + const char[], + NotifyUrgency, + int32_t + ); #endif diff --git a/src/jo_n_speak.c b/src/jo_n_speak.c index 4db4113..5fc935e 100644 --- a/src/jo_n_speak.c +++ b/src/jo_n_speak.c @@ -15,15 +15,15 @@ void jo_n_speak(const char *msg) { - espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, 0x0, 0); + espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0); espeak_Synth(msg, strlen(msg), 0, POS_CHARACTER, 0, espeakCHARS_UTF8 | espeakENDPAUSE, - 0x0, - 0x0); + NULL, + NULL); espeak_Synchronize(); espeak_Terminate(); } diff --git a/src/jo_n_speak.h b/src/jo_n_speak.h index 36dced4..c0eb40f 100644 --- a/src/jo_n_speak.h +++ b/src/jo_n_speak.h @@ -15,6 +15,7 @@ #include <espeak/speak_lib.h> #include <string.h> +#include <stddef.h> void jo_n_speak(const char *); |