first commit
This commit is contained in:
56
ESP8266_BATTERIE_INJECTION/regulation.h
Normal file
56
ESP8266_BATTERIE_INJECTION/regulation.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifdef PIN_REGULATION
|
||||
|
||||
void setReg(int speed_to_set)
|
||||
{
|
||||
current_regulation = speed_to_set;
|
||||
if (current_regulation > 100) current_regulation = 100;
|
||||
if (current_regulation <= 1) {
|
||||
current_regulation = 0;
|
||||
}
|
||||
|
||||
Serial.println(current_regulation);
|
||||
|
||||
analogWrite(PIN_REGULATION, current_regulation * 2.55);// send current_regulation value to motor
|
||||
|
||||
blink(); server.sendHeader("Location", "/?message='Régulation modifiée'");
|
||||
server.send(302, "text/plain", "Redirection vers la page principale");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void exact_reg() {
|
||||
int value_to_set = getParamFromGet("value").toInt();
|
||||
|
||||
current_regulation = value_to_set;
|
||||
if (current_regulation > 100) current_regulation = 100;
|
||||
if (current_regulation < 0) {
|
||||
current_regulation = 0;
|
||||
}
|
||||
|
||||
setReg(current_regulation);
|
||||
|
||||
}
|
||||
void plus_reg() {
|
||||
int value_to_set = getParamFromGet("value").toInt();
|
||||
if (value_to_set <= 0) {
|
||||
value_to_set = 5;
|
||||
}
|
||||
current_regulation += value_to_set;
|
||||
setReg(current_regulation);
|
||||
|
||||
}
|
||||
|
||||
void minus_reg() {
|
||||
int value_to_set = getParamFromGet("value").toInt();
|
||||
if (value_to_set <= 0) {
|
||||
value_to_set = 5;
|
||||
}
|
||||
current_regulation -= value_to_set;
|
||||
setReg(current_regulation);
|
||||
}
|
||||
|
||||
void stop_reg() {
|
||||
current_regulation = 0;
|
||||
setReg(current_regulation);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user