mirror of
https://gitlab.com/Luci_/arduino-photometrics.git
synced 2026-04-03 11:35:37 +02:00
commit all
This commit is contained in:
parent
72ccd96623
commit
acc92ccf6a
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -1,9 +1,13 @@
|
||||||
.pio
|
.pio
|
||||||
.vscode/.browse.c_cpp.db*
|
# .vscode/.browse.c_cpp.db*
|
||||||
.vscode/c_cpp_properties.json
|
# .vscode/c_cpp_properties.json
|
||||||
.vscode/launch.json
|
# .vscode/launch.json
|
||||||
.vscode/ipch
|
# .vscode/ipch
|
||||||
MinMaxPhoto-r
|
.vscode
|
||||||
|
time
|
||||||
|
MinMaxPhoto-r.ods
|
||||||
|
serial
|
||||||
|
*.drawio.bkp
|
||||||
|
|
||||||
|
|
||||||
# Created by https://www.toptal.com/developers/gitignore/api/platformio,c++
|
# Created by https://www.toptal.com/developers/gitignore/api/platformio,c++
|
||||||
|
|
|
||||||
37
include/README
Executable file
37
include/README
Executable file
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
This directory is intended for project header files.
|
||||||
|
|
||||||
|
A header file is a file containing C declarations and macro definitions
|
||||||
|
to be shared between several project source files. You request the use of a
|
||||||
|
header file in your project source file (C, C++, etc) located in `src` folder
|
||||||
|
by including it, with the C preprocessing directive `#include'.
|
||||||
|
|
||||||
|
```src/main.c
|
||||||
|
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Including a header file produces the same results as copying the header file
|
||||||
|
into each source file that needs it. Such copying would be time-consuming
|
||||||
|
and error-prone. With a header file, the related declarations appear
|
||||||
|
in only one place. If they need to be changed, they can be changed in one
|
||||||
|
place, and programs that include the header file will automatically use the
|
||||||
|
new version when next recompiled. The header file eliminates the labor of
|
||||||
|
finding and changing all the copies as well as the risk that a failure to
|
||||||
|
find one copy will result in inconsistencies within a program.
|
||||||
|
|
||||||
|
In C, the convention is to give header files names that end with `.h'.
|
||||||
|
|
||||||
|
Read more about using header files in official GCC documentation:
|
||||||
|
|
||||||
|
* Include Syntax
|
||||||
|
* Include Operation
|
||||||
|
* Once-Only Headers
|
||||||
|
* Computed Includes
|
||||||
|
|
||||||
|
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||||
47
lib/README
Executable file
47
lib/README
Executable file
|
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
This directory is intended for project specific (private) libraries.
|
||||||
|
PlatformIO will compile them to static libraries and link into the executable file.
|
||||||
|
|
||||||
|
The source code of each library should be placed in a separate directory
|
||||||
|
("lib/your_library_name/[Code]").
|
||||||
|
|
||||||
|
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
||||||
|
|
||||||
|
|--lib
|
||||||
|
| |
|
||||||
|
| |--Bar
|
||||||
|
| | |--docs
|
||||||
|
| | |--examples
|
||||||
|
| | |--src
|
||||||
|
| | |- Bar.c
|
||||||
|
| | |- Bar.h
|
||||||
|
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||||
|
| |
|
||||||
|
| |--Foo
|
||||||
|
| | |- Foo.c
|
||||||
|
| | |- Foo.h
|
||||||
|
| |
|
||||||
|
| |- README --> THIS FILE
|
||||||
|
|
|
||||||
|
|- platformio.ini
|
||||||
|
|--src
|
||||||
|
|- main.c
|
||||||
|
|
||||||
|
Example contents of `src/main.c` using Foo and Bar:
|
||||||
|
```
|
||||||
|
#include <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The PlatformIO Library Dependency Finder will find automatically dependent
|
||||||
|
libraries by scanning project source files.
|
||||||
|
|
||||||
|
More information about PlatformIO Library Dependency Finder
|
||||||
|
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||||
|
|
||||||
28
lib/sensor/led.cpp
Executable file
28
lib/sensor/led.cpp
Executable file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
|
Led::Led(uint8_t pin) : pin(pin), state(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led::setup() {
|
||||||
|
pinMode(pin, OUTPUT);
|
||||||
|
state = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led::turnOn() {
|
||||||
|
digitalWrite(pin, HIGH);
|
||||||
|
state = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led::turnOff() {
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
state = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led::toggle() {
|
||||||
|
if (state) {
|
||||||
|
turnOff();
|
||||||
|
} else {
|
||||||
|
turnOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
19
lib/sensor/led.h
Executable file
19
lib/sensor/led.h
Executable file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef LED_H
|
||||||
|
#define LED_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class Led{
|
||||||
|
public:
|
||||||
|
Led(uint8_t pin);
|
||||||
|
void setup();
|
||||||
|
void turnOn();
|
||||||
|
void turnOff();
|
||||||
|
void toggle();
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t pin;
|
||||||
|
bool state;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
28
lib/sensor/photoresistance_ohm_retrieval.cpp
Executable file
28
lib/sensor/photoresistance_ohm_retrieval.cpp
Executable file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "photoresistance_ohm_retrieval.h"
|
||||||
|
|
||||||
|
|
||||||
|
SensorOhm::SensorOhm(uint8_t pin_analog_read, float vcc, int32_t rFixed, float current)
|
||||||
|
: pin_analog_read(pin_analog_read), vcc(vcc), rFixed(rFixed), current(current) {
|
||||||
|
if (vcc > mega2560_max_vcc){
|
||||||
|
Serial.println("FATAL: VCC too high !");
|
||||||
|
while (true); // bloque le programme
|
||||||
|
}
|
||||||
|
if (current > mega2560_max_current){
|
||||||
|
Serial.println("FATAL: Intensity too high !");
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorOhm::setup() {
|
||||||
|
pinMode(pin_analog_read, INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t SensorOhm::readResistance() {
|
||||||
|
// The circuit is connected in series.
|
||||||
|
// The resistance of the photoresistor can be calculated using the voltage divider circuits.
|
||||||
|
int raw = analogRead(pin_analog_read);
|
||||||
|
float vOut = (raw / 1023.0f) * vcc;
|
||||||
|
int32_t res = (int32_t)(rFixed * (vcc - vOut)) / vOut;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
27
lib/sensor/photoresistance_ohm_retrieval.h
Executable file
27
lib/sensor/photoresistance_ohm_retrieval.h
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef PHOTORESISANCE_OHM_RETRIEVAL_H
|
||||||
|
#define PHOTORESISANCE_OHM_RETRIEVAL_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
|
||||||
|
const float mega2560_max_current = 50e-3; // 50 mA
|
||||||
|
const float mega2560_max_vcc = 5.5;
|
||||||
|
const int32_t r_voltage_divider = 330e3;
|
||||||
|
|
||||||
|
// SensorOhm calculate the value of the photoresistor with the voltage divider circuits
|
||||||
|
class SensorOhm {
|
||||||
|
public:
|
||||||
|
SensorOhm(uint8_t pin_analog_read = A0, float vcc = mega2560_max_vcc, int32_t rFixed = r_voltage_divider, float current = mega2560_max_current);
|
||||||
|
|
||||||
|
void setup();
|
||||||
|
int32_t readResistance();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint8_t pin_analog_read;
|
||||||
|
float vcc;
|
||||||
|
int32_t rFixed;
|
||||||
|
float current;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
121
lib/sensor/sensormanager.cpp
Normal file
121
lib/sensor/sensormanager.cpp
Normal file
|
|
@ -0,0 +1,121 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "sensormanager.h"
|
||||||
|
|
||||||
|
|
||||||
|
SensorManager::SensorManager(){}
|
||||||
|
|
||||||
|
SensorManager::~SensorManager(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief setup
|
||||||
|
* * init manager and photorésistor objects
|
||||||
|
*
|
||||||
|
* * @param nb_sensor @c uint8_t number of photoresistor
|
||||||
|
* @param analog_in @c uint8_t* array of pin identificators
|
||||||
|
* @return @c void
|
||||||
|
*/
|
||||||
|
void SensorManager::setup(uint8_t nb_sensor, uint8_t *analog_in){
|
||||||
|
nbPhotoSensor = nb_sensor;
|
||||||
|
for(uint8_t i = 0; i < nbPhotoSensor; i++){
|
||||||
|
SensorOhm tmp(analog_in[i]);
|
||||||
|
sensor_list[i] = tmp;
|
||||||
|
sensor_list[i].setup();
|
||||||
|
// init max and min array
|
||||||
|
if (unsigned_int){
|
||||||
|
min[i]= 2e9;
|
||||||
|
max[i]= 0;
|
||||||
|
}else{
|
||||||
|
min[i]= 2e9;
|
||||||
|
max[i]= -2e9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get_resistance
|
||||||
|
* * Get resistives values of photosensors
|
||||||
|
* Warning res_tab
|
||||||
|
* * @param res_tab @c int32_t must be a local array pointer
|
||||||
|
* @param tab_lenght @c uint8_t equal to or greater than the number of photo-res managed
|
||||||
|
* @return @c void
|
||||||
|
*/
|
||||||
|
void SensorManager::get_resistances(int32_t* res_tab, uint8_t tab_lenght){
|
||||||
|
if (tab_lenght < nbPhotoSensor){
|
||||||
|
Serial.print("Error bad tab size");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < nbPhotoSensor; i++)
|
||||||
|
{
|
||||||
|
res_tab[i] = get_resistances_at(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorManager::updateMinMax(uint8_t index, int32_t current_res) {
|
||||||
|
if(min[index] > current_res){
|
||||||
|
min[index] = current_res;
|
||||||
|
}
|
||||||
|
if(max[index] < current_res){
|
||||||
|
max[index] = current_res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get_min_max
|
||||||
|
* * Get highest and lowest resistives values of photosensors
|
||||||
|
* Warning res_tab
|
||||||
|
* * @param min_res_tab_max_res_tab @c int32_t must be a local array pointer
|
||||||
|
* @param tab_lenght @c uint8_t equal to or greater than the number of photo-res managed
|
||||||
|
* @return @c void
|
||||||
|
*/
|
||||||
|
void SensorManager::get_min_max(int32_t* min_res_tab, int32_t* max_res_tab, uint8_t tab_lenght){
|
||||||
|
if (tab_lenght < nbPhotoSensor){
|
||||||
|
Serial.print("Error bad tab size");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < nbPhotoSensor; i++)
|
||||||
|
{
|
||||||
|
min_res_tab[i] = min[i];
|
||||||
|
max_res_tab[i] = max[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SensorManager::get_nb_photores(){
|
||||||
|
return nbPhotoSensor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorManager::print_current_res(){
|
||||||
|
int32_t curr[nbPhotoSensor];
|
||||||
|
get_resistances(curr, nbPhotoSensor);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < nbPhotoSensor; i++)
|
||||||
|
{
|
||||||
|
Serial.print("Photo-resistance n°");
|
||||||
|
Serial.print(i, DEC);
|
||||||
|
Serial.print(" : ");
|
||||||
|
Serial.print(curr[i], DEC);
|
||||||
|
Serial.print(" | ");
|
||||||
|
}
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorManager::print_min_max_res(){
|
||||||
|
for (uint8_t i = 0; i < nbPhotoSensor; i++)
|
||||||
|
{
|
||||||
|
Serial.print("Photo-resistance n°");
|
||||||
|
Serial.print(i, DEC);
|
||||||
|
Serial.print(" : min = ");
|
||||||
|
Serial.print(min[i], DEC);
|
||||||
|
Serial.print(", max = ");
|
||||||
|
Serial.print(max[i], DEC);
|
||||||
|
Serial.print(" | ");
|
||||||
|
}
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t SensorManager::get_resistances_at(uint8_t index){
|
||||||
|
int32_t tmp = sensor_list[index].readResistance();
|
||||||
|
updateMinMax(index, tmp);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
31
lib/sensor/sensormanager.h
Normal file
31
lib/sensor/sensormanager.h
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef SENSORMANAGER_H
|
||||||
|
#define SENSORMANAGER_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "photoresistance_ohm_retrieval.h"
|
||||||
|
|
||||||
|
class SensorManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static const uint8_t max_sensor = 10;
|
||||||
|
static const bool unsigned_int = 0;
|
||||||
|
uint8_t nbPhotoSensor;
|
||||||
|
SensorOhm sensor_list[max_sensor];
|
||||||
|
int32_t min[max_sensor], max[max_sensor];
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
SensorManager();
|
||||||
|
~SensorManager();
|
||||||
|
|
||||||
|
void setup(uint8_t nb_sensor, uint8_t *analog_in);
|
||||||
|
uint8_t get_nb_photores();
|
||||||
|
int32_t get_resistances_at(uint8_t index);
|
||||||
|
void get_resistances(int32_t* res_tab, uint8_t tab_lenght);
|
||||||
|
void get_min_max(int32_t* min_res_tab, int32_t* max_res_tab, uint8_t tab_lenght);
|
||||||
|
void updateMinMax(uint8_t index, int32_t current_res);
|
||||||
|
void print_current_res();
|
||||||
|
void print_min_max_res();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
263
lib/storage/storage_interface.cpp
Normal file
263
lib/storage/storage_interface.cpp
Normal file
|
|
@ -0,0 +1,263 @@
|
||||||
|
#include "storage_interface.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Manual implements of EEPROM.put() for few uint type
|
||||||
|
|
||||||
|
uint16_t inline read_eeprom_uint16(uint8_t idx){
|
||||||
|
uint8_t tmp;
|
||||||
|
tmp = EEPROM.read(idx); // read high byte
|
||||||
|
return EEPROM.read(idx + 1) | (tmp << 8); // read low byte
|
||||||
|
}
|
||||||
|
|
||||||
|
void inline write_eeprom_uint16(uint8_t idx, uint16_t value){
|
||||||
|
EEPROM.write(idx, value >> 8); // write high byte
|
||||||
|
EEPROM.write(idx + 1, value & 0xFF); // write low byte
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t inline read_eeprom_uint32(uint8_t idx) {
|
||||||
|
uint32_t result = 0;
|
||||||
|
|
||||||
|
// Byte 1 (High level : MSB)
|
||||||
|
result |= (uint32_t)EEPROM.read(idx) << 24;
|
||||||
|
|
||||||
|
// Byte 2
|
||||||
|
result |= (uint32_t)EEPROM.read(idx + 1) << 16;
|
||||||
|
|
||||||
|
// Byte 3
|
||||||
|
result |= (uint32_t)EEPROM.read(idx + 2) << 8;
|
||||||
|
|
||||||
|
// Byte 4 (Low level : LSB)
|
||||||
|
result |= (uint32_t)EEPROM.read(idx + 3);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void inline write_eeprom_uint32(uint8_t idx, uint32_t value) {
|
||||||
|
|
||||||
|
// Byte 1 (High level : MSB)
|
||||||
|
EEPROM.write(idx, (uint8_t)(value >> 24));
|
||||||
|
|
||||||
|
// Byte 2
|
||||||
|
EEPROM.write(idx + 1, (uint8_t)(value >> 16));
|
||||||
|
|
||||||
|
// Byte 3
|
||||||
|
EEPROM.write(idx + 2, (uint8_t)(value >> 8));
|
||||||
|
|
||||||
|
// Byte 4 (Low level : LSB)
|
||||||
|
EEPROM.write(idx + 3, (uint8_t)(value & 0xFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
Storage_interface::Storage_interface(){}
|
||||||
|
|
||||||
|
Storage_interface::~Storage_interface(){}
|
||||||
|
|
||||||
|
void Storage_interface::clear_eeprom(){
|
||||||
|
for (uint16_t i = 0 ; i < EEPROM.length() ; i++) {
|
||||||
|
EEPROM.write(i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Storage_interface::clear_eeprom_at(uint16_t idx){
|
||||||
|
for (uint16_t i = idx ; i < EEPROM.length() ; i++) {
|
||||||
|
EEPROM.write(i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// legacy function (don't finished and never tested)
|
||||||
|
/*
|
||||||
|
uint16_t get_nb_package_legacy(){
|
||||||
|
uint8_t flags, nb_photo_sensor, nb_temp_sensor, temp_size_t, photo_size_t, schedule, tmp, timestamp_size_t;
|
||||||
|
uint16_t nb_package = 0, nb_measure, start_package = 0, timestamp_sum_size, next_position;
|
||||||
|
bool timestamp;
|
||||||
|
flags = EEPROM.read(start_package);
|
||||||
|
|
||||||
|
while ((flags & 0b1) != 0){
|
||||||
|
nb_package++;
|
||||||
|
nb_photo_sensor = EEPROM.read(start_package + OFFSET_NB_PHOTO_SENSOR);
|
||||||
|
photo_size_t = EEPROM.read(start_package + OFFSET_PHOTO_MEASURES_SIZE);
|
||||||
|
|
||||||
|
nb_temp_sensor = EEPROM.read(start_package + OFFSET_NB_TEMP_SENSOR);
|
||||||
|
temp_size_t = EEPROM.read(start_package + OFFSET_TEMP_MEASURES_SIZE);
|
||||||
|
|
||||||
|
tmp = EEPROM.read(start_package + OFFSET_NB_TEMP_SENSOR); // read high byte
|
||||||
|
nb_measure = EEPROM.read(start_package + OFFSET_NB_TEMP_SENSOR + 1) | (tmp << 8); // read low byte
|
||||||
|
|
||||||
|
timestamp = false;
|
||||||
|
timestamp_size_t = EEPROM.read(start_package + OFFSET_timestamp_SIZE);
|
||||||
|
if ((flags & 0b001) != 0 ){
|
||||||
|
timestamp = true;
|
||||||
|
schedule = EEPROM.read(start_package + OFFSET_MEASURES_SCH);
|
||||||
|
timestamp_sum_size = (nb_measure/schedule) * timestamp_size_t;
|
||||||
|
}else if ((flags & 0b01) != 0){
|
||||||
|
timestamp = true;
|
||||||
|
timestamp_sum_size = nb_measure * timestamp_size_t;
|
||||||
|
}else{
|
||||||
|
timestamp_sum_size = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nb_package;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get_last_header_nbpackage
|
||||||
|
* *
|
||||||
|
*
|
||||||
|
* * @param last_header_idx @c uint16_t EEPROM index of the last header
|
||||||
|
* @return @c uint16_t EEPROM stored package number
|
||||||
|
*/
|
||||||
|
uint16_t Storage_interface::get_last_header_nbpackage(uint16_t* last_header_idx){
|
||||||
|
uint8_t flags;
|
||||||
|
uint16_t start_package = 0, nb_package = 0;
|
||||||
|
*last_header_idx = 0;
|
||||||
|
flags = EEPROM.read(start_package);
|
||||||
|
|
||||||
|
while ((flags & 0b1) != 0){
|
||||||
|
nb_package++;
|
||||||
|
*last_header_idx = start_package;
|
||||||
|
start_package = read_eeprom_uint16(start_package + OFFSET_NEXT_PACKAGE);
|
||||||
|
flags = EEPROM.read(start_package);
|
||||||
|
nb_package++;
|
||||||
|
}
|
||||||
|
return nb_package;
|
||||||
|
}
|
||||||
|
|
||||||
|
// factorise reused code implementation and keep level acces
|
||||||
|
uint16_t Storage_interface::get_nb_package(){
|
||||||
|
uint16_t pointer;
|
||||||
|
return get_last_header_nbpackage(&pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Storage_interface::get_store_struct(uint16_t offset, bool* timestamp, bool* is_final_set, bool* photo_sensor, bool* temp_sensor, uint8_t* timestamp_schedule, uint8_t* nb_photo_sensor, uint8_t* nb_temp_sensor, uint8_t* photo_size, uint8_t* temp_size, uint16_t* p_next_package, uint16_t* nb_measures){
|
||||||
|
uint8_t flags;
|
||||||
|
flags = EEPROM.read(offset);
|
||||||
|
|
||||||
|
// Checking there if a struct is possibly at the index
|
||||||
|
if ((flags & 0b1) == 0){
|
||||||
|
Serial.println("Missing struct index or bad index");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// timestamps reads
|
||||||
|
*timestamp = false;
|
||||||
|
if ((flags & 0b001) != 0 ){
|
||||||
|
*timestamp = true;
|
||||||
|
*timestamp_schedule = EEPROM.read(offset + OFFSET_MEASURES_SCH);
|
||||||
|
}
|
||||||
|
*timestamp_schedule = 0;
|
||||||
|
if (flags & 0b01){
|
||||||
|
*timestamp = true;
|
||||||
|
if (EEPROM.read(offset + OFFSET_MEASURES_SCH) != 0)
|
||||||
|
Serial.println("Incoherent timestamp parameter in the header.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// photo res reads
|
||||||
|
*photo_sensor = false;
|
||||||
|
if (flags & 0b0001){
|
||||||
|
*photo_sensor = true;
|
||||||
|
*nb_photo_sensor = EEPROM.read(offset + OFFSET_NB_PHOTO_SENSOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// temp res reads
|
||||||
|
*temp_sensor = false;
|
||||||
|
if (flags & 0b00001){
|
||||||
|
*temp_sensor = true;
|
||||||
|
*nb_temp_sensor = EEPROM.read(offset + OFFSET_NB_TEMP_SENSOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// gather the index of the next package in the EEPROM
|
||||||
|
*p_next_package = read_eeprom_uint16(offset + OFFSET_NEXT_PACKAGE);
|
||||||
|
|
||||||
|
// gather the number of measures
|
||||||
|
*nb_measures = read_eeprom_uint16(offset + OFFSET_NB_TEMP_SENSOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Storage_interface::set_store_struct(uint16_t offset, bool timestamp, bool is_final_set, bool photo_sensor, bool temp_sensor, uint8_t timestamp_schedule, uint8_t nb_photo_sensor, uint8_t nb_temp_sensor, uint8_t photo_size, uint8_t temp_size){
|
||||||
|
uint8_t flags = 0;
|
||||||
|
|
||||||
|
// Existing package flag for function package searcher
|
||||||
|
flags = flags | 0b10000000;
|
||||||
|
|
||||||
|
// Timestamp init struct
|
||||||
|
if(timestamp_schedule != 0){
|
||||||
|
flags = flags | 0b00100000;
|
||||||
|
EEPROM.write(offset + OFFSET_MEASURES_SCH, timestamp_schedule);
|
||||||
|
if(!timestamp)
|
||||||
|
Serial.println("Bad timestamp parameter for header writer.");
|
||||||
|
}else{
|
||||||
|
EEPROM.write(offset + OFFSET_MEASURES_SCH, 0);
|
||||||
|
if (timestamp)
|
||||||
|
flags = flags | 0b01000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sensor part
|
||||||
|
if (photo_sensor){
|
||||||
|
flags = flags | 0b00010000;
|
||||||
|
EEPROM.write(offset + OFFSET_NB_PHOTO_SENSOR, nb_photo_sensor);
|
||||||
|
}else{
|
||||||
|
EEPROM.write(offset + OFFSET_NB_PHOTO_SENSOR, 0);
|
||||||
|
if (nb_photo_sensor != 0)
|
||||||
|
Serial.println("Bad photo sensor parameter for header writer.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp_sensor){
|
||||||
|
flags = flags | 0b00001000;
|
||||||
|
EEPROM.write(offset + OFFSET_NB_TEMP_SENSOR, nb_temp_sensor);
|
||||||
|
}else{
|
||||||
|
EEPROM.write(offset + OFFSET_NB_TEMP_SENSOR, 0);
|
||||||
|
if (nb_temp_sensor != 0)
|
||||||
|
Serial.println("Bad temperature sensor parameter for header writer.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Analyse if is_final_set just be remove from parameter
|
||||||
|
if (is_final_set){
|
||||||
|
flags = flags | 0b00000100;
|
||||||
|
}
|
||||||
|
|
||||||
|
// uint16_t next package pointer set at 0
|
||||||
|
write_eeprom_uint16(offset + OFFSET_NEXT_PACKAGE, offset + OFFSET_START_DATA_MEASURES);
|
||||||
|
|
||||||
|
// set number of measures to 0
|
||||||
|
write_eeprom_uint16(offset + OFFSET_NB_MEASURES, 0);
|
||||||
|
|
||||||
|
// write flags header
|
||||||
|
EEPROM.write(offset , flags);
|
||||||
|
|
||||||
|
clear_eeprom_at(offset + OFFSET_START_DATA_MEASURES);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Storage_interface::add_last_package(bool timestamp, bool is_final_set, bool photo_sensor, bool temp_sensor, uint8_t timestamp_schedule, uint8_t nb_photo_sensor, uint8_t nb_temp_sensor, uint8_t photo_size, uint8_t temp_size, uint16_t nb_measures){
|
||||||
|
uint16_t p_last_header, free_space;
|
||||||
|
uint8_t flags;
|
||||||
|
|
||||||
|
get_last_header_nbpackage(&p_last_header);
|
||||||
|
flags = EEPROM.read(p_last_header);
|
||||||
|
|
||||||
|
// change is_last_package flag
|
||||||
|
flags = flags & 0b11111011;
|
||||||
|
EEPROM.write(p_last_header , flags);
|
||||||
|
|
||||||
|
free_space = EEPROM.read(p_last_header + OFFSET_NEXT_PACKAGE);
|
||||||
|
set_store_struct(free_space, timestamp, is_final_set, photo_sensor, temp_sensor, timestamp_schedule, nb_photo_sensor, nb_temp_sensor, photo_size, temp_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dont check if the stored measure structure match with the header
|
||||||
|
void Storage_interface::add_measure(uint8_t* photo_values, uint8_t* temp_values, uint32_t timestamp, uint8_t nb_photo, uint8_t nb_temp){
|
||||||
|
uint16_t p_last_header, free_space, idx;
|
||||||
|
|
||||||
|
get_last_header_nbpackage(&p_last_header);
|
||||||
|
|
||||||
|
free_space = EEPROM.read(p_last_header + OFFSET_NEXT_PACKAGE);
|
||||||
|
EEPROM.write(p_last_header + OFFSET_NB_MEASURES, EEPROM.read(p_last_header + OFFSET_NB_MEASURES) + 1);
|
||||||
|
|
||||||
|
EEPROM.put(free_space, timestamp);
|
||||||
|
idx = p_last_header + int32_size;
|
||||||
|
for(int i = 0; i < nb_photo; i++, idx += int8_size){
|
||||||
|
EEPROM.put(idx, photo_values[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < nb_temp; i++, idx += int8_size){
|
||||||
|
EEPROM.put(idx, temp_values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
lib/storage/storage_interface.h
Normal file
53
lib/storage/storage_interface.h
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef STORAGE_INTERFACE_H
|
||||||
|
#define STORAGE_INTERFACE_H
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
|
// based on https://docs.arduino.cc/learn/programming/eeprom-guide/
|
||||||
|
|
||||||
|
class Storage_interface
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
static constexpr uint8_t OFFSET_MEASURES_SCH = 1, OFFSET_NB_PHOTO_SENSOR = 2, OFFSET_NB_TEMP_SENSOR = 3, OFFSET_PHOTO_MEASURES_SIZE = 4, OFFSET_TEMP_MEASURES_SIZE = 5, OFFSET_NB_MEASURES = 6, OFFSET_NEXT_PACKAGE = 8, OFFSET_START_DATA_MEASURES = 10; // unit in byte
|
||||||
|
static constexpr uint8_t int32_size = sizeof(int32_t), int16_size = sizeof(int16_t), int8_size = sizeof(int8_t);
|
||||||
|
static constexpr uint16_t MEGA_2560_EEPROM_SIZE = 4096;
|
||||||
|
|
||||||
|
void clear_eeprom();
|
||||||
|
void clear_eeprom_at(uint16_t idx);
|
||||||
|
|
||||||
|
void get_store_struct(uint16_t offset, bool* timestamp, bool* is_final_set, bool* photo_sensor, bool* temp_sensor, uint8_t* timestamp_schedule, uint8_t* nb_photo_sensor, uint8_t* nb_temp_sensor, uint8_t* photo_size, uint8_t* temp_size, uint16_t* p_next_package, uint16_t* nb_measures);
|
||||||
|
void set_store_struct(uint16_t offset, bool timestamp, bool is_final_set, bool photo_sensor, bool temp_sensor, uint8_t timestamp_schedule, uint8_t nb_photo_sensor, uint8_t nb_temp_sensor, uint8_t photo_size, uint8_t temp_size);
|
||||||
|
|
||||||
|
uint16_t get_last_header_nbpackage(uint16_t* last_header_idx);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
uint16_t get_nb_package();
|
||||||
|
void add_last_package(bool timestamp, bool is_final_set, bool photo_sensor, bool temp_sensor, uint8_t timestamp_schedule, uint8_t nb_photo_sensor, uint8_t nb_temp_sensor, uint8_t photo_size, uint8_t temp_size, uint16_t nb_measures);
|
||||||
|
void add_measure(uint8_t* photo_values, uint8_t* temp_values, uint32_t timestamp, uint8_t nb_photo, uint8_t nb_temp);
|
||||||
|
Storage_interface();
|
||||||
|
~Storage_interface();
|
||||||
|
|
||||||
|
// Dont check if the stored measure structure match with the header
|
||||||
|
template< typename T, typename TT>
|
||||||
|
void add_measure(T* photo_values, TT* temp_values, uint32_t timestamp, uint8_t nb_photo, uint8_t nb_temp){
|
||||||
|
uint16_t p_last_header, free_space, idx;
|
||||||
|
|
||||||
|
get_last_header_nbpackage(&p_last_header);
|
||||||
|
|
||||||
|
free_space = EEPROM.read(p_last_header + OFFSET_NEXT_PACKAGE);
|
||||||
|
EEPROM.write(p_last_header + OFFSET_NB_MEASURES, EEPROM.read(p_last_header + OFFSET_NB_MEASURES) + 1);
|
||||||
|
|
||||||
|
EEPROM.put(free_space, timestamp);
|
||||||
|
idx = p_last_header + int32_size;
|
||||||
|
for(int i = 0; i < nb_photo; i++, idx += sizeof(T)){
|
||||||
|
EEPROM.put(idx, photo_values[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < nb_temp; i++, idx += sizeof(TT)){
|
||||||
|
EEPROM.put(idx, temp_values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
23
lib/traitement/traitement.cpp
Normal file
23
lib/traitement/traitement.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "traitement.h"
|
||||||
|
|
||||||
|
Traitement::Traitement(){}
|
||||||
|
|
||||||
|
Traitement::~Traitement(){}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief map_r
|
||||||
|
* * Normalise resistance value
|
||||||
|
*
|
||||||
|
* * @param min_res_tab @c int32_t*
|
||||||
|
* @param max_res_tab @c int32_t*
|
||||||
|
* @param res_values @c int32_t*
|
||||||
|
* @param result @c int32_t*
|
||||||
|
* @param tab_lenght @c uint8_t
|
||||||
|
*/
|
||||||
|
void Traitement::map_r(int32_t* min_res_tab, int32_t* max_res_tab, int32_t* res_values, int16_t* result, uint8_t tab_lenght){
|
||||||
|
for(int i = 0; i < tab_lenght; i++){
|
||||||
|
result[i] = map(res_values[i], min_res_tab[i], max_res_tab[i], min_out_norm, max_out_norm);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
lib/traitement/traitement.h
Normal file
19
lib/traitement/traitement.h
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef TRAITEMENT_H
|
||||||
|
#define TRAITEMENT_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class Traitement
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const uint8_t min_out_norm = 0, max_out_norm = 255;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Traitement();
|
||||||
|
~Traitement();
|
||||||
|
|
||||||
|
void map_r(int32_t* min_res_tab, int32_t* max_res_tab, int32_t* res_values, int16_t* result, uint8_t tab_lenght);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
22
platformio.ini
Executable file
22
platformio.ini
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:megaADK]
|
||||||
|
platform = atmelavr
|
||||||
|
board = megaADK
|
||||||
|
framework = arduino
|
||||||
|
test_framework = unity
|
||||||
|
build_flags = -std=gnu++17
|
||||||
|
lib_deps =
|
||||||
|
northernwidget/DS3231@^1.1.2
|
||||||
|
arduino-libraries/Ethernet
|
||||||
|
robtillaart/CRC
|
||||||
|
|
||||||
|
lib_ldf_mode = deep+
|
||||||
24
src/Notes.txt
Executable file
24
src/Notes.txt
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
40 en moyenne
|
||||||
|
700 grand max avec lumière téléphone
|
||||||
|
téléphoen 100 à 150 lumen
|
||||||
|
-> soit environ 100 lux a 1m contre 100 000 lux en plein jours sur 1m²
|
||||||
|
résistance 120 ohm
|
||||||
|
|
||||||
|
|
||||||
|
0 a 1024 en analogique
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DateTime of RTC: 2025-11-21 10:46:8 | Temp of RTC: 24.0000
|
||||||
|
Photo-resistance n°0 : 620 | Photo-resistance n°1 : 686 | Photo-resistance n°2 : 854 | Photo-resistance n°3 : 653 | Photo-resistance n°4 : 1058 | Photo-resistance n°5 : 686 |
|
||||||
|
Photo-resistance n°0 : min = 128, max = 2062273 | Photo-resistance n°1 : min = 160, max = 5554006 | Photo-resistance n°2 : min = 193, max = 784809 | Photo-resistance n°3 : min = 96, max = 4755895 | Photo-resistance n°4 : min = 323, max = 1939035 | Photo-resistance n°5 : min = 96, max = 289546 |
|
||||||
|
|
||||||
|
|
||||||
|
DateTime of RTC: 2025-11-21 10:46:10 | Temp of RTC: 24.0000
|
||||||
|
Photo-resistance n°0 : 620 | Photo-resistance n°1 : 686 | Photo-resistance n°2 : 888 | Photo-resistance n°3 : 653 | Photo-resistance n°4 : 1092 | Photo-resistance n°5 : 720 |
|
||||||
|
Photo-resistance n°0 : min = 128, max = 2062273 | Photo-resistance n°1 : min = 160, max = 5554006 | Photo-resistance n°2 : min = 193, max = 784809 | Photo-resistance n°3 : min = 96, max = 4755895 | Photo-resistance n°4 : min = 323, max = 1939035 | Photo-resistance n°5 : min = 96, max = 289546 |
|
||||||
|
|
||||||
|
|
||||||
|
DateTime of RTC: 2025-11-21 10:46:13 | Temp of RTC: 24.0000
|
||||||
|
Photo-resistance n°0 : 620 | Photo-resistance n°1 : 720 | Photo-resistance n°2 : 888 | Photo-resistance n°3 : 653 | Photo-resistance n°4 : 1092 | Photo-resistance n°5 : 720 |
|
||||||
|
Photo-resistance n°0 : min = 128, max = 2062273 | Photo-resistance n°1 : min = 160, max = 5554006 | Photo-resistance n°2 : min = 193, max = 784809 | Photo-resistance n°3 : min = 96, max = 4755895 | Photo-resistance n°4 : min = 323, max = 1939035 | Photo-resistance n°5 : min = 96, max = 289546 |
|
||||||
9
src/Robot_Go_West.code-workspace
Executable file
9
src/Robot_Go_West.code-workspace
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"name": "Robot_Go_West",
|
||||||
|
"path": ".."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
108
src/main.cpp
Executable file
108
src/main.cpp
Executable file
|
|
@ -0,0 +1,108 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <DS3231.h>
|
||||||
|
|
||||||
|
#include "photoresistance_ohm_retrieval.h"
|
||||||
|
#include "myFunction.h"
|
||||||
|
#include "sensormanager.h"
|
||||||
|
#include "traitement.h"
|
||||||
|
#include "storage_interface.h"
|
||||||
|
|
||||||
|
int ledPin = 2, decTemp = 4; // nb decimal temperature printing
|
||||||
|
const int nbPhotoSensor = 6;
|
||||||
|
uint8_t analogPin [nbPhotoSensor] = {A0, A1, A2 ,A3 ,A5 ,A6};
|
||||||
|
int32_t min_res [nbPhotoSensor] = {128, 160, 193, 96, 323, 96};
|
||||||
|
int32_t max_res [nbPhotoSensor] = {2062273, 5554006, 784809, 4755895, 1939035, 289546};
|
||||||
|
bool winter = 1;
|
||||||
|
|
||||||
|
SensorOhm test[nbPhotoSensor];
|
||||||
|
SensorManager s_manager;
|
||||||
|
Traitement tr;
|
||||||
|
|
||||||
|
RTClib myRTC;
|
||||||
|
DS3231 Clock;
|
||||||
|
|
||||||
|
// void setup() {
|
||||||
|
// Wire.begin();
|
||||||
|
// Serial.begin(9600);
|
||||||
|
// Serial.println("\nScanning I2C bus...");
|
||||||
|
|
||||||
|
// for (byte addr = 1; addr < 127; addr++) {
|
||||||
|
// Wire.beginTransmission(addr);
|
||||||
|
// if (Wire.endTransmission() == 0) {
|
||||||
|
// Serial.print("I2C device found at address 0x");
|
||||||
|
// Serial.println(addr, HEX);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// Serial.println("Scan complete.");
|
||||||
|
// constexpr time_t tstmp {1660644000UL};
|
||||||
|
|
||||||
|
// Clock.setEpoch(tstmp, false);
|
||||||
|
// // set to 24h
|
||||||
|
// Clock.setClockMode(false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Wire.begin();
|
||||||
|
Serial.begin(9600);
|
||||||
|
//pinMode(ledPin, OUTPUT);
|
||||||
|
|
||||||
|
s_manager.setup(nbPhotoSensor, analogPin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
DateTime now;
|
||||||
|
|
||||||
|
if (Serial.available()) {
|
||||||
|
unsigned long epoch = Serial.parseInt(); // read epoch
|
||||||
|
if (epoch > 1000000000UL) { // sanity check
|
||||||
|
// summer or winter time
|
||||||
|
if (winter == 1) {
|
||||||
|
epoch += 3600;
|
||||||
|
}
|
||||||
|
Clock.setEpoch(epoch);
|
||||||
|
Serial.print("RTC mis à jour avec epoch: ");
|
||||||
|
Serial.println(epoch);
|
||||||
|
}
|
||||||
|
while (Serial.available()) Serial.read(); // clean buffer
|
||||||
|
|
||||||
|
// Just for verification of DS3231 Data
|
||||||
|
// check now the data from ESP8266 and DS3231
|
||||||
|
// get year
|
||||||
|
bool century = false;
|
||||||
|
bool h12Flag;
|
||||||
|
bool pmFlag;
|
||||||
|
now = myRTC.now();
|
||||||
|
Serial.print("\n\n");
|
||||||
|
Serial.print(" DateTime of DS3231: ");
|
||||||
|
Serial.print(Clock.getYear(), DEC);
|
||||||
|
Serial.print("-");
|
||||||
|
Serial.print(Clock.getMonth(century), DEC);
|
||||||
|
Serial.print("-");
|
||||||
|
Serial.print(Clock.getDate(), DEC);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(Clock.getHour(h12Flag, pmFlag), DEC);
|
||||||
|
Serial.print(":");
|
||||||
|
Serial.print(Clock.getMinute(), DEC);
|
||||||
|
Serial.print(":");
|
||||||
|
Serial.print(Clock.getSecond(), DEC);
|
||||||
|
Serial.print(" - weekday ");
|
||||||
|
Serial.print(Clock.getDoW(), DEC);
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
printDate(Clock, decTemp);
|
||||||
|
|
||||||
|
s_manager.print_current_res();
|
||||||
|
s_manager.print_min_max_res();
|
||||||
|
|
||||||
|
int32_t res_array[nbPhotoSensor]/*, min_array[nbPhotoSensor], max_array[nbPhotoSensor]*/;
|
||||||
|
int16_t result[nbPhotoSensor];
|
||||||
|
s_manager.get_resistances(res_array, nbPhotoSensor);
|
||||||
|
|
||||||
|
tr.map_r(min_res, max_res, res_array, result, nbPhotoSensor);
|
||||||
|
print_named_tab(result, nbPhotoSensor, "int32_t normalised",(uint8_t) 18);
|
||||||
|
|
||||||
|
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
45
src/myFunction.cpp
Normal file
45
src/myFunction.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <DS3231.h>
|
||||||
|
|
||||||
|
#include "myFunction.h"
|
||||||
|
|
||||||
|
void printDate(DS3231 Clock, int8_t decTemp){
|
||||||
|
// RTClib myRTC;
|
||||||
|
|
||||||
|
// DateTime now = myRTC.now();
|
||||||
|
|
||||||
|
// Serial.print(now.year(), DEC);
|
||||||
|
// Serial.print('/');
|
||||||
|
// Serial.print(now.month(), DEC);
|
||||||
|
// Serial.print('/');
|
||||||
|
// Serial.print(now.day(), DEC);
|
||||||
|
// Serial.print(' ');
|
||||||
|
// Serial.print(now.hour(), DEC);
|
||||||
|
// Serial.print(':');
|
||||||
|
// Serial.print(now.minute(), DEC);
|
||||||
|
// Serial.print(':');
|
||||||
|
// Serial.print(now.second(), DEC);
|
||||||
|
// Serial.println();
|
||||||
|
|
||||||
|
|
||||||
|
float temp = Clock.getTemperature();
|
||||||
|
RTClib myRTC;
|
||||||
|
DateTime now = myRTC.now();
|
||||||
|
|
||||||
|
Serial.print("\n\n");
|
||||||
|
Serial.print("DateTime of RTC: ");
|
||||||
|
Serial.print(now.year(), DEC);
|
||||||
|
Serial.print("-");
|
||||||
|
Serial.print(now.month(), DEC);
|
||||||
|
Serial.print("-");
|
||||||
|
Serial.print(now.day(), DEC);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print(now.hour(), DEC);
|
||||||
|
Serial.print(":");
|
||||||
|
Serial.print(now.minute(), DEC);
|
||||||
|
Serial.print(":");
|
||||||
|
Serial.print(now.second(), DEC);
|
||||||
|
Serial.print(" | Temp of RTC: ");
|
||||||
|
Serial.println(temp, decTemp);
|
||||||
|
}
|
||||||
23
src/myFunction.h
Normal file
23
src/myFunction.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef MYFUNCTION_H
|
||||||
|
#define MYFUNCTION_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <DS3231.h>
|
||||||
|
|
||||||
|
void printDate(DS3231 Clock, int8_t decTemp);
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void print_named_tab(T v_array, uint8_t array_size, const char *tab_name, uint8_t size_tab_name) {
|
||||||
|
char buffer [32];
|
||||||
|
|
||||||
|
for(int i = 0; i < array_size; i++){
|
||||||
|
// snprintf(buffer, sizeof(buffer), tab_name, " n° "), i, " : ", v_array[i];
|
||||||
|
snprintf(buffer, sizeof(buffer), "%s n° %d : ", tab_name, i);
|
||||||
|
Serial.print(buffer);
|
||||||
|
Serial.print(v_array[i], DEC);
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
226
storage_structure.drawio
Normal file
226
storage_structure.drawio
Normal file
|
|
@ -0,0 +1,226 @@
|
||||||
|
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/28.2.8 Chrome/140.0.7339.240 Electron/38.4.0 Safari/537.36" version="28.2.8">
|
||||||
|
<diagram name="Page-1" id="XH51GEJ8jh-4uo7cCshW">
|
||||||
|
<mxGraphModel dx="679" dy="459" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="0" />
|
||||||
|
<mxCell id="1" parent="0" />
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-1" value="Offset" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="80" width="40" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-2" value="<font style="color: rgb(51, 51, 255);">Octet</font>" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="120" y="80" width="40" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-3" value="Octet" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="100" width="40" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-4" value="<font style="color: rgb(51, 51, 255);">Bit</font>" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="120" y="100" width="40" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-5" value="0" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="120" width="40" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-6" value="<font style="color: rgb(51, 51, 255);">0</font>" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="120" y="120" width="40" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-7" value="0" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="160" y="80" width="80" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-8" value="2" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="240" y="80" width="80" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-9" value="3" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="320" y="80" width="80" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-10" value="4" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="400" y="80" width="80" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-59" value="0" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="160" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-60" value="1" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="170" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-61" value="2" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="180" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-62" value="3" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="190" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-63" value="4" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="200" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-64" value="5" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="210" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-65" value="6" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="220" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-66" value="7" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="230" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-67" value="8" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="240" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-68" value="9" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="250" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-69" value="10" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="260" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-70" value="11" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="270" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-71" value="12" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="280" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-72" value="13" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="290" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-73" value="14" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="300" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-74" value="15" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="310" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-75" value="16" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="320" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-76" value="17" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="330" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-77" value="18" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="340" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-78" value="19" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="350" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-79" value="20" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="360" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-80" value="21" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="370" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-81" value="22" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="380" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-82" value="23" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="390" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-83" value="24" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="400" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-84" value="25" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="410" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-85" value="26" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="420" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-86" value="27" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="430" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-87" value="28" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="440" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-88" value="29" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="450" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-89" value="30" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="460" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-90" value="31" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="470" y="100" width="10" height="20" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-91" value="4" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="150" width="40" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-92" value="<font style="color: rgb(51, 51, 255);">32</font>" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="120" y="150" width="40" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-93" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="160" y="120" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-94" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="225" y="280" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-95" value="<font style="font-size: 8px;">Bool : Final set of measures ? True if final or False if isn't</font>" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="235" y="280" width="110" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-96" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="170" y="120" width="20" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-97" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="205" y="230" width="20" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-98" value="<font style="font-size: 8px;">Bool : Timestamp -&gt; no (00), one for a pack (01), yes for every measures (10)</font>" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="225" y="230" width="140" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-99" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="190" y="120" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-100" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="375" y="230" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-101" value="<font style="font-size: 8px;">Bool : Photo-res ?</font><div><span style="font-size: 8px;">True if at least one or False if none</span></div>" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="385" y="230" width="105" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-102" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="200" y="120" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-103" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="280" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-104" value="<font style="font-size: 8px;">Bool : Temperature captor ?</font><div><span style="font-size: 8px;">True if at least one or False if none</span></div>" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="90" y="280" width="135" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-105" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#000000;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="220" y="120" width="20" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-107" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#000000;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="355" y="280" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-109" value="<font style="font-size: 8px;">Empty</font>" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="365" y="280" width="30" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-110" value="<font size="1">Int_8 : measures schedules</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="240" y="120" width="80" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-112" value="<span style="font-size: x-small;">Int_8</span><font size="1">&nbsp;: Nb photo-sensors</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="320" y="120" width="80" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-113" value="<span style="font-size: x-small;">Int_8</span><font size="1">&nbsp;: Nb Temp sensors</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="400" y="120" width="80" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-115" value="<span style="font-size: x-small;">Int_8</span><font size="1">&nbsp;: photo measures size</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="160" y="150" width="80" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-116" value="<span style="font-size: x-small;">Int_8</span><font size="1">&nbsp;: temp measures size</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="240" y="150" width="80" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-117" value="<font size="1">Int_16 : Nb measures</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="320" y="150" width="160" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-119" value="8" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="180" width="40" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-120" value="<font style="color: rgb(51, 51, 255);">64</font>" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="120" y="180" width="40" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-122" value="<span style="font-size: x-small;">Int_16 :&nbsp;</span><font size="1">Next package</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="160" y="180" width="160" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-123" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="80" y="230" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-124" value="<font style="font-size: 8px;">Bool : This is a package ? True if exist or False if isn't</font>" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="90" y="230" width="110" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="YM7KdBzIgsha6Ef9Inx_-125" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" parent="1" vertex="1">
|
||||||
|
<mxGeometry x="210" y="120" width="10" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="okEfVRTz3dfG7SeP_zBs-1" value="<font size="1">Starting data measures</font>" style="rounded=0;whiteSpace=wrap;html=1;fillStyle=auto;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="320" y="180" width="160" height="30" as="geometry" />
|
||||||
|
</mxCell>
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
||||||
BIN
storage_structure.drawio.png
Normal file
BIN
storage_structure.drawio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 167 KiB |
12
test/EEPROM_test_struct.cpp
Normal file
12
test/EEPROM_test_struct.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <unity.h>
|
||||||
|
#include "storage_interface.h"
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
Serial.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_put_struct(){
|
||||||
|
|
||||||
|
}
|
||||||
11
test/README
Executable file
11
test/README
Executable file
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
This directory is intended for PlatformIO Test Runner and project tests.
|
||||||
|
|
||||||
|
Unit Testing is a software testing method by which individual units of
|
||||||
|
source code, sets of one or more MCU program modules together with associated
|
||||||
|
control data, usage procedures, and operating procedures, are tested to
|
||||||
|
determine whether they are fit for use. Unit testing finds problems early
|
||||||
|
in the development cycle.
|
||||||
|
|
||||||
|
More information about PlatformIO Unit Testing:
|
||||||
|
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||||
12
time.py
Executable file
12
time.py
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import serial
|
||||||
|
import time
|
||||||
|
|
||||||
|
# Remplace par ton port Arduino
|
||||||
|
ser = serial.Serial('/dev/ttyACM0', 9600)
|
||||||
|
time.sleep(2) # attendre que l’Arduino démarre
|
||||||
|
|
||||||
|
epoch = int(time.time()) # secondes depuis 1970
|
||||||
|
ser.write(f"{epoch}\n".encode()) # envoie sous forme texte, terminé par \n
|
||||||
|
|
||||||
|
ser.close()
|
||||||
|
print(f"Envoyé epoch: {epoch}")
|
||||||
Loading…
Reference in a new issue