-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathventilos.cpp
More file actions
97 lines (77 loc) · 2.84 KB
/
Copy pathventilos.cpp
File metadata and controls
97 lines (77 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// include core Wiring API
#include "Arduino.h"
#include "Arducase.h"
#include "ventilos.h"
#include "modes.h"
//=========================================================================================================//
// _______________________________________ VENTILATEURS __________________________________________________
Ventilo vent_pc;
Ventilo vent_rad;
Ventilo vent_tec;
Ventilo *ventilos[MAX_NB_VENTILO];
int nb_ventilos = 0;
extern int nb_TEC_ON;
void create_ventilo(struct Ventilo &ventilo, int pin, char *name, int is_tec){
if (nb_ventilos + 1 > MAX_NB_VENTILO){
return;
}
ventilos[nb_ventilos] = &ventilo;
nb_ventilos++;
ventilo.pin = pin;
ventilo.name = name;
ventilo.curent_PWM = 0;
ventilo.last_PWM = 0;
ventilo.is_tec = is_tec;
ventilo.nb_cam = 0;
}
void init_ventilos(){
// _________________________________ Gestion des Ventilos _____________________________________________
// variable pin nom
create_ventilo(vent_pc , 2 , "vent_pc" , 0); //Groupe de ventilateur à l'intérieur du pc
create_ventilo(vent_rad , 3 , "vent_rad" , 0); //Groupe de ventilateur du radiateur PC
create_ventilo(vent_tec , 5 , "vent_tec" , 1); //Groupe de ventilateur de la watercase
}
void init_ventilo_regulation(){
int min = percent_to_PWM(selected_mode->pourcentage_min);
for (int i = 0; i < nb_ventilos; ++i) {
ventilos[i]->last_PWM = ventilos[i]->curent_PWM;
if (nb_TEC_ON == 0 && ventilos[i]->is_tec) {
ventilos[i]->curent_PWM = 0;
} else {
ventilos[i]->curent_PWM = min;
}
}
}
void finish_ventilo_regulation(){
int nb_boost = 0;
for (int i = 0; i < nb_ventilos; ++i) {
if (ventilos[i]->curent_PWM < PWM_VENTILATEUR_MIN){ // on est en dessous de la capacite du ventilateur, on l'arrete
analogWrite(ventilos[i]->pin, 0);
ventilos[i]->curent_PWM = 0;
}
else {
if (ventilos[i]->last_PWM < PWM_VENTILATEUR_MIN ){ //On est juste au dessus de la capacité du ventilateur, on le démarre avec un boost à fond pendant 200ms
analogWrite(ventilos[i]->pin, 255);
for (int n = 0; n < ventilos[i]->nb_cam; ++n) {
ventilos[i]->cameras[n]->fresh_boosted ++;
}
nb_boost ++;
}
else {
analogWrite(ventilos[i]->pin, ventilos[i]->curent_PWM);
}
}
}
if (nb_boost > 0){
delay(200);
}
}
void add_cam_to_ventilo(struct Camera &camera, struct Ventilo &ventilo){ //Ajout du ventilateur à la caméra correspondante à allumer lorsque celui-ci se mets en route.
if( ventilo.nb_cam + 1 > MAX_NB_CAM ){
return;
}
ventilo.cameras[ ventilo.nb_cam ] = &camera;
ventilo.nb_cam ++;
}
// _______________________________________ VENTILATEURS __________________________________________________
//=========================================================================================================//