refactoring files
Dieser Commit ist enthalten in:
1 Ursprung
58dcdbdcb3
Commit
ab51ed746a
15 Dateien geändert
+945
-292
Keine Dateien entsprechen Ihrer Suche
+41
-13
@@ -1,33 +1,61 @@
|
||||
#ifndef LED_HPP
|
||||
#define LED_HPP
|
||||
/**
|
||||
* @file led.hpp
|
||||
* @brief Thread-safe hardware LED controller with dynamic profile configuration
|
||||
* @author OM Tom (OE3TKT)
|
||||
*
|
||||
* @license SPDX-License-Identifier: MIT
|
||||
* @copyright Copyright (c) 2026 OM Tom (OE3TKT)
|
||||
* For the full license terms, see the LICENSE file in the project root.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
class LedController {
|
||||
public:
|
||||
// Constructor allows passing the GPIO pin (defaults to 25 as requested)
|
||||
// Compound structure holding the full runtime timing behavior profiles
|
||||
struct BlinkProfile {
|
||||
uint32_t intervalMs; // Total period duration of one cycle
|
||||
uint32_t pulseWidthMs; // Active high execution duty duration (on-time)
|
||||
};
|
||||
|
||||
explicit LedController(gpio_num_t gpioPin = GPIO_NUM_25);
|
||||
virtual ~LedController();
|
||||
|
||||
// Destructor (virtual in case of inheritance)
|
||||
virtual ~LedController() = default;
|
||||
|
||||
// Disallow copying to prevent multiple instances controlling the same hardware pin
|
||||
// Disallow copying to prevent multiple runtime instances controlling the same hardware rail
|
||||
LedController(const LedController&) = delete;
|
||||
LedController& operator=(const LedController&) = delete;
|
||||
|
||||
// Spawns the FreeRTOS task pinned to a specific core
|
||||
/**
|
||||
* @brief Spawns the internal FreeRTOS worker thread pinned to a specific core.
|
||||
* @param priority Scheduler task priority level.
|
||||
* @param coreId Destination CPU core ID anchor (0 or 1).
|
||||
*/
|
||||
void startTask(uint32_t priority = 5, BaseType_t coreId = 1);
|
||||
|
||||
/**
|
||||
* @brief Thread-safe atomic updates to configuration parameters from any thread core.
|
||||
* @param profile Target values mapping the new timing configuration layers.
|
||||
*/
|
||||
void updateProfile(const BlinkProfile& profile);
|
||||
|
||||
private:
|
||||
const gpio_num_t m_gpioPin;
|
||||
static const char* TAG;
|
||||
|
||||
// Track the internal task handle to allow cross-thread signaling via notifications
|
||||
TaskHandle_t m_taskHandle = nullptr;
|
||||
|
||||
// Mutex lock handle safeguarding cross-core profile modifications
|
||||
SemaphoreHandle_t m_mutexHandle = nullptr;
|
||||
|
||||
// Internal state profile configuration storage cache
|
||||
BlinkProfile m_currentProfile;
|
||||
|
||||
// Static trampoline function required by the FreeRTOS scheduler
|
||||
static void taskTrampoline(void* pvParameters);
|
||||
|
||||
// Dynamic instance method where the actual blinking loop lives
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif // LED_HPP
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren