diff --git a/ansi_escapes.h b/ansi_escapes.h
new file mode 100644
index 0000000..ea86641
--- /dev/null
+++ b/ansi_escapes.h
@@ -0,0 +1,42 @@
+/**
+ * (C) Copyright Collin J. Doering 2015
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * File: ansi_escapes.h
+ * Author: Collin J. Doering
+ * Date: Oct 9, 2015
+ */
+
+#define CSI "\e["
+
+#define CUU(n) CSI #n "A" // Cursor up
+#define CUD(n) CSI #n "B" // Cursor down
+#define CUF(n) CSI #n "C" // Cursor forward
+#define CUB(n) CSI #n "D" // Cursor backward
+
+#define CNL(n) CSI #n "E" // Cursor next line
+#define CPL(n) CSI #n "F" // Cursor previous line
+
+#define CHA(n) CSI #n "G" // Cursor horizontal absolute
+#define CUP(n,m) CSI #n ";" #m "H" // Cursor position
+
+#define ED(n) CSI #n "J" // Erase display
+#define EL(n) CSI #n "K" // Erase in line
+#define SU(n) CSI #n "S" // Scroll up
+#define SD(n) CSI #n "T" // Scroll down
+
+#define HVP(n,m) CSI #n ";" #m "f" // Horizontal and vertical position
diff --git a/lcdOutput.c b/lcdOutput.c
index 85e5f0f..53a6240 100644
--- a/lcdOutput.c
+++ b/lcdOutput.c
@@ -31,6 +31,7 @@
#include
#include "lcdLib.h"
+#include "ansi_escapes.h"
#include "USART.h"
int main(void) {
@@ -50,17 +51,17 @@ int main(void) {
switch (serialChar) {
case '\r':
writeStringToLCD("\r\n");
- transmitString("\n\e[1E\r");
+ transmitString("\n" CNL(1) "\r");
break;
;
case '\f':
writeCharToLCD(serialChar);
- transmitString("\e[2J\e[1;1H");
+ transmitString(ED(2) CUP(1,1));
break;
;
case 0x7f: // Backspace (sent as delete)
writeStringToLCD("\b \b");
- transmitString("\e[1D \e[1D");
+ transmitString(CUB(1) " " CUB(1));
break;
;
default: