Skip to content

Commit

Permalink
arret automatique dimmer
Browse files Browse the repository at this point in the history
  • Loading branch information
xlyric committed Feb 6, 2025
1 parent 134db8c commit 1ac6815
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/config/config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CONFIG
#define CONFIG

#define VERSION "Version 20250205"
#define VERSION "Version 20250206"
#define FS_RELEASE "20250205" // date de la release

constexpr size_t TEMPERATURE_PRECISION=11;
Expand Down Expand Up @@ -124,6 +124,7 @@ constexpr size_t LOG_MAX_STRING_LENGTH=1500 ;// taille max des logs stockées
#define COOLER D7 // 0 : off -> 1 : On --> need a dry contact or opto
#endif

#define TIME_BOOST 3600 // temps de boost
#define TIME_BOOST 3600 // temps de boost en secondes
#define AUTO_OFF 5 // temps de coupure automatique en minutes
#endif

13 changes: 13 additions & 0 deletions src/function/unified_dimmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ extern dimmerLamp dimmer3;

// @brief structure pour uniformiser les commandes de puissances entre robotdyn et SSR
struct gestion_puissance {
private:
unsigned long last_time = millis();

public: float power;

// setter
void set_power(float is_set_power){
last_time = millis();
/// si la température est supérieur à la température max on coupe tout
if ( sysvar.celsius[sysvar.dallas_maitre]> config.maxtemp ) { is_set_power = 0; }
else if ( is_set_power > config.maxpow ) { is_set_power = config.maxpow; }
Expand Down Expand Up @@ -192,6 +196,15 @@ public: float power;
ssr_burst.set_power(0);
#endif
}

// fonction de coupure automatique après un certain temps
void auto_off(int delay_off) {
if (( millis() - last_time > delay_off*60*1000) && (power > 0) ) {
dimmer_off();
Serial.println("dimmer auto off");
}
}

};


Expand Down
9 changes: 8 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,14 @@ void loop() {
if (strlen(config.SubscribeTEMP) == 0 ) {
restart_dallas();
}
delay(100); // 24/01/2023 changement 500 à 100ms pour plus de réactivité

//// protection contre l'absence de commande
if ( !programme.run && !programme_marche_forcee.run ) {
unified_dimmer.auto_off(AUTO_OFF);
}

delay(100);
// 24/01/2023 changement 500 à 100ms pour plus de réactivité
}

///////////////
Expand Down

0 comments on commit 1ac6815

Please sign in to comment.