Subversion Repositories svnkaklik

Rev

Rev 6 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

#include "D:\KAKLIK\programy\PIC_C\mereni\PS2mys\PIC16F88\mys.h"

#define LCD_RS          PIN_A0      // rizeni registru LCD displeje
#define LCD_E           PIN_A1      // enable LCD displeje
#define LCD_DATA_LSB    PIN_B0      // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
#include "C:\library\CCS\lcd.c"

#define TRIGGER_PIN     PIN_B4

#DEFINE  DATA     PIN_B5      // musi byt definovan kanal DATA
#DEFINE  CLK      PIN_B6      // a taky hodiny CLK
#include "C:\library\kaklik\CCS\ps2.c"



void trigger()
{
   output_high(TRIGGER_PIN);
   delay_us(50);
   output_low(TRIGGER_PIN);
}

void main()
{
signed int16 x=0,y=0;
signed int8 hodnota,dx,dy;
unsigned int8 tl1,tl2,tl3;

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   lcd_init();
   Delay_ms(500);

   send(SET_REMOTE_MODE);

   while (true)
   {
      LCD_gotoxy(1,1);
      printf(lcd_putc,"%X X=%ld Y=%ld TL1=%U   TL2=%U TL3=%U",hodnota, x,y,tl1,tl2,tl3);
      delay_ms(20);
      send(READ_DATA);
      hodnota=read_byte();
      read_standard_byte(&dx,&dy,&tl1,&tl2,&tl3);
      x+=dx;
      y+=dy;
   }
}