跳转至

TinyMeasurement 配置

Info

这个头文件起到配置整个TinyMeasurement模块的作用,每个子模块都包含了此头文件。它定义了TinyMeasurement的配置选项和宏,允许用户根据需要进行自定义设置。通过修改这个头文件中的配置选项,用户可以轻松地调整TinyMeasurement的行为和功能,以满足特定的需求。文档更新速度较慢,可能会与实际代码不一致,请以代码为准。

概述

tiny_measurement_config.h 头文件包含 TinyMeasurement 中间件的所有配置宏。所有配置选项都使用 #ifndef 模式,这意味着您可以在包含此头文件之前定义宏来覆盖任何默认值。

配置类别

在线感知配置

这些宏控制在线感知操作的默认行为:

  • 采样频率:连续数据采集的默认速率(0.1 - 1000 Hz,实测上限:~200 Hz,主要受MQTT传输带宽限制)
  • MQTT传输:启用/禁用自动MQTT数据传输
  • 串口输出:启用/禁用通过printf和ESP_LOG的控制台输出
  • LCD显示:可选的LCD显示支持(需要编译标志)

离线感知配置

这些宏控制高频批量数据采集:

  • 采样频率:离线采集的更高默认速率(1 - 4000 Hz)
  • 采样时长:数据采集的持续时间(0.1 - 3600 秒)
  • 存储选项:启用/禁用SD卡和内存缓冲区存储
  • MQTT报告:采样完成后启用/禁用MQTT报告

自定义配置

要自定义任何默认值,请在包含头文件之前定义宏:

// 覆盖默认在线感知频率
#define TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_FREQ_HZ 10.0f

#include "tiny_measurement.h"
/**
 * @file tiny_measurement_config.h
 * @author SHUAIWEN CUI (SHUAIWEN001@e.ntu.edu.sg)
 * @brief The configuration file for the tiny_measurement middleware.
 * @version 1.0
 * @date 2025-12-17
 * @copyright Copyright (c) 2025
 *
 */

#pragma once

/* DEPENDENCIES */

// lower level dependencies
#include "tiny_ai.h"

#ifdef __cplusplus
extern "C"
{
#endif

/* ============================================================================
 * ONLINE SENSING CONFIGURATION MACROS
 * ============================================================================ */

/**
 * @brief Default sampling frequency for online sensing (Hz)
 * @note Valid range: 0.1 - 300 Hz
 * @note Default: 1.0 Hz
 */
#ifndef TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_FREQ_HZ
#define TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_FREQ_HZ 1.0f
#endif

/**
 * @brief Default MQTT transmission enable state for online sensing
 * @note true: Enable MQTT transmission
 * @note false: Disable MQTT transmission
 * @note Default: true
 */
#ifndef TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_ENABLE_MQTT
#define TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_ENABLE_MQTT true
#endif

/**
 * @brief Default serial output enable state for online sensing
 * @note true: Enable serial output (printf and ESP_LOG)
 * @note false: Disable serial output
 * @note Default: true
 */
#ifndef TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_ENABLE_SERIAL
#define TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_ENABLE_SERIAL true
#endif

/* ============================================================================
 * LCD DISPLAY FEATURE COMPILATION CONTROL
 * ============================================================================ */

/**
 * @brief Enable LCD display feature compilation
 * @note Define this macro to enable LCD display support in online sensing
 * @note If not defined, all LCD-related code will be excluded from compilation
 * @note Default: NOT DEFINED (LCD feature disabled by default)
 * @note To enable: Add -DTINY_MEASUREMENT_ENABLE_LCD to compiler flags
 */
#ifdef TINY_MEASUREMENT_ENABLE_LCD
/**
 * @brief Default LCD display enable state for online sensing
 * @note Only available when TINY_MEASUREMENT_ENABLE_LCD is defined
 * @note true: Enable LCD display output
 * @note false: Disable LCD display output
 * @note Default: false
 */
#ifndef TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_ENABLE_LCD
#define TINY_MEASUREMENT_ONLINE_SENSING_DEFAULT_ENABLE_LCD true
#endif
#endif /* TINY_MEASUREMENT_ENABLE_LCD */

/* ============================================================================
 * OFFLINE SENSING CONFIGURATION MACROS
 * ============================================================================ */

/**
 * @brief Default sampling frequency for offline sensing (Hz)
 * @note Valid range: 1 - 4000 Hz (higher than online sensing for offline data collection)
 * @note Default: 100.0 Hz (high frequency for offline sensing)
 */
#ifndef TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_FREQ_HZ
#define TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_FREQ_HZ 100.0f
#endif

/**
 * @brief Default sampling duration for offline sensing (seconds)
 * @note Valid range: 0.1 - 3600 seconds
 * @note Default: 10.0 seconds
 */
#ifndef TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_DURATION_SEC
#define TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_DURATION_SEC 10.0f
#endif

/**
 * @brief Default SD card storage enable state for offline sensing
 * @note true: Enable SD card storage
 * @note false: Disable SD card storage (only memory buffer)
 * @note Default: true
 */
#ifndef TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_ENABLE_SD
#define TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_ENABLE_SD true
#endif

/**
 * @brief Default memory buffer storage enable state for offline sensing
 * @note true: Enable memory buffer storage
 * @note false: Disable memory buffer storage (only SD card)
 * @note Default: true
 */
#ifndef TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_ENABLE_MEMORY
#define TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_ENABLE_MEMORY true
#endif

/**
 * @brief Default MQTT report enable state for offline sensing
 * @note true: Enable MQTT report after sampling
 * @note false: Disable MQTT report
 * @note Default: true
 */
#ifndef TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_ENABLE_MQTT_REPORT
#define TINY_MEASUREMENT_OFFLINE_SENSING_DEFAULT_ENABLE_MQTT_REPORT true
#endif

#ifdef __cplusplus
}
#endif