Skip to content

Commit

Permalink
view transition and touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
johntalton committed Jan 11, 2024
1 parent c95b120 commit f23d84d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
},
"dependencies": {
"@johntalton/adt7410": "../adt7410",
"@johntalton/aht20": "../aht20",
"@johntalton/adxl375": "../adxl375",
"@johntalton/ags02ma": "../ags02ma",
"@johntalton/aht20": "^1.1.0",
"@johntalton/am2320": "^1.0.0",
"@johntalton/and-other-delights": "../and-other-delights",
"@johntalton/bitsmush": "^1.0.0",
Expand Down
4 changes: 4 additions & 0 deletions public/css/adxl375.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
adxl375-config {
& > button {
margin-block-end: 1em;
}

& canvas {
border: 1px solid black;
background-color: white;
border-radius: 1em;
}
}
12 changes: 9 additions & 3 deletions public/devices-i2c/adxl375.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ADXL375 } from '@johntalton/adxl375'

const delayMs = ms => new Promise(resolve => setTimeout(resolve, ms))

let going = false

export class ADXL375Builder {
#abus
#device
Expand Down Expand Up @@ -60,7 +62,9 @@ export class ADXL375Builder {

}

async close() { }
async close() {
going = false
}

signature() { }

Expand Down Expand Up @@ -140,9 +144,11 @@ export class ADXL375Builder {
}



Promise.resolve().then(async () => {
while(true) {
await delayMs(100)
going = true
while(going) {
// await delayMs(10)

const { entries } = await this.#device.getFIFOStatus()
console.log('fetch', entries)
Expand Down
12 changes: 9 additions & 3 deletions public/devices-serial/exc-i2cdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export class ExcameraI2CDriverUIBuilder {

const deviceGuess = guessSelectElem.value

// todo change over to newer post message style
self.#ui.addI2CDevice({
port: self.#port,
type: deviceGuess,
Expand Down Expand Up @@ -281,7 +282,7 @@ export class ExcameraI2CDriverUIBuilder {
</select>
</form>
<form data-info>
<form data-info method="dialog">
<label>Model</label>
<output name="model">${identifier}</output>
Expand All @@ -306,7 +307,7 @@ export class ExcameraI2CDriverUIBuilder {
<label>SCL</label>
<output name="scl"></output>
<button id="updateConfigInfo">Update</button>
<button id="updateConfigInfo" type="button">Update</button>
</form>
Expand Down Expand Up @@ -492,6 +493,8 @@ export class ExcameraI2CDriverUIBuilder {

const updateButton = stuff.getElementById('updateConfigInfo')
updateButton.addEventListener('click', event => {
event.preventDefault()

updateButton.disabled = true
Promise.resolve()
.then(async () => {
Expand Down Expand Up @@ -527,7 +530,10 @@ export class ExcameraI2CDriverUIBuilder {

updateButton.disabled = false
})
.catch(e => console.warn(e))
.catch(e => {
updateButton.disabled = false
console.warn(e)
})
})


Expand Down
5 changes: 5 additions & 0 deletions public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@
}

}

::view-transition-old(root),
::view-transition-new(root) {
animation-duration: 600ms;
}
4 changes: 4 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="view-transition" content="same-origin" />

<title>Web I²C Playground</title>

<link rel="manifest" href="manifest.json" />
Expand Down
25 changes: 15 additions & 10 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,20 @@ function buildDeviceListItem(deviceListElem, builder) {

//
liElem.addEventListener('click', e => {
deviceListElem.querySelectorAll('li').forEach(li => {
li.removeAttribute('data-active')
const bElem = li.querySelector('button')
bElem.disabled = false
})

liElem.toggleAttribute('data-active', true)
buttonElem.disabled = true
const transition = document.startViewTransition(() => {
deviceListElem.querySelectorAll('li').forEach(li => {
li.removeAttribute('data-active')
const bElem = li.querySelector('button')
bElem.disabled = false
})

mainElem.querySelectorAll('section').forEach(s => s.removeAttribute('data-active'))
liElem.toggleAttribute('data-active', true)
buttonElem.disabled = true

sectionElem.toggleAttribute('data-active', true)
mainElem.querySelectorAll('section').forEach(s => s.removeAttribute('data-active'))

sectionElem.toggleAttribute('data-active', true)
})
}, { once: false })

// demolisher
Expand All @@ -170,6 +171,10 @@ function buildDeviceListItem(deviceListElem, builder) {
// console.log(vdev)
// })

builder.close()
.catch(e => console.warn(e))


liElem.remove()
sectionElem.remove()
}
Expand Down

0 comments on commit f23d84d

Please sign in to comment.