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 mìøení teploty |
|
|
13 |
#include "ds1820.c" //pro mìøení teploty |
|
|
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 |
// TODO: USER CODE!! |
|
|
34 |
|
|
|
35 |
while(true) |
|
|
36 |
{ |
|
|
37 |
temperature = ds1820_read(); //naètení teploty z èidla |
|
|
38 |
|
|
|
39 |
a = 0.10850694; //konstantak pro tlak |
|
|
40 |
t = read_adc(); //za t dosazení hodnoty z a/d pro tlak |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
lcd_init(); //inicializuje LCD |
|
|
45 |
LCD_gotoxy(1,1); //na LCD 1bunka 1øadek |
|
|
46 |
printf(lcd_putc,"Temp: %5.3f°C ", temperature); //teplota v °C |
|
|
47 |
|
|
|
48 |
LCD_gotoxy(1,2); //na LCD 1bunka 2øadek |
|
|
49 |
printf(lcd_putc,"Tlak: %5.3fkPa", ((t-41)*a)+15 ); //tiska tlaku v kPa |
|
|
50 |
|
|
|
51 |
Delay_ms(100); |
|
|
52 |
} |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
} |