add leds all indicators

This commit is contained in:
Alejandro Diaz 2023-09-13 16:00:29 -06:00
parent f6392a43b2
commit 87260d709d
2 changed files with 126 additions and 15 deletions

View file

@ -22,14 +22,14 @@
function toggle_leds(led, x, y, w, h) {
var image = new Image();
$.get("/led/"+ led +"/", function (data) {
console.log(data);
if (led < 6 && led > 0) {
if (data == "off"){
$("#but"+led).text("Turn off "+led)
var image = new Image();
place_blank(x, y, w, h);
image.src = "https://www.freepngimg.com/thumb/light/78155-icons-light-idea-computer-lighting-incandescent-bulb.png";
// Esperar a que la imagen se cargue antes de dibujarla
@ -40,6 +40,8 @@
} else {
$("#but"+led).text("Turn on "+led)
var image = new Image();
place_blank(x, y, w, h);
image.src = "https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.pngmart.com%2Ffiles%2F7%2FLight-Bulb-PNG-Picture.png&f=1&nofb=1&ipt=afac257c7b6ce4e6c1fda1b32c1775c687841d1c138e1257f3f821cbff14c5e0&ipo=images";image.src = "https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.pngmart.com%2Ffiles%2F7%2FLight-Bulb-PNG-Picture.png&f=1&nofb=1&ipt=afac257c7b6ce4e6c1fda1b32c1775c687841d1c138e1257f3f821cbff14c5e0&ipo=images";
// Esperar a que la imagen se cargue antes de dibujarla
@ -47,6 +49,114 @@
ctx.drawImage(image, x, y, w, h); // (imagen, x, y)
};
}
} else if (led == 6){
place_blank(20, 80, 100, 100);
place_blank(500, 400, 100, 100);
place_blank(50, 400, 100, 100);
place_blank(350, 400, 100, 100);
place_blank(350, 50, 100, 100);
var image = new Image();
var src = "https://www.freepngimg.com/thumb/light/78155-icons-light-idea-computer-lighting-incandescent-bulb.png";
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 20, 80, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 500, 400, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 50, 400, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 350, 400, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 350, 50, 100, 100); // (imagen, x, y)
};
} else if (led == 0){
place_blank(20, 80, 100, 100);
place_blank(500, 400, 100, 100);
place_blank(50, 400, 100, 100);
place_blank(350, 400, 100, 100);
place_blank(350, 50, 100, 100);
var image = new Image();
var src = "https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.pngmart.com%2Ffiles%2F7%2FLight-Bulb-PNG-Picture.png&f=1&nofb=1&ipt=afac257c7b6ce4e6c1fda1b32c1775c687841d1c138e1257f3f821cbff14c5e0&ipo=images";image.src = "https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.pngmart.com%2Ffiles%2F7%2FLight-Bulb-PNG-Picture.png&f=1&nofb=1&ipt=afac257c7b6ce4e6c1fda1b32c1775c687841d1c138e1257f3f821cbff14c5e0&ipo=images";
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 20, 80, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 500, 400, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 50, 400, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 350, 400, 100, 100); // (imagen, x, y)
};
var image = new Image();
image.src = src;
// Esperar a que la imagen se cargue antes de dibujarla
image.onload = function () {
ctx.drawImage(image, 350, 50, 100, 100); // (imagen, x, y)
};
}
});
}
@ -143,7 +253,7 @@
// Etiquetas de las habitaciones
ctx.fillStyle = "#000000"; // Color negro
ctx.font = "30px Arial";
ctx.fillText("Cuarto 1", 100, 150);
ctx.fillText("Cuarto 1", 150, 150);
ctx.fillText("Cuarto 2", 600, 450);
ctx.fillText("Sala", 200, 450);
ctx.fillText("Cocina", 600, 150);