57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
#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
|