131 |
pavlicek |
1 |
#include "C:\RS\Lux10b\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 IN 0 |
|
|
7 |
#include "lcd.c" |
|
|
8 |
|
|
|
9 |
void main() |
|
|
10 |
{ |
|
|
11 |
unsigned int16 I; |
|
|
12 |
float E; |
|
|
13 |
|
|
|
14 |
setup_adc_ports(AN0); |
|
|
15 |
setup_adc(ADC_CLOCK_DIV_32); |
|
|
16 |
setup_psp(PSP_DISABLED); |
|
|
17 |
setup_spi(SPI_SS_DISABLED); |
|
|
18 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
19 |
setup_timer_1(T1_DISABLED); |
|
|
20 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
21 |
setup_comparator(NC_NC_NC_NC); |
|
|
22 |
setup_vref(FALSE); |
|
|
23 |
|
|
|
24 |
set_adc_channel (IN); |
|
|
25 |
delay_us(20); |
|
|
26 |
lcd_init(); |
|
|
27 |
|
|
|
28 |
while(TRUE) |
|
|
29 |
{ |
|
|
30 |
|
|
|
31 |
I=read_adc(); |
|
|
32 |
delay_us(600); |
|
|
33 |
E=0.0577*I; |
|
|
34 |
|
|
|
35 |
printf(lcd_putc," E=%3.2f lx \n",E); |
|
|
36 |
if(I<=128) |
|
|
37 |
printf(lcd_putc,"** \r"); |
|
|
38 |
if(I>128&&I<=256) |
|
|
39 |
printf(lcd_putc,"**** \r"); |
|
|
40 |
if(I>256&&I<=384) |
|
|
41 |
printf(lcd_putc,"****** \r"); |
|
|
42 |
if(I>384&&I<=512) |
|
|
43 |
printf(lcd_putc,"******** \r"); |
|
|
44 |
if(I>512&&I<=640) |
|
|
45 |
printf(lcd_putc,"********** \r"); |
|
|
46 |
if(I>640&&I<=768) |
|
|
47 |
printf(lcd_putc,"************ \r"); |
|
|
48 |
if(I>768&&I<=896) |
|
|
49 |
printf(lcd_putc,"************** \r"); |
|
|
50 |
if(I>896&&I<=1016) |
|
|
51 |
printf(lcd_putc,"****************\r"); |
|
|
52 |
if(I>1016) |
|
|
53 |
printf(lcd_putc," *** high *** \r"); |
|
|
54 |
|
|
|
55 |
delay_ms(600); |
|
|
56 |
} |
|
|
57 |
} |