summaryrefslogtreecommitdiff
path: root/c/menu/digilines.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/menu/digilines.c')
-rw-r--r--c/menu/digilines.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/c/menu/digilines.c b/c/menu/digilines.c
new file mode 100644
index 0000000..620d61f
--- /dev/null
+++ b/c/menu/digilines.c
@@ -0,0 +1,66 @@
+/* Menu Thing for RVController - Digilines
+ * A product of Advanced Mesecons Devices, a Cheapie Systems company
+ * This is free and unencumbered software released into the public domain.
+ * See http://unlicense.org/ for more information */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "rvcontroller-ecalls.h"
+
+char dispbuf[] = "\nLast channel:\n(none) \nLast message:\n(none) \ns: Send\nq: Quit";
+
+void dispWrite(char *text,int pos) {
+ int outpos;
+ for (int i=0;;i++) {
+ if (text[i] == 0) { break; }
+ outpos = pos + i;
+ dispbuf[outpos] = text[i];
+ }
+}
+
+void sendUI(void) {
+ char channeloutbuf[19];
+ char msgoutbuf[19];
+ printstr("\n\n\n\n\nEnter channel:\n> ");
+ readstr(channeloutbuf,19);
+ printstr(channeloutbuf);
+ printstr("\nEnter message:\n> ");
+ readstr(msgoutbuf,19);
+ printstr(msgoutbuf);
+ digiline_send(channeloutbuf,msgoutbuf);
+ printstr("\nSent!\nPress any key");
+ readstr(channeloutbuf,1);
+}
+
+void runDigilines(void) {
+ char channelinbuf[21];
+ char msginbuf[21];
+ char kbinput;
+ bool quit = false;
+
+ console_clearbuffer();
+ digiline_clearbuffer();
+ dispWrite("(none) ",15);
+ dispWrite("(none) ",50);
+
+ while (!quit) {
+ if (digiline_bufferlevel() > 0) {
+ digiline_receive(channelinbuf,21,msginbuf,21);
+ dispWrite(" ",15);
+ dispWrite(" ",50);
+ dispWrite(channelinbuf,15);
+ dispWrite(msginbuf,50);
+ }
+ printstr(dispbuf);
+
+ kbinput = console_readchar();
+ switch (kbinput) {
+ case 's':
+ sendUI();
+ break;
+ case 'q':
+ quit = true;
+ break;
+ }
+ }
+}