Add single channel mode feature.
The addition of a single-channel mode implied further modularisation of the component. This commit has broken the component down into the following modules to avoid a huge single source file and to make unit testing easier. The modules: - Separation of public and private code - *types and *defs - public relay_chn API - *adapter - *output - *run_info - *core - *ctl (control) - *tilt Closes #957.
This commit is contained in:
84
private_include/relay_chn_run_info.h
Normal file
84
private_include/relay_chn_run_info.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Kozmotronik Tech
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This is for managing the run information of relay channels.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "relay_chn_priv_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize relay channel run information.
|
||||
*
|
||||
* Initializes the run information for all relay channels with default values.
|
||||
*/
|
||||
void relay_chn_run_info_init(void);
|
||||
|
||||
#if RELAY_CHN_COUNT > 1
|
||||
/**
|
||||
* @brief Get run information object for a specific relay channel.
|
||||
*
|
||||
* @param[in] chn_id Channel ID to get run information for.
|
||||
* @return Pointer to run information structure, or NULL if channel ID is invalid.
|
||||
*/
|
||||
relay_chn_run_info_t *relay_chn_run_info_get(uint8_t chn_id);
|
||||
|
||||
/**
|
||||
* @brief Get run information objects for all relay channels.
|
||||
*
|
||||
* @return Pointer to array of run information structures.
|
||||
*/
|
||||
relay_chn_run_info_t *relay_chn_run_info_get_all(void);
|
||||
#else
|
||||
/**
|
||||
* @brief Get run information object for the single relay channel.
|
||||
*
|
||||
* @return Pointer to run information structure.
|
||||
*/
|
||||
relay_chn_run_info_t *relay_chn_run_info_get(void);
|
||||
#endif // RELAY_CHN_COUNT > 1
|
||||
|
||||
/**
|
||||
* @brief Get the last run command for a relay channel.
|
||||
*
|
||||
* @param[in] run_info Pointer to run information structure.
|
||||
*
|
||||
* @return Last command that was executed, or RELAY_CHN_CMD_NONE if invalid.
|
||||
*/
|
||||
relay_chn_cmd_t relay_chn_run_info_get_last_run_cmd(relay_chn_run_info_t *run_info);
|
||||
|
||||
/**
|
||||
* @brief Set the last run command for a relay channel.
|
||||
*
|
||||
* @param[in] run_info Pointer to run information structure.
|
||||
* @param[in] cmd Command to set as last run command.
|
||||
*/
|
||||
void relay_chn_run_info_set_last_run_cmd(relay_chn_run_info_t *run_info, relay_chn_cmd_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Get the timestamp of the last run command.
|
||||
*
|
||||
* @param[in] run_info Pointer to run information structure.
|
||||
*
|
||||
* @return Timestamp in milliseconds of last command, or 0 if invalid.
|
||||
*/
|
||||
uint32_t relay_chn_run_info_get_last_run_cmd_time_ms(relay_chn_run_info_t *run_info);
|
||||
|
||||
/**
|
||||
* @brief Set the timestamp for the last run command.
|
||||
*
|
||||
* @param[in] run_info Pointer to run information structure.
|
||||
* @param[in] time_ms Timestamp in milliseconds to set.
|
||||
*/
|
||||
void relay_chn_run_info_set_last_run_cmd_time_ms(relay_chn_run_info_t *run_info, uint32_t time_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user