Absender: Frank Menzel
Datum: Mo, 17.12.2007 16:36:27
In-reply-to:
<6FFE30EB-4F48-4F8D-BAC0-8B1D89689FCF@xxxxxxxxxxxxxxx>
Hallo, hoffe nun alles beruecksichtigt zu haben. Den Stack habe ich als Array implementiert und die vorherige dynamische Version aber drin gelassen. Via Define ist die Array-Version mit 20 Einträgen aktiv. Gruß, Frank Menzel -----Ursprüngliche Nachricht----- Von: ct-bot-entwickler-bounces@xxxxxxxxxxxxxxxxx [mailto:ct-bot-entwickler-bounces@xxxxxxxxxxxxxxxxx] Im Auftrag von Timo Sandmann Gesendet: Sonntag, 16. Dezember 2007 16:47 An: Entwicklung rund um den c't-bot Betreff: Re: AW: [ct-bot] Stackimplementation und Verhalten bot_drive_stack Hallo, Am 16.12.2007 um 11:47 schrieb Frank Menzel: > Hallo, > die Stackimplementation als Array hatte ich auch schon angedacht. > Allerdings liegt doch hier die Begrenzung des Arrays von Anfang an > fest > oder ? Und ich wollte ja nicht gleich von Anfang an Platz fuer 100 x- > und Y-Koordinaten reservieren. Und die 100 koentnen ja auch mal > ueberschritten werden. Oder gibt es ein dynamisches Array ? Wie ist > hier > die Denkweise ? also 100 passen so oder so nicht ins RAM. Wie gesagt, ich würde irgendwann einfach die ältesten Daten überschreiben. Alternativ könnte man bei vollem Stack auch seitenweise die ältesten Daten ins EEPROM auslagern, der Zugriff erfolgt ja immer sequentiell. Gruß Timo _______________________________________________ ct-bot-entwickler Mailingliste ct-bot-entwickler@xxxxxxxxxxxxxxxxx http://www.heise.de/bin/newsletter/listinfo/ct-bot-entwickler
Index: C:/botneu/ct-Bot/bot-logic/behaviour_drive_stack.c =================================================================== --- C:/botneu/ct-Bot/bot-logic/behaviour_drive_stack.c (revision 0) +++ C:/botneu/ct-Bot/bot-logic/behaviour_drive_stack.c (revision 0) @@ -0,0 +1,146 @@ +/* + * c't-Bot + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your + * option) any later version. + * This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307, USA. + * + */ + + +/*! + * @file behaviour_drive_stack.c + * @brief Anfahren aller auf dem Stack befindlichen Punkte + * @author Frank Menzel (Menzelfr@xxxxxxx) + * @date 13.12.2007 + */ + + +#include "bot-logic/bot-logik.h" +#ifdef BEHAVIOUR_DRIVE_STACK_AVAILABLE +#include "display.h" +#include "rc5.h" +#include "rc5-codes.h" +#include "pos_stack.h" + +static uint8 drivestack_state = 0; /*!< Status des drive_stack-Verhaltens */ + +static int16 posx=0; /*!< hier die vom Stack geholten oder zu sichernden xy-Koordinaten; werden im Display angezeigt */ +static int16 posy=0; + + +/*! + * Verhalten zum Anfahren aller auf dem Stack befindlichen Punkte, wobei das Fahr-Unterverhalten bot_goto_pos benutzt wird + * @param data Verhaltensdatensatz + */ +void bot_drive_stack_behaviour(Behaviour_t *data) { + switch (drivestack_state) { + case 0: + // Koordinaten werden vom Stack geholt und angefahren; Ende nach nicht mehr erfolgreichem Pop + if (!pop_pos(&posx,&posy)) + drivestack_state++; + else + bot_goto_pos(data,posx,posy,999); + break; + + default: + clear_stack(); // sicherheitshalber bereinigen und auf Null + return_from_behaviour(data); + break; + } +} + +/*! + * Botenfunktion: Verhalten zum Anfahren aller auf dem Stack befindlichen Punkte + * @param caller der Verhaltensdatensatz + */ +void bot_drive_stack(Behaviour_t * caller) { + switch_to_behaviour(caller,bot_drive_stack_behaviour,OVERRIDE); + drivestack_state = 0; +} + + +/*! + * Verhalten zum Abspeichern eines Koordinatenpunktes auf dem Stack; Implementierung als kleines Verhalten + * zur Verwendung via remotecall; nach erfolgtem Push wird das Verhalten sofort wieder beendet + * @param data Verhaltensdatensatz + */ +/*void bot_set_stackpos_behaviour(Behaviour_t *data) { + push_pos(posx,posy); + return_from_behaviour(data); +} +*/ + +/*! + * Speichern der uebergebenen Koordinaten auf dem Stack + * @param pos_x X-Koordinate + * @param pos_y Y-Koordinate + */ +void bot_set_stackpos(int16 pos_x, int16 pos_y) { + // sichern der Koordinaten in den Stack + push_pos(pos_x,pos_y); +} + +/*! + * Sichern der aktuellen Botposition auf den Stack + * @param caller einfach nur Zeiger, damit remotecall verwendbar + * @param pos_x X-Koordinate + * @param pos_y Y-Koordinate + */ +void push_actual_pos(Behaviour_t * caller) { + // sichern der aktuellen Botposition auf den Stack + posx=(int16)x_pos; + posy=(int16)y_pos; + bot_set_stackpos(x_pos,y_pos); +} + +/*! + * Keyhandler zur Verwendung via Fernbedienung auf dem Display zum Stackanfahren +*/ +#ifdef DISPLAY_DRIVE_STACK_AVAILABLE + static void drivestack_disp_key_handler(void) { + switch (RC5_Code) { + case RC5_CODE_3: + /* Speichern der aktuellen Botposition */ + RC5_Code = 0; + push_actual_pos(0); + break; + + case RC5_CODE_4: + /* Verhalten starten zum Anfahren der Stackpunkte */ + RC5_Code = 0; + bot_drive_stack(0); + break; + + } // switch + } // Ende Keyhandler + + + /*! + * @brief Display zum Setzen und Anfahren der Stackpunkte + */ + void drive_stack_display(void) { + display_cursor(1,1); + display_printf("Bot-Pos %1d %1d",(int16)x_pos,(int16)y_pos); + display_cursor(2,1); + display_printf("Stack-Pos %1d %1d",posx,posy); + display_cursor(4,1); + display_printf("Pos Save/Goto: 3/4"); + + drivestack_disp_key_handler(); // aufrufen des Key-Handlers + } +#endif // DISPLAY_DRIVE_STACK_AVAILABLE + + + +#endif Index: C:/botneu/ct-Bot/bot-logic/bot-logik.c =================================================================== --- C:/botneu/ct-Bot/bot-logic/bot-logik.c (revision 1322) +++ C:/botneu/ct-Bot/bot-logic/bot-logik.c (working copy) @@ -244,6 +244,10 @@ insert_behaviour_to_list(&behaviour, new_behaviour(40, bot_follow_object_behaviour, INACTIVE)); #endif + #ifdef BEHAVIOUR_DRIVE_STACK_AVAILABLE + insert_behaviour_to_list(&behaviour, new_behaviour(33, bot_drive_stack_behaviour, INACTIVE)); + #endif + #ifdef BEHAVIOUR_CALIBRATE_PID_AVAILABLE insert_behaviour_to_list(&behaviour, new_behaviour(30, bot_calibrate_pid_behaviour, INACTIVE)); #endif Index: C:/botneu/ct-Bot/bot-logic/behaviour_remotecall.c =================================================================== --- C:/botneu/ct-Bot/bot-logic/behaviour_remotecall.c (revision 1322) +++ C:/botneu/ct-Bot/bot-logic/behaviour_remotecall.c (working copy) @@ -155,6 +155,10 @@ #ifdef BEHAVIOUR_TRANSPORT_PILLAR_AVAILABLE PREPARE_REMOTE_CALL(bot_transport_pillar,0,""), #endif + #ifdef BEHAVIOUR_DRIVE_STACK_AVAILABLE + PREPARE_REMOTE_CALL(push_actual_pos,0,""), + PREPARE_REMOTE_CALL(bot_drive_stack,0,""), + #endif }; #define STORED_CALLS (sizeof(calls)/sizeof(call_t)) /*!< Anzahl der Remote-Calls im Array */ Index: C:/botneu/ct-Bot/include/bot-logic/behaviour_drive_stack.h =================================================================== --- C:/botneu/ct-Bot/include/bot-logic/behaviour_drive_stack.h (revision 0) +++ C:/botneu/ct-Bot/include/bot-logic/behaviour_drive_stack.h (revision 0) @@ -0,0 +1,72 @@ +/* + * c't-Bot + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your + * option) any later version. + * This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307, USA. + * + */ + + +/*! + * @file behaviour_drive_stack.h + * @brief Anfahren aller auf dem Stack befindlichen Punkte + * @author Frank Menzel (Menzelfr@xxxxxxx) + * @date 13.12.2007 + */ + +#ifndef BEHAVIOUR_DRIVESTACK_H_ +#define BEHAVIOUR_DRIVESTACK_H_ + +#include "ct-Bot.h" +#include "bot-logic/bot-logik.h" + + +#ifdef BEHAVIOUR_DRIVE_STACK_AVAILABLE + +/*! + * Verhalten zum Anfahren aller auf dem Stack befindlichen Punkte, wobei das Fahr-Unterverhalten bot_goto_pos benutzt wird + * @param data Verhaltensdatensatz + */ +void bot_drive_stack_behaviour(Behaviour_t *data); + +/*! + * Botenfunktion: Verhalten zum Anfahren aller auf dem Stack befindlichen Punkte + * @param caller der Verhaltensdatensatz + */ +void bot_drive_stack(Behaviour_t * caller); + +/*! + * Sichern der aktuellen Botposition auf den Stack + * @param caller einfach nur Zeiger, damit remotecall verwendbar + * @param pos_x X-Koordinate + * @param pos_y Y-Koordinate + */ +void push_actual_pos(Behaviour_t * caller); + +/*! + * Speichern der uebergebenen Koordinaten auf dem Stack + * @param pos_x X-Koordinate + * @param pos_y Y-Koordinate + */ +void bot_set_stackpos(int16 pos_x, int16 pos_y); + + /*! + * @brief Display zum Setzen und Anfahren der Stackpunkte + */ + void drive_stack_display(void); + + + +#endif // BEHAVIOUR_DRIVE_STACK_AVAILABLE +#endif /*BEHAVIOUR_DRIVESTACK_H_*/ Index: C:/botneu/ct-Bot/include/bot-logic/available_behaviours.h =================================================================== --- C:/botneu/ct-Bot/include/bot-logic/available_behaviours.h (revision 1322) +++ C:/botneu/ct-Bot/include/bot-logic/available_behaviours.h (working copy) @@ -33,6 +33,8 @@ #define BEHAVIOUR_SERVO_AVAILABLE /*!< Kontrollverhalten fuer die Servos */ +#define BEHAVIOUR_DRIVE_STACK_AVAILABLE /*!< Abfahren der auf dem Stack gesicherten Koordinaten */ + //#define BEHAVIOUR_OLYMPIC_AVAILABLE /*!< Olympiadenverhalten vorhanden? */ //#define BEHAVIOUR_CATCH_PILLAR_AVAILABLE /*!< Suche eine Dose und fange sie ein */ @@ -64,6 +66,10 @@ #define BEHAVIOUR_TURN_AVAILABLE #endif +#ifdef BEHAVIOUR_DRIVE_STACK_AVAILABLE + #define BEHAVIOUR_GOTO_POS_AVAILABLE +#endif + #ifdef BEHAVIOUR_AVOID_COL_AVAILABLE #define BEHAVIOUR_TURN_AVAILABLE #endif @@ -72,6 +78,10 @@ #define BEHAVIOUR_TURN_AVAILABLE #endif +#ifndef POS_STACK_AVAILABLE + #undef BEHAVIOUR_DRIVE_STACK_AVAILABLE +#endif + #ifdef BEHAVIOUR_FOLLOW_LINE_AVAILABLE #define BEHAVIOUR_DRIVE_DISTANCE_AVAILABLE #define BEHAVIOUR_TURN_AVAILABLE @@ -186,5 +196,7 @@ #include "bot-logic/behaviour_transport_pillar.h" +#include "bot-logic/behaviour_drive_stack.h" + #endif // BEHAVIOUR_AVAILABLE #endif /*AVAILABLE_BEHAVIOURS_H_*/ Index: C:/botneu/ct-Bot/include/pos_stack.h =================================================================== --- C:/botneu/ct-Bot/include/pos_stack.h (revision 0) +++ C:/botneu/ct-Bot/include/pos_stack.h (revision 0) @@ -0,0 +1,132 @@ +/* + * c't-Bot + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your + * option) any later version. + * This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307, USA. + * + */ + +/*! + * @file stack.h + * @brief Implementierung eines Stacks mit den ueblichen Stackbefehlen push(_pos), pop(_pos),... + * @author Frank Menzel (Menzelfr@xxxxxxx) + * @date 13.12.2007 + */ + +#ifndef POS_STACK_H_ +#define POS_STACK_H_ + +#include "global.h" + +#ifdef POS_STACK_AVAILABLE + +/*! Der ARRAY-Stack ist verfuegbar; im anderen Fall mit dynamischem Speicherholen und Freigabe */ +#define ARRAY_POINT_STACK + + +/*! ab hier der statische Stack mittels Array */ +#ifdef ARRAY_POINT_STACK + +#define STACK_SIZE 20 // Staeckgroesse ist beim Array begrenzt +#define EMPTY_TOS -1 // Leerindexwert + +/*! Datenstruktur eines Koordinatenpunktes */ +typedef struct point_element element_t; +struct point_element { + int16 posx; + int16 posy; +}; + + +struct stack_record { + int16 top_of_stack; + element_t stack_array[STACK_SIZE]; +} Point_Stack; + + + + +/*! ab hier der dynamische Stack */ +#else + +/*! Datenstruktur eines Koordinatenpunktes */ +typedef struct ele *element_t; +struct ele { + int16 posx; + int16 posy; +}; + +/*! Stack-Datenstruktur zur Speicherung aller Koordinatenpunktes nach LIFO */ +typedef struct node *node_ptr; +struct node { + element_t element; + node_ptr next; +}; +typedef node_ptr pos_stack_t; + + +/*! die eigentlich zu verwendende Stack-Variable */ +pos_stack_t Point_Stack; + +#endif + + + +/*! + * Initialisierung des Stacks; Routine muss vor der ersten Benutzung des Stacks aufgerufen worden sein + */ +void create_stack(void); + +/*! + * Speicherfreigabe der noch im Stack befindlichen Elemente und Ruecksetzen des Stacks auf NULL + */ +void clear_stack(void); + +/*! + * Pop-Routine zur Rueckgabe des letzten auf dem Stack gepushten Punktes + * @param x zuletzt gepoppte X-Koordinate + * @param y zuletzt gepoppte Y-Koordinate + * @return False falls Pop nicht erfolgreich, d.h. kein Punkt mehr auf dem Stack, sonst True nach erfolgreichem Pop + */ +uint8 pop_pos(int16 *x, int16 *y); + +/*! + * Speichern einer Koordinate auf dem Stack + * @param x X-Koordinate des zu sichernden Punktes + * @param y Y-Koordinate des zu sichernden Punktes + */ +void push_pos(int16 x, int16 y); + +/*! + * Rueckgabe der beiden zuletzt gespeicherten Stackkoordinaten, welche zu einer Linie gehoeren + * @param x1 X-Koordinate des zuletzt gespeicherten Linienpunktes + * @param y1 Y-Koordinate des zuletzt gespeicherten Linienpunktes + * @param x2 X-Koordinate des ersten Linienpunktes + * @param y2 Y-Koordinate des ersten Linienpunktes + * @return True nach erfolgreichem Pop beider Punkte sonst False wenn kein Pop mehr moeglich war + */ +uint8 pop_line(int16 *x1, int16 *y1, int16 *x2, int16 *y2); + +/*! + * Speichern zweier koordinaten auf dem Stack, welche zu einer Linie gehoeren + * @param x1 X-Koordinate des ersten Linienpunktes + * @param y1 Y-Koordinate des ersten Linienpunktes + * @param x2 X-Koordinate des zweiten Linienpunktes + * @param y2 Y-Koordinate des zweiten Linienpunktes + */ +void push_line(int16 x1, int16 y1, int16 x2, int16 y2); + +#endif + +#endif /*POS_STACK_H_*/ Index: C:/botneu/ct-Bot/Changelog.txt =================================================================== --- C:/botneu/ct-Bot/Changelog.txt (revision 1322) +++ C:/botneu/ct-Bot/Changelog.txt (working copy) @@ -1,5 +1,7 @@ CHANGELOG fuer c't-Bot ====================== +2007-12-17 Frank Menzel [Menzelfr@xxxxxxx]: Stack-Implementierung und Stackverhalten bot_drive_stack (laut ToDo-Liste) + 2007-12-16 Timo Sandmann [mail@xxxxxxxxxxxxxxx]: TWI-Treiber auf neue Version umgestellt. Effizienter ist es aber, i2c.h / i2c.c zu benutzen 2007-12-10 Timo Sandmann [mail@xxxxxxxxxxxxxxx]: bot_goto_pos() erweitert, so dass es anstelle von bot_drive_distance() und bot_gotoxy() verwendet werden kann und Rueckwaertsgang ergaenzt. Index: C:/botneu/ct-Bot/pos_stack.c =================================================================== --- C:/botneu/ct-Bot/pos_stack.c (revision 0) +++ C:/botneu/ct-Bot/pos_stack.c (revision 0) @@ -0,0 +1,250 @@ +/* + * c't-Bot + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your + * option) any later version. + * This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307, USA. + * + */ + +/*! + * @file stack.c + * @brief Implementierung eines Stacks mit den ueblichen Stackbefehlen push(_pos), pop(_pos),... + * @author Frank Menzel (Menzelfr@xxxxxxx) + * @date 13.12.2007 + */ + +#include "pos_stack.h" + +#ifdef POS_STACK_AVAILABLE + + +#include <stdio.h> +#include <stdlib.h> /* for dynamic allocation */ + + + +// bei Verfuegbarkeit des ARRY-Stacks; sonst Stack mit dynamischer Speicherfreigabe +#ifdef ARRAY_POINT_STACK + +/*! + * Setzt den Stack auf initial zurueck, d.h. Array-Index wird auf Leerwert rueckgesetzt + */ +void create_stack(void) { + Point_Stack.top_of_stack = EMPTY_TOS; +} + +/*! + * Erkennt an Hand des Stack-Index ob Stack leer ist + * @return True falls Stack leer sonst false + */ +uint8 is_empty(void) { + return(Point_Stack.top_of_stack == EMPTY_TOS); +} + +/*! + * Erkennt an Hand des Stack-Index ob Stack voll ist; d.h. die Arraygrenze erreicht wurde + * @return True falls Stack vollsonst false + */ +uint8 is_full(void) { + return(Point_Stack.top_of_stack == STACK_SIZE-1); +} + +/*! + * Speichern eines Stack-Elementes auf des Stack + * @param element zu sicherndes Stack-Element + */ +void push_element(element_t element) { + if (!is_full()) { + ++Point_Stack.top_of_stack; + Point_Stack.stack_array[Point_Stack.top_of_stack].posx=element.posx; + Point_Stack.stack_array[Point_Stack.top_of_stack].posy=element.posy; + } +} + + +/*! + * Speichern einer Koordinate auf dem Stack + * @param x X-Koordinate des zu sichernden Punktes + * @param y Y-Koordinate des zu sichernden Punktes + */ +void push_pos(int16 x, int16 y) { + element_t element; + element.posx=x;element.posy=y; + push_element(element); +} + + +/*! + * Implementierung der internen Pop-Routine; Rueckgabe nach LIFO des ersten Element-Typs, d.h. des letzten gepoppten Punktes + * @param element Rueckgabe des letzten Pop-Elemetes (LIFO) + */ +uint8 pop_element(element_t *element) { + if (is_empty()) + return False; + else { + *element=(Point_Stack.stack_array[Point_Stack.top_of_stack--]); + return True; + } +} + +/*! + * Pop-Routine zur Rueckgabe des letzten auf dem Stack gepushten Punktes + * @param x zuletzt gepoppte X-Koordinate + * @param y zuletzt gepoppte Y-Koordinate + * @return False falls Pop nicht erfolgreich, d.h. kein Punkt mehr auf dem Stack, sonst True nach erfolgreichem Pop + */ +uint8 pop_pos(int16 *x, int16 *y) { + element_t element; + *x=0;*y=0; + + if (pop_element(&element)) { + *x=element.posx; + *y=element.posy; + return True; + } + return False; +} + +/*! + * Setzt den Stack auf initial zurueck, d.h. Array-Index wird rueckgesetzt + */ +void clear_stack(void) { + create_stack(); +} + + + + +/*! ab hier der dynamische Stack */ +#else + +/*! + * Initialisierung des Stacks; Routine muss vor der ersten Benutzung des Stacks aufgerufen worden sein + */ +void create_stack(void) { + Point_Stack = (pos_stack_t) malloc(sizeof(struct node)); + if (Point_Stack != NULL) + Point_Stack->next = NULL; +} + + +/*! + * Implementierung der Push-Routine, nur fuer interne Verwendung + * @param ele Variable der Punkt-Element-Struktur + */ +void push_element(element_t ele) { + node_ptr tmp_cell; + tmp_cell = (node_ptr) malloc(sizeof(struct node)); + if (tmp_cell != NULL) { + tmp_cell->element = ele; + tmp_cell->next = Point_Stack->next; + Point_Stack->next = tmp_cell; + } +} + + +/*! + * Implementierung der internen Pop-Routine; Rueckgabe nach LIFO des ersten Element-Typs, d.h. des letzten gepoppten Punktes + * @param first_cell Rueckgabe des letzten Pop-Elemetes (LIFO) + */ +void pop_element(node_ptr *first_cell) { + if (Point_Stack->next != NULL) { + *first_cell = Point_Stack->next; + Point_Stack->next = Point_Stack->next->next; + } +} + + +/*! + * Speicherfreigabe der noch im Stack befindlichen Elemente und Ruecksetzen des Stacks auf NULL + */ +void clear_stack(void) { + int16 x;int16 y; + while (pop_pos(&x,&y)){} + Point_Stack->next = NULL; +} + +/*! + * Pop-Routine zur Rueckgabe des letzten auf dem Stack gepushten Punktes + * @param x zuletzt gepoppte X-Koordinate + * @param y zuletzt gepoppte Y-Koordinate + * @return False falls Pop nicht erfolgreich, d.h. kein Punkt mehr auf dem Stack, sonst True nach erfolgreichem Pop + */ +uint8 pop_pos(int16 *x, int16 *y) { + node_ptr first_cell=NULL; + pop_element(&first_cell); + *x=0;*y=0; + if (first_cell!=NULL) { + *x=first_cell->element->posx; + *y=first_cell->element->posy; + free(first_cell); + return True; + } + return False; +} + + +/*! + * Speichern einer Koordinate auf dem Stack + * @param x X-Koordinate des zu sichernden Punktes + * @param y Y-Koordinate des zu sichernden Punktes + */ +void push_pos(int16 x, int16 y) { + element_t element; + element = malloc(sizeof(struct ele)); + element->posx=x;element->posy=y; + push_element(element); +} + + +#endif + +/*! + * Rueckgabe der beiden zuletzt gespeicherten Stackkoordinaten, welche zu einer Linie gehoeren + * @param x1 X-Koordinate des zuletzt gespeicherten Linienpunktes + * @param y1 Y-Koordinate des zuletzt gespeicherten Linienpunktes + * @param x2 X-Koordinate des ersten Linienpunktes + * @param y2 Y-Koordinate des ersten Linienpunktes + * @return True nach erfolgreichem Pop beider Punkte sonst False wenn kein Pop mehr moeglich war + */ +uint8 pop_line(int16 *x1, int16 *y1, int16 *x2, int16 *y2) { + + pop_pos(x1,y1); + return pop_pos(x2,y2); +} + +/*! + * Speichern zweier Koordinaten auf dem Stack, welche zu einer Linie gehoeren + * @param x1 X-Koordinate des ersten Linienpunktes + * @param y1 Y-Koordinate des ersten Linienpunktes + * @param x2 X-Koordinate des zweiten Linienpunktes + * @param y2 Y-Koordinate des zweiten Linienpunktes + */ +void push_line(int16 x1, int16 y1, int16 x2, int16 y2) { + push_pos(x1,y1); + push_pos(x2,y2); +} + + +#endif + + + + + + + + + + Index: C:/botneu/ct-Bot/ui/gui.c =================================================================== --- C:/botneu/ct-Bot/ui/gui.c (revision 1322) +++ C:/botneu/ct-Bot/ui/gui.c (working copy) @@ -39,6 +39,7 @@ #include "led.h" #include "mini-fat.h" #include "map.h" +#include "pos_stack.h" #include <stdlib.h> #ifdef DISPLAY_AVAILABLE @@ -137,6 +138,9 @@ #ifdef DISPLAY_TRANSPORT_PILLAR register_screen(&transportpillar_display); #endif + #ifdef DISPLAY_DRIVE_STACK_AVAILABLE + register_screen(&drive_stack_display); + #endif } #endif // DISPLAY_AVAILABLE Index: C:/botneu/ct-Bot/ui/available_screens.h =================================================================== --- C:/botneu/ct-Bot/ui/available_screens.h (revision 1322) +++ C:/botneu/ct-Bot/ui/available_screens.h (working copy) @@ -45,8 +45,8 @@ #define DISPLAY_MAP_GO_DESTINATION /*!< Steuerung Map-Verhalten auf diesem Screen */ #define DISPLAY_MAP_AVAILABLE /*!< Zeigt Map-Display an */ #define DISPLAY_TRANSPORT_PILLAR /*!< Steuerung Transport-Pillar-Verhalten auf diesem Screen */ +#define DISPLAY_DRIVE_STACK_AVAILABLE /*!< Steuerung Stack-Verhalten auf diesem Screen */ - #ifndef SPEED_CONTROL_AVAILABLE #undef DISPLAY_REGELUNG_AVAILABLE #endif @@ -73,6 +73,5 @@ #undef DISPLAY_TRANSPORT_PILLAR #endif - #endif // DISPLAY_AVAILABLE #endif // available_screens_H_ Index: C:/botneu/ct-Bot/.settings/org.eclipse.cdt.core.prefs =================================================================== --- C:/botneu/ct-Bot/.settings/org.eclipse.cdt.core.prefs (revision 0) +++ C:/botneu/ct-Bot/.settings/org.eclipse.cdt.core.prefs (revision 0) @@ -0,0 +1,3 @@ +#Mon Dec 17 16:08:46 CET 2007 +eclipse.preferences.version=1 +indexerId=org.eclipse.cdt.core.fastIndexer Index: C:/botneu/ct-Bot/ct-Bot.h =================================================================== --- C:/botneu/ct-Bot/ct-Bot.h (revision 1322) +++ C:/botneu/ct-Bot/ct-Bot.h (working copy) @@ -53,6 +53,7 @@ #define MEASURE_MOUSE_AVAILABLE /*!< Geschwindigkeiten werden aus den Maussensordaten berechnet */ //#define MEASURE_COUPLED_AVAILABLE /*!< Geschwindigkeiten werden aus Maus- und Encoderwerten ermittelt und gekoppelt */ +#define POS_STACK_AVAILABLE /*!< Positionsstack wird verfuegbar*/ //#define WELCOME_AVAILABLE /*!< kleiner Willkommensgruss */