Subversion Repositories svnkaklik

Rev

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

Rev Author Line No. Line
6 kaklik 1
#include "D:\KAKLIK\programy\PIC_C\mereni\PS2mys\PIC16F88\mys.h"
2
 
3
#define LCD_RS          PIN_A0      // rizeni registru LCD displeje
4
#define LCD_E           PIN_A1      // enable LCD displeje
5
#define LCD_DATA_LSB    PIN_B0      // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
6
#include "C:\library\CCS\lcd.c"
7
 
8
#define TRIGGER_PIN     PIN_B4
9
 
10
#DEFINE  DATA     PIN_B5      // musi byt definovan kanal DATA
11
#DEFINE  CLK      PIN_B6      // a taky hodiny CLK
12
#include "C:\library\kaklik\CCS\ps2.c"
13
 
14
 
15
 
16
void trigger()
17
{
18
   output_high(TRIGGER_PIN);
19
   delay_us(50);
20
   output_low(TRIGGER_PIN);
21
}
22
 
23
void main()
24
{
25
signed int16 x=0,y=0;
26
signed int8 hodnota,dx,dy;
27
unsigned int8 tl1,tl2,tl3;
28
 
29
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
30
   setup_adc(ADC_OFF);
31
   setup_spi(FALSE);
32
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
33
   setup_timer_1(T1_DISABLED);
34
   setup_timer_2(T2_DISABLED,0,1);
35
   setup_comparator(NC_NC_NC_NC);
36
   setup_vref(FALSE);
37
 
38
   lcd_init();
39
   Delay_ms(500);
40
 
41
   send(SET_REMOTE_MODE);
42
 
43
   while (true)
44
   {
45
      LCD_gotoxy(1,1);
46
      printf(lcd_putc,"%X X=%ld Y=%ld TL1=%U   TL2=%U TL3=%U",hodnota, x,y,tl1,tl2,tl3);
47
      delay_ms(20);
48
      send(READ_DATA);
49
      hodnota=read_byte();
50
      read_standard_byte(&dx,&dy,&tl1,&tl2,&tl3);
51
      x+=dx;
52
      y+=dy;
53
   }
54
}