update
This commit is contained in:
parent
ace13b7f6d
commit
4e17a28519
@ -129,25 +129,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="button" data-action="clear">clear all</button>
|
||||
<button onclick="emit('clear')">clear all</button>
|
||||
<br>
|
||||
<button class="button" data-action="hello">hello</button>
|
||||
<button onclick="emit('hello')">hello</button>
|
||||
<br>
|
||||
<button class="button" data-action="flash">flash</button>
|
||||
<button onclick="emit('flash')">flash</button>
|
||||
<br>
|
||||
<button class="button" data-action="temp">temp</button>
|
||||
<button onclick="emit('temp')">temp</button>
|
||||
|
||||
<script src="socket.io/socket.io.js"></script>
|
||||
<script>
|
||||
const client = io()
|
||||
document.addEventListener('click', (event) => {
|
||||
const item = event.target
|
||||
if (item.classList.contains('button')) {
|
||||
const { action } = item.dataset
|
||||
document.querySelectorAll('.led').forEach((led) => led.classList.remove('on'))
|
||||
client.emit('action', { action })
|
||||
}
|
||||
})
|
||||
function emit(action) {
|
||||
client.emit('action', { action })
|
||||
}
|
||||
function turnon(led) {
|
||||
const { x, y } = led.dataset
|
||||
const action = led.classList.toggle('on') ? 'on' : 'off'
|
||||
|
@ -8,7 +8,7 @@ app.use(express.static('public'))
|
||||
sense.setRotation(180)
|
||||
sense.lowLight = true
|
||||
|
||||
const blue = [50, 50, 200]
|
||||
const blue = [0, 0, 100]
|
||||
flash()
|
||||
io.on('connection', (client) => {
|
||||
client.on('action', ({ action, x, y }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user