Skip to content
Snippets Groups Projects
Commit cb16c934 authored by Manon MALIQUE's avatar Manon MALIQUE
Browse files

Adding comments

parent 3bb85ae5
Branches
No related tags found
No related merge requests found
//Manon
//BLE device
/*
#include <advertisedDeviceCallbacks.h>
//Display the BLE Device data
void advertisedDeviceCallbacks::onResult(BLEAdvertisedDevice device) {
if (device.getName() == "TP358 (5551)") {
log_debug(F("\nReference temperature : "));
......
//Manon
//BLE device
/*
#include <Arduino.h>
#include <BLEDevice.h>
......
......@@ -112,7 +112,7 @@ bool checkCLEARswitch( uint8_t sw_pin ) {
return _res;
}
//Manon
// --- CALIBRATION switch management ------------------------------------------------
/* check incr switch and decr switch for CALIBRATION procedure
......@@ -131,7 +131,7 @@ bool checkCALIBRATIONswitch(uint8_t decr_sw_pin, uint8_t incr_sw_pin) {
pinMode( decr_sw_pin, INPUT );
pinMode( incr_sw_pin, INPUT );
log_debug(F("\n[CALIBRATION] Press + AND - switch for 5s to activate TEST MANON :) ...")); log_flush();
log_debug(F("\n[CALIBRATION] Press + AND - switch for 5s to activate ...")); log_flush();
delay(1000);
log_debug(F("\n[CALIBRATION] check for incr_switch and decr_switch activation ...")); log_flush();
delay(250);
......@@ -162,11 +162,8 @@ bool checkCALIBRATIONswitch(uint8_t decr_sw_pin, uint8_t incr_sw_pin) {
delay(250);
}
if (_res==true){
log_debug(F("\n[neocampus_utils] Need to calibrate"));log_flush();
_need2calibrate=true;
}
log_debug(F("\n test "));log_debug(_res);
return _res;
}
......
......@@ -36,7 +36,7 @@
*/
// reboot flag
extern bool _need2reboot;
//Manon
// calibrate flag
extern bool _need2calibrate;
......
......@@ -285,12 +285,13 @@ boolean SHT3x::getTemp( float *pval )
// 100.0 x _tmp = (17500 x _tmp) / (16384 x 4) - 4500
_tmp = ((4375 * _tmp) >> 14) - 4500;
*pval = ((float)_tmp / 100.0f);
//Manon
if ((not _need2reboot) && _need2calibrate){
auto result = calibrate(pval, _a, _b);
auto result = calibrate(pval, _a, _b); // updating of (a,b)
_a = std::get<0>(result);
_b = std::get<1>(result);
}
// calibration
*pval = *pval * _a;
*pval = *pval + _b;
return true;
......
......@@ -127,7 +127,8 @@ class SHT3x : public generic_driver {
// device detection
static boolean is_device( uint8_t );
Sketch uses 1103089 bytes (84%) of program storage space. Maximum is 1310720 bytes.
Global variables use 49528 bytes (15%) of dynamic memory, leaving 278152 bytes for local variables. Maximum is 327680 bytes.
private:
// -- private methods
bool _readSensor( uint16_t* ); // low-level function to read value registers
......@@ -155,8 +156,8 @@ class SHT3x : public generic_driver {
static const uint8_t _crc8_table[256];
#endif /* SHT3X_CRC_LOOKUP_TABLE */
float _a = 1.0; //Manon
float _b = (-2.0); //Manon
float _a = 1.0; //coefficient for calibration
float _b = (-2.0); //coefficient for calibration
};
#endif /* _SHT3X_H_ */
......@@ -23,8 +23,8 @@
#include "neocampus.h" // _MAX_COOLDOWN_SENSOR
#include "generic_driver.h"
#include "neocampus_debug.h" //Manon
#include "neocampus_utils.h" //Manon
#include "neocampus_debug.h"
#include "neocampus_utils.h"
/******************************************
......@@ -166,13 +166,15 @@ void generic_driver::setDataSent( void ) {
_lastMsSent = millis();
}
//Manon
/******************************************
* Calibration of a sensor by updating a and b
* pval : last value
*/
std::tuple<float, float> generic_driver::calibrate(float* pval, float a, float b){
//TO-DO : Ajouter une variable globale externe -> valeur du capteur de référence : valBLE
float valBLE = 22.0; //<----- à enlever
//TO-DO : Add an extern global variable -> ThermoPro sensor value : valBLE to replace the one below
float valBLE = 20.5;
b= valBLE-*pval;
//TO-DO traiter le cas de non-linéarité
//On vient de calibrer donc plus besoin de le faire
// calibration is done so no need to do it again
_need2calibrate=false;
return std::make_tuple(a, b);
}
\ No newline at end of file
......@@ -112,7 +112,7 @@ class generic_driver {
float valueSent; // official value that has been sent
unsigned long _lastMsSent; // (ms) time the official value has been sent
std::tuple<float, float> calibrate(float*, float a, float b); // Manon
std::tuple<float, float> calibrate(float*, float a, float b); //return a tuple (a,b) to calibrate a sensor
};
#endif /* _GENERIC_DRIVER_H_ */
......@@ -121,7 +121,6 @@
// WiFi parameters management
#include "wifiParametersMgt.h"
//Manon
//BLE device
//#include <advertisedDeviceCallbacks.h>
......@@ -130,7 +129,7 @@
* Definitions
*/
//Manon
//BLE device
#define SCAN_TIME 5 // scan period in second
bool BLEScanActivated = false;
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8))
......@@ -186,7 +185,6 @@ typedef enum {
* Global variables
*/
bool _need2reboot = false; // flag to tell a reboot is requested
//Manon
bool _need2calibrate = false; // flag to tell a calibration is requested
// WiFi parameters management statically allocated instance
wifiParametersMgt wifiParameters = wifiParametersMgt();
......@@ -786,7 +784,7 @@ void lateSetup( void ) {
log_info(F("\n# --- --- ---")); log_flush();
}
//Manon
//BLE device
// ***** start BLE scan *****
/*
void startScanBLE() {
......@@ -1231,7 +1229,7 @@ if( res!=uint8_t(0x44) ) {
*/
modulesList.startAll( &sensocampus, sharedRoot );
//Manon
//BLE device
/*
//Init BLE
BLEDevice::init("");
......@@ -1241,7 +1239,7 @@ if( res!=uint8_t(0x44) ) {
log_debug(F(" done !"));log_flush();
*/
//Manon
//check if the sensor need a calibration
#ifdef INCR_SW
#ifdef DECR_SW
checkCALIBRATIONswitch(DECR_SW, INCR_SW);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment