Finish documention until someone change something
This commit is contained in:
@@ -18,9 +18,11 @@ char DebugMqtt::msg[MQTT_BUFFER_SIZE];
|
||||
char DebugMqtt::topic[MQTT_BUFFER_SIZE];
|
||||
|
||||
|
||||
DebugMqtt::DebugMqtt(const char* name) {
|
||||
DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) {
|
||||
this->name = name;
|
||||
this->buf = new char[this->bufSitze];
|
||||
if (bufSize != 0)
|
||||
this->bufSize = bufSize;
|
||||
this->buf = new char[this->bufSize];
|
||||
}
|
||||
|
||||
DebugMqtt::~DebugMqtt() {
|
||||
@@ -62,7 +64,7 @@ void DebugMqtt::writeToInflux(String measurement_name, String field_set, float m
|
||||
void DebugMqtt::addCharacter(char c) {
|
||||
this->buf[this->bufPos] = c;
|
||||
this->bufPos++;
|
||||
if (c == '\n' || this->bufPos >= this->bufSitze - 1) {
|
||||
if (c == '\n' || this->bufPos >= this->bufSize - 1) {
|
||||
this->buf[this->bufPos - 1] = '\0';
|
||||
this->sendMsg(Loglevel::info, buf);
|
||||
this->bufPos = 0;
|
||||
|
||||
+19
-9
@@ -69,15 +69,16 @@ class DebugMqtt {
|
||||
* @brief Construct a new Debug Mqtt object.
|
||||
*
|
||||
* @param name A String with send with every Message.
|
||||
* @param bufSize for the addCharacter function.
|
||||
*/
|
||||
DebugMqtt(const char* name);
|
||||
DebugMqtt(const char* name, uint8_t bufSize = 0);
|
||||
|
||||
~DebugMqtt();
|
||||
|
||||
/**
|
||||
* @brief Send a Message via MQTT
|
||||
*
|
||||
* This funtion uses sendData to send the given string and
|
||||
* This function uses sendData to send the given string and
|
||||
* add the name to the message given by the constructer.
|
||||
*
|
||||
* @see sendData()
|
||||
@@ -93,9 +94,9 @@ class DebugMqtt {
|
||||
/**
|
||||
* @brief Send a Message via MQTT
|
||||
*
|
||||
* This funtion sends the Data via MQTT with the given topic
|
||||
* This function sends the Data via MQTT with the given topic
|
||||
* from Loglevel or followed by given String topic.
|
||||
* Normaly this function is called by sendMsg() or by
|
||||
* Normally this function is called by sendMsg() or by
|
||||
* writeToInflux()
|
||||
*
|
||||
* @see sendData()
|
||||
@@ -112,7 +113,7 @@ class DebugMqtt {
|
||||
/**
|
||||
* @brief Send a Message via MQTT for InfluxDB
|
||||
*
|
||||
* This funtion sends a MQTT message which is intended for
|
||||
* This function sends a MQTT message which is intended for
|
||||
* Telegraf. Telegraf can listen on MQTT messages and put
|
||||
* them in an Influx Database.
|
||||
*
|
||||
@@ -123,14 +124,23 @@ class DebugMqtt {
|
||||
*/
|
||||
void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos);
|
||||
|
||||
/**
|
||||
* @brief Adds a single character to the buf
|
||||
*
|
||||
* The buf will be flushed out:
|
||||
* 1. when the buffer is full
|
||||
* 2. when the character is '\n'
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
void addCharacter(char c);
|
||||
|
||||
/**
|
||||
* @brief Initalize debugMQTT for all instances
|
||||
* @brief Initialize debugMQTT for all instances
|
||||
*
|
||||
* You only have to call this function once for your project.
|
||||
* If you call this funtion again you overwrite the client and
|
||||
* the loglevel. If you only eant du overwrite the max_loglevel
|
||||
* If you call this function again you overwrite the client and
|
||||
* the loglevel. If you only want du overwrite the max_loglevel
|
||||
* use changeLoglevel()
|
||||
*
|
||||
* @see changeLoglevel()
|
||||
@@ -153,7 +163,7 @@ class DebugMqtt {
|
||||
const char* name;
|
||||
char* buf;
|
||||
uint8_t bufPos = 0;
|
||||
uint8_t bufSitze = 100;
|
||||
uint8_t bufSize = 100;
|
||||
|
||||
static String enum_to_string(Loglevel loglevel);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file outputStreamMqtt.cpp
|
||||
* @file outputBufMqtt.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains the implementation of the class OutputBufMqtt
|
||||
* @version 0.1
|
||||
* @date 2022-02-14
|
||||
*
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/**
|
||||
* @file outputStreamMqtt.h
|
||||
* @file outputBufMqtt.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a small class that provide a streambuf
|
||||
*
|
||||
* The streambuf is used to double the std::cout to consol
|
||||
* and MQTT.
|
||||
*
|
||||
* @version 0.1
|
||||
* @date 2022-02-14
|
||||
*
|
||||
@@ -19,11 +23,29 @@
|
||||
|
||||
#include "debugMqtt.h"
|
||||
|
||||
/**
|
||||
* @brief A alternativ streambuf for std::cout
|
||||
*
|
||||
* The streambuf is used to double the std::cout to consol
|
||||
* and MQTT.
|
||||
*
|
||||
*/
|
||||
class OutputBufMqtt : public std::streambuf {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Output Buf Mqtt object
|
||||
*
|
||||
* @param debugMqtt
|
||||
*/
|
||||
OutputBufMqtt(DebugMqtt* debugMqtt);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param c
|
||||
* @return std::streambuf::int_type
|
||||
*/
|
||||
virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
|
||||
|
||||
public:
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file menu.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Implementation of the class Menu
|
||||
* @version 0.1
|
||||
* @date 2022-01-12
|
||||
*
|
||||
|
||||
+20
-10
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file menu.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains the Menu class
|
||||
* @version 0.1
|
||||
* @date 2022-01-12
|
||||
*
|
||||
@@ -17,20 +17,30 @@
|
||||
#include "menuControl.h"
|
||||
|
||||
class MenuAction;
|
||||
|
||||
/**
|
||||
* @brief A class to build menu structers
|
||||
*/
|
||||
class Menu : public MenuControl {
|
||||
public:
|
||||
Menu();
|
||||
|
||||
/**
|
||||
* @brief Add a menu action to the menu
|
||||
*
|
||||
* @param entry
|
||||
*/
|
||||
void addEntry(MenuAction* entry);
|
||||
void printMenu();
|
||||
void update();
|
||||
|
||||
void down();
|
||||
void up();
|
||||
void right();
|
||||
void left();
|
||||
void yes();
|
||||
void no();
|
||||
void printMenu() override;
|
||||
void update() override;
|
||||
|
||||
void down() override;
|
||||
void up() override;
|
||||
void right() override;
|
||||
void left() override;
|
||||
void yes() override;
|
||||
void no() override;
|
||||
|
||||
private:
|
||||
bool inSubmenu = false;
|
||||
@@ -40,4 +50,4 @@ class Menu : public MenuControl {
|
||||
|
||||
};
|
||||
|
||||
#endif // MENU_H
|
||||
#endif // MENU_H
|
||||
|
||||
+3
-17
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file menuEntry.cpp
|
||||
* @file menuAction.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Implentation of the class MenuAction
|
||||
* @version 0.1
|
||||
* @date 2022-01-12
|
||||
*
|
||||
@@ -16,20 +16,6 @@ MenuAction::MenuAction(const char* name, void (*function) (), void (*callback) (
|
||||
this->callback = callback;
|
||||
}
|
||||
|
||||
MenuAction::MenuAction(const char* name, void (*function) ()) {
|
||||
this->name = name;
|
||||
this->function = function;
|
||||
this->callback = nullptr;
|
||||
}
|
||||
|
||||
// MenuAction::MenuAction(const char* name, void (DriveManager:: *classFunction) ()) {
|
||||
// this->name = name;
|
||||
// this->classFunction = classFunction;
|
||||
// this->classFunc = true;
|
||||
// this->function = nullptr;
|
||||
// this->callback = nullptr;
|
||||
// }
|
||||
|
||||
MenuAction::MenuAction(const char* name, MenuControl* menu) {
|
||||
this->name = name;
|
||||
this->menu = menu;
|
||||
@@ -60,4 +46,4 @@ MenuControl* MenuAction::getMenu() {
|
||||
return this->menu;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
+53
-5
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file menuEntry.h
|
||||
* @file menuAction.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains the MenuAction class
|
||||
* @version 0.1
|
||||
* @date 2022-01-12
|
||||
*
|
||||
@@ -14,15 +14,63 @@
|
||||
#include "menu.h"
|
||||
|
||||
class MenuControl;
|
||||
|
||||
/**
|
||||
* @brief This class forms the transition between menus.
|
||||
*
|
||||
* In the Menu these are the entries.
|
||||
* This class can be call an submenu or a function.
|
||||
*/
|
||||
class MenuAction {
|
||||
public:
|
||||
MenuAction(const char* name, void (*function) (), void (*callback) ());
|
||||
MenuAction(const char* name, void (*function) ());
|
||||
|
||||
/**
|
||||
* @brief Construct a new Menu Action object
|
||||
*
|
||||
* @param name shown in the Menu
|
||||
* @param function to call when activate the entry
|
||||
* @param callback to call when leave the entry
|
||||
*/
|
||||
MenuAction(const char* name, void (*function) (), void (*callback) () = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Construct a new Menu Action object
|
||||
*
|
||||
* This constructer is used for submenus.
|
||||
*
|
||||
* @param name shown in the Menu
|
||||
* @param menu to call when activate the entry
|
||||
*/
|
||||
MenuAction(const char* name, MenuControl* menu);
|
||||
|
||||
/**
|
||||
* @brief activates the entry
|
||||
*/
|
||||
void runAction();
|
||||
|
||||
/**
|
||||
* @brief Get the Name string
|
||||
*
|
||||
* @return const char*
|
||||
*/
|
||||
const char* getName();
|
||||
|
||||
/**
|
||||
* @brief Get the Is Menu object
|
||||
*
|
||||
* @return true runAction calls a submenu
|
||||
* @return false runAction call a function
|
||||
*/
|
||||
bool getIsMenu();
|
||||
|
||||
/**
|
||||
* @brief Get the Menu object
|
||||
*
|
||||
* Before call this function it may be useful
|
||||
* to check if is it a submenu with getIsMenu.
|
||||
*
|
||||
* @return MenuControl*
|
||||
*/
|
||||
MenuControl* getMenu();
|
||||
|
||||
private:
|
||||
@@ -35,4 +83,4 @@ class MenuAction {
|
||||
MenuControl* menu;
|
||||
};
|
||||
|
||||
#endif // MENU_ENTRY_H
|
||||
#endif // MENU_ENTRY_H
|
||||
|
||||
+37
-3
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file menuControl.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a abstract class for Menu
|
||||
* @version 0.1
|
||||
* @date 2022-01-19
|
||||
*
|
||||
@@ -15,25 +15,59 @@
|
||||
#include <iostream>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
/**
|
||||
* @brief Baseclass to build Menus
|
||||
*
|
||||
* This class must be inherited by other classes which want to be
|
||||
* act as a menu, because the menu structure uses polymorphism.
|
||||
*
|
||||
*/
|
||||
class MenuControl {
|
||||
public:
|
||||
|
||||
// Ínputs from the Gamepad
|
||||
/** @name UserInputs
|
||||
* @brief This functions should be called be user actions.
|
||||
*
|
||||
* This functions have to be implement in every other menu
|
||||
* class.
|
||||
*/
|
||||
///@{
|
||||
virtual void down();
|
||||
virtual void up();
|
||||
virtual void right();
|
||||
virtual void left();
|
||||
virtual void yes();
|
||||
virtual void no();
|
||||
///@}
|
||||
|
||||
/**
|
||||
* @brief can be called to update shown data
|
||||
*/
|
||||
virtual void update();
|
||||
|
||||
virtual void printMenu();
|
||||
|
||||
/**
|
||||
* @brief Set the Parent Menu
|
||||
*
|
||||
* If the parentMenu is set it will be called automaticaly
|
||||
* when the user left the child menu.
|
||||
*
|
||||
* @param menu
|
||||
*/
|
||||
void setParentMenu(MenuControl* menu) { this->parentMenu = menu; }
|
||||
|
||||
/**
|
||||
* @brief Set the Lcd object
|
||||
*
|
||||
* If this is set the menu will be print on the display too.
|
||||
*
|
||||
* @param lcd
|
||||
*/
|
||||
void setLcd(LiquidCrystal_I2C* lcd) { this->lcd = lcd; }
|
||||
|
||||
protected:
|
||||
MenuControl* parentMenu = nullptr;
|
||||
LiquidCrystal_I2C* lcd = nullptr;
|
||||
};
|
||||
#endif // MENU_CONTROLL_H
|
||||
#endif // MENU_CONTROLL_H
|
||||
|
||||
@@ -32,7 +32,7 @@ class MotorControl {
|
||||
MotorControl();
|
||||
|
||||
/**
|
||||
* @brief Initalize the motorcontroler
|
||||
* @brief Initialize the motorController
|
||||
*
|
||||
* @param pwm_pin The output pin for the signal on the esp.
|
||||
* @param pwm_channel One of the pwm channels from the esp.
|
||||
@@ -53,7 +53,7 @@ class MotorControl {
|
||||
uint16_t loop();
|
||||
|
||||
/**
|
||||
* @brief Normaly called repeatedly by loop() to update the pwm signal.
|
||||
* @brief Normally called repeatedly by loop() to update the pwm signal.
|
||||
*
|
||||
* Checks the difference between target power and current power to
|
||||
* increase or decrease the duty cycle. The amount of decrease or increase
|
||||
@@ -167,4 +167,4 @@ class MotorControl {
|
||||
|
||||
};
|
||||
|
||||
#endif // MOTOR_CONTROL_H
|
||||
#endif // MOTOR_CONTROL_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file navigation.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains the implementation of the class Navigation
|
||||
* @version 0.1
|
||||
* @date 2022-01-31
|
||||
*
|
||||
@@ -50,7 +50,7 @@ CourseCorrection Navigation::getCourseCorrection() {
|
||||
|
||||
Point currentPos = this->currentLocation();
|
||||
double targetCourse = Navigation::courseTo(currentPos, this->targetPoint);
|
||||
double distance = Navigation::distanceBetwenn(currentPos, this->targetPoint);
|
||||
double distance = Navigation::distanceBetween(currentPos, this->targetPoint);
|
||||
|
||||
if (targetCourse < 0 || distance < 0 || this->navigationFinished)
|
||||
return courseCorrection;
|
||||
@@ -89,7 +89,7 @@ bool Navigation::addCurrentPosToRoute() {
|
||||
}
|
||||
|
||||
// Ever Point after the first
|
||||
if (MIN_DISTANCE_BETWEEN_POINTS <= this->distanceBetwenn(p, this->lastPoint)) {
|
||||
if (MIN_DISTANCE_BETWEEN_POINTS <= this->distanceBetween(p, this->lastPoint)) {
|
||||
this->route->addPointToRoute(p);
|
||||
this->lastPoint = p;
|
||||
return true;
|
||||
@@ -121,7 +121,7 @@ bool Navigation::setTargetPoint(Point target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double Navigation::distanceBetwenn(Point p1, Point p2) {
|
||||
double Navigation::distanceBetween(Point p1, Point p2) {
|
||||
if (p1.isValid() && p2.isValid())
|
||||
return TinyGPSPlus::distanceBetween(p1.lat, p1.lon, p2.lat, p2.lon);
|
||||
return -1;
|
||||
|
||||
+123
-3
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file navigation.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a class which navigate an object by the given route
|
||||
* @version 0.1
|
||||
* @date 2022-01-10
|
||||
*
|
||||
@@ -18,33 +18,153 @@
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/**
|
||||
* @brief The minimal distance between Points
|
||||
*
|
||||
* This is a very critical option. It have to be
|
||||
* around the half accuracy of the positioning system
|
||||
*
|
||||
*/
|
||||
#define MIN_DISTANCE_BETWEEN_POINTS 1
|
||||
|
||||
/**
|
||||
* @brief This struct inherits the result of the navigation
|
||||
*
|
||||
* The drive get objects of this struct and should
|
||||
* correct the direction in dependency on this.
|
||||
*
|
||||
*/
|
||||
struct CourseCorrection {
|
||||
int16_t correction;
|
||||
double distance;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class navigate an object
|
||||
*
|
||||
* The class use the given Route and the gps device
|
||||
* to tell the driver in which direction he have to
|
||||
* be drive and the distance to the next checkpoint.
|
||||
*
|
||||
*/
|
||||
class Navigation {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Navigation object
|
||||
*
|
||||
* @param rx pin to the gps device
|
||||
* @param tx pin to the gps device
|
||||
* @param route with which to navigate
|
||||
*/
|
||||
Navigation(uint8_t rx, uint8_t tx, Route* route = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Destroy the Navigation object
|
||||
*
|
||||
*/
|
||||
~Navigation();
|
||||
|
||||
/**
|
||||
* @brief Decodes new GPS information
|
||||
*
|
||||
* Should be called ever main loop.
|
||||
*/
|
||||
void loop();
|
||||
|
||||
/**
|
||||
* @brief creates a new empty route
|
||||
*
|
||||
*/
|
||||
void newRoute();
|
||||
|
||||
/**
|
||||
* @brief Tries to start the route
|
||||
*
|
||||
* For example the route can not be started
|
||||
* if there are no Points or wrong Points.
|
||||
*
|
||||
* @return true route is started
|
||||
* @return false route can not be started
|
||||
*/
|
||||
bool startNavigation();
|
||||
|
||||
/**
|
||||
* @brief Get the Course Correction object
|
||||
*
|
||||
* This should be called by the driver to get new instructions.
|
||||
*
|
||||
* @return CourseCorrection
|
||||
*/
|
||||
CourseCorrection getCourseCorrection();
|
||||
|
||||
/**
|
||||
* @brief Tries to add the current Position to the route
|
||||
*
|
||||
* This can be go wrong if there is no valid GPS signal
|
||||
*
|
||||
* @return true successful added point
|
||||
* @return false no point added to route
|
||||
*/
|
||||
bool addCurrentPosToRoute();
|
||||
|
||||
/**
|
||||
* @brief Returns the GPS object
|
||||
*
|
||||
* @return TinyGPSPlus*
|
||||
*/
|
||||
TinyGPSPlus* getGPS() { return this->gps; }
|
||||
|
||||
/**
|
||||
* @brief Get the Route Info object
|
||||
*
|
||||
* This object contains information about the route.
|
||||
* For example the stored points.
|
||||
*
|
||||
* @return RouteInfo
|
||||
*/
|
||||
RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); }
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Returns the current Location
|
||||
*
|
||||
* @return Point
|
||||
*/
|
||||
Point currentLocation();
|
||||
|
||||
/**
|
||||
* @brief Set the next point as target
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool nextPoint();
|
||||
|
||||
/**
|
||||
* @brief Set the target point
|
||||
*
|
||||
* @param target
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool setTargetPoint(Point target);
|
||||
static double distanceBetwenn(Point p1, Point p2);
|
||||
|
||||
/**
|
||||
* @brief Calculate the distance between to points
|
||||
*
|
||||
* @param p1 point 1
|
||||
* @param p2 point 2
|
||||
* @return double distance in meter
|
||||
*/
|
||||
static double distanceBetween(Point p1, Point p2);
|
||||
|
||||
/**
|
||||
* @brief Calculates the course from point1 to point2
|
||||
*
|
||||
* @param p1 point 1
|
||||
* @param p2 point 2
|
||||
* @return double degree north = 0° west = 270°
|
||||
*/
|
||||
static double courseTo(Point p1, Point p2);
|
||||
|
||||
TinyGPSPlus* gps;
|
||||
@@ -57,4 +177,4 @@ class Navigation {
|
||||
bool navigationFinished = false;
|
||||
};
|
||||
|
||||
#endif // NAVIGATION_H
|
||||
#endif // NAVIGATION_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file route.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Implements the class Route
|
||||
* @version 0.1
|
||||
* @date 2022-01-31
|
||||
*
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
#include "route.h"
|
||||
|
||||
// TODO: Delete iostream
|
||||
#include <iostream>
|
||||
|
||||
Route::Route() {
|
||||
|
||||
}
|
||||
|
||||
+68
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file route.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a class which hold multiple Points
|
||||
* @version 0.1
|
||||
* @date 2022-01-31
|
||||
*
|
||||
@@ -16,33 +16,100 @@
|
||||
#include <list>
|
||||
|
||||
|
||||
/**
|
||||
* @brief A to handle points on the earth
|
||||
*
|
||||
* The points inherits latidue and longitude as doubles
|
||||
*
|
||||
*/
|
||||
class Point{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Point object
|
||||
*
|
||||
* @param lat latidude
|
||||
* @param lon longitude
|
||||
*/
|
||||
Point(double lat, double lon) { this->lat = lat; this->lon = lon; }
|
||||
Point(){ this->lat = 0; this->lon = 0; }
|
||||
|
||||
double lat = 0;
|
||||
double lon = 0;
|
||||
|
||||
/**
|
||||
* @brief checks if to points are equal
|
||||
*
|
||||
* @param rhs
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool operator==(const Point& rhs) const {
|
||||
return this->lat == rhs.lat && this->lon == rhs.lon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the Point is valid
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool isValid() const { return this->lat + this->lon; }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Holds some route information
|
||||
*
|
||||
*/
|
||||
struct RouteInfo{
|
||||
/**
|
||||
* @brief Selected number of Points
|
||||
*/
|
||||
uint16_t currentPoint;
|
||||
|
||||
/**
|
||||
* @brief Total points stored in route
|
||||
*/
|
||||
uint16_t totalPoints;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class to manage multiple points
|
||||
*
|
||||
* The list of point presents a route which can be driven
|
||||
*/
|
||||
class Route {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Route object
|
||||
*/
|
||||
Route();
|
||||
|
||||
/**
|
||||
* @brief Adds a point to the list
|
||||
*
|
||||
* @param point
|
||||
*/
|
||||
void addPointToRoute(Point point);
|
||||
|
||||
/**
|
||||
* @brief Select the first point as target
|
||||
*
|
||||
* @return Point
|
||||
*/
|
||||
Point startRoute();
|
||||
|
||||
/**
|
||||
* @brief Get the next point and set it as target
|
||||
*
|
||||
* @return Point is zero if there are no more Points
|
||||
*/
|
||||
Point getNextPoint();
|
||||
|
||||
/**
|
||||
* @brief Get the Route Info object
|
||||
*
|
||||
* @return RouteInfo
|
||||
*/
|
||||
RouteInfo getRouteInfo();
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file speedometer.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief A complete implementation to measure wheel speeds with an encoder.
|
||||
* @brief A implementation to measure wheel speeds with an encoder.
|
||||
* @version 0.1
|
||||
* @date 2021-12-09
|
||||
*
|
||||
@@ -32,7 +32,7 @@
|
||||
* @brief A class which use a encoder to calc the speed
|
||||
*
|
||||
* This class use ESP32 pulse counter hardware peripheral.
|
||||
* The calclutaed speed is the average of an amount of last measurments.
|
||||
* The calculated speed is the average of an amount of last measurements.
|
||||
*
|
||||
*/
|
||||
class Speedometer {
|
||||
@@ -40,7 +40,7 @@ class Speedometer {
|
||||
Speedometer();
|
||||
|
||||
/**
|
||||
* @brief Initalize the speedometer
|
||||
* @brief Initialize the speedometer
|
||||
*
|
||||
* @param pinA Pin on the Esp from the encoder.
|
||||
* @param pinB Pin on the Esp from the encoder.
|
||||
@@ -63,7 +63,7 @@ class Speedometer {
|
||||
uint16_t loop();
|
||||
|
||||
/**
|
||||
* @brief Noramly called repeatedly by loop() to calcluate new values.
|
||||
* @brief Normally called repeatedly by loop() to calculate new values.
|
||||
*
|
||||
* Add a new Value to the average and update the speed.
|
||||
*/
|
||||
@@ -121,4 +121,4 @@ class Speedometer {
|
||||
uint32_t last_millis_calc = 0;
|
||||
};
|
||||
|
||||
#endif // SPEEDOMETER_H
|
||||
#endif // SPEEDOMETER_H
|
||||
|
||||
Reference in New Issue
Block a user