diff --git a/README.md b/README.md index 2bf7f83d..fcad3cc6 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Together with [Radon Ulzer](https://github.com/BlueAndi/RadonUlzer) it can be ru 1. Build the firmware using the ```Build``` task in the "PlatformIO Project Tasks" - For the target use only the applications with "Target" as postfix, e.g. LineFollowerTarget. 2. Upload the firmware to the ZumoComSystem using the ```Upload``` task in the "PlatformIO Project Tasks" tab, or the arrow on the bottom task bar. -3. After succesfully uploading the firmware, the configuration has to be uploaded to the filesystem. Make sure that the information in ```data/config/config.json``` matches your setup. Upload the configuration using the ```Upload Filesystem Image``` task in the "PlatformIO Project Tasks" tab. +3. After successfully uploading the firmware, the configuration has to be uploaded to the filesystem. Make sure that the information in ```data/config/config.json``` matches your setup. Upload the configuration using the ```Upload Filesystem Image``` task in the "PlatformIO Project Tasks" tab. Note that the robotName can be left empty in case you want the MAC address of the hardware to be used as the name. In case you prefer to give the robot a more descriptive name, can set the name. Beware, if you use multiple robots, you will have to give each a different name manually. diff --git a/lib/APPTurtle/src/MicroRosClient.h b/lib/APPTurtle/src/MicroRosClient.h index e1360b0d..c472b623 100644 --- a/lib/APPTurtle/src/MicroRosClient.h +++ b/lib/APPTurtle/src/MicroRosClient.h @@ -94,7 +94,7 @@ class MicroRosClient * @param[in] subscriber Pointer to a new subscriber. It shall be instanced using new. The MicroRosClient will * delete the pointer once it is no longer used. Checks if the instance is nullptr. * - * @returns If succesfully created, returns true. Otherwise, false. + * @returns If successfully created, returns true. Otherwise, false. */ bool registerSubscriber(BaseSubscriber* subscriber); @@ -202,7 +202,7 @@ class MicroRosClient * * @param[in] ipAddress The Micro-ROS agent IP-address. * @param[in] port The Micro-ROS agent port. - * + * * @return If successful it will return true otherwise false. */ bool setupCustomTransport(const IPAddress& ipAddress, uint16_t port); diff --git a/lib/APPTurtle/src/Subscriber.h b/lib/APPTurtle/src/Subscriber.h index b2371632..58568f16 100644 --- a/lib/APPTurtle/src/Subscriber.h +++ b/lib/APPTurtle/src/Subscriber.h @@ -82,7 +82,7 @@ class BaseSubscriber * @param[in] node Pointer to the RCL node. * @param[in] executor Pointer to the RCLC executor. * - * @returns If succesfully initialized, returns true. Otherwise, false. + * @returns If successfully initialized, returns true. Otherwise, false. */ virtual bool init(rcl_node_t* node, rclc_executor_t* executor) = 0; @@ -174,7 +174,7 @@ class Subscriber : public BaseSubscriber * @param[in] node Pointer to the RCL node. * @param[in] executor Pointer to the RCLC executor. * - * @returns If succesfully initialized, returns true. Otherwise, false. + * @returns If successfully initialized, returns true. Otherwise, false. */ bool init(rcl_node_t* node, rclc_executor_t* executor) final { diff --git a/lib/HALInterfaces/src/IMqttClient.h b/lib/HALInterfaces/src/IMqttClient.h index 1b9c5d5a..5d189553 100644 --- a/lib/HALInterfaces/src/IMqttClient.h +++ b/lib/HALInterfaces/src/IMqttClient.h @@ -111,7 +111,7 @@ class IMqttClient * This method does not necessarily wait for the connection to be established, it just starts the connection * process. Check `isConnected()` for the current connection status. * - * @return If connection has been succesfully started, returns true. Otherwise, false. + * @return If connection has been successfully started, returns true. Otherwise, false. */ virtual bool connect() = 0; diff --git a/lib/HALInterfaces/src/IRobot.h b/lib/HALInterfaces/src/IRobot.h index 8430f610..0aa7fb54 100644 --- a/lib/HALInterfaces/src/IRobot.h +++ b/lib/HALInterfaces/src/IRobot.h @@ -78,7 +78,7 @@ class IRobot virtual void process() = 0; /** - * Get comunication stream. + * Get communication stream. * * @return Robot data stream. */ diff --git a/lib/HALSim/src/Board.h b/lib/HALSim/src/Board.h index 53f63351..81844f46 100644 --- a/lib/HALSim/src/Board.h +++ b/lib/HALSim/src/Board.h @@ -45,7 +45,7 @@ #include #include #include "Battery.h" -#include "Button.h" +#include "ButtonReset.h" #include "LedBlue.h" #include "LedGreen.h" #include "LedRed.h" @@ -210,8 +210,8 @@ class Board : public IBoard /** Battery driver */ Battery m_battery; - /** Button driver */ - Button m_button; + /** Button "Reset" driver */ + ButtonReset m_button; /** Blue LED driver */ LedBlue m_ledBlue; diff --git a/lib/HALSim/src/ButtonA.cpp b/lib/HALSim/src/ButtonA.cpp new file mode 100644 index 00000000..1fbb316a --- /dev/null +++ b/lib/HALSim/src/ButtonA.cpp @@ -0,0 +1,80 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "A" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonA.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonA::isPressed() +{ + return m_keyboard.buttonAPressed(); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALSim/src/Button.h b/lib/HALSim/src/ButtonA.h similarity index 91% rename from lib/HALSim/src/Button.h rename to lib/HALSim/src/ButtonA.h index b610cc95..830e9bd4 100644 --- a/lib/HALSim/src/Button.h +++ b/lib/HALSim/src/ButtonA.h @@ -25,7 +25,7 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Button realization + * @brief Button "A" realization * @author Gabryel Reyes * * @addtogroup HALSim @@ -33,8 +33,8 @@ * @{ */ -#ifndef BUTTON_H -#define BUTTON_H +#ifndef BUTTON_A_H +#define BUTTON_A_H /****************************************************************************** * Compile Switches @@ -54,8 +54,8 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the simulation button. */ -class Button : public IButton +/** This class provides access to the robot button "A". */ +class ButtonA : public IButton { public: /** @@ -63,14 +63,14 @@ class Button : public IButton * * @param[in] keyboard The keyboard to use for button simulation. */ - Button(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) + ButtonA(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) { } /** * Destroys the button adapter. */ - virtual ~Button() + virtual ~ButtonA() { } @@ -89,5 +89,5 @@ class Button : public IButton * Functions *****************************************************************************/ -#endif /* BUTTON_H */ +#endif /* BUTTON_A_H */ /** @} */ diff --git a/lib/HALSim/src/ButtonB.cpp b/lib/HALSim/src/ButtonB.cpp new file mode 100644 index 00000000..af991a75 --- /dev/null +++ b/lib/HALSim/src/ButtonB.cpp @@ -0,0 +1,80 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "B" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonB.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonB::isPressed() +{ + return m_keyboard.buttonBPressed(); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALSim/src/ButtonB.h b/lib/HALSim/src/ButtonB.h new file mode 100644 index 00000000..b0747d60 --- /dev/null +++ b/lib/HALSim/src/ButtonB.h @@ -0,0 +1,93 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "B" realization + * @author Gabryel Reyes + * + * @addtogroup HALSim + * + * @{ + */ + +#ifndef BUTTON_B_H +#define BUTTON_B_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include "Keyboard.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot button "B". */ +class ButtonB : public IButton +{ +public: + /** + * Constructs the button adapter. + * + * @param[in] keyboard The keyboard to use for button simulation. + */ + ButtonB(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonB() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: + Keyboard& m_keyboard; /**< Robot keyboard */ +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BUTTON_B_H */ +/** @} */ diff --git a/lib/HALSim/src/ButtonC.cpp b/lib/HALSim/src/ButtonC.cpp new file mode 100644 index 00000000..914b498d --- /dev/null +++ b/lib/HALSim/src/ButtonC.cpp @@ -0,0 +1,80 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "C" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonC.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonC::isPressed() +{ + return m_keyboard.buttonCPressed(); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALSim/src/ButtonC.h b/lib/HALSim/src/ButtonC.h new file mode 100644 index 00000000..825531c7 --- /dev/null +++ b/lib/HALSim/src/ButtonC.h @@ -0,0 +1,93 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "C" realization + * @author Gabryel Reyes + * + * @addtogroup HALSim + * + * @{ + */ + +#ifndef BUTTON_C_H +#define BUTTON_C_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include "Keyboard.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot button "C". */ +class ButtonC : public IButton +{ +public: + /** + * Constructs the button adapter. + * + * @param[in] keyboard The keyboard to use for button simulation. + */ + ButtonC(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonC() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: + Keyboard& m_keyboard; /**< Robot keyboard */ +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BUTTON_C_H */ +/** @} */ diff --git a/lib/HALSim/src/Button.cpp b/lib/HALSim/src/ButtonReset.cpp similarity index 97% rename from lib/HALSim/src/Button.cpp rename to lib/HALSim/src/ButtonReset.cpp index 45efbae2..5cefad74 100644 --- a/lib/HALSim/src/Button.cpp +++ b/lib/HALSim/src/ButtonReset.cpp @@ -25,14 +25,14 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Button realization + * @brief Button "Reset" realization * @author Gabryel Reyes */ /****************************************************************************** * Includes *****************************************************************************/ -#include "Button.h" +#include "ButtonReset.h" /****************************************************************************** * Compiler Switches @@ -58,7 +58,7 @@ * Public Methods *****************************************************************************/ -bool Button::isPressed() +bool ButtonReset::isPressed() { return m_keyboard.buttonSPressed(); } diff --git a/lib/HALSim/src/ButtonReset.h b/lib/HALSim/src/ButtonReset.h new file mode 100644 index 00000000..c086c4c2 --- /dev/null +++ b/lib/HALSim/src/ButtonReset.h @@ -0,0 +1,93 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "Reset" realization + * @author Gabryel Reyes + * + * @addtogroup HALSim + * + * @{ + */ + +#ifndef BUTTON_RESET_H +#define BUTTON_RESET_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include "Keyboard.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot button "Reset". */ +class ButtonReset : public IButton +{ +public: + /** + * Constructs the button adapter. + * + * @param[in] keyboard The keyboard to use for button simulation. + */ + ButtonReset(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonReset() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: + Keyboard& m_keyboard; /**< Robot keyboard */ +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BUTTON_RESET_H */ +/** @} */ diff --git a/lib/HALSim/src/Keyboard.h b/lib/HALSim/src/Keyboard.h index d1f4a0ef..588d5998 100644 --- a/lib/HALSim/src/Keyboard.h +++ b/lib/HALSim/src/Keyboard.h @@ -85,7 +85,7 @@ class Keyboard void getPressedButtons() { /* Getting the new key values. Currently the limit of the simulation is seven - * keypresses that can be detected simultaniously. + * keypresses that can be detected simultaneously. */ for (uint8_t keyIndex = 0; keyIndex < (sizeof(m_keys) / sizeof(*m_keys)); ++keyIndex) { @@ -94,7 +94,7 @@ class Keyboard } /** - * Checks weather the button S was pressed. + * Checks whether the button S was pressed. * * @return Return true if button S was pressed. */ @@ -104,7 +104,7 @@ class Keyboard } /** - * Checks weather the button S is released. + * Checks whether the button S is released. * * @return Return true if button S is released. */ @@ -131,14 +131,146 @@ class Keyboard } } + /** + * Checks whether the button A was pressed. + * + * @return Return true if button A was pressed. + */ + bool buttonAPressed() + { + return isButtonPressed(KEY_CODE_A_LOWER_CASE, KEY_CODE_A_UPPER_CASE); + } + + /** + * Checks whether the button A is released. + * + * @return Return true if button A is released. + */ + bool buttonAReleased() + { + return isButtonReleased(KEY_CODE_A_LOWER_CASE, KEY_CODE_A_UPPER_CASE); + } + + /** + * Waits until Button A gets released. + * Needs to call the robots step() method and getPressedButtons() + * to update the keypresses correctly and avoid getting stuck + * in the while loop. + */ + void waitForReleaseA() + { + while (!buttonAReleased()) + { + if (false == m_simTime.step()) + { + break; + } + getPressedButtons(); + } + } + + /** + * Checks whether the button B was pressed. + * + * @return Return true if button B was pressed. + */ + bool buttonBPressed() + { + return isButtonPressed(KEY_CODE_B_LOWER_CASE, KEY_CODE_B_UPPER_CASE); + } + + /** + * Checks whether the button B is released. + * + * @return Return true if button B is released. + */ + bool buttonBReleased() + { + return isButtonReleased(KEY_CODE_B_LOWER_CASE, KEY_CODE_B_UPPER_CASE); + } + + /** + * Waits until Button B gets released. + * Needs to call the robots step() method and getPressedButtons() + * to update the keypresses correctly and avoid getting stuck + * in the while loop. + */ + void waitForReleaseB() + { + while (!buttonBReleased()) + { + if (false == m_simTime.step()) + { + break; + } + getPressedButtons(); + } + } + + /** + * Checks whether the button C was pressed. + * + * @return Return true if button C was pressed. + */ + bool buttonCPressed() + { + return isButtonPressed(KEY_CODE_C_LOWER_CASE, KEY_CODE_C_UPPER_CASE); + } + + /** + * Checks whether the button C is released. + * + * @return Return true if button C is released. + */ + bool buttonCReleased() + { + return isButtonReleased(KEY_CODE_C_LOWER_CASE, KEY_CODE_C_UPPER_CASE); + } + + /** + * Waits until Button C gets released. + * Needs to call the robots step() method and getPressedButtons() + * to update the keypresses correctly and avoid getting stuck + * in the while loop. + */ + void waitForReleaseC() + { + while (!buttonCReleased()) + { + if (false == m_simTime.step()) + { + break; + } + getPressedButtons(); + } + } + private: - /** The key code of the lower case s character, which simulates the button. */ + /** The key code of the lower case s character, which simulates the button "Reset". */ static const char KEY_CODE_S_LOWER_CASE = 's'; - /** The key code of the upper case S character, which simulates the button. */ + /** The key code of the upper case S character, which simulates the button "Reset". */ static const char KEY_CODE_S_UPPER_CASE = 'S'; - /** The maximum number of keys pressed simultaniously, that the simulation can process. */ + /** The key code of the lower case a character, which simulates the button "A". */ + static const char KEY_CODE_A_LOWER_CASE = 'a'; + + /** The key code of the upper case A character, which simulates the button "A". */ + static const char KEY_CODE_A_UPPER_CASE = 'A'; + + /** The key code of the lower case b character, which simulates the button "B". */ + static const char KEY_CODE_B_LOWER_CASE = 'b'; + + /** The key code of the upper case B character, which simulates the button "B". */ + static const char KEY_CODE_B_UPPER_CASE = 'B'; + + /** The key code of the lower case c character, which simulates the button "C". */ + static const char KEY_CODE_C_LOWER_CASE = 'c'; + + /** The key code of the upper case C character, which simulates the button "C". */ + static const char KEY_CODE_C_UPPER_CASE = 'C'; + + /** The maximum number of keys pressed simultaneously, that the simulation can process. */ static const uint8_t MAX_KEY_NUMBER = 7; /** The keys pressed during this update. */ diff --git a/lib/HALSim/src/LedA.cpp b/lib/HALSim/src/LedA.cpp new file mode 100644 index 00000000..9272c11d --- /dev/null +++ b/lib/HALSim/src/LedA.cpp @@ -0,0 +1,81 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "A" LED realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "LedA.h" +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +void LedA::enable(bool enableIt) +{ + LOG_DEBUG("LED A State: %s", enableIt ? "ON" : "OFF"); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALSim/src/LedA.h b/lib/HALSim/src/LedA.h new file mode 100644 index 00000000..01f9ff2c --- /dev/null +++ b/lib/HALSim/src/LedA.h @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "A" LED realization + * @author Gabryel Reyes + * + * @addtogroup HALSim + * + * @{ + */ + +#ifndef LED_A_H +#define LED_A_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ILed.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the "A" LED. */ +class LedA : public ILed +{ +public: + /** + * Constructs the "A" LED adapter. + */ + LedA() : ILed() + { + } + + /** + * Destroys the "A" LED adapter. + */ + virtual ~LedA() + { + } + + /** + * Enables/Disables the LED. + * + * @param[in] enableIt Enable LED with true, disable it with false. + */ + void enable(bool enableIt) final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* LED_A_H */ +/** @} */ diff --git a/lib/HALSim/src/LedB.cpp b/lib/HALSim/src/LedB.cpp new file mode 100644 index 00000000..c9afb407 --- /dev/null +++ b/lib/HALSim/src/LedB.cpp @@ -0,0 +1,81 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "B" LED realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "LedB.h" +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +void LedB::enable(bool enableIt) +{ + LOG_DEBUG("LED B State: %s", enableIt ? "ON" : "OFF"); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALSim/src/LedB.h b/lib/HALSim/src/LedB.h new file mode 100644 index 00000000..c5a6225f --- /dev/null +++ b/lib/HALSim/src/LedB.h @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "B" LED realization + * @author Gabryel Reyes + * + * @addtogroup HALSim + * + * @{ + */ + +#ifndef LED_B_H +#define LED_B_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ILed.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the "B" LED. */ +class LedB : public ILed +{ +public: + /** + * Constructs the "B" LED adapter. + */ + LedB() : ILed() + { + } + + /** + * Destroys the "B" LED adapter. + */ + virtual ~LedB() + { + } + + /** + * Enables/Disables the LED. + * + * @param[in] enableIt Enable LED with true, disable it with false. + */ + void enable(bool enableIt) final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* LED_B_H */ +/** @} */ diff --git a/lib/HALSim/src/LedC.cpp b/lib/HALSim/src/LedC.cpp new file mode 100644 index 00000000..c1dfe5ef --- /dev/null +++ b/lib/HALSim/src/LedC.cpp @@ -0,0 +1,81 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "C" LED realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "LedC.h" +#include + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +void LedC::enable(bool enableIt) +{ + LOG_DEBUG("LED C State: %s", enableIt ? "ON" : "OFF"); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALSim/src/LedC.h b/lib/HALSim/src/LedC.h new file mode 100644 index 00000000..31dfa76f --- /dev/null +++ b/lib/HALSim/src/LedC.h @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "C" LED realization + * @author Gabryel Reyes + * + * @addtogroup HALSim + * + * @{ + */ + +#ifndef LED_C_H +#define LED_C_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ILed.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the "C" LED. */ +class LedC : public ILed +{ +public: + /** + * Constructs the "C" LED adapter. + */ + LedC() : ILed() + { + } + + /** + * Destroys the "C" LED adapter. + */ + virtual ~LedC() + { + } + + /** + * Enables/Disables the LED. + * + * @param[in] enableIt Enable LED with true, disable it with false. + */ + void enable(bool enableIt) final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* LED_C_H */ +/** @} */ diff --git a/lib/HALSim/src/MqttClient.h b/lib/HALSim/src/MqttClient.h index 9aa0836b..25338ae8 100644 --- a/lib/HALSim/src/MqttClient.h +++ b/lib/HALSim/src/MqttClient.h @@ -97,7 +97,7 @@ class MqttClient : public IMqttClient * This method does not necessarily wait for the connection to be established, it just starts the connection * process. Check `isConnected()` for the current connection status. * - * @return If connection has been succesfully started, returns true. Otherwise, false. + * @return If connection has been successfully started, returns true. Otherwise, false. */ bool connect() final; diff --git a/lib/HALSim/src/Robot.h b/lib/HALSim/src/Robot.h index 91d56399..fde36b70 100644 --- a/lib/HALSim/src/Robot.h +++ b/lib/HALSim/src/Robot.h @@ -88,7 +88,7 @@ class Robot : public IRobot, public IRobotNative void process() final; /** - * Get comunication stream. + * Get communication stream. * * @return Robot data stream. */ diff --git a/lib/HALTargetCommon/src/Battery.h b/lib/HALTargetCommon/src/Battery.h index 89fa46a7..64ece817 100644 --- a/lib/HALTargetCommon/src/Battery.h +++ b/lib/HALTargetCommon/src/Battery.h @@ -28,7 +28,7 @@ * @brief Battery realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -93,7 +93,8 @@ class Battery : public IBattery static const uint32_t REFERENCE_VOLTAGE = 3300U; /**< Reference voltage of the ADCs in millivolts*/ static const uint32_t CONVERSION_FACTOR = 10000U; /**< Conversion factor from measured to real battery voltage. */ - MovAvg m_voltMovAvg; /**< The moving average of the measured voltage over 2 calling cycles. */ + MovAvg + m_voltMovAvg; /**< The moving average of the measured voltage over 2 calling cycles. */ }; /****************************************************************************** diff --git a/lib/HALTargetV1/src/Board.cpp b/lib/HALTargetCommon/src/Board.cpp similarity index 100% rename from lib/HALTargetV1/src/Board.cpp rename to lib/HALTargetCommon/src/Board.cpp diff --git a/lib/HALTargetV1/src/Board.h b/lib/HALTargetCommon/src/Board.h similarity index 97% rename from lib/HALTargetV1/src/Board.h rename to lib/HALTargetCommon/src/Board.h index 7370a211..38ee66e8 100644 --- a/lib/HALTargetV1/src/Board.h +++ b/lib/HALTargetCommon/src/Board.h @@ -28,7 +28,7 @@ * @brief The target board realization. * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -44,7 +44,7 @@ *****************************************************************************/ #include #include "Battery.h" -#include "Button.h" +#include "ButtonReset.h" #include "LedBlue.h" #include "LedGreen.h" #include "LedRed.h" @@ -185,8 +185,8 @@ class Board : public IBoard /** Battery driver */ Battery m_battery; - /** Button driver */ - Button m_button; + /** Button "Reset" driver */ + ButtonReset m_button; /** Blue LED driver */ LedBlue m_ledBlue; diff --git a/lib/HALTargetV1/src/Button.cpp b/lib/HALTargetCommon/src/ButtonA.cpp similarity index 97% rename from lib/HALTargetV1/src/Button.cpp rename to lib/HALTargetCommon/src/ButtonA.cpp index 8bded0b0..cecab40d 100644 --- a/lib/HALTargetV1/src/Button.cpp +++ b/lib/HALTargetCommon/src/ButtonA.cpp @@ -25,14 +25,14 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Button realization + * @brief Button "A" realization * @author Gabryel Reyes */ /****************************************************************************** * Includes *****************************************************************************/ -#include "Button.h" +#include "ButtonA.h" #include "GPIO.h" #include "ButtonDrv.h" @@ -60,9 +60,9 @@ * Public Methods *****************************************************************************/ -bool Button::isPressed() +bool ButtonA::isPressed() { - return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_OK)); + return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_A)); } /****************************************************************************** diff --git a/lib/HALTargetV1/src/Button.h b/lib/HALTargetCommon/src/ButtonA.h similarity index 90% rename from lib/HALTargetV1/src/Button.h rename to lib/HALTargetCommon/src/ButtonA.h index ef0ebf82..86e3f40c 100644 --- a/lib/HALTargetV1/src/Button.h +++ b/lib/HALTargetCommon/src/ButtonA.h @@ -25,16 +25,16 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Button realization + * @brief Button "A" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ -#ifndef BUTTON_H -#define BUTTON_H +#ifndef BUTTON_A_H +#define BUTTON_A_H /****************************************************************************** * Compile Switches @@ -54,21 +54,21 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ -class Button : public IButton +/** This class provides access to the robot button "A". */ +class ButtonA : public IButton { public: /** * Constructs the button adapter. */ - Button() : IButton() + ButtonA() : IButton() { } /** * Destroys the button adapter. */ - virtual ~Button() + virtual ~ButtonA() { } @@ -86,5 +86,5 @@ class Button : public IButton * Functions *****************************************************************************/ -#endif /* BUTTON_H */ +#endif /* BUTTON_A_H */ /** @} */ diff --git a/lib/HALTargetCommon/src/ButtonB.cpp b/lib/HALTargetCommon/src/ButtonB.cpp new file mode 100644 index 00000000..e180a486 --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonB.cpp @@ -0,0 +1,82 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "B" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonB.h" +#include "GPIO.h" +#include "ButtonDrv.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonB::isPressed() +{ + return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_B)); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/ButtonB.h b/lib/HALTargetCommon/src/ButtonB.h new file mode 100644 index 00000000..82842092 --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonB.h @@ -0,0 +1,90 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "B" realization + * @author Gabryel Reyes + * + * @addtogroup HALTargetCommon + * + * @{ + */ + +#ifndef BUTTON_B_H +#define BUTTON_B_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot button "B". */ +class ButtonB : public IButton +{ +public: + /** + * Constructs the button adapter. + */ + ButtonB() : IButton() + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonB() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BUTTON_B_H */ +/** @} */ diff --git a/lib/HALTargetCommon/src/ButtonC.cpp b/lib/HALTargetCommon/src/ButtonC.cpp new file mode 100644 index 00000000..0a477baa --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonC.cpp @@ -0,0 +1,82 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "C" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonC.h" +#include "GPIO.h" +#include "ButtonDrv.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonC::isPressed() +{ + return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_C)); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/ButtonC.h b/lib/HALTargetCommon/src/ButtonC.h new file mode 100644 index 00000000..d2575dca --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonC.h @@ -0,0 +1,90 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "C" realization + * @author Gabryel Reyes + * + * @addtogroup HALTargetCommon + * + * @{ + */ + +#ifndef BUTTON_C_H +#define BUTTON_C_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot button "C". */ +class ButtonC : public IButton +{ +public: + /** + * Constructs the button adapter. + */ + ButtonC() : IButton() + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonC() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BUTTON_C_H */ +/** @} */ diff --git a/lib/HALTargetV1/src/ButtonDrv.cpp b/lib/HALTargetCommon/src/ButtonDrv.cpp similarity index 92% rename from lib/HALTargetV1/src/ButtonDrv.cpp rename to lib/HALTargetCommon/src/ButtonDrv.cpp index fa8383d3..bc45f125 100644 --- a/lib/HALTargetV1/src/ButtonDrv.cpp +++ b/lib/HALTargetCommon/src/ButtonDrv.cpp @@ -62,6 +62,9 @@ static void IRAM_ATTR isrButton(void* arg); const IoPin* ButtonDrv::BUTTON_PIN[BUTTON_ID_CNT] = { &GpioPins::resetButtonPin, + &GpioPins::buttonAPin, + &GpioPins::buttonBPin, + &GpioPins::buttonCPin, }; /** @@ -70,7 +73,10 @@ const IoPin* ButtonDrv::BUTTON_PIN[BUTTON_ID_CNT] = { * (re-)start the debounce timer. */ static ButtonId gButtonId[BUTTON_ID_CNT] = { - BUTTON_ID_OK, + BUTTON_ID_RESET, + BUTTON_ID_A, + BUTTON_ID_B, + BUTTON_ID_C, }; /** Number of elements in the button id queue. */ @@ -81,7 +87,7 @@ static const uint32_t QUEUE_SIZE = 10U; * Every time the task detects a pin level change, it will notify the task * about it by sending the corresponding button id via queue. */ -static QueueHandle_t gxQueue = nullptr; +static QueueHandle_t gxQueue = nullptr; /****************************************************************************** * Public Methods @@ -94,7 +100,7 @@ bool ButtonDrv::init() /* Create semaphore to protect the button trigger array, which is accessed * by the task and the ISR. */ - gxQueue = xQueueCreate(QUEUE_SIZE, sizeof(ButtonId)); + gxQueue = xQueueCreate(QUEUE_SIZE, sizeof(ButtonId)); if (nullptr == gxQueue) { @@ -174,7 +180,7 @@ void ButtonDrv::registerObserver(IButtonObserver& observer) { uint8_t buttonIndex = 0U; - m_observer = &observer; + m_observer = &observer; while (BUTTON_ID_CNT > buttonIndex) { @@ -223,6 +229,9 @@ bool ButtonDrv::enableWakeUpSources() /* If no button is pressed anymore, enable them as wakeup source. */ if (true == allButtonsReleased) { + /* Reset button index. */ + buttonIdx = 0U; + /* Use all available buttons as wakeup sources. */ while (BUTTON_ID_CNT > buttonIdx) { @@ -268,10 +277,7 @@ void ButtonDrv::attachButtonsToInterrupt() { if (IoPin::NC != BUTTON_PIN[buttonIdx]->getPinNo()) { - attachInterruptArg(BUTTON_PIN[buttonIdx]->getPinNo(), - isrButton, - &gButtonId[buttonIdx], - CHANGE); + attachInterruptArg(BUTTON_PIN[buttonIdx]->getPinNo(), isrButton, &gButtonId[buttonIdx], CHANGE); /* Start the debouncing to get a stable initial button state. */ m_timer[buttonIdx].start(DEBOUNCING_TIME); @@ -321,17 +327,25 @@ void ButtonDrv::buttonTaskMainLoop() /* Debounce buttons */ while (BUTTON_ID_CNT > buttonIdx) { - if ((true == m_timer[buttonIdx].isTimerRunning()) && - (true == m_timer[buttonIdx].isTimeout())) + if ((true == m_timer[buttonIdx].isTimerRunning()) && (true == m_timer[buttonIdx].isTimeout())) { ButtonState buttonState = BUTTON_STATE_UNKNOWN; uint8_t buttonValue = HIGH; switch (buttonIdx) { - case BUTTON_ID_OK: + case BUTTON_ID_RESET: buttonValue = GpioPins::resetButtonPin.read(); break; + case BUTTON_ID_A: + buttonValue = GpioPins::buttonAPin.read(); + break; + case BUTTON_ID_B: + buttonValue = GpioPins::buttonBPin.read(); + break; + case BUTTON_ID_C: + buttonValue = GpioPins::buttonCPin.read(); + break; default: break; diff --git a/lib/HALTargetV1/src/ButtonDrv.h b/lib/HALTargetCommon/src/ButtonDrv.h similarity index 86% rename from lib/HALTargetV1/src/ButtonDrv.h rename to lib/HALTargetCommon/src/ButtonDrv.h index 98b68a85..1386c5a2 100644 --- a/lib/HALTargetV1/src/ButtonDrv.h +++ b/lib/HALTargetCommon/src/ButtonDrv.h @@ -28,7 +28,7 @@ * @brief Button driver * @author Andreas Merkle * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -61,8 +61,11 @@ */ typedef enum { - BUTTON_ID_OK = 0, /**< Button "ok" */ - BUTTON_ID_CNT /**< Number of buttons */ + BUTTON_ID_RESET = 0, /**< Button "reset" */ + BUTTON_ID_A, /**< Button "A" */ + BUTTON_ID_B, /**< Button "B" */ + BUTTON_ID_C, /**< Button "C" */ + BUTTON_ID_CNT /**< Number of buttons */ } ButtonId; @@ -84,7 +87,6 @@ typedef enum class IButtonObserver { public: - /** * Destroys the button observer interface. */ @@ -101,7 +103,6 @@ class IButtonObserver virtual void notify(ButtonId buttonId, ButtonState state) = 0; protected: - /** * Creates the button observer interface. */ @@ -116,7 +117,6 @@ class IButtonObserver class ButtonDrv { public: - /** * Get the button driver instance. * @@ -146,7 +146,7 @@ class ButtonDrv ButtonState getState(ButtonId buttonId); /** - * Register an observer to get notifyed about button + * Register an observer to get notified about button * state changes. Only one observer is supported! * * @param[in] observer The button observer @@ -162,7 +162,7 @@ class ButtonDrv * Enable all buttons as wakeup sources. * A low level of the wakeup source will trigger the wakeup. * Ensure that all buttons are released at the time of calling it, - * otherwise the wakeup will occurre immediately. + * otherwise the wakeup will occur immediately. * * @return If not all buttons are released, it will return false and the * wakeup sources are not enabled. Otherwise it will return true @@ -171,7 +171,6 @@ class ButtonDrv bool enableWakeUpSources(); private: - /** * The digital input buttons. */ @@ -182,32 +181,32 @@ class ButtonDrv */ static const uint32_t DEBOUNCING_TIME = 100U; - Task m_buttonTask; /**< Button task. */ - SemaphoreHandle_t m_xSemaphore; /**< Semaphore to protect button state member. */ - ButtonState m_state[BUTTON_ID_CNT]; /**< Current button states */ - SimpleTimer m_timer[BUTTON_ID_CNT]; /**< Timer used for debouncing */ - IButtonObserver* m_observer; /**< Observer for button state changes */ + Task m_buttonTask; /**< Button task. */ + SemaphoreHandle_t m_xSemaphore; /**< Semaphore to protect button state member. */ + ButtonState m_state[BUTTON_ID_CNT]; /**< Current button states */ + SimpleTimer m_timer[BUTTON_ID_CNT]; /**< Timer used for debouncing */ + IButtonObserver* m_observer; /**< Observer for button state changes */ /** Button task stack size in bytes. */ - static const uint32_t BUTTON_TASK_STACKE_SIZE = 2048U; + static const uint32_t BUTTON_TASK_STACK_SIZE = 2048U; /** Button task priority. */ - static const UBaseType_t BUTTON_TASK_PRIORITY = 1U; + static const UBaseType_t BUTTON_TASK_PRIORITY = 1U; /** MCU core where the button task shall run. */ - static const BaseType_t BUTTON_TASK_RUN_CORE = APP_CPU_NUM; + static const BaseType_t BUTTON_TASK_RUN_CORE = APP_CPU_NUM; /** Task period in ms. */ - static const uint32_t BUTTON_TASK_PERIOD = 10U; + static const uint32_t BUTTON_TASK_PERIOD = 10U; /** Button debouncing time in ms. */ - static const uint32_t BUTTON_DEBOUNCE_TIME = 100U; + static const uint32_t BUTTON_DEBOUNCE_TIME = 100U; /** * Constructs the button driver instance. */ ButtonDrv() : - m_buttonTask("buttonTask", buttonTask, BUTTON_TASK_STACKE_SIZE, BUTTON_TASK_PRIORITY, BUTTON_TASK_RUN_CORE), + m_buttonTask("buttonTask", buttonTask, BUTTON_TASK_STACK_SIZE, BUTTON_TASK_PRIORITY, BUTTON_TASK_RUN_CORE), m_xSemaphore(nullptr), m_state(), m_timer(), diff --git a/lib/HALTargetCommon/src/ButtonReset.cpp b/lib/HALTargetCommon/src/ButtonReset.cpp new file mode 100644 index 00000000..ea85f747 --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonReset.cpp @@ -0,0 +1,82 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "Reset" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonReset.h" +#include "GPIO.h" +#include "ButtonDrv.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonReset::isPressed() +{ + return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_RESET)); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/ButtonReset.h b/lib/HALTargetCommon/src/ButtonReset.h new file mode 100644 index 00000000..ae926150 --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonReset.h @@ -0,0 +1,90 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Button "Reset" realization + * @author Gabryel Reyes + * + * @addtogroup HALTargetCommon + * + * @{ + */ + +#ifndef BUTTON_RESET_H +#define BUTTON_RESET_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot button "Reset". */ +class ButtonReset : public IButton +{ +public: + /** + * Constructs the button adapter. + */ + ButtonReset() : IButton() + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonReset() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* BUTTON_RESET_H */ +/** @} */ diff --git a/lib/HALTargetCommon/src/FileHandler.h b/lib/HALTargetCommon/src/FileHandler.h index a9d17343..c10c8d58 100644 --- a/lib/HALTargetCommon/src/FileHandler.h +++ b/lib/HALTargetCommon/src/FileHandler.h @@ -28,7 +28,7 @@ * @brief FileHandler implementation. * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetV1/src/GPIO.cpp b/lib/HALTargetCommon/src/GPIO.cpp similarity index 85% rename from lib/HALTargetV1/src/GPIO.cpp rename to lib/HALTargetCommon/src/GPIO.cpp index f1e0e95b..4077400a 100644 --- a/lib/HALTargetV1/src/GPIO.cpp +++ b/lib/HALTargetCommon/src/GPIO.cpp @@ -25,7 +25,7 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Abtraction of the GPIOs of the device. + * @brief Abstraction of the GPIOs of the device. * @author Gabryel Reyes */ @@ -83,6 +83,36 @@ const DOutPin GpioPins::infoLedBluePin; */ const AnalogPin GpioPins::batteryVoltagePin; +/** + * Digital input pin: Button A. + */ +const DInPin GpioPins::buttonAPin; + +/** + * Digital input pin: Button B. + */ +const DInPin GpioPins::buttonBPin; + +/** + * Digital input pin: Button C. + */ +const DInPin GpioPins::buttonCPin; + +/** + * Digital output pin: LED A. + */ +const DOutPin GpioPins::ledAPin; + +/** + * Digital output pin: LED B. + */ +const DOutPin GpioPins::ledBPin; + +/** + * Digital output pin: LED C. + */ +const DOutPin GpioPins::ledCPin; + /****************************************************************************** * Local Variables *****************************************************************************/ @@ -96,6 +126,12 @@ static const IoPin* ioPinList[] = &infoLedGreenPin, &infoLedBluePin, &batteryVoltagePin, + &buttonAPin, + &buttonBPin, + &buttonCPin, + &ledAPin, + &ledBPin, + &ledCPin, }; /****************************************************************************** @@ -127,4 +163,3 @@ extern void GpioPins::init() /****************************************************************************** * Local Functions *****************************************************************************/ - diff --git a/lib/HALTargetV1/src/GPIO.h b/lib/HALTargetCommon/src/GPIO.h similarity index 80% rename from lib/HALTargetV1/src/GPIO.h rename to lib/HALTargetCommon/src/GPIO.h index 9f1abfdf..da0fa10c 100644 --- a/lib/HALTargetV1/src/GPIO.h +++ b/lib/HALTargetCommon/src/GPIO.h @@ -28,7 +28,7 @@ * @brief Abstraction of the GPIOs of the device. * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -43,9 +43,9 @@ /****************************************************************************** * Includes *****************************************************************************/ -#include #include #include +#include /****************************************************************************** * Macros @@ -60,29 +60,6 @@ */ namespace GpioPins { - /** Pin number of all used pins. */ - namespace Pin - { - /** Pin for push button for system reset/AP mode start (ACTIVE LOW) */ - constexpr uint8_t PIN_WIFI_AND_RESET_KEY = 4; - - /** Pin for resetting the attached Zumo robot (ACTIVE LOW) */ - constexpr uint8_t PIN_DEVICE_RESET = 27; - - /** Pin for info LED RGB channel RED (ACTIVE LOW) */ - constexpr uint8_t INFO_LED_R = 16; - - /** Pin for info LED RGB channel GREEN (ACTIVE LOW) */ - constexpr uint8_t INFO_LED_G = 22; - - /** Pin for info LED RGB channel BLUE (ACTIVE LOW) */ - constexpr uint8_t INFO_LED_B = 21; - - /** Pin for analog measurement of battery voltage */ - constexpr uint8_t PIN_BATT_MEASUREMENT = 35; - - }; // namespace Pin - /** * Digital input pin: Reset Button. */ @@ -113,12 +90,42 @@ namespace GpioPins */ extern const AnalogPin batteryVoltagePin; + /** + * Digital input pin: Button A. + */ + extern const DInPin buttonAPin; + + /** + * Digital input pin: Button B. + */ + extern const DInPin buttonBPin; + + /** + * Digital input pin: Button C. + */ + extern const DInPin buttonCPin; + + /** + * Digital output pin: LED A. + */ + extern const DOutPin ledAPin; + + /** + * Digital output pin: LED B. + */ + extern const DOutPin ledBPin; + + /** + * Digital output pin: LED C. + */ + extern const DOutPin ledCPin; + /** * Initialize all i/o pins. */ extern void init(); -}; // namespace GPIO +}; /* namespace GpioPins */ /****************************************************************************** * Functions diff --git a/lib/HALTargetCommon/src/Io.hpp b/lib/HALTargetCommon/src/Io.hpp index 81a2cda1..0ccc004f 100644 --- a/lib/HALTargetCommon/src/Io.hpp +++ b/lib/HALTargetCommon/src/Io.hpp @@ -28,7 +28,7 @@ * @brief I/O abstraction * @author Andreas Merkle * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/LedA.cpp b/lib/HALTargetCommon/src/LedA.cpp new file mode 100644 index 00000000..01b8ad9c --- /dev/null +++ b/lib/HALTargetCommon/src/LedA.cpp @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "A" LED realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "LedA.h" +#include "GPIO.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +void LedA::enable(bool enableIt) +{ + uint8_t value = HIGH; + + /* LED is active-low. */ + if (true == enableIt) + { + value = LOW; + } + + GpioPins::ledAPin.write(value); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/LedA.h b/lib/HALTargetCommon/src/LedA.h new file mode 100644 index 00000000..c23ecd85 --- /dev/null +++ b/lib/HALTargetCommon/src/LedA.h @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "A" LED realization + * @author Gabryel Reyes + * + * @addtogroup HALTargetCommon + * + * @{ + */ + +#ifndef LED_A_H +#define LED_A_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ILed.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the "A" LED. */ +class LedA : public ILed +{ +public: + /** + * Constructs the "A" LED adapter. + */ + LedA() : ILed() + { + } + + /** + * Destroys the "A" LED adapter. + */ + virtual ~LedA() + { + } + + /** + * Enables/Disables the LED. + * + * @param[in] enableIt Enable LED with true, disable it with false. + */ + void enable(bool enableIt) final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* LED_A_H */ +/** @} */ diff --git a/lib/HALTargetCommon/src/LedB.cpp b/lib/HALTargetCommon/src/LedB.cpp new file mode 100644 index 00000000..55292ec5 --- /dev/null +++ b/lib/HALTargetCommon/src/LedB.cpp @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "B" LED realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "LedB.h" +#include "GPIO.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +void LedB::enable(bool enableIt) +{ + uint8_t value = HIGH; + + /* LED is active-low. */ + if (true == enableIt) + { + value = LOW; + } + + GpioPins::ledBPin.write(value); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/LedB.h b/lib/HALTargetCommon/src/LedB.h new file mode 100644 index 00000000..2e308a33 --- /dev/null +++ b/lib/HALTargetCommon/src/LedB.h @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "B" LED realization + * @author Gabryel Reyes + * + * @addtogroup HALTargetCommon + * + * @{ + */ + +#ifndef LED_B_H +#define LED_B_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ILed.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the "B" LED. */ +class LedB : public ILed +{ +public: + /** + * Constructs the "B" LED adapter. + */ + LedB() : ILed() + { + } + + /** + * Destroys the "B" LED adapter. + */ + virtual ~LedB() + { + } + + /** + * Enables/Disables the LED. + * + * @param[in] enableIt Enable LED with true, disable it with false. + */ + void enable(bool enableIt) final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* LED_B_H */ +/** @} */ diff --git a/lib/HALTargetCommon/src/LedBlue.h b/lib/HALTargetCommon/src/LedBlue.h index 2a9706ce..0b8be78b 100644 --- a/lib/HALTargetCommon/src/LedBlue.h +++ b/lib/HALTargetCommon/src/LedBlue.h @@ -28,7 +28,7 @@ * @brief Blue LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/LedC.cpp b/lib/HALTargetCommon/src/LedC.cpp new file mode 100644 index 00000000..7cbfc70b --- /dev/null +++ b/lib/HALTargetCommon/src/LedC.cpp @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "C" LED realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "LedC.h" +#include "GPIO.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +void LedC::enable(bool enableIt) +{ + uint8_t value = HIGH; + + /* LED is active-low. */ + if (true == enableIt) + { + value = LOW; + } + + GpioPins::ledCPin.write(value); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/LedC.h b/lib/HALTargetCommon/src/LedC.h new file mode 100644 index 00000000..8abeea41 --- /dev/null +++ b/lib/HALTargetCommon/src/LedC.h @@ -0,0 +1,89 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief "C" LED realization + * @author Gabryel Reyes + * + * @addtogroup HALTargetCommon + * + * @{ + */ + +#ifndef LED_C_H +#define LED_C_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ILed.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the "C" LED. */ +class LedC : public ILed +{ +public: + /** + * Constructs the "C" LED adapter. + */ + LedC() : ILed() + { + } + + /** + * Destroys the "C" LED adapter. + */ + virtual ~LedC() + { + } + + /** + * Enables/Disables the LED. + * + * @param[in] enableIt Enable LED with true, disable it with false. + */ + void enable(bool enableIt) final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* LED_C_H */ +/** @} */ diff --git a/lib/HALTargetCommon/src/LedGreen.h b/lib/HALTargetCommon/src/LedGreen.h index ad4e7bce..b9ba742b 100644 --- a/lib/HALTargetCommon/src/LedGreen.h +++ b/lib/HALTargetCommon/src/LedGreen.h @@ -28,7 +28,7 @@ * @brief Green LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/LedRed.h b/lib/HALTargetCommon/src/LedRed.h index 863f3d1d..0a0105f1 100644 --- a/lib/HALTargetCommon/src/LedRed.h +++ b/lib/HALTargetCommon/src/LedRed.h @@ -28,7 +28,7 @@ * @brief Red LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/MqttClient.cpp b/lib/HALTargetCommon/src/MqttClient.cpp index 7cea59b2..31d6560b 100644 --- a/lib/HALTargetCommon/src/MqttClient.cpp +++ b/lib/HALTargetCommon/src/MqttClient.cpp @@ -415,7 +415,7 @@ void MqttClient::handleConnectingState() if (false == m_birthTopic.isEmpty()) { - /* Publish birth message. Should succesfully publish if connected to broker. */ + /* Publish birth message. Should successfully publish if connected to broker. */ (void)publish(m_birthTopic, false, m_birthMessage); } } diff --git a/lib/HALTargetCommon/src/MqttClient.h b/lib/HALTargetCommon/src/MqttClient.h index 010322a7..5cd0ccb3 100644 --- a/lib/HALTargetCommon/src/MqttClient.h +++ b/lib/HALTargetCommon/src/MqttClient.h @@ -28,7 +28,7 @@ * @brief MQTTClient realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -98,7 +98,7 @@ class MqttClient : public IMqttClient * This method does not necessarily wait for the connection to be established, it just starts the connection * process. Check `isConnected()` for the current connection status. * - * @return If connection has been succesfully started, returns true. Otherwise, false. + * @return If connection has been successfully started, returns true. Otherwise, false. */ bool connect() final; @@ -181,7 +181,7 @@ class MqttClient : public IMqttClient /** * Max. MQTT client buffer size in byte. - * Received MQTT messages greather than this will be skipped. + * Received MQTT messages greater than this will be skipped. */ static const size_t MAX_BUFFER_SIZE = 1024U; diff --git a/lib/HALTargetCommon/src/Network.h b/lib/HALTargetCommon/src/Network.h index 2f17b8f7..a3871fa5 100644 --- a/lib/HALTargetCommon/src/Network.h +++ b/lib/HALTargetCommon/src/Network.h @@ -28,7 +28,7 @@ * @brief Network realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -134,7 +134,7 @@ class Network : public INetwork /** WiFi Access Point Mode SSID */ String m_apSSID; - /** WiFi Access Poit Mode Password */ + /** WiFi Access Point Mode Password */ String m_apPassword; /** WiFi Timeout Timer. */ diff --git a/lib/HALTargetCommon/src/Robot.h b/lib/HALTargetCommon/src/Robot.h index 31d86516..4adbdd64 100644 --- a/lib/HALTargetCommon/src/Robot.h +++ b/lib/HALTargetCommon/src/Robot.h @@ -28,7 +28,7 @@ * @brief Robot realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ @@ -86,7 +86,7 @@ class Robot : public IRobot void process() final; /** - * Get comunication stream. + * Get communication stream. * * @return Robot data stream. */ diff --git a/lib/HALTargetV1/src/Pin.h b/lib/HALTargetV1/src/Pin.h new file mode 100644 index 00000000..567f0244 --- /dev/null +++ b/lib/HALTargetV1/src/Pin.h @@ -0,0 +1,103 @@ +/* MIT License + * + * Copyright (c) 2023 - 2025 Andreas Merkle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/******************************************************************************* + DESCRIPTION +*******************************************************************************/ +/** + * @brief Pin definition for the target board. + * @author Gabryel Reyes + * + * @addtogroup HALTargetV1 + * + * @{ + */ +#ifndef PIN_H +#define PIN_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ + +#include +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** Pin number of all used pins. */ +namespace Pin +{ + /** Pin for push button for system reset/AP mode start (ACTIVE LOW) */ + constexpr uint8_t PIN_WIFI_AND_RESET_KEY = 4U; + + /** Pin for resetting the attached Zumo robot (ACTIVE LOW) */ + constexpr uint8_t PIN_DEVICE_RESET = 27U; + + /** Pin for info LED RGB channel RED (ACTIVE LOW) */ + constexpr uint8_t INFO_LED_R = 16U; + + /** Pin for info LED RGB channel GREEN (ACTIVE LOW) */ + constexpr uint8_t INFO_LED_G = 22U; + + /** Pin for info LED RGB channel BLUE (ACTIVE LOW) */ + constexpr uint8_t INFO_LED_B = 21U; + + /** Pin for analog measurement of battery voltage */ + constexpr uint8_t PIN_BATT_MEASUREMENT = 35U; + + /** Pin for push button A */ + constexpr uint8_t PIN_BUTTON_A = IoPin::NC; + + /** Pin for push button B */ + constexpr uint8_t PIN_BUTTON_B = IoPin::NC; + + /** Pin for push button C */ + constexpr uint8_t PIN_BUTTON_C = IoPin::NC; + + /** Pin for LED A */ + constexpr uint8_t PIN_LED_A = IoPin::NC; + + /** Pin for LED B */ + constexpr uint8_t PIN_LED_B = IoPin::NC; + + /** Pin for LED C */ + constexpr uint8_t PIN_LED_C = IoPin::NC; + +}; /* namespace Pin */ + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* PIN_H */ +/** @} */ diff --git a/lib/HALTargetV1/src/USBHostDriver.cpp b/lib/HALTargetV1/src/USBHostDriver.cpp index 42cfb034..7328d309 100644 --- a/lib/HALTargetV1/src/USBHostDriver.cpp +++ b/lib/HALTargetV1/src/USBHostDriver.cpp @@ -232,13 +232,13 @@ int USBHost::available() int USBHost::read() { /* Not implemented. */ - return 0; + return -1; } int USBHost::peek() { /* Not implemented. */ - return 0; + return -1; } size_t USBHost::readBytes(uint8_t* buffer, size_t length) diff --git a/lib/HALTargetV1/src/USBHostDriver.h b/lib/HALTargetV1/src/USBHostDriver.h index 9d5bc4c5..4422776f 100644 --- a/lib/HALTargetV1/src/USBHostDriver.h +++ b/lib/HALTargetV1/src/USBHostDriver.h @@ -28,7 +28,7 @@ * @brief Abstraction and Stream implementation of USB Host * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetV1 * * @{ */ @@ -215,7 +215,7 @@ class USBHost : public Stream /** * Get a Byte from the receiving buffer, if any. * @param[out] byte buffer to write the byte to. - * @returns If a received byte has been succesfully written to the buffer, returns true. Otherwise, false. + * @returns If a received byte has been successfully written to the buffer, returns true. Otherwise, false. */ bool getByte(uint8_t& byte); diff --git a/lib/HALTest/src/MqttClient.h b/lib/HALTest/src/MqttClient.h index fbc2f358..cc68e79a 100644 --- a/lib/HALTest/src/MqttClient.h +++ b/lib/HALTest/src/MqttClient.h @@ -94,7 +94,7 @@ class MqttClient : public IMqttClient * This method does not necessarily wait for the connection to be established, it just starts the connection * process. Check `isConnected()` for the current connection status. * - * @return If connection has been succesfully started, returns true. Otherwise, false. + * @return If connection has been successfully started, returns true. Otherwise, false. */ bool connect() final; diff --git a/lib/Service/src/SettingsHandler.h b/lib/Service/src/SettingsHandler.h index 0359a60b..6b7dd6c3 100644 --- a/lib/Service/src/SettingsHandler.h +++ b/lib/Service/src/SettingsHandler.h @@ -75,7 +75,7 @@ class SettingsHandler * * @param[in] filename Name of file to read. * - * @returns true if configuration succesfully loaded. Otherwise, false. + * @returns true if configuration successfully loaded. Otherwise, false. */ bool loadConfigurationFile(const String& filename); @@ -84,7 +84,7 @@ class SettingsHandler * * @param[in] filename Name of file to write. * - * @returns true if configuration succesfully saved. Otherwise, false. + * @returns true if configuration successfully saved. Otherwise, false. */ bool saveConfigurationFile(const String& filename);