This commit is contained in:
parent
7d2ad1cd49
commit
00bf392931
@ -105,20 +105,28 @@ class App:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error occurred: {e}")
|
print(f"Error occurred: {e}")
|
||||||
|
|
||||||
def measure_distance(self):
|
def measure_distance(self) -> float:
|
||||||
self.trigger.low()
|
self.trigger.low()
|
||||||
utime.sleep_us(2)
|
utime.sleep_us(2)
|
||||||
self.trigger.high()
|
self.trigger.high()
|
||||||
utime.sleep_us(10)
|
utime.sleep_us(10)
|
||||||
self.trigger.low()
|
self.trigger.low()
|
||||||
|
|
||||||
|
start_time = utime.ticks_us()
|
||||||
sent_time = utime.ticks_us()
|
sent_time = utime.ticks_us()
|
||||||
while self.echo.value() == 0:
|
while self.echo.value() == 0:
|
||||||
|
print("hey", end="\r")
|
||||||
sent_time = utime.ticks_us()
|
sent_time = utime.ticks_us()
|
||||||
|
if sent_time - start_time >= 100_000: # if it takes more than 100ms, stop
|
||||||
|
return -1
|
||||||
|
|
||||||
|
start_time = utime.ticks_us()
|
||||||
received_time = utime.ticks_us()
|
received_time = utime.ticks_us()
|
||||||
while self.echo.value() == 1:
|
while self.echo.value() == 1:
|
||||||
|
print("ho", end="\r")
|
||||||
received_time = utime.ticks_us()
|
received_time = utime.ticks_us()
|
||||||
|
if received_time - start_time >= 100_000: # same
|
||||||
|
return -1
|
||||||
|
|
||||||
delta_time = received_time - sent_time
|
delta_time = received_time - sent_time
|
||||||
distance = delta_time / 1_000_000 * SOUND_SPEED / 2
|
distance = delta_time / 1_000_000 * SOUND_SPEED / 2
|
||||||
@ -170,5 +178,6 @@ class App:
|
|||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
App().run()
|
App().run()
|
||||||
|
24
web/.gitignore
vendored
Normal file
24
web/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Nuxt dev/build outputs
|
||||||
|
.output
|
||||||
|
.data
|
||||||
|
.nuxt
|
||||||
|
.nitro
|
||||||
|
.cache
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Node dependencies
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
.DS_Store
|
||||||
|
.fleet
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Local env files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
75
web/README.md
Normal file
75
web/README.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Nuxt Minimal Starter
|
||||||
|
|
||||||
|
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Make sure to install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Server
|
||||||
|
|
||||||
|
Start the development server on `http://localhost:3000`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm dev
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn dev
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
Build the application for production:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm build
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Locally preview production build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run preview
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm preview
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn preview
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run preview
|
||||||
|
```
|
||||||
|
|
||||||
|
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
9
web/app.vue
Normal file
9
web/app.vue
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<template>
|
||||||
|
<UApp>
|
||||||
|
<NuxtPage/>
|
||||||
|
</UApp>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import "assets/css/main.css";
|
||||||
|
</style>
|
2
web/assets/css/main.css
Normal file
2
web/assets/css/main.css
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
|
@import "@nuxt/ui";
|
3
web/assets/css/tailwind.css
Normal file
3
web/assets/css/tailwind.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
1996
web/bun.lock
Normal file
1996
web/bun.lock
Normal file
File diff suppressed because it is too large
Load Diff
6
web/nuxt.config.ts
Normal file
6
web/nuxt.config.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
|
export default defineNuxtConfig({
|
||||||
|
compatibilityDate: '2025-05-15',
|
||||||
|
devtools: { enabled: true },
|
||||||
|
modules: ['@nuxt/icon', '@nuxt/ui', '@nuxtjs/tailwindcss']
|
||||||
|
})
|
13
web/pages/index.vue
Normal file
13
web/pages/index.vue
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<main class="flex items-center justify-center min-w-screen min-h-screen">
|
||||||
|
<UButton icon="material-symbols:lock" size="xl" color="primary" variant="solid">Lock</UButton>
|
||||||
|
{{ res }}
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const res = await useFetch("https://door.svitan.dev/", {
|
||||||
|
method: "GET",
|
||||||
|
retry: 2,
|
||||||
|
})
|
||||||
|
</script>
|
3
web/pages/token.vue
Normal file
3
web/pages/token.vue
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<template>
|
||||||
|
<main>where token?</main>
|
||||||
|
</template>
|
BIN
web/public/favicon.ico
Normal file
BIN
web/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
2
web/public/robots.txt
Normal file
2
web/public/robots.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
User-Agent: *
|
||||||
|
Disallow: /
|
3
web/server/tsconfig.json
Normal file
3
web/server/tsconfig.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "../.nuxt/tsconfig.server.json"
|
||||||
|
}
|
11
web/tailwind.config.js
Normal file
11
web/tailwind.config.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
module.exports = {
|
||||||
|
purge: [],
|
||||||
|
darkMode: "class", // or 'media' or 'class'
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
variants: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
4
web/tsconfig.json
Normal file
4
web/tsconfig.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
// https://nuxt.com/docs/guide/concepts/typescript
|
||||||
|
"extends": "./.nuxt/tsconfig.json"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user