From 7e95d8957905a7f913e8d420cbaa05f4ba815c7d Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 4 Mar 2025 17:03:23 +0100 Subject: [PATCH] Updated documentation --- Arduino/Things/DRV8833.h | 9 ++++----- Arduino/Things/DigitalInput.h | 6 ++++++ Arduino/Things/UltrasonicSensor.h | 14 ++++++++++++-- LocalParticipant.h | 3 ++- Messages/BinaryMsg.cpp | 4 ---- Messages/BinaryMsg.h | 18 ++++++++++++++---- README.md | 3 --- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Arduino/Things/DRV8833.h b/Arduino/Things/DRV8833.h index 836b15a..cbbfb3c 100644 --- a/Arduino/Things/DRV8833.h +++ b/Arduino/Things/DRV8833.h @@ -3,9 +3,10 @@ #include "Thing.h" #include "Things/DifferentialDrive.h" -/// @brief Support for a DRV8833 motor controller namespace RoboidControl { +namespace Arduino { +/// @brief Support for a DRV8833 motor controller class DRV8833Motor : public Thing { public: /// @brief Motor turning direction @@ -15,10 +16,7 @@ class DRV8833Motor : public Thing { /// @param pinIn1 the pin number for the in1 signal /// @param pinIn2 the pin number for the in2 signal /// @param direction the forward turning direction of the motor - DRV8833Motor(Participant* participant, - unsigned char pinIn1, - unsigned char pinIn2, - bool reverse = false); + DRV8833Motor(Participant* participant, unsigned char pinIn1, unsigned char pinIn2, bool reverse = false); void SetMaxRPM(unsigned int rpm); virtual void SetAngularVelocity(Spherical velocity) override; @@ -58,4 +56,5 @@ class DRV8833 : public Thing { unsigned char pinStandby = 255; }; +} // namespace Arduino } // namespace RoboidControl \ No newline at end of file diff --git a/Arduino/Things/DigitalInput.h b/Arduino/Things/DigitalInput.h index 9d89118..059ebd8 100644 --- a/Arduino/Things/DigitalInput.h +++ b/Arduino/Things/DigitalInput.h @@ -5,13 +5,19 @@ namespace RoboidControl { namespace Arduino { +/// @brief A digital input represents the stat of a digital GPIO pin class DigitalInput : public TouchSensor { public: + /// @brief Create a new digital input + /// @param participant The participant to use + /// @param pin The digital pin DigitalInput(Participant* participant, unsigned char pin); + /// @copydoc RoboidControl::Thing::Update(unsigned long currentTimeMs) virtual void Update(unsigned long currentTimeMs) override; protected: + /// @brief The pin used for digital input unsigned char pin = 0; }; diff --git a/Arduino/Things/UltrasonicSensor.h b/Arduino/Things/UltrasonicSensor.h index c5dc4f3..c130876 100644 --- a/Arduino/Things/UltrasonicSensor.h +++ b/Arduino/Things/UltrasonicSensor.h @@ -5,25 +5,35 @@ namespace RoboidControl { namespace Arduino { +/// @brief An HC-SR04 ultrasonic distance sensor class UltrasonicSensor : public TouchSensor { public: + /// @brief Setup an ultrasonic sensor + /// @param participant The participant to use + /// @param pinTrigger The pin number of the trigger signal + /// @param pinEcho The pin number of the echo signal UltrasonicSensor(Participant* participant, unsigned char pinTrigger, unsigned char pinEcho); // parameters + /// @brief The distance at which the object is considered to be touched float touchDistance = 0.2f; // state + /// @brief The last read distance float distance = 0; + /// @brief erform an ultrasonic 'ping' to determine the distance to the nearest object + /// @return the measured distance in meters to the nearest object float GetDistance(); + /// @copydoc RoboidControl::Thing::Update(unsigned long currentTimeMs) virtual void Update(unsigned long currentTimeMs) override; - // virtual void ProcessBinary(char* bytes) override; - protected: + /// @brief The pin number of the trigger signal unsigned char pinTrigger = 0; + /// @brief The pin number of the echo signal unsigned char pinEcho = 0; }; diff --git a/LocalParticipant.h b/LocalParticipant.h index 8d479b3..76e5400 100644 --- a/LocalParticipant.h +++ b/LocalParticipant.h @@ -31,8 +31,9 @@ namespace RoboidControl { /// An participant can be isolated. In that case it is standalong and does not communicate with other participants. /// /// It is possible to work with an hidden participant by creating things without specifying a participant in the -/// constructor (@sa RoboidControl::Thing::Thing()). In that case an hidden isolated participant is created which can be +/// constructor. In that case an hidden isolated participant is created which can be /// obtained using RoboidControl::LocalParticipant::Isolated(). +/// @sa RoboidControl::Thing::Thing() class LocalParticipant : public Participant { public: /// @brief Create a participant without connecting to a site diff --git a/Messages/BinaryMsg.cpp b/Messages/BinaryMsg.cpp index 81ad261..7ab7f5d 100644 --- a/Messages/BinaryMsg.cpp +++ b/Messages/BinaryMsg.cpp @@ -30,9 +30,5 @@ unsigned char BinaryMsg::Serialize(char* buffer) { return ix; } -BinaryMsg BinaryMsg::Receive(char* buffer, unsigned char bufferSize) { - BinaryMsg msg = BinaryMsg(buffer); - return msg; -} } // namespace RoboidControl diff --git a/Messages/BinaryMsg.h b/Messages/BinaryMsg.h index 986eaf0..0b03111 100644 --- a/Messages/BinaryMsg.h +++ b/Messages/BinaryMsg.h @@ -4,25 +4,35 @@ namespace RoboidControl { +/// @brief Message to send thing-specific data class BinaryMsg : public IMessage { public: + /// @brief The message ID static const unsigned char id = 0xB1; + /// @brief The length of the message without the binary data itslef static const unsigned length = 3; + /// @brief The network ID of the thing unsigned char networkId; + /// @brief The ID of the thing unsigned char thingId; + /// @brief The thing for which the binary data is communicated Thing* thing; - unsigned char bytesSize; + /// @brief The binary data which is communicated char* bytes = nullptr; - BinaryMsg(char* buffer); + /// @brief Create a new message for sending + /// @param networkId The network ID of the thing + /// @param thing The thing for which binary data is sent BinaryMsg(unsigned char networkId, Thing* thing); + /// @copydoc RoboidControl::IMessage::IMessage(char*) + BinaryMsg(char* buffer); + /// @brief Destructor for the message virtual ~BinaryMsg(); + /// @copydoc RoboidControl::IMessage::Serialize virtual unsigned char Serialize(char* buffer) override; - - static BinaryMsg Receive(char* buffer, unsigned char bufferSize); }; } // namespace RoboidControl diff --git a/README.md b/README.md index f01cb53..937bd44 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,6 @@ Supporting: - ESP8266 - ESP32 - UNO R4 WiFi - - ESP8266 - - ESP32 - - UNO R4 WiFi # Basic components