Ljubuncic Orhan Odobasic Faris

Dependencies:   N5110 mbed

Revision:
0:6a52cbe1aa9b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 05 10:05:01 2014 +0000
@@ -0,0 +1,107 @@
+#include "mbed.h"
+#include "N5110.h"
+
+#define backspace 8
+#define del 127
+#define LF 10
+#define CR 13
+
+Serial pc(USBTX, USBRX);
+
+N5110 display(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
+
+int x(0), y(0);
+
+void obrisi()
+{
+    if(x==0 && y==0)
+    {   
+        x = 84;
+        y = 40;
+    }
+    
+    if(x==0)
+    {
+        y = y - 1;
+        x = 84;
+        
+    }
+    
+    int nx(x-6);
+    int ny(y+1);
+    
+    for(int i = x - 1;i>=nx;i--)
+    
+        for(int j = y;j<ny;j++)
+        {
+            display.setXYAddress(x,y);
+            display.clearPixel(i,j);
+        }
+    
+    
+    display.refresh();
+    x = nx;
+
+}
+
+void obrisiSve()
+{
+    display.clear();
+    display.refresh();
+    x = y = 0;
+    display.setXYAddress(0,0);
+
+}
+
+void noviRed()
+{
+    if(y==40) y = 0;
+    else y = y + 1;
+    
+    x = 0;
+    
+    display.setXYAddress(x,y);
+    
+}
+
+void ispisiKarakter(char c)
+{
+    //display.setXYAddress(0,0);
+    display.printChar(c);
+    
+    
+    x = x + 6;
+    
+    if(x==84)
+    { 
+        x = 0;
+        y = y + 8;
+    }
+
+}
+
+
+
+
+int main()
+{
+    display.init();
+    display.normalMode();
+    display.setXYAddress(0,0);
+
+    while(1)
+    {
+        char c = pc.getc();
+        
+        if(c=='-')
+            obrisi();
+        else if(c=='*')
+            obrisiSve();
+        else if(c=='+')
+            noviRed();
+         else ispisiKarakter(c);
+         
+    
+    }
+
+}