Project

General

Profile

Revision 1212

Finished the bom test (calling the not-finished hardware functions for now)

View differences:

test_bom.c
1 1
#include "test_bom.h"
2 2
#include "global.h"
3 3

  
4
#include "hardware_turntable.h"
5
#include "hardware_rbom.h"
6
#include "comm_robot.h"
7

  
8
static uint16_t bom_emitter_position (uint8_t num)
9
{
10
	switch (num)
11
	{
12
		case 0:  return  100; break;
13
		case 1:  return  200; break;
14
		case 2:  return  300; break;
15
		case 3:  return  400; break;
16
		case 4:  return  500; break;
17
		case 5:  return  600; break;
18
		case 6:  return  700; break;
19
		case 7:  return  800; break;
20
		case 8:  return  900; break;
21
		case 9:  return 1000; break;
22
		case 10: return 1100; break;
23
		case 11: return 1200; break;
24
		case 12: return 1300; break;
25
		case 13: return 1400; break;
26
		case 14: return 1500; break;
27
		case 15: return 1600; break;
28
		default: return 0; break;
29
	}
30
}
31

  
32
static uint16_t bom_detector_position (uint8_t num)
33
{
34
	return bom_emitter_position (num)-50;
35
}
36

  
37

  
4 38
void test_bom_bitmask (uint16_t emitter_bitmask, uint16_t detector_bitmask)
5 39
{
6 40
	usb_puts("# Testing BOM" NL);
......
9 43
	{
10 44
		if (emitter_bitmask&1)
11 45
		{
46
			uint16_t values[4];
47
			
12 48
			usb_puts("# Testing BOM emitter ");
13 49
			usb_puti(n);
14 50
			usb_puts(NL);
15
	//		rotate (emitter position)
16
	//		send (turn on only light i)
17
	//		wait (done)
18
	//		read values
19
	//		send (turn off lights)
20
	//		wait (done)
21
	//send data
22
			usb_puts ("data bom emitter ");
23
			usb_puti (n);
24
			usb_puts (" 1 2 3 4");
51
			
52
			turntable_rotate_to_position (bom_emitter_position (n));
53
			robot_set_bom (1<<n); // TODO check: wait until done
54
		
55
			rbom_update ();
56
#define N 0
57
#define E 1
58
#define S 2
59
#define W 3
60
			values[N]=rbom_read (RBOM_SENSOR_N);
61
			values[E]=rbom_read (RBOM_SENSOR_E);
62
			values[S]=rbom_read (RBOM_SENSOR_S);
63
			values[W]=rbom_read (RBOM_SENSOR_W);
64

  
65
			robot_set_bom (0); // TODO check: wait until done
66

  
67
			// Send data
68
			usb_puts ("data bom emitter");
69
			usb_puts (" N/"); usb_puti (values[N]);
70
			usb_puts (" E/"); usb_puti (values[E]);
71
			usb_puts (" S/"); usb_puti (values[S]);
72
			usb_puts (" W/"); usb_puti (values[W]);
73
#undef N
74
#undef E
75
#undef S
76
#undef W
25 77
			usb_puts (NL);
26 78
		}
27 79
		
......
30 82
			usb_puts("# Testing BOM detector ");
31 83
			usb_puti(n);
32 84
			usb_puts(NL);
33
	//		rotate (detector position)
34
	//		
35
	//		turn light on
36
	//		send (read data)
37
	//		receive (data)
38
	//		turn lights off
39
	//		send (read data)
40
	//		receive (data)
41
	//send data
85
			turntable_rotate_to_position (bom_detector_position (n));
86

  
87
			rbom_set (true);
88
			uint16_t on_value=robot_read_bom (n);
89
			rbom_set (false);
90
			uint16_t off_value=robot_read_bom (n);
91

  
92
			// Send data
42 93
			usb_puts ("data bom detector ");
43 94
			usb_puti (n);
44
			usb_puts (" 1");
95
			usb_puts (" on/");
96
			usb_puti (on_value);
97
			usb_puts (" off/");
98
			usb_puti (off_value);
45 99
			usb_puts (NL);
46 100
		}
47
		
48
	//	turn lights off
49 101
	}
50
	
51 102

  
52 103
	usb_puts("# Testing BOM finished" NL);
53 104
}

Also available in: Unified diff