This commit is contained in:
Nogard
2025-03-22 15:30:57 +01:00
+27
View File
@@ -7,6 +7,7 @@ const DEBUG = false;
let socketMoteur = undefined;
let socketInfos = undefined;
let moteur = undefined;
let led = undefined;
let position = undefined;
@@ -104,6 +105,31 @@ class Moteur {
}
class Led {
http = undefined;
send(color){
this.http = new XMLHttpRequest();
this.http.open('POST', 'http://' + URL + '/led/set_color', true);
this.http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
this.http.send('ledcolor=' + color);
}
red(){
this.send("#ff0000")
}
green(){
this.send("#00ff00")
}
blue(){
this.send("#0000ff")
}
}
class Position {
posX = 0;
@@ -144,6 +170,7 @@ class Position {
function run() {
connectSockets();
moteur = new Moteur();
led = new Led();
position = new Position(socketInfos);
}