A LCD Program

Dependencies:   TextLCD mbed Interruptpins

Revision:
3:119ffed38b29
Parent:
2:9693c1f2a4f2
--- a/main.cpp	Wed Feb 17 11:28:57 2016 +0000
+++ b/main.cpp	Wed Mar 02 15:37:47 2016 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "TextLCD.h"
+#include "Interruptpins.h"
 TextLCD lcd(D2, D3, D4, D5, D6, D7, TextLCD::LCD8x2 );
 Serial pc(SERIAL_TX, SERIAL_RX);
 DigitalOut myled(D10);
@@ -8,17 +9,19 @@
 InterruptIn mybuttontwo(PA_1);
 Timer Timerone;
 DigitalOut mynewled(A2);
-volatile long entprellZeit=250, alteZeitOne=0,alteZeitTwo=0;
+volatile long entprellZeit=250, alteZeitOne=0,alteZeitTwo=0,alteZeit=0;
 volatile int counterOne=0, counterTwo=0;
 void pressedone()
 {if((Timerone.read_ms()-alteZeitOne)>entprellZeit)
     {alteZeitOne=Timerone.read_ms();
-        lcd.cls();
+       lcd.locate(0,0);
+        lcd.printf("        ");
+        
     lcd.locate(0,0);
     counterOne++;
      if (pc.writeable()) 
         {
-    pc.printf("Counterone: %i alteZeitOne %i \n",counterOne, alteZeitOne);
+    pc.printf("1,%i, %i \n",counterOne, alteZeitOne);
   
     //delay=buffer[movingVar];
     }
@@ -30,14 +33,17 @@
 void pressedtwo()
 {if((Timerone.read_ms()-alteZeitTwo)>entprellZeit)
     {alteZeitTwo=Timerone.read_ms();
-    lcd.cls();
+    lcd.locate(0,0);
+        lcd.printf("        ");
+        //lcd.printf("new");
+        
     lcd.locate(0,0);
     //delay=buffer[movingVar];
     lcd.printf("Button 2\n");
     counterTwo++;
      if (pc.writeable()) 
         {
-    pc.printf("Countertwo: %i AlteZeitTwo %i \n",counterTwo, alteZeitTwo);
+    pc.printf("2,%i,%i \n",counterTwo, alteZeitTwo);
     }
     }
     //wait(1);
@@ -51,7 +57,7 @@
 }
 
 int main()
-{  
+{  pc.baud(115200);
     mybuttonone.fall(&pressedone);
     mybuttonone.mode(PullUp);
     Timerone.start();
@@ -62,14 +68,17 @@
     lcd.cls();
     mynewled=true;
     while(1) {
-        if(Timerone.read()>1583180)
+        alteZeit=Timerone.read_ms();
+        if(alteZeit>1000)
         {Timerone.reset();
         alteZeitOne=0;
-        alteZeitTwo=0;}
+        alteZeitTwo=0;
+        alteZeit=0;}
         if(aout.read()<0.5f) {
             myled = !myled;
         }
-        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("        ");
         //lcd.printf("new");
         lcd.locate(0,1);
         lcd.printf("ana=%1.2f", aout.read() * 3.3f);