summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/main.cpp
blob: f689d883c7a0befd3356bc50104dc92c8783f857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "stdafx.h"

int main()
{
	//Init our robot
	Robot* localRobot = new Robot();

	//Init Engines
	for(uint8 i = IO_ENGINE_START; i < IO_ENGINE_END; i++)
	{
		Engine* newEngine = new Engine(i);
		localRobot->AddModule(newEngine);
		newEngine = NULL;
	}

	//Init Dribbler
	for(uint8 i = IO_DRIBBLER_START; i < IO_DRIBBLER_END; i++)
	{
		Dribbler* newDribbler = new Dribbler(i);
		localRobot->AddModule(newDribbler);
		newDribbler = NULL;
	}

	//Init Kicker
	for(uint8 i = IO_KICKER_START; i < IO_KICKER_END; i++)
	{
		Kicker* newKicker = new Kicker(i);
		localRobot->AddModule(newKicker);
		newKicker = NULL;
	}

	//Init Sensors
	for(uint8 i = IO_SENSOR_START; i < IO_SENSOR_END; i++)
	{
		switch(i)
		{
			//Create correct type of sensor
			case IO_SENSOR_IR_0_DEG:
			case IO_SENSOR_IR_30_DEG:
			case IO_SENSOR_IR_60_DEG:
			case IO_SENSOR_IR_100_DEG:
			case IO_SENSOR_IR_180_DEG:
			case IO_SENSOR_IR_260_DEG:
			case IO_SENSOR_IR_300_DEG:
			case IO_SENSOR_IR_330_DEG:
			{
				IR_Sensor* newSensor = new IR_Sensor(i);
				localRobot->AddModule(newSensor);
				newSensor = NULL;
				break;
			}
			case IO_SENSOR_DISTANCE_0_DEG:
			case IO_SENSOR_DISTANCE_90_DEG:
			case IO_SENSOR_DISTANCE_180_DEG:
			case IO_SENSOR_DISTANCE_270_DEG:
			{
				Distance_Sensor* newSensor = new Distance_Sensor(i);
				localRobot->AddModule(newSensor);
				newSensor = NULL;
				break;
			}
			case IO_SENSOR_MOUSE_LEFT:
			case IO_SENSOR_MOUSE_RIGHT:
			{
				Mouse_Sensor* newSensor = new Mouse_Sensor(i);
				localRobot->AddModule(newSensor);
				newSensor = NULL;
				break;
			}
			//Other cases
			default:
			{
				Sensor* newSensor = new Sensor(i);
				localRobot->AddModule(newSensor);
				newSensor = NULL;
				break;
			}
		}
	}

	//Init Leds
	for(uint8 i = IO_LED_START; i < IO_LED_END; i++)
	{
		Led* newLed = new Led(i);
		localRobot->AddModule(newLed);
		newLed = NULL;
	}

	//Init Displays
	for(uint8 i = IO_DISPLAY_START; i < IO_DISPLAY_END; i++)
	{
		Display* newDisplay = new Display(i);
		localRobot->AddModule(newDisplay);
		newDisplay = NULL;
	}

	//Init Keyboards
	for(uint8 i = IO_KEYBOARD_START; i < IO_KEYBOARD_END; i++)
	{
		Keyboard* newKeyboard = new Keyboard(i);
		localRobot->AddModule(newKeyboard);
		newKeyboard = NULL;
	}

	Keyboard* ourKeyboard = localRobot->GetModule<Keyboard>(IO_KEYBOARD_MAIN);
	IR_Sensor* ourSensor = NULL;
	uint16 value = 0;
	Display* ourDisplay = localRobot->GetModule<Display>(IO_DISPLAY_MAIN);
	uint32 i = 1;

	//Run
	while(true)
	{
		msleep(500);
		ourDisplay->Clear();
		ourDisplay->Print(i++);
		ourDisplay->NewLine();
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_0_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value, 1, 2);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_30_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_60_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_100_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_180_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value, 1, 3);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_260_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_300_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value);
		ourDisplay->Print(";");
		ourSensor = localRobot->GetModule<IR_Sensor>(IO_SENSOR_IR_330_DEG);
		value = ourSensor->GetIRIntensity();
		ourDisplay->Print(value);
		ourDisplay->Print(";");
		ourDisplay->Print(ourKeyboard->GetInput(), 1, 4);

		localRobot->Update();
	}

	//Cleanup
	delete localRobot;
	localRobot = NULL;
}