Code-Work @ lowlevel
This commit is contained in:
parent
54a7ea32d4
commit
5c33efe58d
13 changed files with 1079 additions and 480 deletions
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@ Sensor sensor;
|
|||
|
||||
int main() {
|
||||
//board.ledOn();
|
||||
sleep(1);
|
||||
sleep(2);
|
||||
int speed = 255;
|
||||
/*for(int i=-255;i<=255;i+=30) {
|
||||
board.motor(0,i);
|
||||
|
@ -25,6 +25,8 @@ int main() {
|
|||
board.motor(3, speed);
|
||||
PORTB |= (1 << PB5) | (1 << PB7); // Setze PWM-Ports auf high
|
||||
PORTE |= (1 << PE3) | (1 << PE4);
|
||||
//sleep(10);
|
||||
while(true) { sleep(1); }
|
||||
/*sleep(10);
|
||||
board.motor(0, 0);
|
||||
board.motor(1, 0);
|
||||
|
@ -33,23 +35,24 @@ int main() {
|
|||
//while(true) { sleep(1); }
|
||||
//board.beep(450);
|
||||
//board.ledOn();
|
||||
//keylcd.print("test");
|
||||
//sleep(1);
|
||||
/*keylcd.print("test");
|
||||
sleep(1);
|
||||
//board.ledOff();
|
||||
//sleep(1);
|
||||
/*for(int i=0;i<keylcd.error();i++) {
|
||||
for(int i=0;i<keylcd.error();i++) {
|
||||
board.ledOn();
|
||||
sleep(1);
|
||||
board.ledOff();
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
board.ledOn();
|
||||
uart1_puts("18");
|
||||
uart1_puts("Hallo Du! Hier ist dein AtMega128\n");
|
||||
sleep(1);
|
||||
board.ledOff();
|
||||
sleep(10);
|
||||
//board.ledOff();
|
||||
//board.ledOff();*/
|
||||
|
||||
while(true) {
|
||||
navigation.Aktualisieren(0,0,speed);
|
||||
|
@ -61,7 +64,7 @@ int main() {
|
|||
navigation.Aktualisieren(270,0,speed);
|
||||
sleep(2);
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0
|
|||
|
||||
|
||||
## Objects that must be built in order to link
|
||||
OBJECTS = Soccer.o board.o keylcd.o i2c.o global.o uart.o navigation.o sensor.o ballsensor.o
|
||||
OBJECTS = Soccer.o board.o keylcd.o i2c.o global.o uart.o navigation.o sensor.o ballsensor.o maussensor.o
|
||||
|
||||
## Objects explicitly added by the user
|
||||
LINKONLYOBJECTS =
|
||||
|
@ -70,6 +70,9 @@ sensor.o: ../sensor/sensor.c
|
|||
ballsensor.o: ../sensor/ballsensor.c
|
||||
$(CC) $(INCLUDES) $(CFLAGS) -c $<
|
||||
|
||||
maussensor.o: ../hal/maussensor.c
|
||||
$(CC) $(INCLUDES) $(CFLAGS) -c $<
|
||||
|
||||
##Link
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,9 @@ Soccer.o: ../Soccer.c ../global.h c:/winavr/bin/../avr/include/stdlib.h \
|
|||
c:/winavr/bin/../avr/include/util/twi.h \
|
||||
c:/winavr/bin/../avr/include/string.h ../navigation.h \
|
||||
c:/winavr/bin/../avr/include/math.h ../sensor/sensor.h \
|
||||
../sensor/../hal/board.h ../sensor/ballsensor.h ../sensor/../global.h
|
||||
../sensor/../hal/board.h ../sensor/ballsensor.h \
|
||||
../sensor/../hal/maussensor.h ../sensor/../hal/../global.h \
|
||||
../sensor/../global.h
|
||||
|
||||
../global.h:
|
||||
|
||||
|
@ -63,4 +65,8 @@ c:/winavr/bin/../avr/include/math.h:
|
|||
|
||||
../sensor/ballsensor.h:
|
||||
|
||||
../sensor/../hal/maussensor.h:
|
||||
|
||||
../sensor/../hal/../global.h:
|
||||
|
||||
../sensor/../global.h:
|
||||
|
|
|
@ -11,7 +11,8 @@ navigation.o: ../navigation.c ../navigation.h \
|
|||
c:/winavr/bin/../avr/include/stdlib.h \
|
||||
c:\winavr\bin\../lib/gcc/avr/4.1.1/include/stddef.h ../hal/uart.h \
|
||||
../sensor/sensor.h ../sensor/../hal/board.h ../sensor/ballsensor.h \
|
||||
../sensor/../global.h ../sensor/../hal/board.h
|
||||
../sensor/../hal/maussensor.h ../sensor/../hal/../global.h \
|
||||
../sensor/../hal/../hal/board.h ../sensor/../global.h
|
||||
|
||||
../navigation.h:
|
||||
|
||||
|
@ -47,6 +48,10 @@ c:\winavr\bin\../lib/gcc/avr/4.1.1/include/stddef.h:
|
|||
|
||||
../sensor/ballsensor.h:
|
||||
|
||||
../sensor/../global.h:
|
||||
../sensor/../hal/maussensor.h:
|
||||
|
||||
../sensor/../hal/board.h:
|
||||
../sensor/../hal/../global.h:
|
||||
|
||||
../sensor/../hal/../hal/board.h:
|
||||
|
||||
../sensor/../global.h:
|
||||
|
|
|
@ -9,8 +9,9 @@ sensor.o: ../sensor/sensor.c ../sensor/sensor.h ../sensor/../hal/board.h \
|
|||
c:/winavr/bin/../avr/include/avr/interrupt.h \
|
||||
c:/winavr/bin/../avr/include/stdlib.h \
|
||||
c:\winavr\bin\../lib/gcc/avr/4.1.1/include/stddef.h \
|
||||
../sensor/../hal/uart.h ../sensor/ballsensor.h ../sensor/../global.h \
|
||||
../sensor/../hal/board.h
|
||||
../sensor/../hal/uart.h ../sensor/ballsensor.h \
|
||||
../sensor/../hal/maussensor.h ../sensor/../hal/../global.h \
|
||||
../sensor/../hal/../hal/board.h ../sensor/../global.h
|
||||
|
||||
../sensor/sensor.h:
|
||||
|
||||
|
@ -40,6 +41,10 @@ c:\winavr\bin\../lib/gcc/avr/4.1.1/include/stddef.h:
|
|||
|
||||
../sensor/ballsensor.h:
|
||||
|
||||
../sensor/../global.h:
|
||||
../sensor/../hal/maussensor.h:
|
||||
|
||||
../sensor/../hal/board.h:
|
||||
../sensor/../hal/../global.h:
|
||||
|
||||
../sensor/../hal/../hal/board.h:
|
||||
|
||||
../sensor/../global.h:
|
||||
|
|
|
@ -13,11 +13,28 @@ inline void sleep(int sec)
|
|||
}
|
||||
};
|
||||
|
||||
inline void msleep(int msec)
|
||||
{
|
||||
for (int s=0; s<msec; s++) {
|
||||
for (long int i=0; i<1405; i++) {
|
||||
asm volatile("nop");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void *operator new(size_t sz);
|
||||
void operator delete(void *p);
|
||||
|
||||
// Typendefinitionen für den CT-Bot-Code
|
||||
typedef unsigned char uint8; /*!< vorzeichenlose 8-Bit-Zahl */
|
||||
typedef unsigned int word; /*!< vorzeichenlose 16-Bit-Zahl */
|
||||
typedef signed char int8; /*!< vorzeichenbehaftete 8-Bit-Zahl */
|
||||
typedef short int int16; /*!< vorzeichenbehaftete 16-Bit-Zahl */
|
||||
|
||||
typedef unsigned long uint32; /*!< vorzeichenlose 32-Bit-Zahl */
|
||||
typedef signed long int32; /*!< vorzeichenbehaftete 32-Bit-Zahl */
|
||||
|
||||
#define uint16 word /*!< Int mit 16 Bit */
|
||||
|
||||
|
||||
/* defines for compatibility */
|
||||
|
|
|
@ -1,11 +1,35 @@
|
|||
#include "ballsensor.h"
|
||||
|
||||
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];
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../hal/board.h"
|
||||
#include "ballsensor.h"
|
||||
#include "../hal/maussensor.h"
|
||||
#include "../global.h"
|
||||
|
||||
extern Board board;
|
||||
|
|
Reference in a new issue