matrix json
This commit is contained in:
10
src/index.js
10
src/index.js
@@ -5,7 +5,7 @@ const SocketIO = require("socket.io");
|
||||
var mqtt = require('mqtt')
|
||||
var client = mqtt.connect('mqtt://192.168.1.105',{username:'mdchaparror',password:'un80187452'})
|
||||
|
||||
app.set("port", 6000);
|
||||
app.set("port", 3000);
|
||||
app.use(express.static(path.join(__dirname, "public")));
|
||||
console.log(__dirname);
|
||||
|
||||
@@ -23,5 +23,13 @@ io.on("connection", (socket) => {
|
||||
client.publish('matrix/rgb',mensaje.color_rgb);
|
||||
console.log("mensaje MQTT =>",mensaje)
|
||||
});
|
||||
|
||||
socket.on("mensaje2", (mensaje) => {
|
||||
client.publish('matrix/full',mensaje);
|
||||
console.log("mensaje2 MQTT =>",mensaje)
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -9,6 +9,13 @@ var matrixMessage ={
|
||||
color_rgb:'255,0,0'
|
||||
}
|
||||
|
||||
var matrixMessage2 ={
|
||||
msg:'Mensaje inicial',
|
||||
R:255,
|
||||
G:0,
|
||||
B:0
|
||||
}
|
||||
|
||||
jscolor.presets.default = {
|
||||
format:'rgb', previewSize:40, mode:'HVS'
|
||||
};
|
||||
@@ -16,8 +23,12 @@ jscolor.presets.default = {
|
||||
enviar_mensaje.addEventListener('click', function () {
|
||||
|
||||
matrixMessage.message=mensaje.value;
|
||||
console.log(matrixMessage)
|
||||
socket.emit('mensaje',matrixMessage)
|
||||
matrixMessage2.msg=mensaje.value;
|
||||
|
||||
//console.log(matrixMessage)
|
||||
console.log(JSON.stringify(matrixMessage2))
|
||||
//socket.emit('mensaje',matrixMessage)
|
||||
socket.emit('mensaje2',JSON.stringify(matrixMessage2))
|
||||
})
|
||||
|
||||
socket.on('Error',(mensaje)=>{
|
||||
@@ -37,4 +48,9 @@ function update(color) {
|
||||
//console.log(color.toRGBString())
|
||||
matrixMessage.color_rgb = `${Math.trunc(color.channel('R'))},${Math.trunc(color.channel('G'))},${Math.trunc(color.channel('B'))}`
|
||||
|
||||
matrixMessage2.R = Math.trunc(color.channel('R'));
|
||||
matrixMessage2.G = Math.trunc(color.channel('G'))
|
||||
matrixMessage2.B = Math.trunc(color.channel('B'))
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user