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"		// modul pro ovladani LCD
7
 
8
#define TRIGGER_PIN     PIN_B4
9
 
10
#DEFINE  DATA     PIN_B5      // drat DATA
11
#DEFINE  CLK      PIN_B6      // hodiny CLK
12
#include "C:\library\kaklik\CCS\ps2.c"		// modul pro SW ovladani PS2
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(200);
40
   ps2send(RESET);   // resetuje mys
41
   read_byte();      // prijme 0xFA
42
   read_byte();      // 0xAA self-test passed
43
   read_byte();      // mouse ID
44
   Delay_ms(200);
45
   ps2send(SET_REMOTE_MODE);
46
 
47
   while (true)
48
   {
49
      LCD_gotoxy(1,1);
50
      printf(lcd_putc,"%X X=%ld Y=%ld TL1=%U   TL2=%U TL3=%U",hodnota, x,y,tl1,tl2,tl3);
51
      delay_ms(20);
52
      send(READ_DATA);
53
      hodnota=read_byte();
54
      read_standard_byte(&dx,&dy,&tl1,&tl2,&tl3);
55
      x+=dx;
56
      y+=dy;
57
   }
58
}