Revision e1f1c4b5

View differences:

devices/DiWheelDrive/Makefile
124 124
         DiWheelDrive.cpp \
125 125
         userthread.cpp \
126 126
         linefollow.cpp \
127
				 amiro_map.cpp \
127 128
         main.cpp \
128 129
         exti.cpp
129 130

  
devices/DiWheelDrive/amiro_map.cpp
1
#include "amiro_map.hpp"
2

  
3

  
4
void AmiroMap::initialize(int8_t (&config)[MAX_NODES][NODE_ATTRIBUTES]){
5

  
6
  uint8_t nodeCount = 0;
7
  bool end = false;
8

  
9
  for (int i=0; i<MAX_NODES; i++){
10
    if(config[i][NODE_ATTRIBUTES - 1] == 255){
11
      end = true;
12
      break;
13
    }
14
    nodeCount++;
15
  }
16
  if (!end || nodeCount == 0 ){
17

  
18
    // Failed to determine the amount of nodes
19
    return;
20
  }
21

  
22
  this->nodeList = (struct node*) malloc(nodeCount * sizeof(struct node)); 
23

  
24
  
25

  
26
}
27

  
28

  
29
void AmiroMap::update(){
30
  
31
}
32

  
33

  
34
void AmiroMap::uninitialize(){
35
  
36
}
37

  
devices/DiWheelDrive/amiro_map.hpp
1
#ifndef AMIRO_MAP
2
#define AMIRO_MAP
3

  
4
#include <ch.hpp>
5
#include "global.hpp"
6
#include <amiroosconf.h>
7

  
8

  
9
#define MAX_NODES 20
10
#define NODE_ATTRIBUTES 4
11

  
12

  
13
namespace amiro {
14

  
15

  
16
  struct node{
17
    uint8_t id;
18
    uint8_t flag;
19
    types::position pL; //Left
20
    types::position pR; //Right
21
    types::position pB; //Back
22
  };
23

  
24
  class AmiroMap{
25
  public:
26
    AmiroMap(Global *global):global{global}{}
27
    void initialize(int8_t (&config)[MAX_NODES][NODE_ATTRIBUTES]);
28
    void update();
29
  private:
30
    Global *global;
31
    bool valid = false;
32
    node *nodeList = NULL;
33
    node *current = NULL;
34
    node *next = NULL;
35
    void uninitialize();
36
  };
37
};
38

  
39

  
40
#endif /* AMIRO_MAP */

Also available in: Unified diff