Amina Puce Muhamed Parić Benjamin Ramić
Dependencies: SPI_TFT_ILI9341 TFT_fonts mbed
Fork of US2016_LV3_Z2 by
main.cpp
00001 #include "mbed.h" 00002 #define dp23 P0_0 00003 00004 00005 #include "stdio.h" 00006 #include "SPI_TFT_ILI9341.h" 00007 #include "string" 00008 #include "Arial12x12.h" 00009 #include "Arial24x23.h" 00010 #include "Arial28x28.h" 00011 #include "font_big.h" 00012 //#include "SDFileSystem.h" 00013 00014 SPI_TFT_ILI9341 TFT(dp2,dp1,dp6,dp24,dp23,dp25,"TFT"); // mosi, miso, sclk, cs, reset, dc 00015 InterruptIn startDugme(dp4);//, resetDugme(dp2); //tasteri za start i reset 00016 float ocitajVrijeme(0); 00017 Ticker tikerIspis; 00018 Timer timer, timer1, timer2; 00019 bool pokrenuta(false); 00020 int indeks = 0; 00021 00022 void ispisNaEkran() //ispis cifara 00023 { 00024 TFT.fillrect(0, 0, 160, 30, Cyan); 00025 TFT.locate(10, 10); 00026 ocitajVrijeme = timer.read(); //ocitava se vrijeme u sekundama 00027 printf("%.1f s", ocitajVrijeme); 00028 } 00029 00030 void startStop() 00031 { 00032 if(timer1.read_ms() > 200) 00033 { 00034 if(pokrenuta) timer.stop(); 00035 else timer.start(); 00036 pokrenuta = !pokrenuta; 00037 } 00038 timer1.reset(); 00039 } 00040 00041 void resetuj() 00042 { 00043 if(timer2.read_ms() > 200) 00044 { 00045 pokrenuta = false; 00046 timer.reset(); 00047 timer.stop(); 00048 } 00049 timer2.reset(); 00050 } 00051 00052 int main() 00053 { 00054 int i=0; 00055 //Inicijalizacija; 00056 TFT.claim(stdout); 00057 TFT.set_orientation(3); 00058 TFT.background(Cyan); // set background to black 00059 TFT.foreground(Black); // set chars to white 00060 TFT.cls(); // clear the screen 00061 TFT.set_font((unsigned char*) Arial28x28); 00062 TFT.locate(10,10); 00063 00064 TFT.locate(120, 120); 00065 printf("Benjamin"); 00066 TFT.locate(120, 160); 00067 printf("Muhamed"); 00068 TFT.locate(120, 200); 00069 TFT.foreground(Red); 00070 printf("Amina"); 00071 TFT.foreground(Black); 00072 timer.start(); 00073 timer1.start(); 00074 timer2.start(); 00075 00076 startDugme.rise(&startStop); 00077 //resetDugme.rise(&resetuj); 00078 tikerIspis.attach(&ispisNaEkran, 0.1); 00079 00080 while(1) 00081 { 00082 } 00083 00084 /*while(1) { 00085 00086 00087 printf("Mi volimo US!"); 00088 00089 wait(2); 00090 //Crtanje linija 00091 TFT.line(0,0,100,0,Green); 00092 TFT.line(0,0,0,200,Green); 00093 TFT.line(0,0,100,200,Green); 00094 00095 //Crtanje dijagrama piksel po poksel 00096 double s; 00097 for (i=0; i<320; i++) { 00098 s =20 * sin((long double) i / 10 ); 00099 TFT.pixel(i,100 + (int)s ,Red); 00100 } 00101 00102 wait(2); 00103 TFT.cls(); 00104 00105 }*/ 00106 } 00107 00108 00109
Generated on Sun Jul 24 2022 03:44:46 by 1.7.2