Project

General

Profile

Revision 331

Added by Chris Mar over 16 years ago

rangefinders work w/ buffer.
new function names:
- analog8() = use buffer
- analog_get8() = direct

View differences:

branches/analog/trunk/code/projects/template/main.c
1 1
#include "../libdragonfly/dragonfly_lib.h"
2 2

  
3 3
int main(void) {
4
	int count = 0;
4
	unsigned int count = 0;
5 5
	int count2 = 0;
6 6
	dragonfly_init(ALL_ON);
7
	
7
	range_init();
8
	//analog_stop_loop();
9
	usb_puts("starting");
8 10
	while (1) {
9
		if (count == 1000) {
10
			usb_puts("the value of the pot is: ");
11
			usb_puti(analog_get8(WHEEL_PORT));
12
			usb_puts("\t");
13
			usb_puti(analog_get10(WHEEL_PORT));
11
		if (count == 50000) {
12
			for(int i=2; i<7; i++) {
13
				usb_puti( linearize_distance(analog8(i)) );
14
				usb_puts("  ");
15
			}
14 16
			usb_puts("\n\r");
15 17
			count = 0;
16 18
		}
17
		
19
		/*
18 20
		if (count2 == 5000) {
19 21
			usb_puts("Loop stopped\n\r");
20 22
			analog_stop_loop();
......
24 26
			usb_puts("Loop started\n\r");
25 27
			analog_start_loop();
26 28
			count2 = 0;
27
		}
29
		}*/
28 30
		
29 31
		
30 32
		count++;
31
		count2++;
33
		//count2++;
32 34
	}
33 35
	
34 36
	return 0;
branches/analog/trunk/code/projects/template/Makefile
14 14
# USE_WIRELESS = 1
15 15

  
16 16
# com1 = serial port. Use lpt1 to connect to parallel port.
17
AVRDUDE_PORT = com4
17
AVRDUDE_PORT = com8
18 18
#
19 19
#
20 20
###################################
branches/analog/trunk/code/projects/libdragonfly/analog.c
102 102
	
103 103
}	
104 104

  
105
unsigned int analog_get8(int which) {
105
unsigned int analog8(int which) {
106 106
	if (which == BOM_PORT) {
107 107
		return 0;
108 108
	} else {
......
110 110
	}
111 111
}
112 112

  
113
unsigned int analog_get10(int which) {
113
unsigned int analog10(int which) {
114 114
	if (which == BOM_PORT) {
115 115
		return 0;
116 116
	} else {
......
140 140
 *
141 141
 * @see analog_init, analog10
142 142
 **/
143
unsigned int analog8(int which)
143
unsigned int analog_get8(int which)
144 144
{	
145 145
	// Let any previous conversion finish
146 146
	while (ADCSRA & _BV(ADSC));
......
173 173
 * 
174 174
 * @see analog_init, analog8
175 175
 **/
176
unsigned int analog10(int which)
176
unsigned int analog_get10(int which)
177 177
{
178 178
	int adc_h;
179 179
	int adc_l;
......
193 193

  
194 194
	// Wait for the conversion to finish
195 195
	while (ADCSRA & _BV(ADSC));
196

  
196
	
197 197
	adc_l = ADCL;
198 198
	adc_h = ADCH;
199 199

  
......
212 212
 **/
213 213
int wheel(void)
214 214
{
215
	return analog_get8(WHEEL_PORT);
215
	return analog8(WHEEL_PORT);
216 216
}
217 217

  
218 218

  
branches/analog/trunk/code/projects/libdragonfly/bom.c
141 141
      else
142 142
        output_low(MONK0);
143 143

  
144
      a = analog8(MONKI);
144
      a = analog_get8(MONKI);
145 145
              
146 146
      if (a < h)
147 147
      {
branches/analog/trunk/code/projects/libdragonfly/rangefinder.c
134 134
 **/
135 135
int range_read_distance (int range_id)
136 136
{
137
	return linearize_distance(analog_get8(range_id));
137
	return linearize_distance(analog8(range_id));
138 138
}
139 139

  
140 140
/** @} **/ //end defgroup

Also available in: Unified diff