Rev Author Line No. Line
171 chroust 1 #include "C:\Rs\zdrojáky\projekt\Posledni\main.h"
2  
3 #define LCD_RS PIN_C7 // rizeni registru LCD displeje <lcd.c>
4 #define LCD_E PIN_B7 // enable LCD displeje <lcd.c>
5 #define LCD_D0 PIN_B3 // data LCD <lcd.c>
6 #define LCD_D1 PIN_B2
7 #define LCD_D2 PIN_B1
8 #define LCD_D3 PIN_B0
9  
10 #include "LCD.C" //pro LCD
11  
12 #include "1wire.c" //pro komunikaci se sbìrnicí
13 #include "ds1820.c" //pro definici èidla
14  
15 void main()
16 {
17  
18 double t; // promena pro hodnotu z A/D pro tlak
19 double a; // konstanta pro vypocet tlaku
20  
21 float temperature; //pro mìøení teploty
22  
23 setup_adc_ports(AN0);
24 setup_adc(ADC_CLOCK_INTERNAL);
25 setup_psp(PSP_DISABLED);
26 setup_spi(SPI_SS_DISABLED);
27 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
28 setup_timer_1(T1_DISABLED);
29 setup_timer_2(T2_DISABLED,0,1);
30 setup_comparator(NC_NC_NC_NC);
31 setup_vref(FALSE);
32  
33  
34 while(true)
35 {
36 temperature = ds1820_read(); //naètení teploty z èidla
37  
38 a = 0.10850694; //konstantak pro tlak
39 t = read_adc(); //za t dosazení hodnoty z a/d pro tlak
40  
41  
42  
43 lcd_init(); //inicializuje LCD
44 LCD_gotoxy(1,1); //na LCD 1bunka 1øadek
45 printf(lcd_putc,"Temp: %5.1f°C ", temperature); //teplota v °C
46  
47 LCD_gotoxy(1,2); //na LCD 1bunka 2øadek
48 printf(lcd_putc,"Tlak: %5.3fkPa", ((t-41)*a)+15 ); //tiska tlaku v kPa
49  
50 Delay_ms(100);
51 }
52 }