Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
#ifndef CompInterface_h
#define CompInterface_h
#include "Arduino.h"
#include "HardwareConnector.h"
#include "SimulationConnector.h"
class CompInterface {
  private:
  boolean simulation;
  
  public:
  CompInterface();
  void resetTick();
  void simulate(boolean active);
};
#endif

The CompInterface represents the communication interface to the sensors and actuators. It has a boolean, which knows if a simulation or real flight is running and gives the ability to get notified about a new tick.

Since the Arduino supports C++, most custom routines are written in it. This gives the ability to use classes for exampleNote also that Arduino.h is an Arduino library for using Arduino methods in C++ code.

CompInterface.cpp

Code Block
languagecpp
#include "Arduino.h"
#include "CompInterface.h"
boolean simulation;
HardwareConnector connector;
CompInterface::CompInterface() {
  simulation = false;
}
void CompInterface::resetTick() { 
  //TODO: Implement some code 
}
void CompInterface::simulate(boolean active) {
  simulation = active;
}

This file is just the implementation of the CompInterface.h. Note that Arduino.h is an Arduino library for using Arduino methods in C++ code.

CompInterface.cpp

Connector.h

Code Block
languagecpp
#include "Arduino.h"
#include "CompInterface.h"
boolean simulation;
HardwareConnector connector;
CompInterface::CompInterface() {
  simulation = false;
}
void CompInterface::resetTick() { #ifndef Connector_h
#define Connector_h
class Connector { 
  public:
  virtual int getProximity() = 0;
  //TODO: Implement somemore code 
}
void CompInterface::simulate(boolean active) {
  simulation = active;
}

...

methods
};
#endif

Connector.h creates an abstract class which cannot be instanced but forces all inheriting classes to implement the virtual methods equaling 0.

Heirs will be the HardwareConnector, which