This commit is contained in:
赵鑫 2022-09-05 01:05:08 +08:00
parent 88f261f311
commit 83546bed9c

View File

@ -129,24 +129,23 @@
</div>
</div>
<button onclick="client.emit('action', {action:'clear'})">clear all</button>
<button onclick="client.emit('operation', {action:'clear'})">clear</button>
<br>
<button onclick="client.emit('action', {action:'hello'})">hello</button>
<button onclick="client.emit('operation', {action:'hello'})">hello</button>
<br>
<button onclick="client.emit('action', {action:'flash'})">flash</button>
<button onclick="client.emit('operation', {action:'flash'})">flash</button>
<br>
<button onclick="client.emit('action', {action:'temp'})">temp</button>
<button onclick="client.emit('operation', {action:'temp'})">temp</button>
<div id="rpis"></div>
<script src="http://pi/sensehat/socket.io/socket.io.js"></script>
<script>
const client = io.connect('ws://pi', { path: '/sensehat/socket.io', })
client.on("message", (message) => console.log(message))
// function turnon(led) {
// const { x, y } = led.dataset
// const action = led.classList.toggle('on') ? 'on' : 'off'
// client.emit('action', { action, x, y })
// }
function turnon(led) {
const { x, y } = led.dataset
const action = led.classList.toggle('on') ? 'on' : 'off'
client.emit('operation', { action, x, y })
}
// client.on('leds', (array) => {
// const leds = document.querySelectorAll('.led')
// for (let y = 0; y < 8; y++) {