Amina Puce Muhamed Parić Benjamin Ramić

Dependencies:   SPI_TFT_ILI9341 TFT_fonts mbed

Fork of US2016_LV3_Z2 by Emir Sokic

Files at this revision

API Documentation at this revision

Comitter:
2016US_BenjaminRamic
Date:
Mon Mar 28 23:09:18 2016 +0000
Parent:
0:393e8184af1a
Commit message:
LV3_US_Grupa8_Tim3

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Mar 09 09:14:00 2016 +0000
+++ b/main.cpp	Mon Mar 28 23:09:18 2016 +0000
@@ -12,20 +12,78 @@
 //#include "SDFileSystem.h"
 
 SPI_TFT_ILI9341 TFT(dp2,dp1,dp6,dp24,dp23,dp25,"TFT"); // mosi, miso, sclk, cs, reset, dc
+InterruptIn startDugme(dp4);//, resetDugme(dp2); //tasteri za start i reset
+float ocitajVrijeme(0);
+Ticker tikerIspis;
+Timer timer, timer1, timer2;
+bool pokrenuta(false);
+int indeks = 0;
+
+void ispisNaEkran() //ispis cifara
+{
+    TFT.fillrect(0, 0, 160, 30, Cyan);
+    TFT.locate(10, 10);
+    ocitajVrijeme = timer.read(); //ocitava se vrijeme u sekundama
+    printf("%.1f s", ocitajVrijeme);
+}
+
+void startStop()
+{
+    if(timer1.read_ms() > 200)
+    {
+        if(pokrenuta) timer.stop();
+        else timer.start();
+        pokrenuta = !pokrenuta;
+    }
+    timer1.reset();
+}
+
+void resetuj()
+{
+    if(timer2.read_ms() > 200)
+    {
+        pokrenuta = false;
+        timer.reset();
+        timer.stop();
+    }
+    timer2.reset();
+}
 
 int main()
 {
     int i=0;
     //Inicijalizacija;
     TFT.claim(stdout);
-    TFT.set_orientation(1);
-    TFT.background(Blue);     // set background to black
-    TFT.foreground(White);    // set chars to white
+    TFT.set_orientation(3);
+    TFT.background(Cyan);     // set background to black
+    TFT.foreground(Black);    // set chars to white
     TFT.cls();                // clear the screen
+    TFT.set_font((unsigned char*) Arial28x28);
+    TFT.locate(10,10);
+    
+    TFT.locate(120, 120);
+    printf("Benjamin");
+    TFT.locate(120, 160);
+    printf("Muhamed");
+    TFT.locate(120, 200);
+    TFT.foreground(Red);
+    printf("Amina");
+    TFT.foreground(Black);
+    timer.start();
+    timer1.start();
+    timer2.start();
+    
+    startDugme.rise(&startStop);
+    //resetDugme.rise(&resetuj);
+    tikerIspis.attach(&ispisNaEkran, 0.1);
+   
+    while(1)
+    {
+    }
 
-    while(1) {
-        TFT.set_font((unsigned char*) Arial28x28);
-        TFT.locate(10,10);
+    /*while(1) {
+        
+        
         printf("Mi volimo US!");
 
         wait(2);
@@ -44,7 +102,7 @@
         wait(2);
         TFT.cls();
 
-    }
+    }*/
 }