Elma Kusundzija Amela Spica

Dependencies:   N5110 mbed

Revision:
0:91269f323f72
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 08 14:04:36 2014 +0000
@@ -0,0 +1,97 @@
+#include "mbed.h"
+#include "N5110.h"
+
+Serial pc(USBTX, USBRX); 
+N5110 display(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
+int x=0;
+int y=0;
+
+void ispisi(char znak)
+{
+    display.printChar(znak);
+    x = x + 6;
+    if(x==84 && y==6)return;
+    if(x==84)
+    { 
+        x = 0;
+        y = y + 1;
+    }
+    display.setXYAddress(x,y);
+}
+void backspace()
+{
+    if(x==0 && y==0)
+    {   
+        /*x = 84;
+        y = 40;*/
+        return;
+    }
+    else if(x==0)
+    {
+        y = y - 1;
+        x = 78;
+    display.setXYAddress(x,y); 
+    ispisi(' ');
+    x=x-6;
+    display.setXYAddress(x,y);
+        
+    }
+    else if(x==78)
+    {
+        x=x-6;
+        display.setXYAddress(x,y); 
+    ispisi(' ');
+    x=x-6;
+    display.setXYAddress(x,y);
+        }
+    else
+    {x=x-6;
+    display.setXYAddress(x,y); 
+    ispisi(' ');
+    x=x-6;
+    display.setXYAddress(x,y);
+       
+    }
+    /*display.setXYAddress(x,y); 
+    ispisi(' ');
+    if(x==0){
+        y=y-1;
+        x=84;}
+   else {x=x-6;}
+    display.setXYAddress(x,y);*/
+    
+}
+void DeleteAll()
+{
+    display.clear();
+    display.refresh();
+    x = y = 0;
+    display.setXYAddress(x,y);
+}
+void Enter()
+{
+    if(y==40) return;
+    else y = y + 1;
+    x = 0;
+    display.setXYAddress(x,y);
+    
+}
+int main()
+{
+    display.init();
+    display.normalMode();
+    display.setXYAddress(0,0);
+ 
+    while(1)
+    {
+        char znak = pc.getc();
+        if(znak==',')
+            backspace();
+        else if(znak=='.')
+            DeleteAll();
+        else if(znak=='-')
+            Enter();
+         else ispisi(znak);
+    }
+ 
+}