documentation checked and edit

for all files in lib folder
This commit is contained in:
2023-10-12 18:45:12 +02:00
parent 61a95e4601
commit db74898b72
41 changed files with 1030 additions and 569 deletions
+5
View File
@@ -123,11 +123,13 @@
"Ahnung", "Ahnung",
"akku", "akku",
"ardui", "ardui",
"Baseclass",
"blox", "blox",
"bluedroid", "bluedroid",
"carr", "carr",
"CIPO", "CIPO",
"COPI", "COPI",
"Doxygen",
"Dutycycle", "Dutycycle",
"gast", "gast",
"GNSS", "GNSS",
@@ -137,9 +139,12 @@
"Keine", "Keine",
"kleiax", "kleiax",
"Lebennig", "Lebennig",
"microcontroller",
"MQTT",
"NMEA", "NMEA",
"NMEAGPGGA", "NMEAGPGGA",
"NTRIP", "NTRIP",
"pcnt",
"pidl", "pidl",
"pidr", "pidr",
"Punica", "Punica",
+5 -5
View File
@@ -51,7 +51,7 @@ PROJECT_BRIEF = "A small verhicle which should be drive a route with GP
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory. # the logo to the output directory.
PROJECT_LOGO = C:/Users/alex1/git/projektarbeit/doc/Doxygen/logo.png PROJECT_LOGO = logo.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is # into which the generated documentation will be written. If a relative path is
@@ -606,7 +606,7 @@ HIDE_COMPOUND_REFERENCE= NO
# will show which file needs to be included to use the class. # will show which file needs to be included to use the class.
# The default value is: YES. # The default value is: YES.
SHOW_HEADERFILE = YES # SHOW_HEADERFILE = YES
# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
# the files that are included by a file in the documentation of that file. # the files that are included by a file in the documentation of that file.
@@ -824,7 +824,7 @@ WARN_IF_DOC_ERROR = YES
# parameters have no documentation without warning. # parameters have no documentation without warning.
# The default value is: YES. # The default value is: YES.
WARN_IF_INCOMPLETE_DOC = YES # WARN_IF_INCOMPLETE_DOC = YES
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
# are documented, but have no documentation for their parameters or return # are documented, but have no documentation for their parameters or return
@@ -1608,7 +1608,7 @@ GENERATE_TREEVIEW = YES
# The default value is: NO. # The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
FULL_SIDEBAR = NO # FULL_SIDEBAR = NO
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation. # doxygen will group on one line in the generated HTML documentation.
@@ -1691,7 +1691,7 @@ USE_MATHJAX = NO
# The default value is: MathJax_2. # The default value is: MathJax_2.
# This tag requires that the tag USE_MATHJAX is set to YES. # This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_VERSION = MathJax_2 # MATHJAX_VERSION = MathJax_2
# When MathJax is enabled you can set the default output format to be used for # When MathJax is enabled you can set the default output format to be used for
# the MathJax output. For more details about the output format see MathJax # the MathJax output. For more details about the output format see MathJax
+2
View File
@@ -28,6 +28,8 @@ Do later:
-> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung -> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung
-> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird. -> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird.
-> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz -> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz
-> Doxygen comments
- navigation
Do now: Do now:
-9
View File
@@ -1,9 +0,0 @@
void KomponenteA::loop() {
this->komponenteB->loop();
this->komponenteC->loop();
if (millis() - this->lastMillis < this->delayMillis)
return;
this->doSomething();
}
+7 -8
View File
@@ -1,9 +1,8 @@
// AUTO GENERATED FILE, DO NOT EDIT // AUTO GENERATED FILE, DO NOT EDIT
#ifndef VERSION #ifndef VERSION
#define VERSION "0.8.36" #define VERSION "1.8.36"
#endif #endif
#ifndef BUILD_TIMESTAMP #ifndef BUILD_TIMESTAMP
#define BUILD_TIMESTAMP "2023-08-13 15:13:34.491991" #define BUILD_TIMESTAMP "2023-10-13 15:13:34.491991"
#endif #endif
+147 -143
View File
@@ -4,9 +4,9 @@
* @brief Contains the MoveControl class * @brief Contains the MoveControl class
* @version 0.1 * @version 0.1
* @date 2021-12-14 * @date 2021-12-14
* *
* @copyright Copyright (c) 2021 * @copyright Copyright (c) 2021
* *
*/ */
#ifndef MOVE_CONTROL_H #ifndef MOVE_CONTROL_H
#define MOVE_CONTROL_H #define MOVE_CONTROL_H
@@ -22,178 +22,182 @@
#include "debugTimes.h" #include "debugTimes.h"
#include "component.h" #include "component.h"
/** /**
* @brief A struct to easy set the speed * @brief A struct to easy set the speed
* *
*/ */
struct DrivingSpeeds { struct DrivingSpeeds
{
double x; double x;
double rot; double rot;
}; };
/** /**
* @brief This class manages the motors and the encoders * @brief This class manages the motors and the encoders
* *
* The class uses two PIDs to control the motors. The PIDs * The class uses two PIDs to control the motors. The PIDs
* use the Speedometer class to get the current speed and the * use the Speedometer class to get the current speed and the
* given target speed to calculate a new duty cycle for the motors. * given target speed to calculate a new duty cycle for the motors.
* *
*/ */
class MoveControl : public Component { class MoveControl : public Component
public: {
/** public:
* @brief used to set driving status /**
* * @brief Used to set driving status
* When set to stop all motors are set to halt *
* When set to Raw the PIDs are not used. The target * When set to stop all motors are set to halt
* values must be given withe @see setRawPowerLeft and *
* @see setRawPowerRight. * When set to Raw the PIDs are not used. The target
* * values must be given withe setRawPowerLeft() and
* Drive is the normal working mode. * setRawPowerRight().
* *
*/ * Drive is the normal working mode.
enum Status {Stop, *
Drive, */
Raw}; enum Status
{
Stop,
Drive,
Raw
};
/**
* @brief Construct a new Move Control object
*
* Initialize the motors, encoders and PIDs with given
* values in config.h
*/
MoveControl();
/** /**
* @brief Construct a new Move Control object * @brief Destroy the Move Control object
* *
* Initialize the motors, encoders and PIDs with given * Stops the motors with emergencyStop()
* values in config.h */
*/ ~MoveControl();
MoveControl();
/** /**
* @brief Destroy the Move Control object * @brief Set the Status
* *
* Stops the motors with emergencyStop() * Control if this component should work normally or with
*/ * raw values for the motors.
~MoveControl(); *
* @see Status
* @param status
*/
void setDrivingStatus(Status status);
/** /**
* @brief Set the Status * @brief Stops the engine immediately
* *
* Control if this component should work normally or with */
* raw values for the motors. void emergencyStop();
*
* @see Status
* @param status
*/
void setDrivingStatus(Status status);
/** /**
* @brief Stops the engine immediately * @brief Set the target speed
* *
*/ * If the given speed is close to zero, then the
void emergencyStop(); * target speed is set to zero.
* @param speed in m/s
*/
void setSpeed(double speed);
/** /**
* @brief Set the target speed * @brief Set the rotationSpeed
* *
* If the given speed is close to zero, then the * If the given rotationSpeed is close to zero, then the
* target speed is set to zero. * target rotationSpeed is set to zero.
* @param speed in m/s * @param speed rad/s
*/ */
void setSpeed(double speed); void setRotationSpeed(double speed);
/** /**
* @brief Set the rotationSpeed * @brief Set the speeds
* *
* If the given rotationSpeed is close to zero, then the * This function is a combination of the functions setSpeed() and
* target rotationSpeed is set to zero. * setRotationSpeed(). The struct DrivingSpeeds
* @param speed rad/s * is used for this.
*/ *
void setRotationSpeed(double speed); *
* @param drivingSpeeds
*/
void setSpeeds(DrivingSpeeds drivingSpeeds);
/** /**
* @brief Set the speeds * @brief Set raw power left
* *
* This function is a combination of @see setSpeed and * This value has only an effect if the status is raw.
* @see setRotationSpeed. The struct @see DrivingSpeeds * @see setDrivingStatus
* is used for this. *
* * @param power between -100 and 100
* @param drivingSpeeds */
*/ void setRawPowerLeft(int16_t power);
void setSpeeds(DrivingSpeeds drivingSpeeds);
/** /**
* @brief Set raw power left * @brief Set the raw power right
* *
* This value has only an effect if the status is raw. * This value has only an effect if status is raw.
* @see setDrivingStatus *
* * @param power between -100 and 100
* @param power between -100 and 100 */
*/ void setRawPowerRight(int16_t power);
void setRawPowerLeft(int16_t power);
/** /**
* @brief Set the raw power right * @brief Set the pid tunings
* *
* This value has only an effect if status is raw. * @param side 0 -> left, 1 -> right
* * @param pPart
* @param power between -100 and 100 * @param iPart
*/ * @param dPart
void setRawPowerRight(int16_t power); */
void setPidTunings(uint8_t side, double pPart, double iPart, double dPart);
/** /**
* @brief Set the pid tunings * @brief Returns the PID object of the choosen side.
* *
* @param side 0 -> left, 1 -> right * @param side 0 -> left, 1 -> right
* @param pPart * @return PID*
* @param iPart */
* @param dPart PID *getPID(uint8_t side) const;
*/
void setPidTunings(uint8_t side, double pPart, double iPart, double dPart);
/** Speedometer *getSpeedometerLeft() const { return this->leftSpeedometer; }
* @brief Returns the PID object of the choosen side. Speedometer *getSpeedometerRight() const { return this->rightSpeedometer; }
*
* @param side 0 -> left, 1 -> right
* @return PID*
*/
PID* getPID(uint8_t side) const;
Speedometer* getSpeedometerLeft() const { return this->leftSpeedometer; } uint16_t getDutycycleLeft() const { return this->leftMotor->getDutycycle(); }
Speedometer* getSpeedometerRight() const { return this->rightSpeedometer; } uint16_t getDutycycleRight() const { return this->rightMotor->getDutycycle(); }
uint16_t getDutycycleLeft() const { return this->leftMotor->getDutycycle(); } private:
uint16_t getDutycycleRight() const { return this->rightMotor->getDutycycle(); } void run() override;
static void setSpeedometerDirection(Speedometer *speedometer, double value);
void calcTargetWheelSpeed();
void regulateMotors();
void updateCurrentWheelSpeed();
private: MotorControl *leftMotor;
void run() override; MotorControl *rightMotor;
static void setSpeedometerDirection(Speedometer *speedometer, double value); Speedometer *leftSpeedometer;
void calcTargetWheelSpeed(); Speedometer *rightSpeedometer;
void regulateMotors(); PID *leftPid;
void updateCurrentWheelSpeed(); PID *rightPid;
MotorControl *leftMotor; Status driving_status = Status::Stop;
MotorControl *rightMotor; DrivingSpeeds drivingSpeeds = {0, 0};
Speedometer *leftSpeedometer;
Speedometer *rightSpeedometer;
PID *leftPid;
PID *rightPid;
Status driving_status = Status::Stop; double wheelspeedLeftTarget = 0;
DrivingSpeeds drivingSpeeds = {0, 0}; double wheelspeedRightTarget = 0;
double wheelspeedLeft = 0;
double wheelspeedRight = 0;
double leftPidOut = 0;
double rightPidOut = 0;
double wheelspeedLeftTarget = 0; uint8_t overTimeCounter = 0;
double wheelspeedRightTarget = 0; uint8_t overTimeMax = 100;
double wheelspeedLeft = 0; int8_t rawPowerLeft = 0;
double wheelspeedRight = 0; int8_t rawPowerRight = 0;
double leftPidOut = 0;
double rightPidOut = 0;
uint8_t overTimeCounter = 0;
uint8_t overTimeMax = 100;
int8_t rawPowerLeft = 0;
int8_t rawPowerRight = 0;
static constexpr int8_t maxPercentage = 100;
static constexpr float minSpeed = 0.2;
static constexpr uint8_t loopDelay = 20;
static constexpr int8_t maxPercentage = 100;
static constexpr float minSpeed = 0.2;
static constexpr uint8_t loopDelay = 20;
}; };
#endif // MOVE_CONTROL_H #endif // MOVE_CONTROL_H
+18 -13
View File
@@ -2,14 +2,14 @@
* @file networkConfig.h * @file networkConfig.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains the settings for the Network class * @brief Contains the settings for the Network class
* *
* With different defines the location can be choosen. * With different defines the location can be choosen.
* *
* @version 0.1 * @version 0.1
* @date 2022-02-15 * @date 2022-02-15
* *
* @copyright Copyright (c) 2022 * @copyright Copyright (c) 2022
* *
*/ */
#include <stdint.h> #include <stdint.h>
@@ -17,7 +17,8 @@
#define HW1 #define HW1
#ifdef HOTSPOT #ifdef HOTSPOT
namespace NetworkConfig { namespace NetworkConfig
{
const char ssid[] = "Kleiax Handy"; const char ssid[] = "Kleiax Handy";
const char password[] = "12345677"; const char password[] = "12345677";
const char ip[] = "192.168.43.4"; const char ip[] = "192.168.43.4";
@@ -26,10 +27,11 @@ namespace NetworkConfig {
const char dns[] = "8.8.8.8"; const char dns[] = "8.8.8.8";
const bool mqtt = false; const bool mqtt = false;
} }
#endif //HOTSPOT #endif // HOTSPOT
#ifdef HW1 #ifdef HW1
namespace NetworkConfig { namespace NetworkConfig
{
const char ssid[] = "hw1_gast"; const char ssid[] = "hw1_gast";
const char password[] = "KeineAhnung"; const char password[] = "KeineAhnung";
const char ip[] = "192.168.0.4"; const char ip[] = "192.168.0.4";
@@ -38,11 +40,12 @@ namespace NetworkConfig {
const char dns[] = "8.8.8.8"; const char dns[] = "8.8.8.8";
const bool mqtt = false; const bool mqtt = false;
} }
#endif //HW1 #endif // HW1
//Network config Rhede // Network config Rhede
#ifdef RHEDE #ifdef RHEDE
namespace NetworkConfig { namespace NetworkConfig
{
const char ssid[] = "LebennigHuus"; const char ssid[] = "LebennigHuus";
const char password[] = "Punica-699"; const char password[] = "Punica-699";
const char ip[] = "192.168.11.4"; const char ip[] = "192.168.11.4";
@@ -51,16 +54,18 @@ namespace NetworkConfig {
const char dns[] = "8.8.8.8"; const char dns[] = "8.8.8.8";
const bool mqtt = true; const bool mqtt = true;
} }
#endif //RHEDE #endif // RHEDE
namespace MqttConfig { namespace MqttConfig
{
const char server[] = "192.168.1.7"; const char server[] = "192.168.1.7";
const uint16_t port = 1883; const uint16_t port = 1883;
const char user[] = "kleiax"; const char user[] = "kleiax";
const char password[] = "p?{$_~5%hBM7wrcFkr55KWr#"; const char password[] = "p?{$_~5%hBM7wrcFkr55KWr#";
} }
namespace NtripConfig { namespace NtripConfig
{
const char host[] = "rtk2go.com"; const char host[] = "rtk2go.com";
const uint16_t port = 2101; const uint16_t port = 2101;
// const char mountPoint[] = "GER-Dortmund"; // const char mountPoint[] = "GER-Dortmund";
+5 -5
View File
@@ -37,12 +37,12 @@ void Battery::run()
this->readAdcToBuf(); this->readAdcToBuf();
this->loopCounter++; this->loopCounter++;
if (this->loopCounter >= this->calulationDelayMultiplier) if (this->loopCounter >= this->calculateDelayMultiplier)
{ {
this->calculateBatteryVoltage(); this->calculateBatteryVoltage();
this->calculateBatteryPercent(); this->calculateBatteryPercent();
this->loopCounter = 0; this->loopCounter = 0;
this->calculatetNewValues = true; this->calculatedNewValues = true;
} }
} }
@@ -89,12 +89,12 @@ bool Battery::isBatteryLow(double voltage) const
bool Battery::isNewValue() bool Battery::isNewValue()
{ {
if (!this->calculatetNewValues) if (!this->calculatedNewValues)
{ {
return false; return false;
} }
this->calculatetNewValues = false; this->calculatedNewValues = false;
return true; return true;
} }
@@ -136,7 +136,7 @@ double Battery::calculateInputVoltage()
return 0; return 0;
} }
return -this->adcCurveCoeficient[0] * pow(reading, 4) + this->adcCurveCoeficient[1] * pow(reading, 3) - this->adcCurveCoeficient[2] * pow(reading, 2) + this->adcCurveCoeficient[3] * reading + this->adcCurveCoeficient[4]; return -this->adcCurveCoefficient[0] * pow(reading, 4) + this->adcCurveCoefficient[1] * pow(reading, 3) - this->adcCurveCoefficient[2] * pow(reading, 2) + this->adcCurveCoefficient[3] * reading + this->adcCurveCoefficient[4];
} }
void Battery::calculateBatteryVoltage() void Battery::calculateBatteryVoltage()
+66 -11
View File
@@ -24,12 +24,20 @@
* *
* This class reads the voltage from an analog pin to calculate the * This class reads the voltage from an analog pin to calculate the
* charge level of a 3 Cell Li-Poly battery pack. The battery pack have * charge level of a 3 Cell Li-Poly battery pack. The battery pack have
* to be after a voltage diveder, so that maximum voltage for the * to be after a voltage divider, so that maximum voltage for the
* microcontroller is 3.3 Volt. * microcontroller is 3.3 Volt.
*/ */
class Battery : public Component class Battery : public Component
{ {
public: public:
/**
* @brief States when the calibration modes is active
*
* - None means that no calibration is running
* - Reading means that the adc takes multiple values to calculate an average
* - Waiting means that the user has to set the new wanted voltage
* - Finished means that all measurements was taken
*/
enum CalibrationState enum CalibrationState
{ {
None, None,
@@ -41,15 +49,25 @@ public:
/** /**
* @brief Construct a new Battery object * @brief Construct a new Battery object
* *
* The voltage devider have to be calculated, so that the input * The voltage divider have to be calculated, so that the input
* voltage from 3.3 Volt is never exceeded. It is assumed that * voltage from 3.3 Volt is never exceeded. It is assumed that
* the microcontroller is connected to the second resistor. * the microcontroller is connected to the second resistor.
* *
* @param pin The analog to read from. * @param pin The analog to read from.
* @param firstResistor First resistor of the voltage devider. * @param firstResistor First resistor of the voltage divider.
* @param secondResistor Second resistor of the voltage devider. * @param secondResistor Second resistor of the voltage divider.
*/ */
Battery(uint8_t pin, uint32_t firstResistor, uint32_t secondResistor); Battery(uint8_t pin, uint32_t firstResistor, uint32_t secondResistor);
/**
* @brief Construct a new Battery object
*
* With this constructor the real voltage is not calculated with the
* voltage divider but with a table which contains the raw reading from
* the adc mapped to a specific voltage
*
* @param pin
*/
Battery(uint8_t pin); Battery(uint8_t pin);
/** /**
@@ -79,13 +97,50 @@ public:
*/ */
bool isBatteryLow(double voltage) const; bool isBatteryLow(double voltage) const;
/**
* @brief Check if a new voltage was been calculated
*
* @return true
* @return false
*/
bool isNewValue(); bool isNewValue();
// Calibration // Calibration
CalibrationState getCalibrationState() const { return this->calibrationState; } CalibrationState getCalibrationState() const { return this->calibrationState; }
/**
* @brief Get the current calibration voltage target
*
* The returned value stand for the index of the table for this reason
* the real value have to be calculated. After the returned voltage has been set
* you have to call nextVoltageIsReady().
*
* @return uint8_t voltage multiply with 0,1 and add 7
*/
uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; } uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; }
/**
* @brief Read next wanted voltage
*
* If this function is called, the calibration mode reads the new voltage
* and save the value in the table.
*/
void nextVoltageIsReady(); void nextVoltageIsReady();
/**
* @brief Calibrate the battery readings
*
* This calibration has only an effect if the Component
* uses the table with the raw adc values. The calibration gives
* the user different voltages that have to be set with a
* laboratory power supply. The power supply have to be connected
* instead of the battery.
*/
void startCalibration(); void startCalibration();
/**
* @brief abort the calibration
*/
void finishCalibration(); void finishCalibration();
private: private:
@@ -109,14 +164,14 @@ private:
uint8_t batteryPercent = 0; uint8_t batteryPercent = 0;
uint8_t batteryLowPercent = 10; uint8_t batteryLowPercent = 10;
uint8_t bufferPos = 0; uint8_t bufferPos = 0;
uint8_t calulationDelayMultiplier = 5; uint8_t calculateDelayMultiplier = 5;
uint8_t loopCounter = 0; uint8_t loopCounter = 0;
uint8_t currentCalibrationVoltage = 0; // *0.1 + 7 uint8_t currentCalibrationVoltage = 0; // *0.1 + 7
uint16_t adcBuffer[bufferSize]; uint16_t adcBuffer[bufferSize];
uint16_t *newRawAdcVoltages = nullptr; uint16_t *newRawAdcVoltages = nullptr;
uint32_t firstResistor = 0; uint32_t firstResistor = 0;
uint32_t secondResistor = 0; uint32_t secondResistor = 0;
bool calculatetNewValues = false; bool calculatedNewValues = false;
double batteryVoltage = 0; double batteryVoltage = 0;
double batteryVoltageFactor; double batteryVoltageFactor;
@@ -137,11 +192,11 @@ private:
2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226, 2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226,
3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636, 3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636,
3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095}; 3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095};
const double adcCurveCoeficient[5] = {0.000000000000016, const double adcCurveCoefficient[5] = {0.000000000000016,
0.000000000118171, 0.000000000118171,
0.000000301211691, 0.000000301211691,
0.001109019271794, 0.001109019271794,
0.034143524634089}; 0.034143524634089};
}; };
#endif // BATTERY_H #endif // BATTERY_H
+37 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file calcAzimuth.h * @file calcAzimuth.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a class that calculates the azimuth from a last and a current position
* @version 0.1 * @version 0.1
* @date 2023-09-03 * @date 2023-09-03
* *
@@ -15,9 +15,18 @@
#include "component.h" #include "component.h"
#include "point.h" #include "point.h"
/**
* @brief A class to calculate an azimuth
*
* This class calculates the current Azimuth with the last position
* where the rover has been rotated and the current position
*/
class CalcAzimuth : public Component class CalcAzimuth : public Component
{ {
public: public:
/**
* @brief States which represent the quality of the current calculated azimuth
*/
enum State enum State
{ {
Invalid, Invalid,
@@ -27,13 +36,40 @@ public:
Super Super
}; };
/**
* @brief Construct a new Calc Azimuth object
*
* @param point current position
*/
CalcAzimuth(Point point); CalcAzimuth(Point point);
/**
* @brief Have to be called if the rover rotates
*
* @param point current position
*/
void drivingDirectionChange(Point point); void drivingDirectionChange(Point point);
/**
* @brief update the current position
*
* This function should be called if the rover has moved in
* a straight direction, to calculated the current Azimuth.
* More distance to the point given to drivingDirectionChange()
* increase the accuracy of the calculation.
*
* @param point current position
*/
void updateCurrentPosition(Point point); void updateCurrentPosition(Point point);
void disableCalcAzimuth() { this->directionChangeMode = false; } void disableCalcAzimuth() { this->directionChangeMode = false; }
int16_t getAzimuth() const { return this->calcAzimuth; } int16_t getAzimuth() const { return this->calcAzimuth; }
/**
* @brief Get the State struct
*
* @return State current quality of the calculation
*/
State getState() const { return this->state; } State getState() const { return this->state; }
static String stateToString(State state); static String stateToString(State state);
+110
View File
@@ -0,0 +1,110 @@
/**
* @file calibrateCompass.h
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains a class to calibrate the compass module
* @version 0.1
* @date 2023-05-23
*
* @copyright Copyright (c) 2023
*
*/
#pragma once
#include <QMC5883LCompass.h>
#include <Preferences.h>
#include <iostream>
#include "component.h"
/**
* @brief A Class to calibrate the compass
*
* This class reads the raw values of the compass while
* the rove have to be moved. The lowest and highest values
* are used to calibrate the compass to the current location.
*/
class CalibrateCompass : public Component
{
public:
/**
* @brief State of the calibration process
*/
enum State
{
Ready,
Calibrating,
Finished
};
/**
* @brief Type for calibration data
*
* The data consist of 6 values. For each for the 3 axis
* are to integer needed.
*/
struct CalibrationData
{
int data[3][2];
};
CalibrateCompass(QMC5883LCompass *compass);
/**
* @brief Starts the calibration
*/
void start();
/**
* @brief Use the measured calibration data
*/
void useData();
/**
* @brief Remove the measured calibration data
*/
void removeCalibration();
/**
* @brief Reset the calibration process to start again
*/
void reset();
/**
* @brief Save the measured calibration data to the flash
*/
void saveData();
/**
* @brief Load the measured calibration data from the flash
*
*/
void loadData();
State getState() const { return this->state; }
CalibrationData getCalibrationData() const { return this->data; }
/**
* @brief Makes the calibration data printable with std::cout()
*
* @param stream
* @param caliComp
* @return std::ostream&
*/
friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp);
private:
void runAsChild() override;
void run() override;
void checkDataValidity();
QMC5883LCompass *compass;
State state = State::Ready;
CalibrationData data{};
void clearData();
bool dataValid = false;
const uint16_t maxTimeWithoutChange = 10000;
uint32_t lastChange = 0;
};
+1 -1
View File
@@ -19,7 +19,7 @@ void Component::loop()
(*it)->loop(); (*it)->loop();
} }
} }
this->runAsChild(); this->runAsChild();F
if (this->onlyChilds) if (this->onlyChilds)
{ {
+93 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file component.h * @file component.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains an interface to make non blocking components with delay.
* @version 0.1 * @version 0.1
* @date 2023-08-16 * @date 2023-08-16
* *
@@ -15,31 +15,123 @@
#include <list> #include <list>
/**
* @brief An Interface to make components
*
* A component is a task that be called in a loop which not
* runs every loop, so every component has a non blocking delay.
*
* A component can manage other components which called children components.
*/
class Component class Component
{ {
public: public:
/**
* @brief Construct a new Component object
*
* With the default constructor the created component is
* by default inactive. This does not affect the execution of
* the children components.
*/
Component() {} Component() {}
/**
* @brief Construct a new Component object
*
* If the given parameter is zero, there are no differences to the
* default constructor.
*
* @param loopDelay the minimum time in milliseconds before the task runs
*/
Component(uint16_t loopDelay); Component(uint16_t loopDelay);
/**
* @brief Runs the children components and the task
*
* The loop() function of the children is called every time this
* loop is called.
*
* The run() function which presents the task of this component is
* only called if the delay is reached.
*/
void loop(); void loop();
/**
* @brief Deactivate this component
*
* If the component is deactivated the call of loop() ha no effect
*/
void deactivate() { this->active = false; } void deactivate() { this->active = false; }
void activate() { this->active = false; } void activate() { this->active = false; }
protected: protected:
/**
* @brief Override this function to avoid the delay
*/
virtual void runAsChild() {} virtual void runAsChild() {}
/**
* @brief Runs befor the run() function
*
* This function is only called, if the delay
* is reached.
* The function do nothing, except the function is overwritten
* by the class which inherits this class.
*/
virtual void beforeRun() {} virtual void beforeRun() {}
/**
* @brief The actual task
*
* This function have to be overwritten by the inheriting class.
*/
virtual void run() = 0; virtual void run() = 0;
/**
* @brief Runs after the run() function
*
* This function is only called, if the delay
* is reached.
* The function do nothing, except the function is overwritten
* by the class which inherits this class.
*/
virtual void afterRun() {} virtual void afterRun() {}
/**
* @brief Adds a child component
*
* The child component will be called every time the loop() function
* is called.
*
* @param child
*/
void addChildComponent(Component *child); void addChildComponent(Component *child);
void removeChildComponent(Component *child); void removeChildComponent(Component *child);
void activateOnlyChilds() { this->onlyChilds = true; } void activateOnlyChilds() { this->onlyChilds = true; }
/**
* @brief Skip the actual task
*
* Same as set the loopDelay to zero.
*/
void deactivateOnlyChilds() { this->onlyChilds = false; } void deactivateOnlyChilds() { this->onlyChilds = false; }
/**
* @brief Set the timer after task
*
* If this function is called once the measurement of the delay
* starts after task has finished. The default is, that the
* measurement begins at the start of the task.
*/
void setTimerAfterTask() { this->timeUpdateAfter = true; } void setTimerAfterTask() { this->timeUpdateAfter = true; }
/**
* @brief the minimum time in milliseconds before the task runs
*
* If this value is zero, the functions beforeRun(), run() and
* afterRun() would not be called
*/
uint16_t loopDelay = 0; uint16_t loopDelay = 0;
private: private:
+1 -1
View File
@@ -11,7 +11,7 @@
#include "controlPad.h" #include "controlPad.h"
ControlPad::ControlPad() : Component(5), controlInput{0, 0, 0, 0} {} ControlPad::ControlPad() : Component(10), controlInput{0, 0, 0, 0} {}
void ControlPad::run() void ControlPad::run()
{ {
+32 -1
View File
@@ -1,7 +1,7 @@
/** /**
* @file controlPad.h * @file controlPad.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a class that gets the input data
* @version 0.1 * @version 0.1
* @date 2023-03-30 * @date 2023-03-30
* *
@@ -16,15 +16,46 @@
#include <controlPadInput.h> #include <controlPadInput.h>
#include <component.h> #include <component.h>
/**
* @brief A class to manage inputs
*
* This class converts the incoming data to the buttons and
* the axis from the joystick. The converted data will be send
* to the menu.
*/
class ControlPad : public Component class ControlPad : public Component
{ {
public: public:
ControlPad(); ControlPad();
/**
* @brief Insert the incoming data to convert
*
* The data is converted to the ControlPadInput struct.
*
* @param data have to be 4 byte long
*/
void insertData(const uint8_t *data); void insertData(const uint8_t *data);
/**
* @brief Set the MenuControl object
*
* The MenuControl object is used to control the Menu.
*
* @see Menu
* @see ControlPadInput
*
* @param menuControl
*/
void setMenuControl(MenuControl *menuControl) { this->menuControl = menuControl; } void setMenuControl(MenuControl *menuControl) { this->menuControl = menuControl; }
/**
* @brief Get the Control Pad Data
*
* The pointer holds the lates data from the ControlPad
*
* @return const ControlPadInput*
*/
const ControlPadInput *getControlPadDataPtr() const { return &this->controlInput; } const ControlPadInput *getControlPadDataPtr() const { return &this->controlInput; }
bool isControlPadConnected() const { return this->connected; } bool isControlPadConnected() const { return this->connected; }
+45 -1
View File
@@ -1,21 +1,65 @@
/**
* @file counter.h
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains a class that abstract the hardware counter from the esp32
* @version 0.1
* @date 2023-10-12
*
* @copyright Copyright (c) 2023
*
*/
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include <driver/pcnt.h> #include <driver/pcnt.h>
#include <cinttypes> #include <cinttypes>
/**
* @brief A class that abstract the hardware counter from the esp32
*/
class Counter class Counter
{ {
public: public:
/**
* @brief Construct a new Counter object
*
* @param pin with incoming pulses
*/
Counter(uint8_t pin); Counter(uint8_t pin);
/**
* @brief Pause the pulse counting
*/
void pause(); void pause();
/**
* @brief Resume the pulse counting
*/
void resume(); void resume();
/**
* @brief Start counting by zero again
*/
void clear(); void clear();
/**
* @brief Get the counted pulses
*
* @return int16_t
*/
int16_t getValue() const; int16_t getValue() const;
/**
* @brief Set the filter value
*
* The filter skip all pulses after a pulse for the filter time.
* The filter time depends on the frequency of the processor. The time
* for a whole tact multiplied with the filter value results the filter time.
*
* @param value max 1023
*/
void setFilterValue(uint16_t value); void setFilterValue(uint16_t value);
void filterEnable(); void filterEnable();
void filterDisable(); void filterDisable();
@@ -26,7 +70,7 @@ private:
static uint8_t amountOfCounter; static uint8_t amountOfCounter;
bool initalised = false; bool initalized = false;
uint8_t pulsePin; uint8_t pulsePin;
pcnt_unit_t unit; pcnt_unit_t unit;
+1 -1
View File
@@ -1,5 +1,5 @@
/** /**
* @file displayWrapper.cpp * @file LcdWrapper.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains the implementation of the class LcdWrapper * @brief Contains the implementation of the class LcdWrapper
* @version 0.1 * @version 0.1
+1 -2
View File
@@ -1,5 +1,5 @@
/** /**
* @file displayWrapper.h * @file LcdWrapper.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains the LcdWrapper class * @brief Contains the LcdWrapper class
* @version 0.1 * @version 0.1
@@ -37,7 +37,6 @@ public:
/** /**
* @brief Empty the buffer * @brief Empty the buffer
*
*/ */
void clear() override; void clear() override;
+48 -35
View File
@@ -5,101 +5,115 @@
* @see debugMqtt.h * @see debugMqtt.h
* @version 0.1 * @version 0.1
* @date 2021-12-13 * @date 2021-12-13
* *
* @copyright Copyright (c) 2021 * @copyright Copyright (c) 2021
* *
*/ */
#include "debugMqtt.h" #include "debugMqtt.h"
PubSubClient* DebugMqtt::client; PubSubClient *DebugMqtt::client;
Loglevel DebugMqtt::loglevel; Loglevel DebugMqtt::loglevel;
bool DebugMqtt::isInit = false; bool DebugMqtt::isInit = false;
char DebugMqtt::msg[MQTT_BUFFER_SIZE]; char DebugMqtt::msg[MQTT_BUFFER_SIZE];
char DebugMqtt::topic[MQTT_BUFFER_SIZE]; char DebugMqtt::topic[MQTT_BUFFER_SIZE];
DebugMqtt::DebugMqtt(const char *name, uint8_t bufSize)
DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) : name{name}
: name {name}
{ {
if (bufSize != 0) { if (bufSize != 0)
{
this->bufSize = bufSize; this->bufSize = bufSize;
} }
this->buf = new char[this->bufSize]; this->buf = new char[this->bufSize];
} }
DebugMqtt::~DebugMqtt() { DebugMqtt::~DebugMqtt()
{
delete this->buf; delete this->buf;
} }
void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg) { void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg)
snprintf (static_cast<char*>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char*>("%s: %s"),this->name ,msg.c_str()); {
this->sendData(loglevel, topic, static_cast<const char*>(DebugMqtt::msg)); snprintf(static_cast<char *>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char *>("%s: %s"), this->name, msg.c_str());
this->sendData(loglevel, topic, static_cast<const char *>(DebugMqtt::msg));
} }
void DebugMqtt::sendMsg(Loglevel loglevel, String msg) { void DebugMqtt::sendMsg(Loglevel loglevel, String msg)
{
this->sendMsg(loglevel, "", msg); this->sendMsg(loglevel, "", msg);
} }
void DebugMqtt::sendData(Loglevel loglevel, String topic, String data) { void DebugMqtt::sendData(Loglevel loglevel, String topic, String data)
if (!DebugMqtt::isInit) { {
if (!DebugMqtt::isInit)
{
return; return;
} }
if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none) { if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none)
snprintf (static_cast<char*>(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast<const char*>("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); {
snprintf (static_cast<char*>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char*>("%s"), data.c_str()); snprintf(static_cast<char *>(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast<const char *>("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str());
client->publish(DebugMqtt::topic, static_cast<const char*>(DebugMqtt::msg)); snprintf(static_cast<char *>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char *>("%s"), data.c_str());
client->publish(DebugMqtt::topic, static_cast<const char *>(DebugMqtt::msg));
} }
} }
void DebugMqtt::sendData(Loglevel loglevel, String data){ void DebugMqtt::sendData(Loglevel loglevel, String data)
{
DebugMqtt::sendData(loglevel, "", data); DebugMqtt::sendData(loglevel, "", data);
} }
void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos) { void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos)
{
// Example String: "weather temperature=82 1465839830100400200"; // Example String: "weather temperature=82 1465839830100400200";
snprintf(static_cast<char*>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char*>("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos); snprintf(static_cast<char *>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char *>("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos);
this->sendData(Loglevel::influx, static_cast<const char*>(DebugMqtt::msg)); this->sendData(Loglevel::influx, static_cast<const char *>(DebugMqtt::msg));
} }
void DebugMqtt::addCharacter(char character) { void DebugMqtt::addCharacter(char character)
{
this->buf[this->bufPos] = character; this->buf[this->bufPos] = character;
this->bufPos++; this->bufPos++;
if (character == '\n' || this->bufPos >= this->bufSize - 1) { if (character == '\n' || this->bufPos >= this->bufSize - 1)
{
this->buf[this->bufPos - 1] = '\0'; this->buf[this->bufPos - 1] = '\0';
this->sendMsg(Loglevel::info, buf); this->sendMsg(Loglevel::info, buf);
this->bufPos = 0; this->bufPos = 0;
} }
} }
void DebugMqtt::init(PubSubClient *client, Loglevel max_loglevel) { void DebugMqtt::init(PubSubClient *client, Loglevel max_loglevel)
{
DebugMqtt::client = client; DebugMqtt::client = client;
DebugMqtt::loglevel = max_loglevel; DebugMqtt::loglevel = max_loglevel;
DebugMqtt::isInit = true; DebugMqtt::isInit = true;
} }
void DebugMqtt::changeLoglevel(Loglevel loglevel) { void DebugMqtt::changeLoglevel(Loglevel loglevel)
{
DebugMqtt::loglevel = loglevel; DebugMqtt::loglevel = loglevel;
} }
String DebugMqtt::enum_to_string(Loglevel loglevel) { String DebugMqtt::enum_to_string(Loglevel loglevel)
{
String topic = ""; String topic = "";
topic += MQTT_DEBUG_TOPIC; topic += MQTT_DEBUG_TOPIC;
switch(loglevel){ switch (loglevel)
case Loglevel::error : {
case Loglevel::error:
topic += "/Error"; topic += "/Error";
break; break;
case Loglevel::warn : case Loglevel::warn:
topic += "/Warn"; topic += "/Warn";
break; break;
case Loglevel::info : case Loglevel::info:
topic += "/Info"; topic += "/Info";
break; break;
case Loglevel::debug : case Loglevel::debug:
topic += "/Debug"; topic += "/Debug";
break; break;
case Loglevel::influx : case Loglevel::influx:
topic += "/Influx"; topic += "/Influx";
break; break;
default: default:
@@ -107,5 +121,4 @@ String DebugMqtt::enum_to_string(Loglevel loglevel) {
break; break;
} }
return topic; return topic;
} }
+120 -117
View File
@@ -4,9 +4,9 @@
* @brief Inherits a class to send debug messages over MQTT * @brief Inherits a class to send debug messages over MQTT
* @version 0.1 * @version 0.1
* @date 2021-12-13 * @date 2021-12-13
* *
* @copyright Copyright (c) 2021 * @copyright Copyright (c) 2021
* *
*/ */
#ifndef DEBUG_MQTT_H #ifndef DEBUG_MQTT_H
#define DEBUG_MQTT_H #define DEBUG_MQTT_H
@@ -14,10 +14,9 @@
#include <iostream> #include <iostream>
#include <PubSubClient.h> #include <PubSubClient.h>
/** /**
* @brief * @brief
* *
* If you want to change the default topic * If you want to change the default topic
* to an other value, than you have to define this define * to an other value, than you have to define this define
* in your code befor you include this File. * in your code befor you include this File.
@@ -28,151 +27,155 @@
/** /**
* @brief Defualt for max message size * @brief Defualt for max message size
* *
* If you want to change the default size of 128 Byte * If you want to change the default size of 128 Byte
* to an other value, than you have to define this define * to an other value, than you have to define this define
* in your code befor you include this File. * in your code befor you include this File.
*/ */
#ifndef MQTT_BUFFER_SIZE #ifndef MQTT_BUFFER_SIZE
#define MQTT_BUFFER_SIZE 128 #define MQTT_BUFFER_SIZE 128
#endif //MQTT_BUFFER_SIZE #endif // MQTT_BUFFER_SIZE
/** /**
* @brief An enum to set the log level * @brief An enum to set the log level
* *
* The log level is the last part of the MQTT topic. * The log level is the last part of the MQTT topic.
* Unless you give sendMsg() or sendData() a additional * Unless you give sendMsg() or sendData() a additional
* topic as String. * topic as String.
* *
* @see sendMsg() * @see sendMsg()
* @see sendData() * @see sendData()
* *
*/ */
enum Loglevel { none, enum Loglevel
error, {
warn, none,
info, error,
debug, warn,
influx}; info,
debug,
influx
};
/** /**
* @brief A class to send debug messages over MQTT * @brief A class to send debug messages over MQTT
* *
* This class send debug messages over MQTT with different topics * This class send debug messages over MQTT with different topics
* by the enum Loglevel. Besides that this class supports to send * by the enum Loglevel. Besides that this class supports to send
* data via Telegraf into Grafana. * data via Telegraf into Grafana.
* *
* @see Loglevel * @see Loglevel
*/ */
class DebugMqtt { class DebugMqtt
public: {
/** public:
* @brief Construct a new Debug Mqtt object. /**
* * @brief Construct a new Debug Mqtt object.
* @param name A String with send with every Message. *
* @param bufSize for the addCharacter function. * @param name A String with send with every Message.
*/ * @param bufSize for the addCharacter function.
DebugMqtt(const char* name, uint8_t bufSize = 0); */
DebugMqtt(const char *name, uint8_t bufSize = 0);
~DebugMqtt(); ~DebugMqtt();
/** /**
* @brief Send a Message via MQTT * @brief Send a Message via MQTT
* *
* This function 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. * add the name to the message given by the constructer.
* *
* @see sendData() * @see sendData()
* @see Loglevel * @see Loglevel
* *
* @param loglevel Loglevel given by the enum Loglevel * @param loglevel Loglevel given by the enum Loglevel
* @param topic Additional topic behind loglevel * @param topic Additional topic behind loglevel
* @param msg The message to send as String * @param msg The message to send as String
*/ */
void sendMsg(Loglevel loglevel, String topic, String msg); void sendMsg(Loglevel loglevel, String topic, String msg);
void sendMsg(Loglevel loglevel, String msg); void sendMsg(Loglevel loglevel, String msg);
/** /**
* @brief Send a Message via MQTT * @brief Send a Message via MQTT
* *
* This function 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. * from Loglevel or followed by given String topic.
* Normally this function is called by sendMsg() or by * Normally this function is called by sendMsg() or by
* writeToInflux() * writeToInflux()
* *
* @see sendData() * @see sendData()
* @see writeToInflux() * @see writeToInflux()
* @see Loglevel * @see Loglevel
* *
* @param loglevel Loglevel given by the enum Loglevel * @param loglevel Loglevel given by the enum Loglevel
* @param topic Additional topic behind loglevel * @param topic Additional topic behind loglevel
* @param data The message to send as String * @param data The message to send as String
*/ */
static void sendData(Loglevel loglevel, String topic, String data); static void sendData(Loglevel loglevel, String topic, String data);
static void sendData(Loglevel loglevel, String data); static void sendData(Loglevel loglevel, String data);
/** /**
* @brief Send a Message via MQTT for InfluxDB * @brief Send a Message via MQTT for InfluxDB
* *
* This function 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 * Telegraf. Telegraf can listen on MQTT messages and put
* them in an Influx Database. * them in an Influx Database.
* *
* @param measurement_name like a category * @param measurement_name like a category
* @param field_set the name of the value e.g temperature * @param field_set the name of the value e.g temperature
* @param measurement the real value * @param measurement the real value
* @param nanos Current time in nanoseconds * @param nanos Current time in nanoseconds
*/ */
void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos); void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos);
/** /**
* @brief Adds a single character to the buf * @brief Adds a single character to the buf
* *
* The buf will be flushed out: * The buf will be flushed out:
* 1. when the buffer is full * 1. when the buffer is full
* 2. when the character is '\n' * 2. when the character is '\n'
* *
* @param character * @param character
*/ */
void addCharacter(char character); void addCharacter(char character);
/** /**
* @brief Initialize debugMQTT for all instances * @brief Initialize debugMQTT for all instances
* *
* You only have to call this function once for your project. * You only have to call this function once for your project.
* If you call this function again you overwrite the client and * If you call this function again you overwrite the client and
* the loglevel. If you only want du overwrite the max_loglevel * the loglevel. If you only want du overwrite the max_loglevel
* use changeLoglevel() * use changeLoglevel()
* *
* @see changeLoglevel() * @see changeLoglevel()
* *
* @param client PubSubClient * @param client PubSubClient
* @param max_loglevel Max loglevel to send. * @param max_loglevel Max loglevel to send.
*/ */
static void init(PubSubClient* client, Loglevel max_loglevel); static void init(PubSubClient *client, Loglevel max_loglevel);
/** /**
* @brief Change loglevel * @brief Change loglevel
* *
* This function changes the maximum loglevel which be send. * This function changes the maximum loglevel which be send.
* *
* @param loglevel * @param loglevel
*/ */
static void changeLoglevel(Loglevel loglevel); static void changeLoglevel(Loglevel loglevel);
private: private:
const char* name; const char *name;
char* buf; char *buf;
uint8_t bufPos = 0; uint8_t bufPos = 0;
uint8_t bufSize = 100; uint8_t bufSize = 100;
static String enum_to_string(Loglevel loglevel); static String enum_to_string(Loglevel loglevel);
static PubSubClient* client; static PubSubClient *client;
static Loglevel loglevel; static Loglevel loglevel;
static bool isInit; static bool isInit;
static char msg[MQTT_BUFFER_SIZE]; static char msg[MQTT_BUFFER_SIZE];
static char topic[MQTT_BUFFER_SIZE]; static char topic[MQTT_BUFFER_SIZE];
}; };
#endif // DEBUG_MQTT_H #endif // DEBUG_MQTT_H
+6 -7
View File
@@ -52,9 +52,10 @@ public:
}; };
/** /**
* @brief Construct a new Navigation object and using I2C * @brief Construct a new Navigation object
* *
* @param route with which to navigate * @param sensorData
* @param route
*/ */
Navigation(const SensorData *sensorData, Route *route = nullptr); Navigation(const SensorData *sensorData, Route *route = nullptr);
@@ -89,11 +90,9 @@ public:
/** /**
* @brief Get the Course Correction object * @brief Get the Course Correction object
* *
* This should be called by the driver to get new instructions. * @param correction
* * @param forceUpdate
* @param correction passed as refernce to get the data * @return Status
* @return true if new correction data provided
* @return false if route is finished
*/ */
Status getCourseCorrection(CourseCorrection &correction, bool forceUpdate = false); Status getCourseCorrection(CourseCorrection &correction, bool forceUpdate = false);
+13 -13
View File
@@ -21,18 +21,18 @@ Network::Network(const char *ssid, const char *passphrase)
this->init(ssid, passphrase); this->init(ssid, passphrase);
} }
Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) Network::Network(const char *ssid, const char *passphrase, NetworkAddresses adresses)
: adresses{adresses} : addresses{adresses}
{ {
if (!WiFiGenericClass::mode(WIFI_AP_STA)) if (!WiFiGenericClass::mode(WIFI_AP_STA))
{ {
std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl;
} }
if (!WiFi.config(this->adresses.localIP, if (!WiFi.config(this->addresses.localIP,
this->adresses.gateway, this->addresses.gateway,
this->adresses.subnet, this->addresses.subnet,
this->adresses.dnsServer)) this->addresses.dnsServer))
{ {
std::cout << "STA Failed to configure" << std::endl; std::cout << "STA Failed to configure" << std::endl;
} }
@@ -45,7 +45,7 @@ Network::~Network()
delete mqttClient; delete mqttClient;
} }
bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) bool Network::activateEspNow(receiveCallbackPtr reci, sendCallbackPtr send)
{ {
if (esp_now_init() != ESP_OK) if (esp_now_init() != ESP_OK)
{ {
@@ -76,7 +76,7 @@ bool Network::activateMqtt(const char *user, const char *passphrase)
this->mqttPassphrase = passphrase; this->mqttPassphrase = passphrase;
this->mqttClient = new PubSubClient(this->wifiClient); this->mqttClient = new PubSubClient(this->wifiClient);
this->mqttClient->setServer(this->adresses.mqttServer, this->adresses.mqttPort); this->mqttClient->setServer(this->addresses.mqttServer, this->addresses.mqttPort);
this->mqttClient->setSocketTimeout(1); this->mqttClient->setSocketTimeout(1);
if (this->wifiConnected) if (this->wifiConnected)
@@ -116,7 +116,7 @@ uint8_t Network::getCurrentChannel()
void Network::runAsChild() void Network::runAsChild()
{ {
if (!this->initSucessful) if (!this->initSuccessful)
{ {
return; return;
} }
@@ -154,21 +154,21 @@ void Network::init(const char *ssid, const char *passphrase)
void Network::checkWifi() void Network::checkWifi()
{ {
if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiReconnectAttempt >= Network::wifiReconnectDelay))
{ {
std::cout << "Reconnecting to WiFi..." << std::endl; std::cout << "Reconnecting to WiFi..." << std::endl;
WiFi.disconnect(); WiFi.disconnect();
this->wifiConnected = WiFi.reconnect(); this->wifiConnected = WiFi.reconnect();
this->lastWifiRecoonectAttemp = millis(); this->lastWifiReconnectAttempt = millis();
} }
} }
void Network::checkMqtt() void Network::checkMqtt()
{ {
if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttempt > Network::mqttReconnectDelay)
{ {
this->mqttConnected = this->connectMqtt(); this->mqttConnected = this->connectMqtt();
this->lastMqttReconnectAttemp = millis(); this->lastMqttReconnectAttempt = millis();
} }
if (this->mqttConnected) if (this->mqttConnected)
+59 -8
View File
@@ -20,10 +20,20 @@
#include <esp_now.h> #include <esp_now.h>
#include <esp_wifi.h> #include <esp_wifi.h>
typedef void (*recieveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len); /**
* @brief Typedef to easy handle the receive Callback
*/
typedef void (*receiveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len);
/**
* @brief Typedef to easy handle the send Callback
*/
typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status); typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status);
struct NetworkAdresses /**
* @brief A Struct to hold all network addresses
*/
struct NetworkAddresses
{ {
IPAddress localIP; IPAddress localIP;
IPAddress gateway; IPAddress gateway;
@@ -33,17 +43,58 @@ struct NetworkAdresses
uint16_t mqttPort = 1883; uint16_t mqttPort = 1883;
}; };
/**
* @brief A class to manage the wireless connections
*/
class Network : public Component class Network : public Component
{ {
public: public:
/**
* @brief Construct a new Network object
*
* With this constructor the esp gets its ip from a Dhcp server
*
* @param ssid
* @param passphrase
*/
Network(const char *ssid, const char *passphrase); Network(const char *ssid, const char *passphrase);
Network(const char *ssid, const char *passphrase, NetworkAdresses adresses);
/**
* @brief Construct a new Network object
*
* This constructor is used for a static ip setup
*
* @param ssid
* @param passphrase
* @param addresses
*/
Network(const char *ssid, const char *passphrase, NetworkAddresses addresses);
~Network(); ~Network();
bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); /**
* @brief Activate ESP-NOW to communicate with the remote Control
*
* @param receive
* @param send
* @return true
* @return false
*/
bool activateEspNow(receiveCallbackPtr receive, sendCallbackPtr send);
/**
* @brief Activate MQTT to send debug messages
*
* @param user
* @param passphrase
* @return true
* @return false
*/
bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr);
/**
* @brief Print the current used IPs
*/
const void printIPs(); const void printIPs();
bool isWifiConnected() const { return this->wifiConnected; } bool isWifiConnected() const { return this->wifiConnected; }
@@ -61,11 +112,11 @@ private:
void checkMqtt(); void checkMqtt();
bool connectMqtt(); bool connectMqtt();
NetworkAdresses adresses; NetworkAddresses addresses;
WiFiClient wifiClient; WiFiClient wifiClient;
PubSubClient *mqttClient = nullptr; PubSubClient *mqttClient = nullptr;
bool initSucessful = false; bool initSuccessful = false;
bool wifiConnected = false; bool wifiConnected = false;
bool mqttConnected = false; bool mqttConnected = false;
@@ -73,8 +124,8 @@ private:
const char *mqttPassphrase = nullptr; const char *mqttPassphrase = nullptr;
uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10};
uint32_t lastWifiRecoonectAttemp = 0; uint32_t lastWifiReconnectAttempt = 0;
uint32_t lastMqttReconnectAttemp = 0; uint32_t lastMqttReconnectAttempt = 0;
static constexpr uint8_t wifiConnectTimeout = 20; static constexpr uint8_t wifiConnectTimeout = 20;
static constexpr uint16_t wifiConnectLoopTime = 500; static constexpr uint16_t wifiConnectLoopTime = 500;
+6 -7
View File
@@ -18,9 +18,9 @@
#define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300 #define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300
/** /**
* @brief A to handle points on the earth * @brief A class to handle points on the earth
* *
* The points inherits latidue and longitude as doubles * The points inherits latitude and longitude as doubles
* *
*/ */
class Point class Point
@@ -58,11 +58,10 @@ public:
/** /**
* @brief Construct a new Point object * @brief Construct a new Point object
* *
* @param lat latitude * @param lat
* @param lon longitude * @param lon
* @param horizontalAccuracy mm * @param horizontalAccuracy
* @param coords Coordinates * @param creationTime
* @param imported if true than highest accuracy
*/ */
Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0);
Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0);
+66 -66
View File
@@ -1,27 +1,28 @@
/** /**
* @file route.h * @file route.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains the class Point and Route * @brief Contains the class Route
* @version 0.1 * @version 0.1
* @date 2022-01-31 * @date 2022-01-31
* *
* @copyright Copyright (c) 2022 * @copyright Copyright (c) 2022
* *
*/ */
#ifndef ROUTE_H #ifndef ROUTE_H
#define ROUTE_H #define ROUTE_H
#include <cstdint> #include <cstdint>
#include <list> #include <list>
#include "point.h" #include "point.h"
/** /**
* @brief Holds some route information * @brief Holds some route information
* *
*/ */
struct RouteInfo{ struct RouteInfo
{
/** /**
* @brief Selected number of Points * @brief Selected number of Points
*/ */
@@ -35,77 +36,76 @@ struct RouteInfo{
/** /**
* @brief A class to manage multiple points * @brief A class to manage multiple points
* *
* The list of point presents a route which can be driven * The list of point presents a route which can be driven
*/ */
class Route { class Route
public: {
/** public:
* @brief Adds a point to the list. /**
* * @brief Adds a point to the list.
* @param point *
*/ * @param point
void addPointToRoute(Point point); */
void addPointToRoute(Point point);
/** /**
* @brief Delete all points. * @brief Delete all points
* */
*/ void clear();
void clear();
/** /**
* @brief Select the first point as target. * @brief Select the first point as target.
* *
* @return Point * @return Point
*/ */
Point startRoute(); Point startRoute();
/** /**
* @brief Select the last point as target. * @brief Select the last point as target.
* *
* @return Point * @return Point
*/ */
Point endRoute(); Point endRoute();
/** /**
* @brief Get the next point and set it as target. * @brief Get the next point and set it as target.
* *
* @return Point is zero if there are no more Points. * @return Point is zero if there are no more Points.
*/ */
Point getNextPoint(); Point getNextPoint();
/** /**
* @brief Get the previous point and set it as target. * @brief Get the previous point and set it as target.
* *
* @return Point * @return Point
*/ */
Point getPreviousPoint(); Point getPreviousPoint();
/** /**
* @brief Get the Route Info object * @brief Get the Route Info object
* *
* @return RouteInfo * @return RouteInfo
*/ */
RouteInfo getRouteInfo(); RouteInfo getRouteInfo();
/** /**
* @brief Get the Started object * @brief Get the Started object
* *
* The Route will be marked as started when startRoute or * The Route will be marked as started when startRoute or
* endRoute has been called. * endRoute has been called.
* *
* @return true * @return true
* @return false * @return false
*/ */
bool getStarted() const { return this->started; } bool getStarted() const { return this->started; }
private: private:
uint16_t currentPoint = 0; uint16_t currentPoint = 0;
bool started = false; bool started = false;
std::list<Point> points;
std::list<Point>::iterator it;
std::list<Point> points;
std::list<Point>::iterator it;
}; };
#endif // ROUTE_H #endif // ROUTE_H
+20 -20
View File
@@ -1,5 +1,5 @@
/** /**
* @file senors.cpp * @file sensorData.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief
* @version 0.1 * @version 0.1
@@ -83,32 +83,32 @@ void SensorData::enableCalcCompass()
// TODO: !!! implementieren // TODO: !!! implementieren
} }
void SensorData::enableGyroskop() void SensorData::enableGyroscope()
{ {
this->gyroskop = new MPU6050(); this->gyroscope = new MPU6050();
this->gyroskop->initialize(); this->gyroscope->initialize();
if (!this->gyroskop->testConnection()) if (!this->gyroscope->testConnection())
{ {
std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl; std::cout << "SensorData::enableGyroscope: Gyroskop is not conntected. Freeze!" << std::endl;
while (true) while (true)
{ {
} }
} }
const uint8_t deviceStatus = this->gyroskop->dmpInitialize(); const uint8_t deviceStatus = this->gyroscope->dmpInitialize();
// TODO: !!! MagicNumer 6x // TODO: !!! MagicNumer 6x
this->gyroskop->setXGyroOffset(220); this->gyroscope->setXGyroOffset(220);
this->gyroskop->setYGyroOffset(76); this->gyroscope->setYGyroOffset(76);
this->gyroskop->setZGyroOffset(-85); this->gyroscope->setZGyroOffset(-85);
this->gyroskop->setZAccelOffset(1788); this->gyroscope->setZAccelOffset(1788);
if (deviceStatus == 0) if (deviceStatus == 0)
{ {
this->gyroskop->CalibrateAccel(6); this->gyroscope->CalibrateAccel(6);
this->gyroskop->CalibrateGyro(6); this->gyroscope->CalibrateGyro(6);
this->gyroskop->PrintActiveOffsets(); this->gyroscope->PrintActiveOffsets();
this->gyroskop->setDMPEnabled(true); this->gyroscope->setDMPEnabled(true);
} }
else else
{ {
@@ -116,7 +116,7 @@ void SensorData::enableGyroskop()
// 1 = initial memory load failed // 1 = initial memory load failed
// 2 = DMP configuration updates failed // 2 = DMP configuration updates failed
// (if it's going to break, usually the code will be 1) // (if it's going to break, usually the code will be 1)
std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << static_cast<int>(deviceStatus) << "). Freeze!" << std::endl; std::cout << "SensorData::enableGyroscope: DMP Initialization failed (code" << static_cast<int>(deviceStatus) << "). Freeze!" << std::endl;
while (true) while (true)
{ {
} }
@@ -236,11 +236,11 @@ void SensorData::run()
this->realAzimuth = this->realCompass->getAzimuth(); this->realAzimuth = this->realCompass->getAzimuth();
} }
if (static_cast<bool>(this->gyroskop) && this->gyroskop->dmpGetCurrentFIFOPacket(static_cast<uint8_t *>(this->gyroBuffer))) if (static_cast<bool>(this->gyroscope) && this->gyroscope->dmpGetCurrentFIFOPacket(static_cast<uint8_t *>(this->gyroBuffer)))
{ {
this->gyroskop->dmpGetQuaternion(&this->quaternion, static_cast<uint8_t *>(this->gyroBuffer)); this->gyroscope->dmpGetQuaternion(&this->quaternion, static_cast<uint8_t *>(this->gyroBuffer));
this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion); this->gyroscope->dmpGetGravity(&this->gravity, &this->quaternion);
this->gyroskop->dmpGetYawPitchRoll(static_cast<float *>(this->yawPitchRoll), &this->quaternion, &this->gravity); this->gyroscope->dmpGetYawPitchRoll(static_cast<float *>(this->yawPitchRoll), &this->quaternion, &this->gravity);
} }
} }
+73 -6
View File
@@ -1,7 +1,7 @@
/** /**
* @file sensorData.h * @file sensorData.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains the SensorData class
* @version 0.1 * @version 0.1
* @date 2023-09-02 * @date 2023-09-02
* *
@@ -26,8 +26,12 @@
#include "ntripClient.h" #include "ntripClient.h"
#include "point.h" #include "point.h"
class Sensors;
/**
* @brief A class to manage all sensors
*
* Each sensor have separately to be enabled
*/
class SensorData : public Component class SensorData : public Component
{ {
public: public:
@@ -35,26 +39,89 @@ public:
~SensorData(); ~SensorData();
void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password);
/**
* @brief Enable the gnss module over spi
*
* @param spiPort
* @param csPin
*/
void enableGnss(SPIClass *spiPort, uint8_t csPin); void enableGnss(SPIClass *spiPort, uint8_t csPin);
/**
* @brief Enable the gnss module over i2c
*/
void enableGnss(); void enableGnss();
void enableRealCompass(); void enableRealCompass();
void enableCalcCompass(); void enableCalcCompass();
void enableGyroskop(); void enableGyroscope();
// Interface Const kram // Interface Const
/**
* @brief Get the azimuth measured by the compass module
*
* @return int16_t
*/
int16_t getRealAzimuth() const { return this->realAzimuth; } int16_t getRealAzimuth() const { return this->realAzimuth; }
/**
* @brief Get the azimuth calculated by CalcAzimuth
*
* Consider to call getCalcAzimuthState() to check, if the data is valid.
*
* @return int16_t
*/
int16_t getCalcAzimuth() const { return this->calcAzimuth; } int16_t getCalcAzimuth() const { return this->calcAzimuth; }
/**
* @brief Get the CalcAzimuth::State object
*
* Needed to check the quality of calculated azimuth
*
* @return CalcAzimuth::State
*/
CalcAzimuth::State getCalcAzimuthState() const; CalcAzimuth::State getCalcAzimuthState() const;
Point getCurrentPos() const { return this->currentPosition; } Point getCurrentPos() const { return this->currentPosition; }
const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; };
NTRIPClientStates getNtripState() const; NTRIPClientStates getNtripState() const;
/**
* @brief Get the data from the gyroscope
*
* The returned float pointer is an array of 3 floats
* - Yaw
* - Pitch
* - Roll
*
* @return const float*
*/
const float *getGyroData() const { return this->yawPitchRoll; } const float *getGyroData() const { return this->yawPitchRoll; }
/**
* @brief Get the CalcCompass object
* @return CalcAzimuth*
*/
CalcAzimuth *getCalcCompass() const { return this->calcCompass; } CalcAzimuth *getCalcCompass() const { return this->calcCompass; }
/**
* @brief Get the RealCompass object
* @return QMC5883LCompass*
*/
QMC5883LCompass *getRealCompass() const { return this->realCompass; } QMC5883LCompass *getRealCompass() const { return this->realCompass; }
/**
* @brief Get the NTRIPClient object
* @return NTRIPClient*
*/
NTRIPClient *getNtripClient() const { return this->ntripClient; } NTRIPClient *getNtripClient() const { return this->ntripClient; }
MPU6050 *getGyroskop() const { return this->gyroskop; }
/**
* @brief Get the Gyroscope object
* @return MPU6050*
*/
MPU6050 *getGyroscope() const { return this->gyroscope; }
// static // static
/** /**
@@ -77,7 +144,7 @@ private:
CalcAzimuth *calcCompass = nullptr; CalcAzimuth *calcCompass = nullptr;
SFE_UBLOX_GNSS *gnss = nullptr; SFE_UBLOX_GNSS *gnss = nullptr;
NTRIPClient *ntripClient = nullptr; NTRIPClient *ntripClient = nullptr;
MPU6050 *gyroskop = nullptr; MPU6050 *gyroscope = nullptr;
UBX_NAV_PVT_data_t *gnssData = nullptr; UBX_NAV_PVT_data_t *gnssData = nullptr;
Point currentPosition; Point currentPosition;
+14 -2
View File
@@ -48,7 +48,7 @@ public:
* *
* @param pin Pin on the Esp from the encoder. * @param pin Pin on the Esp from the encoder.
* @param diameter Diameter of the wheel in meters. * @param diameter Diameter of the wheel in meters.
* @param steps Encodersteps for a complete wheel rotation. * @param steps EncoderSteps for a complete wheel rotation.
*/ */
Speedometer(uint8_t pin, double diameter, uint16_t steps); Speedometer(uint8_t pin, double diameter, uint16_t steps);
@@ -78,12 +78,24 @@ public:
Direction getDirection() const { return this->currentDirection; } Direction getDirection() const { return this->currentDirection; }
/** /**
* @brief Get the calculated speed of the Wheel * @brief Get the calculated speed of the wheel
* *
* @return double speed in m/s * @return double speed in m/s
*/ */
double getSpeed() const { return this->speed; } double getSpeed() const { return this->speed; }
/**
* @brief Get the calculated speed of the wheel
*
* @return double speed in rad/s
*/
double getSpeedRad() const { return this->rad; }; double getSpeedRad() const { return this->rad; };
/**
* @brief Get the calculated average speed of the wheel
*
* @return double speed in m/s
*/
double getAvgSpeed() const; double getAvgSpeed() const;
/** /**
+2 -2
View File
@@ -1,7 +1,7 @@
/** /**
* @file debugTimes.cpp * @file debugTimes.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Implemention of the class debugTimes.h. * @brief Implementation of the class debugTimes.h.
* @version 0.1 * @version 0.1
* @date 2021-12-13 * @date 2021-12-13
* *
@@ -19,7 +19,7 @@ DebugTimes::DebugTimes()
if (DebugTimes::printWarning) if (DebugTimes::printWarning)
{ {
std::cout << std::endl std::cout << std::endl
<< "Warning: DebugTimes is muuted, no times are be shown." << std::endl << "Warning: DebugTimes is muted, no times are be shown." << std::endl
<< std::endl; << std::endl;
DebugTimes::printWarning = false; DebugTimes::printWarning = false;
} }
+1 -1
View File
@@ -53,7 +53,7 @@ public:
/** /**
* @brief Print the elapsed time to consol * @brief Print the elapsed time to consol
* *
* @param name Functionname to print * @param name FunctionName to print
* @param minTime A minimum time before printing * @param minTime A minimum time before printing
* *
* @return uint16_t elapsed milliseconds * @return uint16_t elapsed milliseconds
-63
View File
@@ -1,63 +0,0 @@
/**
* @file calibrateCompass.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2023-05-23
*
* @copyright Copyright (c) 2023
*
*/
#pragma once
#include <QMC5883LCompass.h>
#include <Preferences.h>
#include <iostream>
#include "component.h"
class CalibrateCompass : public Component
{
public:
enum State
{
Ready,
Calibrating,
Finished
};
struct CallibrationData
{
int data[3][2];
};
CalibrateCompass(QMC5883LCompass *compass);
void start();
void useData();
void removeCalibration();
void reset();
void saveData();
void loadData();
State getState() const { return this->state; }
CallibrationData getCallibrationData() const { return this->data; }
friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp);
private:
void runAsChild() override;
void run() override;
void checkDataValidity();
QMC5883LCompass *compass;
State state = State::Ready;
CallibrationData data{};
void clearData();
bool dataValid = false;
const uint16_t maxTimeWithoutChange = 10000;
uint32_t lastChange = 0;
};
+1 -1
View File
@@ -1,5 +1,5 @@
/** /**
* @file outputBufMqtt.cpp * @file outputBuf.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains the implementation of the class OutputBufMqtt * @brief Contains the implementation of the class OutputBufMqtt
* @version 0.1 * @version 0.1
+2 -1
View File
@@ -1,5 +1,5 @@
/** /**
* @file outputBufMqtt.h * @file outputBuf.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains a small class that provide a streambuf * @brief Contains a small class that provide a streambuf
* *
@@ -38,6 +38,7 @@ class OutputBuf : public std::streambuf {
* @brief Construct a new Output Buf Mqtt object * @brief Construct a new Output Buf Mqtt object
* *
* @param debugMqtt * @param debugMqtt
* @param serialBT
*/ */
OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr); OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr);
@@ -31,8 +31,7 @@ class MenuSysteminformation : public MenuInformationSites {
/** /**
* @brief Construct a new Menu Systeminformation object * @brief Construct a new Menu Systeminformation object
* *
* @param mainBattery * @param mainBattery
* @param gamepad
*/ */
MenuSysteminformation(Battery* mainBattery); MenuSysteminformation(Battery* mainBattery);
@@ -81,23 +81,23 @@ void MenuCalibrateCompass::printPage() const {
case 8: case 8:
lineOne = "X min: "; lineOne = "X min: ";
lineOne.concat(this->caliCompass->getCallibrationData().data[0][0]); lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]);
lineTwo = "X max: "; lineTwo = "X max: ";
lineTwo.concat(this->caliCompass->getCallibrationData().data[0][1]); lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]);
break; break;
case 9: case 9:
lineOne = "Y min: "; lineOne = "Y min: ";
lineOne.concat(this->caliCompass->getCallibrationData().data[1][0]); lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]);
lineTwo = "Y max: "; lineTwo = "Y max: ";
lineTwo.concat(this->caliCompass->getCallibrationData().data[1][1]); lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]);
break; break;
case 10: case 10:
lineOne = "Z min: "; lineOne = "Z min: ";
lineOne.concat(this->caliCompass->getCallibrationData().data[2][0]); lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]);
lineTwo = "Z max: "; lineTwo = "Z max: ";
lineTwo.concat(this->caliCompass->getCallibrationData().data[2][1]); lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]);
break; break;
default: default:
@@ -164,7 +164,7 @@ void MenuTestMode::init() {
auto *lightBlueAction = new MenuAction("Blue", dummy); auto *lightBlueAction = new MenuAction("Blue", dummy);
auto *lightOffAction = new MenuAction("Off", dummy); auto *lightOffAction = new MenuAction("Off", dummy);
// Add entrys to the menus // Add entries to the menus
this->mainMenu->addEntry(engineAction); this->mainMenu->addEntry(engineAction);
this->mainMenu->addEntry(drivingAction); this->mainMenu->addEntry(drivingAction);
this->mainMenu->addEntry(encoderAction); this->mainMenu->addEntry(encoderAction);
@@ -1,5 +1,5 @@
/** /**
* @file menuTest.cpp * @file speedometerTest.cpp
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains the implementation of the class SpeedometerTest. * @brief Contains the implementation of the class SpeedometerTest.
* @version 0.1 * @version 0.1
@@ -1,5 +1,5 @@
/** /**
* @file menuTest.h * @file speedometerTest.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief Contains a class to test the wheel encoder. * @brief Contains a class to test the wheel encoder.
* @version 0.1 * @version 0.1
+9 -2
View File
@@ -22,14 +22,21 @@
class DriveManager : public Component { class DriveManager : public Component {
public: public:
/** /**
* @brief Construct a new Drive Manager object * @brief Construct a new Drive Manager object
* *
* Creates a Navigation object
*
* @param moveControl * @param moveControl
* @param sensorData
* @param input
*/ */
DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input); DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input);
/**
* @brief Construct a new Drive Manager object
*
* @param params
*/
DriveManager(DriveModiParams params); DriveManager(DriveModiParams params);
/** /**
+4 -4
View File
@@ -70,7 +70,7 @@ void restart();
void receiveCallback(const uint8_t *mac, const uint8_t *incomingData, int len); void receiveCallback(const uint8_t *mac, const uint8_t *incomingData, int len);
void sendCallback(const uint8_t *mac_addr, esp_now_send_status_t status); void sendCallback(const uint8_t *mac_addr, esp_now_send_status_t status);
void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows); void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows);
NetworkAdresses setIPs(); NetworkAddresses setIPs();
void setup() void setup()
{ {
@@ -130,7 +130,7 @@ void setup()
static_cast<const char*>(NtripConfig::mountPoint), static_cast<const char*>(NtripConfig::mountPoint),
static_cast<const char*>(NtripConfig::user), static_cast<const char*>(NtripConfig::user),
static_cast<const char*>(NtripConfig::password)); static_cast<const char*>(NtripConfig::password));
// sensorData->enableGyroskop(); // sensorData->enableGyroscope();
driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr());
char wifiIndicator = 'X'; char wifiIndicator = 'X';
@@ -355,9 +355,9 @@ void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines,
} }
} }
NetworkAdresses setIPs() NetworkAddresses setIPs()
{ {
NetworkAdresses adresses; NetworkAddresses adresses;
adresses.localIP.fromString(static_cast<const char *>(NetworkConfig::ip)); adresses.localIP.fromString(static_cast<const char *>(NetworkConfig::ip));
adresses.subnet.fromString(static_cast<const char *>(NetworkConfig::subnet)); adresses.subnet.fromString(static_cast<const char *>(NetworkConfig::subnet));
adresses.gateway.fromString(static_cast<const char *>(NetworkConfig::gateway)); adresses.gateway.fromString(static_cast<const char *>(NetworkConfig::gateway));