Project

General

Profile

Revision 1637

added robot testing code for IR data collection

View differences:

trunk/code/tools/rangefinders/robot/testIRcycle.c
1
#include <dragonfly_lib.h>
2

  
3
int main(void)
4
{
5
	/* initialize components, set wireless channel */
6
	dragonfly_init(ALL_ON);
7
	
8
  //Replace the next two lines with your own code
9
  //You can add as many lines as you want
10
  
11
  uint8_t rangeNumber[] = {IR1,IR2,IR3,IR4,IR5}; //0 indexed
12
  uint8_t cIndex;
13
  
14
  //initial setup (IR1)
15
  cIndex=0;
16
  orb1_set_color(BLUE);
17
  orb2_set_color(GREEN);
18
  
19
	while(1) {
20
		
21
		usb_puti(range_read_distance(rangeNumber[cIndex]));
22
		usb_putc('\r');
23
		
24
		if (button1_click()) {
25
			switch (cIndex){ //button1 chooses a color channel
26
				case 0: //IR1
27
					orb1_set_color(RED);
28
					orb2_set_color(RED);
29
					cIndex=1;
30
					break;
31
				case 1: //IR2
32
					
33
					orb1_set_color(GREEN);
34
					orb2_set_color(GREEN);
35
					cIndex=2;
36
					break;
37
				case 2: //IR3
38
					
39
					orb1_set_color(BLUE);
40
					orb2_set_color(BLUE);
41
					cIndex=3;
42
					break;
43
				case 3: //IR4
44
					orb1_set_color(YELLOW);
45
					orb2_set_color(YELLOW);
46
					cIndex=4;
47
					break;	
48
				case 4: //IR5
49
					orb1_set_color(BLUE);
50
					orb2_set_color(GREEN);
51
					cIndex=0;
52
					break;
53
				default: //undefined
54
					return 0;
55
					break;
56
			}
57
			delay_ms(50); //allows button press to release
58
		}
59
		delay_ms(50); //refresh frequency: 1000/(50ms) refresh rate
60

  
61
	}
62
		
63
		
64
	
65
  //this tell the robot to just chill out forever. don't put anything after this
66
  while(1);
67
	return 0;
68
}
trunk/code/tools/rangefinders/robot/Makefile
1
# this is a local makefile
2

  
3
# Relative path to the root directory (containing lib directory)
4
ifndef COLONYROOT
5
COLONYROOT := ..
6

  
7
# Target file name (without extension).
8
TARGET = testIRcycle
9

  
10
# Uncomment this to use the wireless library
11
USE_WIRELESS = 1
12

  
13
# com1 = serial port. Use lpt1 to connect to parallel port.
14
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
15

  
16
else
17
COLONYROOT := ../$(COLONYROOT)
18
endif
19

  
20
include $(COLONYROOT)/Makefile
trunk/code/tools/rangefinders/Makefile
1
# this is a local makefile
2

  
3
# Relative path to the root directory (containing lib directory)
4
ifndef COLONYROOT
5
COLONYROOT := ..
6

  
7
# Target file name (without extension).
8
TARGET = 
9

  
10
# Uncomment this to use the wireless library
11
USE_WIRELESS = 1
12

  
13
# com1 = serial port. Use lpt1 to connect to parallel port.
14
AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
15

  
16
else
17
COLONYROOT := ../$(COLONYROOT)
18
endif
19

  
20
include $(COLONYROOT)/Makefile

Also available in: Unified diff