Rev Author Line No. Line
157 pavlicek 1 #include "C:\RS\Lux10brf\main.h"
2  
3 #define LCD_RS PIN_B1 // rizeni registru LCD displeje
4 #define LCD_E PIN_B0 // enable LCD displeje
5 #define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
6 #define LUX1 PIN_B2
7 #define LUX2 PIN_B3
8 #define LUX3 PIN_B4
9 #define LUX4 PIN_B5
10 #define HOLD PIN_B6
11 #define IN 0
12 #include "lcd.c"
13  
14 void main()
15 {
16 unsigned int16 I;
17 float E;
18  
19 port_b_pullups(TRUE);
20 setup_adc_ports(AN0_VREF_VREF);
21 setup_adc(ADC_CLOCK_DIV_32);
22 setup_psp(PSP_DISABLED);
23 setup_spi(SPI_SS_DISABLED);
24 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
25 setup_timer_1(T1_DISABLED);
26 setup_timer_2(T2_DISABLED,0,1);
27 setup_comparator(NC_NC_NC_NC);
28 setup_vref(FALSE);
29  
30 set_adc_channel (IN);
31 delay_us(20);
32 lcd_init();
33  
34 while(TRUE)
35 {
36 I=read_adc();
37 delay_us(600);
38 E=0.019531*I;
39 if(!input(LUX1))
40 {
41 printf(lcd_putc," E=%4.2f lx \n",E);
42 printf(lcd_putc," rozsah 1\n\r");
43 delay_ms(300);
44 }
45 if(!input(LUX2))
46 {
47 printf(lcd_putc," E=%3.1f lx \n",10*E);
48 printf(lcd_putc," rozsah 2\n\r");
49 delay_ms(300);
50 }
51 if(!input(LUX3))
52 {
53 printf(lcd_putc," E=%4.0f lx \n",100*E);
54 printf(lcd_putc," rozsah 3\n\r");
55 delay_ms(300);
56 }
57 if(!input(LUX4))
58 {
59 printf(lcd_putc," E=%3.1f klx \n",E);
60 printf(lcd_putc," rozsah 4\n\r");
61 delay_ms(300);
62 }
63 //while(!input(HOLD));
64 }
65 }