Drugi zadatak, LV3.

Dependencies:   SPI_TFT_ILI9341 TFT_fonts mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

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 
00013 
00014 SPI_TFT_ILI9341 TFT(dp2,dp1,dp6,dp24,dp23,dp25,"TFT"); // mosi, miso, sclk, cs, reset, dc
00015 AnalogIn napon(dp9);
00016 
00017 int main() {
00018     
00019     float ocitavanje;
00020     float temperatura;
00021     int hor = 20;
00022     int ver = 170 - 1833*( napon-0.06);
00023     int vrijeme = 0;
00024     
00025     TFT.claim(stdout);
00026     TFT.set_orientation(1);
00027     TFT.background(White);     
00028     TFT.foreground(Black);    
00029     TFT.cls();                
00030     
00031     TFT.line(20, 170, 230, 170, Black); //x-osa
00032     TFT.line (25, 175, 25, 50, Black); //y-osa
00033     
00034     while(1) {
00035 
00036         ocitavanje = napon;
00037         if (ocitavanje*330<temperatura)
00038         koeficijent = 1;
00039         else 
00040         koeficijent = -1;
00041         
00042         temperatura = ocitavanje * 330;
00043         
00044         //240x320
00045         
00046         
00047         TFT.set_font((unsigned char*) Arial12x12);
00048         
00049         TFT.locate(160,10);
00050         printf("Napon: %f mV",ocitavanje*3300);
00051         
00052         TFT.locate(160,38);
00053         printf("Temp: %f C",ocitavanje*330);
00054         
00055         TFT.locate(160,66);
00056         printf("Vrijeme %d:",vrijeme);
00057         
00058         if (hor==170) break;
00059          
00060          
00061         TFT.line(hor, ver, hor + 10, (170 - 1833*( ocitavanje-0.06)), Red); 
00062         
00063         TFT.fillcircle(hor+10,170 - 1833*( ocitavanje-0.06),4,Black);
00064         
00065         hor = hor + 10;
00066         
00067         ver = 170 - 1833*( ocitavanje-0.06);
00068         
00069         wait_ms(950);
00070         
00071         vrijeme++;
00072         
00073       
00074     }
00075 }
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084