diff options
author | sicarius <devnull@localhost> | 2007-02-13 20:10:02 +0100 |
---|---|---|
committer | sicarius <devnull@localhost> | 2007-02-13 20:10:02 +0100 |
commit | 5c33efe58da97d1277f8615ef750c0695497c0b9 (patch) | |
tree | 47cc611e70ed13f2ea7a9b0228794dc74d9b1680 /source/AVR_Studio/Soccer/sensor | |
parent | 54a7ea32d4c79b5ca56b66a5dac28690e928740e (diff) | |
download | rc2007-soccer-5c33efe58da97d1277f8615ef750c0695497c0b9.tar rc2007-soccer-5c33efe58da97d1277f8615ef750c0695497c0b9.zip |
Code-Work @ lowlevel
Diffstat (limited to 'source/AVR_Studio/Soccer/sensor')
-rwxr-xr-x | source/AVR_Studio/Soccer/sensor/ballsensor.c | 28 | ||||
-rwxr-xr-x | source/AVR_Studio/Soccer/sensor/ballsensor.h | 4 | ||||
-rwxr-xr-x | source/AVR_Studio/Soccer/sensor/sensor.h | 1 |
3 files changed, 31 insertions, 2 deletions
diff --git a/source/AVR_Studio/Soccer/sensor/ballsensor.c b/source/AVR_Studio/Soccer/sensor/ballsensor.c index bf97f99..af9434b 100755 --- a/source/AVR_Studio/Soccer/sensor/ballsensor.c +++ b/source/AVR_Studio/Soccer/sensor/ballsensor.c @@ -1,11 +1,35 @@ #include "ballsensor.h"
-Ballsensor::Ballsensor() {
+Ballsensor::Ballsensor() {
+ // Umrechnungstabelle position i in Winkel
+ winkel[0] = 0;
+ winkel[1] = 30;
+ winkel[2] = 60;
+ winkel[3] = 100;
+ winkel[4] = 180;
+ winkel[5] = 260;
+ winkel[6] = 300;
+ winkel[7] = 330;
}
Ballsensor::~Ballsensor() {
}
int Ballsensor::getBallwinkel() {
- return 0;
+ // Erstelle ein Array für die Sensorwerte
+ int sensor[NUM_BALLSENSOR];
+ int result = 0; // und einer Variable fürs Ergebnis
+ int current = 1024; // Setze aktuellen Wert auf Maximum
+
+ // Analoge Sensoren abfragen und eintragen
+ for(int i=0;i<NUM_BALLSENSOR;i++) sensor[i] = board.GetADC(i);
+
+ // Suche den kleinsten Wert
+ for(int i=0;i<NUM_BALLSENSOR;i++) {
+ // Wenn der Sensorwert kleiner ist ist der Ball näher dran
+ if(sensor[i] < current) result = i; // Ergebnis ist erstmal index
+ }
+
+ // Gebe den Winkel zum index result zurück
+ return winkel[result];
}
diff --git a/source/AVR_Studio/Soccer/sensor/ballsensor.h b/source/AVR_Studio/Soccer/sensor/ballsensor.h index 46daf90..5fa7f08 100755 --- a/source/AVR_Studio/Soccer/sensor/ballsensor.h +++ b/source/AVR_Studio/Soccer/sensor/ballsensor.h @@ -3,11 +3,15 @@ #include "../hal/board.h"
+// Anzahl der Ballsensoren
+#define NUM_BALLSENSOR 8
+
extern Board board;
class Ballsensor
{
private:
+ int winkel[NUM_BALLSENSOR];
public:
Ballsensor();
~Ballsensor();
diff --git a/source/AVR_Studio/Soccer/sensor/sensor.h b/source/AVR_Studio/Soccer/sensor/sensor.h index 25d36c2..afbb3a0 100755 --- a/source/AVR_Studio/Soccer/sensor/sensor.h +++ b/source/AVR_Studio/Soccer/sensor/sensor.h @@ -3,6 +3,7 @@ #include "../hal/board.h"
#include "ballsensor.h"
+#include "../hal/maussensor.h"
#include "../global.h"
extern Board board;
|