Amina Puce Muhamed Parić Benjamin Ramić

Dependencies:   SPI_TFT_ILI9341 TFT_fonts mbed

Fork of US2016_LV3_Z2 by Emir Sokic

main.cpp

Committer:
2016US_BenjaminRamic
Date:
2016-03-28
Revision:
1:408418a8264f
Parent:
0:393e8184af1a

File content as of revision 1:408418a8264f:

#include "mbed.h"
#define dp23 P0_0


#include "stdio.h"
#include "SPI_TFT_ILI9341.h"
#include "string"
#include "Arial12x12.h"
#include "Arial24x23.h"
#include "Arial28x28.h"
#include "font_big.h"
//#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(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) {
        
        
        printf("Mi volimo US!");

        wait(2);
        //Crtanje linija
        TFT.line(0,0,100,0,Green);
        TFT.line(0,0,0,200,Green);
        TFT.line(0,0,100,200,Green);

        //Crtanje dijagrama piksel po poksel
        double s;
        for (i=0; i<320; i++) {
            s =20 * sin((long double) i / 10 );
            TFT.pixel(i,100 + (int)s ,Red);
        }

        wait(2);
        TFT.cls();

    }*/
}