Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
328 kaklik 1
#include ".\gmetr.h"
6 kaklik 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
 
7
#include "C:\library\CCS\lcd.c"
8
 
9
 
10
void main()
11
{
328 kaklik 12
signed int16 stred;
13
signed int8 hodnota;
14
unsigned int8 i, offset;
15
 
6 kaklik 16
   setup_adc_ports(ALL_ANALOG);
17
   setup_adc(ADC_CLOCK_DIV_2);
18
   setup_spi(FALSE);
19
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
20
   setup_timer_1(T1_DISABLED);
21
   setup_timer_2(T2_DISABLED,0,1);
22
 
23
   lcd_init();
24
   Delay_ms(100);
25
   set_adc_channel(1);
328 kaklik 26
 
27
   LCD_gotoxy(1,1);
28
   printf(lcd_putc,"Gmetr 0.1.2 Beta");
29
   LCD_gotoxy(1,2);
30
   printf(lcd_putc,"Kaklik@mlab.cz");
6 kaklik 31
   Delay_ms(500);
328 kaklik 32
 
33
   LCD_clr();
34
   LCD_gotoxy(1,1);
35
   printf(lcd_putc,"Clibration...");
36
 
37
   stred = 0; 
38
   for(i=0;i<=127;i++)
39
   {
40
     Delay_ms(10);
41
     stred = stred + read_adc();
42
   }
43
   stred = stred >> 7;
44
 
6 kaklik 45
   while(true)
46
   {
328 kaklik 47
      hodnota = read_adc();
48
      Delay_ms(50);
49
      LCD_clr();
50
      LCD_gotoxy(6,1);
51
      printf(lcd_putc," %03ld ",(stred - hodnota));
52
      if (hodnota > stred)
6 kaklik 53
      {
328 kaklik 54
        offset = hodnota - stred;
55
        offset = (offset >> 5) + 8;
6 kaklik 56
      }
57
      else
58
      {
328 kaklik 59
        offset = stred - hodnota;
60
        offset = offset >> 5;
6 kaklik 61
      }
328 kaklik 62
      LCD_gotoxy(offset,2);
63
      printf(lcd_putc,"*");
6 kaklik 64
   }
65
}