Merge branch 'main' of https://git.serveurtom.fr/Tom/24hducode
This commit is contained in:
@@ -7,6 +7,7 @@ const DEBUG = false;
|
|||||||
let socketMoteur = undefined;
|
let socketMoteur = undefined;
|
||||||
let socketInfos = undefined;
|
let socketInfos = undefined;
|
||||||
let moteur = undefined;
|
let moteur = undefined;
|
||||||
|
let led = undefined;
|
||||||
let position = 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 {
|
class Position {
|
||||||
|
|
||||||
posX = 0;
|
posX = 0;
|
||||||
@@ -144,6 +170,7 @@ class Position {
|
|||||||
function run() {
|
function run() {
|
||||||
connectSockets();
|
connectSockets();
|
||||||
moteur = new Moteur();
|
moteur = new Moteur();
|
||||||
|
led = new Led();
|
||||||
position = new Position(socketInfos);
|
position = new Position(socketInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user