From 4ea615dd9751658d9775ee2239f328209f61284c Mon Sep 17 00:00:00 2001 From: jhon-p16 Date: Mon, 22 Aug 2022 10:19:19 -0500 Subject: [PATCH] docs: clang format based on LLVM --- src/BslibEnergyMeter.cpp | 249 ++++++++++++++++++--------------------- src/BslibEnergyMeter.h | 71 ++++++----- 2 files changed, 146 insertions(+), 174 deletions(-) diff --git a/src/BslibEnergyMeter.cpp b/src/BslibEnergyMeter.cpp index b3fed43..55a139d 100644 --- a/src/BslibEnergyMeter.cpp +++ b/src/BslibEnergyMeter.cpp @@ -4,238 +4,213 @@ * @brief Biblioteca medidor de energia, permite medir voltaje, y corriente con gran precisión. * @version 2.2.1 * @date 2021-04-16 - * + * * @copyright DataAnalitic (c) {2021} - * + * */ #include "BslibEnergyMeter.h" - int currentReference; - int calibrationCurrent; +int currentReference; +int calibrationCurrent; - int currentADC; - int currentRefADC; - float currentDAC; - float current; +int currentADC; +int currentRefADC; +float currentDAC; +float current; - int voltageADC; - float voltageDAC; - float voltage; +int voltageADC; +float voltageDAC; +float voltage; /** * @brief Configuracion de los pines del sensor de corriente - * + * * @param _inPinCurrent pin analógico Vout del sensor de voltaje * @param _inPinCurrentRef pin analógico Vref del sensor * @param _factorCurrent factor de sensiblidad del sensor */ -void BslibEnergyMeter::SetSensorCurrent(int _inPinCurrent, int _inPinCurrentRef, float _factorCurrent) -{ - inPinCurrent = _inPinCurrent; - inPinCurrentRef = _inPinCurrentRef; - factorCurrent = _factorCurrent; +void BslibEnergyMeter::SetSensorCurrent(int _inPinCurrent, int _inPinCurrentRef, float _factorCurrent) { + inPinCurrent = _inPinCurrent; + inPinCurrentRef = _inPinCurrentRef; + factorCurrent = _factorCurrent; } /** * @brief Configuracion de los pines del sensor de voltaje - * + * * @param _inPinVoltage pin analógico de Vout de sensor de voltaje * @param _factorVoltage factor de sensiblidad del sensor * @param _offsetVoltage compensacion para obtener voltaje real */ -void BslibEnergyMeter::SetSensorVoltage(int _inPinVoltage, float _factorVoltage, float _offsetVoltage = 0) -{ - inPinVoltage = _inPinVoltage; - factorVoltage = _factorVoltage; - offsetVoltage = _offsetVoltage; +void BslibEnergyMeter::SetSensorVoltage(int _inPinVoltage, float _factorVoltage, float _offsetVoltage = 0) { + inPinVoltage = _inPinVoltage; + factorVoltage = _factorVoltage; + offsetVoltage = _offsetVoltage; } /** * @brief Configuracion de los pines del sensor de voltaje - * + * * @param _inPinVoltage pin analógico de sensor de voltaje * @param _factorVoltage factor de sensiblidad del sensor */ -void BslibEnergyMeter::SetSensorVoltage(int _inPinVoltage, float _factorVoltage) -{ - inPinVoltage = _inPinVoltage; - factorVoltage = _factorVoltage; +void BslibEnergyMeter::SetSensorVoltage(int _inPinVoltage, float _factorVoltage) { + inPinVoltage = _inPinVoltage; + factorVoltage = _factorVoltage; } /** * @brief Se usar después de la función AutoCalibrationCurrent para configurar el valor de referencia de corriente debido a que no siempre la corriente es cero. - * - * @param _currentReference + * + * @param _currentReference */ -void BslibEnergyMeter::SetCurrentReference(int _currentReference) -{ - currentReference = _currentReference; +void BslibEnergyMeter::SetCurrentReference(int _currentReference) { + currentReference = _currentReference; } /** * @brief Configura el valor de referencia analógica para el MCU - * - * @param _analogReference + * + * @param _analogReference */ -void BslibEnergyMeter::SetAnalogReference(float _analogReference) -{ - analogReference = _analogReference; +void BslibEnergyMeter::SetAnalogReference(float _analogReference) { + analogReference = _analogReference; } -void BslibEnergyMeter::SetFilterSamples(int _numberOfSamples) -{ - numberOfSamples = _numberOfSamples; +void BslibEnergyMeter::SetFilterSamples(int _numberOfSamples) { + numberOfSamples = _numberOfSamples; } /** * @brief Filtro suave (promedio) de lecturas ADC - * + * * @param pinADC pin analógico al cual leer - * @return int + * @return int */ -int BslibEnergyMeter::FilterValueADC(int pinADC) -{ - unsigned long valueADC = 0; - int filteredValueADC = 0; - for (int i = 0; i < numberOfSamples; i++) - { - valueADC += analogRead(pinADC); - } - filteredValueADC = valueADC / numberOfSamples; - return filteredValueADC; +int BslibEnergyMeter::FilterValueADC(int pinADC) { + unsigned long valueADC = 0; + int filteredValueADC = 0; + for (int i = 0; i < numberOfSamples; i++) { + valueADC += analogRead(pinADC); + } + filteredValueADC = valueADC / numberOfSamples; + return filteredValueADC; } /** * @brief Calcula el valor en voltaje de la lectura ADC del MCU - * - * @param digitalValue - * @return float + * + * @param digitalValue + * @return float */ -float BslibEnergyMeter::SoftwareDAC (int digitalValue) -{ - float convertValueDCA = float(digitalValue) / ADC_SCALE * analogReference; - return convertValueDCA; +float BslibEnergyMeter::SoftwareDAC(int digitalValue) { + float convertValueDCA = float(digitalValue) / ADC_SCALE * analogReference; + return convertValueDCA; } /** * @brief Calibrar automaticamente el sensor de corriente con Vref. Usar esta función cuando la corriente sea cero. - * - * @return int + * + * @return int */ -int BslibEnergyMeter::AutoCalibrationCurrent(int lastVRef) -{ +int BslibEnergyMeter::AutoCalibrationCurrent(int lastVRef) { - float vRef = FilterValueADC(inPinCurrentRef); - float vOut = FilterValueADC(inPinCurrent); + float vRef = FilterValueADC(inPinCurrentRef); + float vOut = FilterValueADC(inPinCurrent); - if (lastVRef == vRef) - { - calibrationCurrent = vRef; - } - else - { - calibrationCurrent = vRef; - } - // algunos sensores tienen un offset (compensacion) cuando Vref