Subversion Repositories svnkaklik

Rev

Rev 149 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 149 Rev 150
Line 1... Line 1...
1
#include ".\camerus.h"
1
#include ".\camerus.h"
2
 
2
 
3
#USE FAST_IO (C)
3
#USE FAST_IO (C)
4
 
4
 
-
 
5
// kroutitka
-
 
6
#define  CERVENA  1  // AN1
-
 
7
#define  CERNA    4  // AN4
-
 
8
#define  ZELENA   3  // AN3
-
 
9
#define  MODRA    0  // AN0
-
 
10
 
-
 
11
// I/O
5
#define LED    PIN_C0
12
#define LED    PIN_C0
6
#define HREF   PIN_C5
13
#define HREF   PIN_C5
7
#define PIX    PIN_C6
14
#define PIX    PIN_C6
8
#define SERVO  PIN_B7
15
#define SERVO  PIN_B7
9
 
16
 
10
void main()
17
void main()
11
{
18
{
12
   int8 cas;
19
   int8 cas;
-
 
20
   int16 offset;
13
 
21
 
14
   setup_adc_ports(ALL_ANALOG);
22
   setup_adc_ports(ALL_ANALOG);
15
   setup_adc(ADC_CLOCK_INTERNAL);
23
   setup_adc(ADC_CLOCK_INTERNAL);
16
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
24
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
17
   setup_timer_1(T1_DISABLED);
25
   setup_timer_1(T1_DISABLED);
Line 73... Line 81...
73
   i2c_write(0x1A);
81
   i2c_write(0x1A);
74
   i2c_write(45);
82
   i2c_write(45);
75
   i2c_stop();
83
   i2c_stop();
76
 
84
 
77
   output_low(LED);
85
   output_low(LED);
-
 
86
   
-
 
87
   cas=128;
78
 
88
 
79
   while(true)
89
   while(true)
80
   {
90
   {
81
      while(!input(HREF));
91
      while(!input(HREF));
82
      set_timer0(0);
92
      set_timer0(0);
Line 86... Line 96...
86
        {
96
        {
87
          cas=get_timer0();
97
          cas=get_timer0();
88
          break;
98
          break;
89
        }
99
        }
90
      };
100
      };
-
 
101
 
-
 
102
      cas=255-cas;
-
 
103
      
-
 
104
      set_adc_channel(MODRA);
-
 
105
      Delay_ms(1);
-
 
106
      offset=read_adc();
91
      output_high(SERVO);
107
      output_high(SERVO);
92
      delay_us(1000);
108
      delay_us(900);
-
 
109
      delay_us(offset);
93
      delay_us(cas);
110
      delay_us(cas);
94
      delay_us(cas);
111
      delay_us(cas);
95
      delay_us(cas);
112
      delay_us(cas);
96
      output_LOW(SERVO);     
113
      output_LOW(SERVO);
97
      set_pwm1_duty(cas);
114
      set_pwm1_duty(cas);
98
      set_pwm2_duty(255-cas);
115
      set_pwm2_duty(255-cas);
99
   };
116
   };
100
}
117
}