refactor(server): ♻️ refactor code to reduce complexity
This commit is contained in:
parent
f1a70e6cfb
commit
704a352724
|
@ -132,46 +132,36 @@ int convertRotToSteps(int rotation)
|
|||
// Lorsqu'une commande arrive au serveur, cette fonction permet
|
||||
void requestCheck(String command, float value)
|
||||
{
|
||||
if (command == "forward")
|
||||
{
|
||||
globalCommand = "forward";
|
||||
commandRunning = true;
|
||||
stopCommand = false;
|
||||
globalValue = convertLengthToSteps(value);
|
||||
}
|
||||
else if (command == "backward")
|
||||
{
|
||||
globalCommand = "backward";
|
||||
commandRunning = true;
|
||||
stopCommand = false;
|
||||
globalValue = convertLengthToSteps(value);
|
||||
}
|
||||
else if (command == "left")
|
||||
{
|
||||
globalCommand = "left";
|
||||
commandRunning = true;
|
||||
stopCommand = false;
|
||||
globalValue = convertRotToSteps(value);
|
||||
}
|
||||
else if (command == "right")
|
||||
{
|
||||
globalCommand = "right";
|
||||
commandRunning = true;
|
||||
stopCommand = false;
|
||||
globalValue = convertRotToSteps(value);
|
||||
}
|
||||
else if (command == "stop")
|
||||
if (command == "stop")
|
||||
{
|
||||
globalCommand = "stop";
|
||||
commandRunning = true;
|
||||
stopCommand = true;
|
||||
}
|
||||
else if setGlobals (command, value)
|
||||
;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
globalValue = 474;
|
||||
}
|
||||
}
|
||||
|
||||
void setGlobals(String command, float value)
|
||||
{
|
||||
// Assert command before updating globals
|
||||
if (command != "forward" && command != "backward" && command != "left" && command != "right")
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
// Update globals
|
||||
globalCommand = command;
|
||||
commandRunning = true;
|
||||
stopCommand = false;
|
||||
globalValue = convertLengthToSteps(value);
|
||||
}
|
||||
|
||||
void connectWiFi()
|
||||
{
|
||||
WiFi.mode(WIFI_AP);
|
||||
|
|
Loading…
Reference in a new issue