From 79ab9b0a30fbafc5356ed2aa9b240e7db4113dab Mon Sep 17 00:00:00 2001 From: greyes Date: Tue, 30 Dec 2025 15:51:30 +0100 Subject: [PATCH 01/16] Fixed several typos and bugfixes suggested by Copilot --- README.md | 2 +- lib/APPTurtle/src/MicroRosClient.h | 4 ++-- lib/APPTurtle/src/Subscriber.h | 4 ++-- lib/HALInterfaces/src/IMqttClient.h | 2 +- lib/HALInterfaces/src/IRobot.h | 2 +- lib/HALSim/src/MqttClient.h | 2 +- lib/HALSim/src/Robot.h | 2 +- lib/HALTargetCommon/src/MqttClient.cpp | 2 +- lib/HALTargetCommon/src/MqttClient.h | 4 ++-- lib/HALTargetCommon/src/Network.h | 2 +- lib/HALTargetCommon/src/Robot.h | 2 +- lib/HALTargetV1/src/ButtonDrv.cpp | 9 ++++++--- lib/HALTargetV1/src/ButtonDrv.h | 8 ++++---- lib/HALTargetV1/src/GPIO.cpp | 2 +- lib/HALTargetV1/src/GPIO.h | 2 +- lib/HALTargetV1/src/USBHostDriver.cpp | 4 ++-- lib/HALTargetV1/src/USBHostDriver.h | 2 +- lib/HALTest/src/MqttClient.h | 2 +- lib/Service/src/SettingsHandler.h | 4 ++-- 19 files changed, 32 insertions(+), 29 deletions(-) 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/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/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..e3684e40 100644 --- a/lib/HALTargetCommon/src/MqttClient.h +++ b/lib/HALTargetCommon/src/MqttClient.h @@ -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..397b1300 100644 --- a/lib/HALTargetCommon/src/Network.h +++ b/lib/HALTargetCommon/src/Network.h @@ -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..3ba7cd2b 100644 --- a/lib/HALTargetCommon/src/Robot.h +++ b/lib/HALTargetCommon/src/Robot.h @@ -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/ButtonDrv.cpp b/lib/HALTargetV1/src/ButtonDrv.cpp index fa8383d3..7593ae7e 100644 --- a/lib/HALTargetV1/src/ButtonDrv.cpp +++ b/lib/HALTargetV1/src/ButtonDrv.cpp @@ -81,7 +81,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 +94,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 +174,7 @@ void ButtonDrv::registerObserver(IButtonObserver& observer) { uint8_t buttonIndex = 0U; - m_observer = &observer; + m_observer = &observer; while (BUTTON_ID_CNT > buttonIndex) { @@ -223,6 +223,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) { diff --git a/lib/HALTargetV1/src/ButtonDrv.h b/lib/HALTargetV1/src/ButtonDrv.h index 98b68a85..fdf3efdf 100644 --- a/lib/HALTargetV1/src/ButtonDrv.h +++ b/lib/HALTargetV1/src/ButtonDrv.h @@ -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 @@ -189,7 +189,7 @@ class ButtonDrv 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; @@ -207,7 +207,7 @@ class ButtonDrv * 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/HALTargetV1/src/GPIO.cpp b/lib/HALTargetV1/src/GPIO.cpp index f1e0e95b..c67af72d 100644 --- a/lib/HALTargetV1/src/GPIO.cpp +++ b/lib/HALTargetV1/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 */ diff --git a/lib/HALTargetV1/src/GPIO.h b/lib/HALTargetV1/src/GPIO.h index 9f1abfdf..651f9db3 100644 --- a/lib/HALTargetV1/src/GPIO.h +++ b/lib/HALTargetV1/src/GPIO.h @@ -118,7 +118,7 @@ namespace GpioPins */ extern void init(); -}; // namespace GPIO +}; // namespace GpioPins /****************************************************************************** * Functions 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..ffa72df3 100644 --- a/lib/HALTargetV1/src/USBHostDriver.h +++ b/lib/HALTargetV1/src/USBHostDriver.h @@ -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); From d8e4cca3ab8cb8265e946d448a66e32f6fc1e4f0 Mon Sep 17 00:00:00 2001 From: greyes Date: Tue, 30 Dec 2025 20:58:56 +0100 Subject: [PATCH 02/16] Moved Button and ButtonDrv to Common HAL --- lib/{HALTargetV1 => HALTargetCommon}/src/Button.cpp | 0 lib/{HALTargetV1 => HALTargetCommon}/src/Button.h | 0 lib/{HALTargetV1 => HALTargetCommon}/src/ButtonDrv.cpp | 0 lib/{HALTargetV1 => HALTargetCommon}/src/ButtonDrv.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename lib/{HALTargetV1 => HALTargetCommon}/src/Button.cpp (100%) rename lib/{HALTargetV1 => HALTargetCommon}/src/Button.h (100%) rename lib/{HALTargetV1 => HALTargetCommon}/src/ButtonDrv.cpp (100%) rename lib/{HALTargetV1 => HALTargetCommon}/src/ButtonDrv.h (100%) diff --git a/lib/HALTargetV1/src/Button.cpp b/lib/HALTargetCommon/src/Button.cpp similarity index 100% rename from lib/HALTargetV1/src/Button.cpp rename to lib/HALTargetCommon/src/Button.cpp diff --git a/lib/HALTargetV1/src/Button.h b/lib/HALTargetCommon/src/Button.h similarity index 100% rename from lib/HALTargetV1/src/Button.h rename to lib/HALTargetCommon/src/Button.h diff --git a/lib/HALTargetV1/src/ButtonDrv.cpp b/lib/HALTargetCommon/src/ButtonDrv.cpp similarity index 100% rename from lib/HALTargetV1/src/ButtonDrv.cpp rename to lib/HALTargetCommon/src/ButtonDrv.cpp diff --git a/lib/HALTargetV1/src/ButtonDrv.h b/lib/HALTargetCommon/src/ButtonDrv.h similarity index 100% rename from lib/HALTargetV1/src/ButtonDrv.h rename to lib/HALTargetCommon/src/ButtonDrv.h From 73dfb994cdb2decea37a5dd1587a1c75dc07aa38 Mon Sep 17 00:00:00 2001 From: greyes Date: Tue, 30 Dec 2025 21:12:57 +0100 Subject: [PATCH 03/16] Moved GPIO to common and extracted pin definitions to specific V1 HAL --- .../src/GPIO.cpp | 0 .../src/GPIO.h | 25 +----- lib/HALTargetV1/src/Pin.h | 84 +++++++++++++++++++ 3 files changed, 85 insertions(+), 24 deletions(-) rename lib/{HALTargetV1 => HALTargetCommon}/src/GPIO.cpp (100%) rename lib/{HALTargetV1 => HALTargetCommon}/src/GPIO.h (81%) create mode 100644 lib/HALTargetV1/src/Pin.h diff --git a/lib/HALTargetV1/src/GPIO.cpp b/lib/HALTargetCommon/src/GPIO.cpp similarity index 100% rename from lib/HALTargetV1/src/GPIO.cpp rename to lib/HALTargetCommon/src/GPIO.cpp diff --git a/lib/HALTargetV1/src/GPIO.h b/lib/HALTargetCommon/src/GPIO.h similarity index 81% rename from lib/HALTargetV1/src/GPIO.h rename to lib/HALTargetCommon/src/GPIO.h index 651f9db3..7d09b1bf 100644 --- a/lib/HALTargetV1/src/GPIO.h +++ b/lib/HALTargetCommon/src/GPIO.h @@ -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. */ diff --git a/lib/HALTargetV1/src/Pin.h b/lib/HALTargetV1/src/Pin.h new file mode 100644 index 00000000..01db9ed8 --- /dev/null +++ b/lib/HALTargetV1/src/Pin.h @@ -0,0 +1,84 @@ +/* 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 HALTarget + * + * @{ + */ +#ifndef PIN_H +#define PIN_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ + +#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; + +}; // namespace Pin + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#endif /* PIN_H */ +/** @} */ From 25955eb01a4f358d4781d26b3f1e28e8b600e62a Mon Sep 17 00:00:00 2001 From: greyes Date: Tue, 30 Dec 2025 21:18:58 +0100 Subject: [PATCH 04/16] Added Pin and GPIO definitions for compatibility with V2 --- lib/HALTargetCommon/src/GPIO.cpp | 37 +++++++++++++++++++++++++++++++- lib/HALTargetCommon/src/GPIO.h | 30 ++++++++++++++++++++++++++ lib/HALTargetV1/src/Pin.h | 19 ++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) diff --git a/lib/HALTargetCommon/src/GPIO.cpp b/lib/HALTargetCommon/src/GPIO.cpp index c67af72d..4077400a 100644 --- a/lib/HALTargetCommon/src/GPIO.cpp +++ b/lib/HALTargetCommon/src/GPIO.cpp @@ -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/HALTargetCommon/src/GPIO.h b/lib/HALTargetCommon/src/GPIO.h index 7d09b1bf..9068029c 100644 --- a/lib/HALTargetCommon/src/GPIO.h +++ b/lib/HALTargetCommon/src/GPIO.h @@ -90,6 +90,36 @@ 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. */ diff --git a/lib/HALTargetV1/src/Pin.h b/lib/HALTargetV1/src/Pin.h index 01db9ed8..e8d28c9a 100644 --- a/lib/HALTargetV1/src/Pin.h +++ b/lib/HALTargetV1/src/Pin.h @@ -44,6 +44,7 @@ *****************************************************************************/ #include +#include /****************************************************************************** * Macros @@ -74,6 +75,24 @@ namespace Pin /** 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 /****************************************************************************** From db39efc6adde0094da0184545c30e61f4cbdf5ba Mon Sep 17 00:00:00 2001 From: greyes Date: Tue, 30 Dec 2025 21:32:00 +0100 Subject: [PATCH 05/16] Added Button definitions for ButtonDrv for compatibility with V2 --- lib/HALTargetCommon/src/ButtonDrv.cpp | 14 ++++++++------ lib/HALTargetCommon/src/ButtonDrv.h | 25 ++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/HALTargetCommon/src/ButtonDrv.cpp b/lib/HALTargetCommon/src/ButtonDrv.cpp index 7593ae7e..03188247 100644 --- a/lib/HALTargetCommon/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, }; /** @@ -71,6 +74,9 @@ const IoPin* ButtonDrv::BUTTON_PIN[BUTTON_ID_CNT] = { */ static ButtonId gButtonId[BUTTON_ID_CNT] = { BUTTON_ID_OK, + BUTTON_ID_A, + BUTTON_ID_B, + BUTTON_ID_C, }; /** Number of elements in the button id queue. */ @@ -271,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); @@ -324,8 +327,7 @@ 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; diff --git a/lib/HALTargetCommon/src/ButtonDrv.h b/lib/HALTargetCommon/src/ButtonDrv.h index fdf3efdf..6bf04b70 100644 --- a/lib/HALTargetCommon/src/ButtonDrv.h +++ b/lib/HALTargetCommon/src/ButtonDrv.h @@ -62,6 +62,9 @@ typedef enum { BUTTON_ID_OK = 0, /**< Button "ok" */ + 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. * @@ -171,7 +171,6 @@ class ButtonDrv bool enableWakeUpSources(); private: - /** * The digital input buttons. */ @@ -182,26 +181,26 @@ 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_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. From 28464051f3c8cc64202983037b46d4c273f64a75 Mon Sep 17 00:00:00 2001 From: greyes Date: Tue, 30 Dec 2025 21:50:31 +0100 Subject: [PATCH 06/16] The board is also a common component of the HAL --- lib/{HALTargetV1 => HALTargetCommon}/src/Board.cpp | 0 lib/{HALTargetV1 => HALTargetCommon}/src/Board.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename lib/{HALTargetV1 => HALTargetCommon}/src/Board.cpp (100%) rename lib/{HALTargetV1 => HALTargetCommon}/src/Board.h (100%) 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 100% rename from lib/HALTargetV1/src/Board.h rename to lib/HALTargetCommon/src/Board.h From bde941ac4ad93d642bdd1ce4939b00f384bf4fad Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 11:25:45 +0100 Subject: [PATCH 07/16] Use smallest include scope --- lib/HALTargetV1/src/Pin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/HALTargetV1/src/Pin.h b/lib/HALTargetV1/src/Pin.h index e8d28c9a..7a628204 100644 --- a/lib/HALTargetV1/src/Pin.h +++ b/lib/HALTargetV1/src/Pin.h @@ -43,7 +43,7 @@ * Includes *****************************************************************************/ -#include +#include #include /****************************************************************************** From a0edae1f261109777676db76d09bd6f1cea1d71b Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 11:26:00 +0100 Subject: [PATCH 08/16] Fixed namespace comments --- lib/HALTargetCommon/src/GPIO.h | 2 +- lib/HALTargetV1/src/Pin.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/HALTargetCommon/src/GPIO.h b/lib/HALTargetCommon/src/GPIO.h index 9068029c..26ff9966 100644 --- a/lib/HALTargetCommon/src/GPIO.h +++ b/lib/HALTargetCommon/src/GPIO.h @@ -125,7 +125,7 @@ namespace GpioPins */ extern void init(); -}; // namespace GpioPins +}; /* namespace GpioPins */ /****************************************************************************** * Functions diff --git a/lib/HALTargetV1/src/Pin.h b/lib/HALTargetV1/src/Pin.h index 7a628204..ba16e2fc 100644 --- a/lib/HALTargetV1/src/Pin.h +++ b/lib/HALTargetV1/src/Pin.h @@ -93,7 +93,7 @@ namespace Pin /** Pin for LED C */ constexpr uint8_t PIN_LED_C = IoPin::NC; -}; // namespace Pin +}; /* namespace Pin */ /****************************************************************************** * Functions From bcf8e7f70f260c3b3a64b71b6a7073925f970032 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 11:31:02 +0100 Subject: [PATCH 09/16] Fixed button reset ID. Replaces button OK --- lib/HALTargetCommon/src/Button.cpp | 2 +- lib/HALTargetCommon/src/ButtonDrv.cpp | 13 +++++++++++-- lib/HALTargetCommon/src/ButtonDrv.h | 10 +++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/HALTargetCommon/src/Button.cpp b/lib/HALTargetCommon/src/Button.cpp index 8bded0b0..80875962 100644 --- a/lib/HALTargetCommon/src/Button.cpp +++ b/lib/HALTargetCommon/src/Button.cpp @@ -62,7 +62,7 @@ bool Button::isPressed() { - return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_OK)); + return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_RESET)); } /****************************************************************************** diff --git a/lib/HALTargetCommon/src/ButtonDrv.cpp b/lib/HALTargetCommon/src/ButtonDrv.cpp index 03188247..bc45f125 100644 --- a/lib/HALTargetCommon/src/ButtonDrv.cpp +++ b/lib/HALTargetCommon/src/ButtonDrv.cpp @@ -73,7 +73,7 @@ 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, @@ -334,9 +334,18 @@ void ButtonDrv::buttonTaskMainLoop() 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/HALTargetCommon/src/ButtonDrv.h b/lib/HALTargetCommon/src/ButtonDrv.h index 6bf04b70..18e9d5eb 100644 --- a/lib/HALTargetCommon/src/ButtonDrv.h +++ b/lib/HALTargetCommon/src/ButtonDrv.h @@ -61,11 +61,11 @@ */ typedef enum { - BUTTON_ID_OK = 0, /**< Button "ok" */ - BUTTON_ID_A, /**< Button "A" */ - BUTTON_ID_B, /**< Button "B" */ - BUTTON_ID_C, /**< Button "C" */ - 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; From aea48f9dd72496a34072720076c6298ae7525089 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 12:40:40 +0100 Subject: [PATCH 10/16] Added drivers for LEDs A, B and C --- lib/HALTargetCommon/src/LedA.cpp | 89 ++++++++++++++++++++++++++++++++ lib/HALTargetCommon/src/LedA.h | 89 ++++++++++++++++++++++++++++++++ lib/HALTargetCommon/src/LedB.cpp | 89 ++++++++++++++++++++++++++++++++ lib/HALTargetCommon/src/LedB.h | 89 ++++++++++++++++++++++++++++++++ lib/HALTargetCommon/src/LedC.cpp | 89 ++++++++++++++++++++++++++++++++ lib/HALTargetCommon/src/LedC.h | 89 ++++++++++++++++++++++++++++++++ 6 files changed, 534 insertions(+) create mode 100644 lib/HALTargetCommon/src/LedA.cpp create mode 100644 lib/HALTargetCommon/src/LedA.h create mode 100644 lib/HALTargetCommon/src/LedB.cpp create mode 100644 lib/HALTargetCommon/src/LedB.h create mode 100644 lib/HALTargetCommon/src/LedC.cpp create mode 100644 lib/HALTargetCommon/src/LedC.h 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..34c335a0 --- /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 HALTarget + * + * @{ + */ + +#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..f62ccd82 --- /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 HALTarget + * + * @{ + */ + +#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/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..8f241653 --- /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 HALTarget + * + * @{ + */ + +#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 */ +/** @} */ From 06fa10e21dff93c1e6b2364986cce66152d8c840 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 12:43:35 +0100 Subject: [PATCH 11/16] Added drivers for Buttons A, B and C --- lib/HALTargetCommon/src/ButtonA.cpp | 82 ++++++++++++++++++++++++++ lib/HALTargetCommon/src/ButtonA.h | 90 +++++++++++++++++++++++++++++ lib/HALTargetCommon/src/ButtonB.cpp | 82 ++++++++++++++++++++++++++ lib/HALTargetCommon/src/ButtonB.h | 90 +++++++++++++++++++++++++++++ lib/HALTargetCommon/src/ButtonC.cpp | 82 ++++++++++++++++++++++++++ lib/HALTargetCommon/src/ButtonC.h | 90 +++++++++++++++++++++++++++++ 6 files changed, 516 insertions(+) create mode 100644 lib/HALTargetCommon/src/ButtonA.cpp create mode 100644 lib/HALTargetCommon/src/ButtonA.h create mode 100644 lib/HALTargetCommon/src/ButtonB.cpp create mode 100644 lib/HALTargetCommon/src/ButtonB.h create mode 100644 lib/HALTargetCommon/src/ButtonC.cpp create mode 100644 lib/HALTargetCommon/src/ButtonC.h diff --git a/lib/HALTargetCommon/src/ButtonA.cpp b/lib/HALTargetCommon/src/ButtonA.cpp new file mode 100644 index 00000000..cecab40d --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonA.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 "A" realization + * @author Gabryel Reyes + */ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "ButtonA.h" +#include "GPIO.h" +#include "ButtonDrv.h" + +/****************************************************************************** + * Compiler Switches + *****************************************************************************/ + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and classes + *****************************************************************************/ + +/****************************************************************************** + * Prototypes + *****************************************************************************/ + +/****************************************************************************** + * Local Variables + *****************************************************************************/ + +/****************************************************************************** + * Public Methods + *****************************************************************************/ + +bool ButtonA::isPressed() +{ + return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_A)); +} + +/****************************************************************************** + * Protected Methods + *****************************************************************************/ + +/****************************************************************************** + * Private Methods + *****************************************************************************/ + +/****************************************************************************** + * External Functions + *****************************************************************************/ + +/****************************************************************************** + * Local Functions + *****************************************************************************/ diff --git a/lib/HALTargetCommon/src/ButtonA.h b/lib/HALTargetCommon/src/ButtonA.h new file mode 100644 index 00000000..1b614f1b --- /dev/null +++ b/lib/HALTargetCommon/src/ButtonA.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 "A" realization + * @author Gabryel Reyes + * + * @addtogroup HALTarget + * + * @{ + */ + +#ifndef BUTTON_A_H +#define BUTTON_A_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot's button. */ +class ButtonA : public IButton +{ +public: + /** + * Constructs the button adapter. + */ + ButtonA() : IButton() + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonA() + { + } + + /** + * Is button pressed or released? + * + * @return If button is pressed, returns true otherwise false. + */ + bool isPressed() final; + +private: +}; + +/****************************************************************************** + * Functions + *****************************************************************************/ + +#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..9468c765 --- /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 HALTarget + * + * @{ + */ + +#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's button. */ +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..cc051248 --- /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 HALTarget + * + * @{ + */ + +#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's button. */ +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 */ +/** @} */ From f7dd8f58167591cbbbe106356b59fa3c47adcedc Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 12:50:23 +0100 Subject: [PATCH 12/16] Renamed button into button reset --- lib/HALSim/src/Board.h | 6 +++--- lib/HALSim/src/{Button.cpp => ButtonReset.cpp} | 6 +++--- lib/HALSim/src/{Button.h => ButtonReset.h} | 14 +++++++------- lib/HALTargetCommon/src/Board.h | 6 +++--- .../src/{Button.cpp => ButtonReset.cpp} | 6 +++--- .../src/{Button.h => ButtonReset.h} | 14 +++++++------- 6 files changed, 26 insertions(+), 26 deletions(-) rename lib/HALSim/src/{Button.cpp => ButtonReset.cpp} (97%) rename lib/HALSim/src/{Button.h => ButtonReset.h} (92%) rename lib/HALTargetCommon/src/{Button.cpp => ButtonReset.cpp} (97%) rename lib/HALTargetCommon/src/{Button.h => ButtonReset.h} (93%) 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/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/Button.h b/lib/HALSim/src/ButtonReset.h similarity index 92% rename from lib/HALSim/src/Button.h rename to lib/HALSim/src/ButtonReset.h index b610cc95..18efcea6 100644 --- a/lib/HALSim/src/Button.h +++ b/lib/HALSim/src/ButtonReset.h @@ -25,7 +25,7 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Button realization + * @brief Button "Reset" realization * @author Gabryel Reyes * * @addtogroup HALSim @@ -33,8 +33,8 @@ * @{ */ -#ifndef BUTTON_H -#define BUTTON_H +#ifndef BUTTON_RESET_H +#define BUTTON_RESET_H /****************************************************************************** * Compile Switches @@ -55,7 +55,7 @@ *****************************************************************************/ /** This class provides access to the simulation button. */ -class Button : public IButton +class ButtonReset : 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) + ButtonReset(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) { } /** * Destroys the button adapter. */ - virtual ~Button() + virtual ~ButtonReset() { } @@ -89,5 +89,5 @@ class Button : public IButton * Functions *****************************************************************************/ -#endif /* BUTTON_H */ +#endif /* BUTTON_RESET_H */ /** @} */ diff --git a/lib/HALTargetCommon/src/Board.h b/lib/HALTargetCommon/src/Board.h index 7370a211..f4f0175a 100644 --- a/lib/HALTargetCommon/src/Board.h +++ b/lib/HALTargetCommon/src/Board.h @@ -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/HALTargetCommon/src/Button.cpp b/lib/HALTargetCommon/src/ButtonReset.cpp similarity index 97% rename from lib/HALTargetCommon/src/Button.cpp rename to lib/HALTargetCommon/src/ButtonReset.cpp index 80875962..ea85f747 100644 --- a/lib/HALTargetCommon/src/Button.cpp +++ b/lib/HALTargetCommon/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" #include "GPIO.h" #include "ButtonDrv.h" @@ -60,7 +60,7 @@ * Public Methods *****************************************************************************/ -bool Button::isPressed() +bool ButtonReset::isPressed() { return (BUTTON_STATE_PRESSED == ButtonDrv::getInstance().getState(BUTTON_ID_RESET)); } diff --git a/lib/HALTargetCommon/src/Button.h b/lib/HALTargetCommon/src/ButtonReset.h similarity index 93% rename from lib/HALTargetCommon/src/Button.h rename to lib/HALTargetCommon/src/ButtonReset.h index ef0ebf82..f3ffd2bc 100644 --- a/lib/HALTargetCommon/src/Button.h +++ b/lib/HALTargetCommon/src/ButtonReset.h @@ -25,7 +25,7 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Button realization + * @brief Button "Reset" realization * @author Gabryel Reyes * * @addtogroup HALTarget @@ -33,8 +33,8 @@ * @{ */ -#ifndef BUTTON_H -#define BUTTON_H +#ifndef BUTTON_RESET_H +#define BUTTON_RESET_H /****************************************************************************** * Compile Switches @@ -55,20 +55,20 @@ *****************************************************************************/ /** This class provides access to the robot's button. */ -class Button : public IButton +class ButtonReset : public IButton { public: /** * Constructs the button adapter. */ - Button() : IButton() + ButtonReset() : IButton() { } /** * Destroys the button adapter. */ - virtual ~Button() + virtual ~ButtonReset() { } @@ -86,5 +86,5 @@ class Button : public IButton * Functions *****************************************************************************/ -#endif /* BUTTON_H */ +#endif /* BUTTON_RESET_H */ /** @} */ From 32ace33d6215c2182e5028733cd3b885254aba31 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 13:07:54 +0100 Subject: [PATCH 13/16] Added Sim drivers for buttons A,B and C --- lib/HALSim/src/ButtonA.cpp | 80 +++++++++++++++++++++ lib/HALSim/src/ButtonA.h | 93 ++++++++++++++++++++++++ lib/HALSim/src/ButtonB.cpp | 80 +++++++++++++++++++++ lib/HALSim/src/ButtonB.h | 93 ++++++++++++++++++++++++ lib/HALSim/src/ButtonC.cpp | 80 +++++++++++++++++++++ lib/HALSim/src/ButtonC.h | 93 ++++++++++++++++++++++++ lib/HALSim/src/Keyboard.h | 140 +++++++++++++++++++++++++++++++++++-- 7 files changed, 655 insertions(+), 4 deletions(-) create mode 100644 lib/HALSim/src/ButtonA.cpp create mode 100644 lib/HALSim/src/ButtonA.h create mode 100644 lib/HALSim/src/ButtonB.cpp create mode 100644 lib/HALSim/src/ButtonB.h create mode 100644 lib/HALSim/src/ButtonC.cpp create mode 100644 lib/HALSim/src/ButtonC.h 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/ButtonA.h b/lib/HALSim/src/ButtonA.h new file mode 100644 index 00000000..f01e56fa --- /dev/null +++ b/lib/HALSim/src/ButtonA.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 "A" realization + * @author Gabryel Reyes + * + * @addtogroup HALTarget + * + * @{ + */ + +#ifndef BUTTON_A_H +#define BUTTON_A_H + +/****************************************************************************** + * Compile Switches + *****************************************************************************/ + +/****************************************************************************** + * Includes + *****************************************************************************/ +#include "IButton.h" +#include "Keyboard.h" + +/****************************************************************************** + * Macros + *****************************************************************************/ + +/****************************************************************************** + * Types and Classes + *****************************************************************************/ + +/** This class provides access to the robot's button. */ +class ButtonA : public IButton +{ +public: + /** + * Constructs the button adapter. + * + * @param[in] keyboard The keyboard to use for button simulation. + */ + ButtonA(Keyboard& keyboard) : IButton(), m_keyboard(keyboard) + { + } + + /** + * Destroys the button adapter. + */ + virtual ~ButtonA() + { + } + + /** + * 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_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..6b0839dd --- /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 HALTarget + * + * @{ + */ + +#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's button. */ +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..1f3ed9fc --- /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 HALTarget + * + * @{ + */ + +#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's button. */ +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/Keyboard.h b/lib/HALSim/src/Keyboard.h index d1f4a0ef..b00c7b30 100644 --- a/lib/HALSim/src/Keyboard.h +++ b/lib/HALSim/src/Keyboard.h @@ -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,13 +131,145 @@ 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 key code of the lower case s character, which simulates the button "A". */ + static const char KEY_CODE_A_LOWER_CASE = 'a'; + + /** The key code of the upper case S character, which simulates the button "A". */ + static const char KEY_CODE_A_UPPER_CASE = 'A'; + + /** The key code of the lower case s character, which simulates the button "B". */ + static const char KEY_CODE_B_LOWER_CASE = 'b'; + + /** The key code of the upper case S character, which simulates the button "B". */ + static const char KEY_CODE_B_UPPER_CASE = 'B'; + + /** The key code of the lower case s character, which simulates the button "C". */ + static const char KEY_CODE_C_LOWER_CASE = 'c'; + + /** The key code of the upper case S character, which simulates the button "C". */ + static const char KEY_CODE_C_UPPER_CASE = 'C'; + /** The maximum number of keys pressed simultaniously, that the simulation can process. */ static const uint8_t MAX_KEY_NUMBER = 7; From 7eb682ca41088fdcf592b1740084a896b588e5b0 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 13:10:02 +0100 Subject: [PATCH 14/16] Added Sim drivers for LEDs A,B and C --- lib/HALSim/src/LedA.cpp | 81 +++++++++++++++++++++++++++++++++++++ lib/HALSim/src/LedA.h | 89 +++++++++++++++++++++++++++++++++++++++++ lib/HALSim/src/LedB.cpp | 81 +++++++++++++++++++++++++++++++++++++ lib/HALSim/src/LedB.h | 89 +++++++++++++++++++++++++++++++++++++++++ lib/HALSim/src/LedC.cpp | 81 +++++++++++++++++++++++++++++++++++++ lib/HALSim/src/LedC.h | 89 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 510 insertions(+) create mode 100644 lib/HALSim/src/LedA.cpp create mode 100644 lib/HALSim/src/LedA.h create mode 100644 lib/HALSim/src/LedB.cpp create mode 100644 lib/HALSim/src/LedB.h create mode 100644 lib/HALSim/src/LedC.cpp create mode 100644 lib/HALSim/src/LedC.h 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..34c335a0 --- /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 HALTarget + * + * @{ + */ + +#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..f62ccd82 --- /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 HALTarget + * + * @{ + */ + +#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..8f241653 --- /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 HALTarget + * + * @{ + */ + +#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 */ +/** @} */ From 998c2fcdc94b23fd1940417233985cab064f29b8 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 13:17:35 +0100 Subject: [PATCH 15/16] Fixed Doxygen groups --- lib/HALSim/src/ButtonA.h | 2 +- lib/HALSim/src/ButtonB.h | 2 +- lib/HALSim/src/ButtonC.h | 2 +- lib/HALSim/src/LedA.h | 2 +- lib/HALSim/src/LedB.h | 2 +- lib/HALSim/src/LedC.h | 2 +- lib/HALTargetCommon/src/Battery.h | 5 +++-- lib/HALTargetCommon/src/Board.h | 2 +- lib/HALTargetCommon/src/ButtonA.h | 2 +- lib/HALTargetCommon/src/ButtonB.h | 2 +- lib/HALTargetCommon/src/ButtonC.h | 2 +- lib/HALTargetCommon/src/ButtonDrv.h | 2 +- lib/HALTargetCommon/src/ButtonReset.h | 2 +- lib/HALTargetCommon/src/FileHandler.h | 2 +- lib/HALTargetCommon/src/GPIO.h | 2 +- lib/HALTargetCommon/src/Io.hpp | 2 +- lib/HALTargetCommon/src/LedA.h | 2 +- lib/HALTargetCommon/src/LedB.h | 2 +- lib/HALTargetCommon/src/LedBlue.h | 2 +- lib/HALTargetCommon/src/LedC.h | 2 +- lib/HALTargetCommon/src/LedGreen.h | 2 +- lib/HALTargetCommon/src/LedRed.h | 2 +- lib/HALTargetCommon/src/MqttClient.h | 2 +- lib/HALTargetCommon/src/Network.h | 2 +- lib/HALTargetCommon/src/Robot.h | 2 +- lib/HALTargetV1/src/Pin.h | 2 +- lib/HALTargetV1/src/USBHostDriver.h | 2 +- 27 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/HALSim/src/ButtonA.h b/lib/HALSim/src/ButtonA.h index f01e56fa..fdddca4c 100644 --- a/lib/HALSim/src/ButtonA.h +++ b/lib/HALSim/src/ButtonA.h @@ -28,7 +28,7 @@ * @brief Button "A" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALSim * * @{ */ diff --git a/lib/HALSim/src/ButtonB.h b/lib/HALSim/src/ButtonB.h index 6b0839dd..65bd3839 100644 --- a/lib/HALSim/src/ButtonB.h +++ b/lib/HALSim/src/ButtonB.h @@ -28,7 +28,7 @@ * @brief Button "B" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALSim * * @{ */ diff --git a/lib/HALSim/src/ButtonC.h b/lib/HALSim/src/ButtonC.h index 1f3ed9fc..af720d21 100644 --- a/lib/HALSim/src/ButtonC.h +++ b/lib/HALSim/src/ButtonC.h @@ -28,7 +28,7 @@ * @brief Button "C" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALSim * * @{ */ diff --git a/lib/HALSim/src/LedA.h b/lib/HALSim/src/LedA.h index 34c335a0..01f9ff2c 100644 --- a/lib/HALSim/src/LedA.h +++ b/lib/HALSim/src/LedA.h @@ -28,7 +28,7 @@ * @brief "A" LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALSim * * @{ */ diff --git a/lib/HALSim/src/LedB.h b/lib/HALSim/src/LedB.h index f62ccd82..c5a6225f 100644 --- a/lib/HALSim/src/LedB.h +++ b/lib/HALSim/src/LedB.h @@ -28,7 +28,7 @@ * @brief "B" LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALSim * * @{ */ diff --git a/lib/HALSim/src/LedC.h b/lib/HALSim/src/LedC.h index 8f241653..31dfa76f 100644 --- a/lib/HALSim/src/LedC.h +++ b/lib/HALSim/src/LedC.h @@ -28,7 +28,7 @@ * @brief "C" LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALSim * * @{ */ 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/HALTargetCommon/src/Board.h b/lib/HALTargetCommon/src/Board.h index f4f0175a..38ee66e8 100644 --- a/lib/HALTargetCommon/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 * * @{ */ diff --git a/lib/HALTargetCommon/src/ButtonA.h b/lib/HALTargetCommon/src/ButtonA.h index 1b614f1b..c2549983 100644 --- a/lib/HALTargetCommon/src/ButtonA.h +++ b/lib/HALTargetCommon/src/ButtonA.h @@ -28,7 +28,7 @@ * @brief Button "A" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/ButtonB.h b/lib/HALTargetCommon/src/ButtonB.h index 9468c765..e012ae29 100644 --- a/lib/HALTargetCommon/src/ButtonB.h +++ b/lib/HALTargetCommon/src/ButtonB.h @@ -28,7 +28,7 @@ * @brief Button "B" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/ButtonC.h b/lib/HALTargetCommon/src/ButtonC.h index cc051248..65e91648 100644 --- a/lib/HALTargetCommon/src/ButtonC.h +++ b/lib/HALTargetCommon/src/ButtonC.h @@ -28,7 +28,7 @@ * @brief Button "C" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/ButtonDrv.h b/lib/HALTargetCommon/src/ButtonDrv.h index 18e9d5eb..1386c5a2 100644 --- a/lib/HALTargetCommon/src/ButtonDrv.h +++ b/lib/HALTargetCommon/src/ButtonDrv.h @@ -28,7 +28,7 @@ * @brief Button driver * @author Andreas Merkle * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/ButtonReset.h b/lib/HALTargetCommon/src/ButtonReset.h index f3ffd2bc..ed8291ca 100644 --- a/lib/HALTargetCommon/src/ButtonReset.h +++ b/lib/HALTargetCommon/src/ButtonReset.h @@ -28,7 +28,7 @@ * @brief Button "Reset" realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ 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/HALTargetCommon/src/GPIO.h b/lib/HALTargetCommon/src/GPIO.h index 26ff9966..da0fa10c 100644 --- a/lib/HALTargetCommon/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 * * @{ */ 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.h b/lib/HALTargetCommon/src/LedA.h index 34c335a0..c23ecd85 100644 --- a/lib/HALTargetCommon/src/LedA.h +++ b/lib/HALTargetCommon/src/LedA.h @@ -28,7 +28,7 @@ * @brief "A" LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ diff --git a/lib/HALTargetCommon/src/LedB.h b/lib/HALTargetCommon/src/LedB.h index f62ccd82..2e308a33 100644 --- a/lib/HALTargetCommon/src/LedB.h +++ b/lib/HALTargetCommon/src/LedB.h @@ -28,7 +28,7 @@ * @brief "B" LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ 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.h b/lib/HALTargetCommon/src/LedC.h index 8f241653..8abeea41 100644 --- a/lib/HALTargetCommon/src/LedC.h +++ b/lib/HALTargetCommon/src/LedC.h @@ -28,7 +28,7 @@ * @brief "C" LED realization * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetCommon * * @{ */ 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.h b/lib/HALTargetCommon/src/MqttClient.h index e3684e40..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 * * @{ */ diff --git a/lib/HALTargetCommon/src/Network.h b/lib/HALTargetCommon/src/Network.h index 397b1300..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 * * @{ */ diff --git a/lib/HALTargetCommon/src/Robot.h b/lib/HALTargetCommon/src/Robot.h index 3ba7cd2b..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 * * @{ */ diff --git a/lib/HALTargetV1/src/Pin.h b/lib/HALTargetV1/src/Pin.h index ba16e2fc..567f0244 100644 --- a/lib/HALTargetV1/src/Pin.h +++ b/lib/HALTargetV1/src/Pin.h @@ -28,7 +28,7 @@ * @brief Pin definition for the target board. * @author Gabryel Reyes * - * @addtogroup HALTarget + * @addtogroup HALTargetV1 * * @{ */ diff --git a/lib/HALTargetV1/src/USBHostDriver.h b/lib/HALTargetV1/src/USBHostDriver.h index ffa72df3..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 * * @{ */ From 8f32da08578672b9cce2fd5d4e7ab4d8a93057d6 Mon Sep 17 00:00:00 2001 From: greyes Date: Wed, 31 Dec 2025 16:47:12 +0100 Subject: [PATCH 16/16] Fixed several comments after copy errors --- lib/HALSim/src/ButtonA.h | 2 +- lib/HALSim/src/ButtonB.h | 2 +- lib/HALSim/src/ButtonC.h | 2 +- lib/HALSim/src/ButtonReset.h | 2 +- lib/HALSim/src/Keyboard.h | 16 ++++++++-------- lib/HALTargetCommon/src/ButtonA.h | 2 +- lib/HALTargetCommon/src/ButtonB.h | 2 +- lib/HALTargetCommon/src/ButtonC.h | 2 +- lib/HALTargetCommon/src/ButtonReset.h | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/HALSim/src/ButtonA.h b/lib/HALSim/src/ButtonA.h index fdddca4c..830e9bd4 100644 --- a/lib/HALSim/src/ButtonA.h +++ b/lib/HALSim/src/ButtonA.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "A". */ class ButtonA : public IButton { public: diff --git a/lib/HALSim/src/ButtonB.h b/lib/HALSim/src/ButtonB.h index 65bd3839..b0747d60 100644 --- a/lib/HALSim/src/ButtonB.h +++ b/lib/HALSim/src/ButtonB.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "B". */ class ButtonB : public IButton { public: diff --git a/lib/HALSim/src/ButtonC.h b/lib/HALSim/src/ButtonC.h index af720d21..825531c7 100644 --- a/lib/HALSim/src/ButtonC.h +++ b/lib/HALSim/src/ButtonC.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "C". */ class ButtonC : public IButton { public: diff --git a/lib/HALSim/src/ButtonReset.h b/lib/HALSim/src/ButtonReset.h index 18efcea6..c086c4c2 100644 --- a/lib/HALSim/src/ButtonReset.h +++ b/lib/HALSim/src/ButtonReset.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the simulation button. */ +/** This class provides access to the robot button "Reset". */ class ButtonReset : public IButton { public: diff --git a/lib/HALSim/src/Keyboard.h b/lib/HALSim/src/Keyboard.h index b00c7b30..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) { @@ -252,25 +252,25 @@ class Keyboard /** The key code of the upper case S character, which simulates the button "Reset". */ static const char KEY_CODE_S_UPPER_CASE = 'S'; - /** The key code of the lower case s character, which simulates the button "A". */ + /** 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 S character, which simulates the button "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 s character, which simulates the button "B". */ + /** 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 S character, which simulates the button "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 s character, which simulates the button "C". */ + /** 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 S character, which simulates the button "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 simultaniously, that the simulation can process. */ + /** 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/HALTargetCommon/src/ButtonA.h b/lib/HALTargetCommon/src/ButtonA.h index c2549983..86e3f40c 100644 --- a/lib/HALTargetCommon/src/ButtonA.h +++ b/lib/HALTargetCommon/src/ButtonA.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "A". */ class ButtonA : public IButton { public: diff --git a/lib/HALTargetCommon/src/ButtonB.h b/lib/HALTargetCommon/src/ButtonB.h index e012ae29..82842092 100644 --- a/lib/HALTargetCommon/src/ButtonB.h +++ b/lib/HALTargetCommon/src/ButtonB.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "B". */ class ButtonB : public IButton { public: diff --git a/lib/HALTargetCommon/src/ButtonC.h b/lib/HALTargetCommon/src/ButtonC.h index 65e91648..d2575dca 100644 --- a/lib/HALTargetCommon/src/ButtonC.h +++ b/lib/HALTargetCommon/src/ButtonC.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "C". */ class ButtonC : public IButton { public: diff --git a/lib/HALTargetCommon/src/ButtonReset.h b/lib/HALTargetCommon/src/ButtonReset.h index ed8291ca..ae926150 100644 --- a/lib/HALTargetCommon/src/ButtonReset.h +++ b/lib/HALTargetCommon/src/ButtonReset.h @@ -54,7 +54,7 @@ * Types and Classes *****************************************************************************/ -/** This class provides access to the robot's button. */ +/** This class provides access to the robot button "Reset". */ class ButtonReset : public IButton { public: