Envorimental Monitoring
Loading...
Searching...
No Matches
main.h File Reference

: Header for main.c file. This file contains the common defines of the application. More...

#include "stm32f4xx_hal.h"
#include "bmp180.h"
#include "bh1750.h"
#include "aht20.h"
#include "ring_buffer.h"
#include "filter.h"
#include <math.h>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  Sensor_Stats_t

Macros

#define LED_GREEN_Pin   GPIO_PIN_12
#define LED_GREEN_GPIO_Port   GPIOD

Functions

void Error_Handler (void)
 This function is executed in case of error occurrence.
void calculate_statistics (buf_handle_t *p_handle, Sensor_Stats_t *stats)
 Computes min, max, median, and standard deviation from a ring buffer.

Detailed Description

: Header for main.c file. This file contains the common defines of the application.

Attention

Copyright (c) 2026 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Function Documentation

◆ calculate_statistics()

void calculate_statistics ( buf_handle_t * p_handle,
Sensor_Stats_t * stats )

Computes min, max, median, and standard deviation from a ring buffer.

Parameters
[in]p_handlePointer to the ring buffer handle to analyse.
[out]statsPointer to the Sensor_Stats_t structure to fill.

Computes min, max, median, and standard deviation from a ring buffer.

Iterates over all valid samples in p_handle to find the minimum, maximum and arithmetic mean. A second pass computes the population standard deviation. The buffer is then copied to a temporary array, sorted with bubble_sort(), and the median is extracted.

Note
The function returns immediately if the buffer is empty.
Parameters
[in]p_handlePointer to the ring buffer handle containing the samples.
[out]statsPointer to the Sensor_Stats_t structure to populate.

◆ Error_Handler()

void Error_Handler ( void )

This function is executed in case of error occurrence.

Return values
None