Project

General

Profile

Revision 773

Added by Kevin Woo almost 16 years ago

Commented some of the encoder functions.

View differences:

encoders.c
45 45

  
46 46
void encoder_recv_complete(){
47 47

  
48
int dx;
48
  int dx;
49 49

  
50 50
   //  usb_puts("[");usb_puti(left_dx);usb_puts(",");usb_puti(right_dx);usb_puts("]\r\n");
51 51
   //   usb_puts("\r\n");
52 52
  data_ready++;
53 53
  
54
  delay_ms(ENCODER_DELAY);
54
  //delay_ms(ENCODER_DELAY);
55 55

  
56 56
   spi_transfer(5);
57 57
}
......
64 64
  usb_puts(" ");
65 65
}
66 66

  
67
/**
68
 * Initializes the encoders variables
69
 **/
67 70
void encoders_init(void){
68 71
	int i;
69 72
	
......
93 96
	spi_transfer(5);
94 97
}
95 98

  
99
/**
100
 * Returns the specified encoders value
101
 *
102
 * @param encoder this is the encoder that you want to read. Valid arguments
103
 *          are LEFT and RIGHT
104
 *
105
 * @return the value of the specified encoder
106
 **/
96 107
int encoder_read(char encoder){
97 108
	if(encoder==LEFT)
98 109
		return left_data;
......
108 119
char encoder_direction(char encoder){
109 120
	return 0;
110 121
}
111

  
122
/**
123
 * Gets the velocity of the specified encoder.
124
 *
125
 * @param encoder the encoder that you want to read, use LEFT or RIGHT
126
 *
127
 * @return The velocity of the specified encoder.
128
 **/
112 129
int encoder_get_dx(char encoder) {
113 130
	if(encoder==LEFT)
114 131
		return left_dx;
......
117 134
	else return -1;
118 135
}
119 136

  
137
/**
138
 * Resets the value of the velocity global variable for the specified
139
 *  encoder.
140
 *
141
 * @param encoder the encoder that you want to modify
142
 **/
120 143
void encoder_rst_dx(char encoder) {
121 144
	if(encoder==LEFT)
122 145
		left_dx = 0;
......
124 147
		right_dx = 0;
125 148
}
126 149

  
150
/**
151
 * Returns the current time count for the encoders.
152
 **/
127 153
int encoder_get_tc(void) {
128 154
	return timecount;
129 155
}
130 156

  
157
/**
158
 * Resets the time count for the encoders.
159
 **/
131 160
void encoder_rst_tc(void) {
132 161
	timecount = 0;
133 162
}
......
180 209
			
181 210
		recv_count=0;
182 211
		
212
		//Parse the encoder data, comes in over 5 bytes 16 bits per encoder,
213
		// second is offset by 1 bit.
183 214
		if(buf_index == 0)
184 215
		  right_data_buf |= ((short)data)<<8 & 0xff00;
185 216

  
......
231 262
			right_data_buf = 0;
232 263

  
233 264
		
234
		if(left_data < INVALID) {
265
		if(left_data < INVALID) {   //Valid? I have no idea what being less than invalid means - KWoo
235 266
			//Put new data onto data array
236 267
			left_data_array_put(left_data);
237 268

  

Also available in: Unified diff