Project

General

Profile

Revision 1886

Tested and finished the database and the valid turns and everything!

database:
files: intersectData.c and intersectData.h
database is an array defined in .h that stores all intersections
right now it is defined for our demo map.
it has an intialize function that is unique for each map and all
other functions that can be reused. (constracted in this way
so that we do not need to keep rewriting code)

validTurns:
integrated with the database. uses database lookup functions to
determine intersection type and position from the given barcode
and determines whether the given turn is valid.

Yay for being done!!

View differences:

validTurns-test.c
1 1
#include <dragonfly_lib.h>
2
#include "lineDrive.h"
2
#include "intersectData.h"
3 3
#include "validTurns.h"
4 4

  
5
#define TEST_VALIDTURNS
6

  
5 7
#ifdef TEST_VALIDTURNS
6 8

  
7 9
int main(){
8
/*barcode should be written as crosstype, crosspos. 5 bit integers*/
9 10

  
10
/*barcode should be three bits of intersection type and 2 of entrypoint*/
11
	dragonfly_init(ALL_ON);
12
	orb1_set_color(YELLOW);
11 13

  
12
dragonfly_init(ALL_ON);
13
orb1_set_color(YELLOW);
14
	initializeData();	
15
	
16
	int barcode = 0;
17
	
18
	if (validateTurn(barcode, ILEFT)==ILEFT) orb1_set_color(GREEN);
14 19

  
15
int barcode1 = (DOUBLE_C<<2)+(TMIDDLE);
16
if (validateTurn(barcode1, ILEFT)==ILEFT) orb1_set_color(GREEN);
20
	delay_ms(100);
21
	orb1_set_color(PINK);
22
	delay_ms(50);
17 23

  
18
delay_ms(100);
19
orb1_set_color(PINK);
20
delay_ms(50);
24
	if (validateTurn(barcode, IUTURN)==IUTURN) orb1_set_color(GREEN);
25
	
26
	delay_ms(100);
27
	orb1_set_color(RED);
28
	delay_ms(50);
21 29

  
22
int barcode2 = (DOUBLE_C<<2)+(TMIDDLE);
23
if (validateTurn(barcode2, IUTURN)==IUTURN) orb1_set_color(GREEN);
30
	while (1){}
24 31

  
25
delay_ms(100);
26
orb1_set_color(RED);
27
delay_ms(50);
28

  
29
int barcode3 = (DOUBLE_T<<2)+(TMIDDLE);
30
if (validateTurn(barcode3, IUTURN)==IUTURN) orb1_set_color(GREEN);
31

  
32
delay_ms(100);
33
orb1_set_color(PURPLE);
34
delay_ms(50);
35

  
36
int barcode4 = (DOUBLE_T<<2)+(TMIDDLE);
37
if (validateTurn(barcode4, ISTRAIGHT)==IUTURN) orb1_set_color(GREEN);
38

  
39
while (1){}
40

  
41 32
}
42 33

  
43
#endif TEST_VALIDTURNS
34
#endif

Also available in: Unified diff