mirror of
https://gitlab.com/Luci_/arduino-photometrics.git
synced 2026-04-03 11:35:37 +02:00
fix average type
This commit is contained in:
parent
4cf327504f
commit
5b5375dd9c
16
src/main.cpp
16
src/main.cpp
|
|
@ -15,7 +15,7 @@ uint8_t ledPin = 2, alarm_pin = 19, decTemp = 4, nb_average_measure = 10; // nb
|
||||||
const uint8_t nbPhotoSensor = 6, nbTempSensor = 1;
|
const uint8_t nbPhotoSensor = 6, nbTempSensor = 1;
|
||||||
uint8_t analogPin [nbPhotoSensor] = {A0, A1, A2 ,A3 ,A5 ,A6}, schedule = 0, photo_sensor_size = sizeof(uint8_t), temp_sensor_size = sizeof(uint8_t);
|
uint8_t analogPin [nbPhotoSensor] = {A0, A1, A2 ,A3 ,A5 ,A6}, schedule = 0, photo_sensor_size = sizeof(uint8_t), temp_sensor_size = sizeof(uint8_t);
|
||||||
int32_t min_res [nbPhotoSensor] = {128- 30, 160-30, 193-80, 96-10, 323-180, 96-10}; // Manual measurement of personal sensors
|
int32_t min_res [nbPhotoSensor] = {128- 30, 160-30, 193-80, 96-10, 323-180, 96-10}; // Manual measurement of personal sensors
|
||||||
int32_t max_res [nbPhotoSensor] = {2062273-206227, 5554006-555400, 784809-78480, 4755895-475589, 1939035-193903, 289546-28954}; // Manual measurement of personal sensors // less 10 %, there are more résidual light in the measurement working (city context) than the box calibration
|
int32_t max_res [nbPhotoSensor] = {2062273, 5554006/2, 784809, 4755895, 1939035, 289546}; // Manual measurement of personal sensors
|
||||||
uint32_t time_sec_sum;
|
uint32_t time_sec_sum;
|
||||||
bool winter = true, timestamping = true, photo_sensor = true, temp_sensor = true, awake = true;
|
bool winter = true, timestamping = true, photo_sensor = true, temp_sensor = true, awake = true;
|
||||||
static byte state = true;
|
static byte state = true;
|
||||||
|
|
@ -151,6 +151,7 @@ void loop() {
|
||||||
uint32_t unixTime;
|
uint32_t unixTime;
|
||||||
int16_t mapped_val_array[nb_average_measure][nbPhotoSensor];
|
int16_t mapped_val_array[nb_average_measure][nbPhotoSensor];
|
||||||
uint8_t converted_val_array[nb_average_measure][nbPhotoSensor], temp[nbTempSensor];
|
uint8_t converted_val_array[nb_average_measure][nbPhotoSensor], temp[nbTempSensor];
|
||||||
|
uint16_t acc[nbPhotoSensor];
|
||||||
|
|
||||||
unixTime = myRTC.now().unixtime();
|
unixTime = myRTC.now().unixtime();
|
||||||
|
|
||||||
|
|
@ -173,18 +174,23 @@ void loop() {
|
||||||
delay(delay_bet_measure);
|
delay(delay_bet_measure);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i < nb_average_measure; i++){
|
// init accumulator
|
||||||
|
for(int i = 0; i < nbPhotoSensor; i++){
|
||||||
|
acc[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < nb_average_measure; i++){
|
||||||
for(int y = 0; y < nbPhotoSensor; y++){
|
for(int y = 0; y < nbPhotoSensor; y++){
|
||||||
converted_val_array[0][y] += converted_val_array[i][y];
|
acc[y] += (uint16_t) converted_val_array[i][y];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int y = 0; y < nbPhotoSensor; y++){
|
for(int y = 0; y < nbPhotoSensor; y++){
|
||||||
converted_val_array[0][y] = converted_val_array[0][y] / nb_average_measure;
|
converted_val_array[0][y] = (uint8_t)(acc[y] / (uint16_t) nb_average_measure);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Readed values from sensors:");
|
Serial.println("Readed values from sensors:");
|
||||||
print_named_tab(converted_val_array[0], nbPhotoSensor, "int8_t normalised");
|
// print_named_tab(converted_val_array[0], nbPhotoSensor, "int8_t normalised");
|
||||||
#endif
|
#endif
|
||||||
// TODO : apply same change of max limit to avoid EEPROM overflow
|
// TODO : apply same change of max limit to avoid EEPROM overflow
|
||||||
sto_intrf.add_measure(converted_val_array[0], temp, unixTime, nbPhotoSensor, nbTempSensor);
|
sto_intrf.add_measure(converted_val_array[0], temp, unixTime, nbPhotoSensor, nbTempSensor);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue