Skip to content

Commit

Permalink
slider fast scrub 🥳
Browse files Browse the repository at this point in the history
  • Loading branch information
johntalton committed Jun 6, 2024
1 parent 9ac8358 commit 83992e8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion public/devices-i2c/aw9523.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ export class AW9523Builder {
}

for (const { port, form } of [ { port: 0, form: form0 }, { port: 1, form: form1 } ]) {
const dimmingSliders = form?.querySelectorAll('input[name="dimming"]')

form?.addEventListener('change', asyncEvent(async event => {
event.preventDefault()


const whatChanged = event.target.getAttribute('name')

const formData = new FormData(form)
Expand Down Expand Up @@ -175,6 +176,27 @@ export class AW9523Builder {

await refresh()
}))

dimmingSliders?.forEach(dimmingSlider => {
const detailsElem = dimmingSlider.closest('details[data-gpio]')
const gpioStr = detailsElem.getAttribute('data-gpio')
const gpio = parseInt(gpioStr)
const pin = (gpio >= 8) ? gpio - 8 : gpio

let future = undefined
let target = 0

dimmingSlider?.addEventListener('input', event => {
//console.log('fast slider')

target = parseInt(event.target.value)

if(future) { return }

future = this.#device.setDimming(port, pin, target)
future.finally(() => { future = undefined })
})
})
}

const resetButton = root.querySelector('button[data-reset]')
Expand Down

0 comments on commit 83992e8

Please sign in to comment.