Compare commits
22 Commits
replace-ru
...
main
Author | SHA1 | Date | |
---|---|---|---|
ca8d4a3d36 | |||
a49306517e | |||
142332730f | |||
5f5824721e | |||
7e70fb9d8d | |||
93de5dd39a | |||
953cb24a3b | |||
a8f2b93de0 | |||
2d502fcd6c | |||
2c6b777fa6 | |||
4a3d7681d6 | |||
2834b7fe57 | |||
c57f52ea74 | |||
9f37b4043c | |||
92349eebb6 | |||
d1fc5713a1 | |||
d1a614fbbb | |||
2a49b081cb | |||
7e2dafa3d2 | |||
90cace679b | |||
99cbaf3b9f | |||
5de105960b |
158
.github/README.md
vendored
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
# GitHub Actions Workflows
|
||||||
|
|
||||||
|
This directory contains GitHub Actions workflows for automated CI/CD processes.
|
||||||
|
|
||||||
|
## Workflows Overview
|
||||||
|
|
||||||
|
### 🔨 `build.yml` - Build Desktop App
|
||||||
|
**Triggers:** Push to main/develop, Pull Requests, Releases
|
||||||
|
|
||||||
|
**Purpose:** Builds the desktop application for all supported platforms (macOS, Windows, Linux)
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Cross-platform builds (macOS Universal, Windows x64, Linux x64)
|
||||||
|
- Automatic artifact uploads
|
||||||
|
- Release asset publishing
|
||||||
|
- Caching for faster builds
|
||||||
|
|
||||||
|
**Artifacts:**
|
||||||
|
- **macOS**: DMG installer and .app bundle
|
||||||
|
- **Windows**: MSI and NSIS installers
|
||||||
|
- **Linux**: DEB package and AppImage
|
||||||
|
|
||||||
|
### 🧪 `ci.yml` - Continuous Integration
|
||||||
|
**Triggers:** Push to main/develop, Pull Requests
|
||||||
|
|
||||||
|
**Purpose:** Code quality checks and testing
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Frontend build verification
|
||||||
|
- Rust formatting and linting (rustfmt, clippy)
|
||||||
|
- Rust unit tests
|
||||||
|
- Security audits for both frontend and backend dependencies
|
||||||
|
|
||||||
|
### 🚀 `release.yml` - Manual Release
|
||||||
|
**Triggers:** Manual workflow dispatch
|
||||||
|
|
||||||
|
**Purpose:** Create tagged releases with built applications
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Manual version input
|
||||||
|
- Pre-release option
|
||||||
|
- Automatic release notes generation
|
||||||
|
- Cross-platform builds and uploads
|
||||||
|
- Comprehensive installation instructions
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
1. Go to Actions tab in GitHub
|
||||||
|
2. Select "Release" workflow
|
||||||
|
3. Click "Run workflow"
|
||||||
|
4. Enter version (e.g., v1.0.0)
|
||||||
|
5. Choose if it's a pre-release
|
||||||
|
6. Click "Run workflow"
|
||||||
|
|
||||||
|
### 🔄 `dependencies.yml` - Dependency Management
|
||||||
|
**Triggers:** Weekly schedule (Mondays 9 AM UTC), Manual dispatch
|
||||||
|
|
||||||
|
**Purpose:** Automated dependency updates and security monitoring
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Weekly dependency updates
|
||||||
|
- Automatic PR creation for updates
|
||||||
|
- Security vulnerability detection
|
||||||
|
- Automatic issue creation for security alerts
|
||||||
|
|
||||||
|
## Setup Requirements
|
||||||
|
|
||||||
|
### Repository Secrets
|
||||||
|
No additional secrets are required beyond the default `GITHUB_TOKEN`.
|
||||||
|
|
||||||
|
### Branch Protection (Recommended)
|
||||||
|
Configure branch protection rules for `main` branch:
|
||||||
|
- Require status checks to pass before merging
|
||||||
|
- Require branches to be up to date before merging
|
||||||
|
- Include status checks: `lint-and-test`, `security-audit`
|
||||||
|
|
||||||
|
### Release Process
|
||||||
|
|
||||||
|
#### Automated (Recommended)
|
||||||
|
1. Merge changes to `main` branch
|
||||||
|
2. Use the manual release workflow to create a new release
|
||||||
|
3. The workflow will automatically build and upload all platform binaries
|
||||||
|
|
||||||
|
#### Manual
|
||||||
|
1. Create a new tag: `git tag v1.0.0`
|
||||||
|
2. Push the tag: `git push origin v1.0.0`
|
||||||
|
3. Create a release on GitHub
|
||||||
|
4. The build workflow will automatically attach binaries
|
||||||
|
|
||||||
|
## Platform-Specific Notes
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
- Builds universal binaries (Intel + Apple Silicon)
|
||||||
|
- Requires macOS 13.0 or later
|
||||||
|
- DMG installer includes code signing (if certificates are configured)
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
- Builds for x64 architecture
|
||||||
|
- Provides both MSI and NSIS installers
|
||||||
|
- Compatible with Windows 10 and later
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
- Builds for x64 architecture
|
||||||
|
- Provides DEB package for Debian/Ubuntu
|
||||||
|
- Provides AppImage for universal Linux compatibility
|
||||||
|
- Requires WebKit2GTK and other system dependencies
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Build Failures
|
||||||
|
1. Check the specific platform logs in the Actions tab
|
||||||
|
2. Ensure all dependencies are properly declared
|
||||||
|
3. Verify Tauri configuration is correct
|
||||||
|
|
||||||
|
### Security Audit Failures
|
||||||
|
1. Review the security report in the workflow logs
|
||||||
|
2. Update vulnerable dependencies
|
||||||
|
3. Consider using `pnpm audit --fix` for frontend issues
|
||||||
|
4. Use `cargo update` for Rust dependency updates
|
||||||
|
|
||||||
|
### Cache Issues
|
||||||
|
If builds are failing due to cache corruption:
|
||||||
|
1. Go to Actions tab
|
||||||
|
2. Click on "Caches" in the sidebar
|
||||||
|
3. Delete relevant caches
|
||||||
|
4. Re-run the workflow
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
### Adding New Platforms
|
||||||
|
To add support for additional platforms, modify the `matrix` section in `build.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: 'macos-latest'
|
||||||
|
args: '--target aarch64-apple-darwin'
|
||||||
|
target: 'aarch64-apple-darwin'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Modifying Build Steps
|
||||||
|
Each workflow can be customized by:
|
||||||
|
1. Adding new steps
|
||||||
|
2. Modifying existing commands
|
||||||
|
3. Adding environment variables
|
||||||
|
4. Configuring different Node.js/Rust versions
|
||||||
|
|
||||||
|
### Adding Code Quality Tools (Optional)
|
||||||
|
If you want to add code quality tools in the future:
|
||||||
|
1. **ESLint**: Add ESLint configuration and dependencies for JavaScript/TypeScript linting
|
||||||
|
2. **Prettier**: Add Prettier for consistent code formatting
|
||||||
|
3. **TypeScript strict checking**: Enable stricter TypeScript rules and type checking
|
||||||
|
|
||||||
|
### Changing Schedule
|
||||||
|
Modify the `cron` expression in `dependencies.yml` to change the update frequency:
|
||||||
|
```yaml
|
||||||
|
schedule:
|
||||||
|
- cron: '0 9 * * 1' # Every Monday at 9 AM UTC
|
||||||
|
```
|
124
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Build Desktop App
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
release:
|
||||||
|
types: [ published ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
RUST_BACKTRACE: 1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: 'macos-latest'
|
||||||
|
args: '--target universal-apple-darwin'
|
||||||
|
target: 'universal-apple-darwin'
|
||||||
|
- platform: 'ubuntu-22.04'
|
||||||
|
args: ''
|
||||||
|
target: 'x86_64-unknown-linux-gnu'
|
||||||
|
- platform: 'windows-latest'
|
||||||
|
args: ''
|
||||||
|
target: 'x86_64-pc-windows-msvc'
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies (Ubuntu only)
|
||||||
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust cache
|
||||||
|
uses: swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: './src-tauri -> target'
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Build Tauri app
|
||||||
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
args: ${{ matrix.args }}
|
||||||
|
|
||||||
|
- name: Upload artifacts (macOS)
|
||||||
|
if: matrix.platform == 'macos-latest'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: macos-app
|
||||||
|
path: |
|
||||||
|
src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
||||||
|
src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app
|
||||||
|
|
||||||
|
- name: Upload artifacts (Linux)
|
||||||
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-app
|
||||||
|
path: |
|
||||||
|
src-tauri/target/release/bundle/deb/*.deb
|
||||||
|
src-tauri/target/release/bundle/appimage/*.AppImage
|
||||||
|
|
||||||
|
- name: Upload artifacts (Windows)
|
||||||
|
if: matrix.platform == 'windows-latest'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-app
|
||||||
|
path: |
|
||||||
|
src-tauri/target/release/bundle/msi/*.msi
|
||||||
|
src-tauri/target/release/bundle/nsis/*.exe
|
||||||
|
|
||||||
|
release:
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -la
|
||||||
|
|
||||||
|
- name: Upload release assets
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
macos-app/**/*
|
||||||
|
linux-app/**/*
|
||||||
|
windows-app/**/*
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
99
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
|
- name: Rust cache
|
||||||
|
uses: swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: './src-tauri -> target'
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Check Rust formatting
|
||||||
|
run: cargo fmt --all --check
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
- name: Lint Rust code
|
||||||
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
- name: Run Rust tests
|
||||||
|
run: cargo test --all-features
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Check Tauri build
|
||||||
|
run: cargo check --all-targets --all-features
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
security-audit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Install cargo-audit
|
||||||
|
run: cargo install cargo-audit
|
||||||
|
|
||||||
|
- name: Run security audit
|
||||||
|
run: cargo audit
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Run npm audit
|
||||||
|
run: pnpm audit --audit-level moderate
|
126
.github/workflows/dependencies.yml
vendored
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
name: Update Dependencies
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Run every Monday at 9:00 AM UTC
|
||||||
|
- cron: '0 9 * * 1'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-dependencies:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Install cargo-edit
|
||||||
|
run: cargo install cargo-edit
|
||||||
|
|
||||||
|
- name: Update frontend dependencies
|
||||||
|
run: |
|
||||||
|
pnpm update --latest
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Update Rust dependencies
|
||||||
|
run: |
|
||||||
|
cargo update
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
- name: Check if build still works
|
||||||
|
run: |
|
||||||
|
pnpm build
|
||||||
|
cargo check --all-targets --all-features
|
||||||
|
working-directory: src-tauri
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v5
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
commit-message: 'chore: update dependencies'
|
||||||
|
title: 'chore: update dependencies'
|
||||||
|
body: |
|
||||||
|
## Automated Dependency Update
|
||||||
|
|
||||||
|
This PR updates all dependencies to their latest versions.
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- Updated frontend dependencies via `pnpm update --latest`
|
||||||
|
- Updated Rust dependencies via `cargo update`
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
- ✅ Frontend build passes
|
||||||
|
- ✅ Rust compilation check passes
|
||||||
|
|
||||||
|
Please review the changes and run full tests before merging.
|
||||||
|
branch: chore/update-dependencies
|
||||||
|
delete-branch: true
|
||||||
|
|
||||||
|
security-updates:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Install cargo-audit
|
||||||
|
run: cargo install cargo-audit
|
||||||
|
|
||||||
|
- name: Check for security vulnerabilities
|
||||||
|
run: |
|
||||||
|
echo "## Frontend Security Audit" >> security-report.md
|
||||||
|
pnpm audit --audit-level moderate >> security-report.md || true
|
||||||
|
|
||||||
|
echo "## Rust Security Audit" >> security-report.md
|
||||||
|
cd src-tauri
|
||||||
|
cargo audit >> ../security-report.md || true
|
||||||
|
|
||||||
|
- name: Create security issue if vulnerabilities found
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const report = fs.readFileSync('security-report.md', 'utf8');
|
||||||
|
|
||||||
|
if (report.includes('vulnerabilities') || report.includes('RUSTSEC')) {
|
||||||
|
github.rest.issues.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
title: '🔒 Security vulnerabilities detected',
|
||||||
|
body: `## Security Audit Report\n\n\`\`\`\n${report}\n\`\`\`\n\nPlease review and update the affected dependencies.`,
|
||||||
|
labels: ['security', 'dependencies']
|
||||||
|
});
|
||||||
|
}
|
140
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Release version (e.g., v1.0.0)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
prerelease:
|
||||||
|
description: 'Mark as pre-release'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
release_id: ${{ steps.create_release.outputs.id }}
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.event.inputs.version }}
|
||||||
|
release_name: Release ${{ github.event.inputs.version }}
|
||||||
|
draft: false
|
||||||
|
prerelease: ${{ github.event.inputs.prerelease }}
|
||||||
|
body: |
|
||||||
|
## Changes in this Release
|
||||||
|
|
||||||
|
- Auto-generated release for version ${{ github.event.inputs.version }}
|
||||||
|
|
||||||
|
## Downloads
|
||||||
|
|
||||||
|
Choose the appropriate installer for your operating system:
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
- **DMG**: Universal binary for Intel and Apple Silicon Macs
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
- **MSI**: Windows Installer package
|
||||||
|
- **EXE**: NSIS installer
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
- **DEB**: Debian/Ubuntu package
|
||||||
|
- **AppImage**: Portable application
|
||||||
|
|
||||||
|
## Installation Notes
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
1. Download the DMG file
|
||||||
|
2. Open the DMG and drag the app to Applications folder
|
||||||
|
3. On first launch, you may need to right-click and select "Open" due to Gatekeeper
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
1. Download the MSI or EXE installer
|
||||||
|
2. Run the installer as administrator
|
||||||
|
3. Follow the installation wizard
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
1. **DEB**: `sudo dpkg -i ambient-light-desktop_*.deb`
|
||||||
|
2. **AppImage**: Make executable and run directly
|
||||||
|
|
||||||
|
## System Requirements
|
||||||
|
|
||||||
|
- **macOS**: 13.0 or later
|
||||||
|
- **Windows**: Windows 10 or later
|
||||||
|
- **Linux**: Ubuntu 22.04 or equivalent
|
||||||
|
|
||||||
|
build-and-upload:
|
||||||
|
needs: create-release
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: 'macos-latest'
|
||||||
|
args: '--target universal-apple-darwin'
|
||||||
|
target: 'universal-apple-darwin'
|
||||||
|
- platform: 'ubuntu-22.04'
|
||||||
|
args: ''
|
||||||
|
target: 'x86_64-unknown-linux-gnu'
|
||||||
|
- platform: 'windows-latest'
|
||||||
|
args: ''
|
||||||
|
target: 'x86_64-pc-windows-msvc'
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies (Ubuntu only)
|
||||||
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Rust cache
|
||||||
|
uses: swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: './src-tauri -> target'
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Build and release
|
||||||
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
releaseId: ${{ needs.create-release.outputs.release_id }}
|
||||||
|
args: ${{ matrix.args }}
|
36
.gitignore
vendored
@ -1,3 +1,39 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/settings.json
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage/
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# ESLint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Prettier cache
|
||||||
|
.prettiercache
|
||||||
|
|
||||||
|
# Build artifacts
|
||||||
|
src-tauri/target/
|
||||||
|
src-tauri/Cargo.lock
|
||||||
|
|
||||||
|
# OS generated files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
Desktop.ini
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
node_modules
|
|
||||||
.DS_Store
|
|
||||||
dist
|
|
||||||
dist-ssr
|
|
||||||
*.local
|
|
||||||
node_modules/*
|
|
||||||
src-tauri
|
|
@ -1,8 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
semi: true,
|
|
||||||
trailingComma: "all",
|
|
||||||
singleQuote: true,
|
|
||||||
printWidth: 90,
|
|
||||||
tabWidth: 2,
|
|
||||||
endOfLine: "auto",
|
|
||||||
};
|
|
3
.vscode/tasks.json
vendored
@ -12,9 +12,6 @@
|
|||||||
"tauri",
|
"tauri",
|
||||||
"dev"
|
"dev"
|
||||||
],
|
],
|
||||||
"problemMatcher": [
|
|
||||||
"$eslint-stylish"
|
|
||||||
],
|
|
||||||
"options": {
|
"options": {
|
||||||
"env": {
|
"env": {
|
||||||
"RUST_LOG": "info"
|
"RUST_LOG": "info"
|
||||||
|
674
LICENSE
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
15
README.md
@ -1,5 +1,9 @@
|
|||||||
# Display Ambient Light Desktop App
|
# Display Ambient Light Desktop App
|
||||||
|
|
||||||
|
[](https://github.com/USERNAME/REPOSITORY/actions/workflows/build.yml)
|
||||||
|
[](https://github.com/USERNAME/REPOSITORY/actions/workflows/ci.yml)
|
||||||
|
[](https://github.com/USERNAME/REPOSITORY/actions/workflows/release.yml)
|
||||||
|
|
||||||
A desktop application built with Tauri 2.0 for ambient light control, supporting multi-monitor screen sampling and LED strip control to create immersive ambient lighting effects.
|
A desktop application built with Tauri 2.0 for ambient light control, supporting multi-monitor screen sampling and LED strip control to create immersive ambient lighting effects.
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
@ -52,12 +56,13 @@ A desktop application built with Tauri 2.0 for ambient light control, supporting
|
|||||||
2. **Install Node.js and pnpm**
|
2. **Install Node.js and pnpm**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install Node.js (recommended using nvm)
|
# Install Node.js 22 LTS (recommended using nvm)
|
||||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
||||||
nvm install node
|
nvm install 22
|
||||||
|
nvm use 22
|
||||||
|
|
||||||
# Install pnpm
|
# Install pnpm 10+
|
||||||
npm install -g pnpm
|
npm install -g pnpm@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Install Tauri CLI**
|
3. **Install Tauri CLI**
|
||||||
@ -166,7 +171,7 @@ desktop/
|
|||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
This project is licensed under the GPLv3 License - see the [LICENSE](LICENSE) file for details.
|
||||||
|
|
||||||
## 🔗 Related Links
|
## 🔗 Related Links
|
||||||
|
|
||||||
|
99
docs/device-auto-refresh-implementation.md
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
# LED Strip Test Device Auto-Refresh Implementation
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
Implemented automatic refresh functionality for the device dropdown in the LED strip test interface. The device list now updates in real-time when devices are discovered, connected, or disconnected.
|
||||||
|
|
||||||
|
## Changes Made
|
||||||
|
|
||||||
|
### 1. Frontend Changes (`src/components/led-strip-test/led-strip-test.tsx`)
|
||||||
|
|
||||||
|
#### Added Event Listener Import
|
||||||
|
```typescript
|
||||||
|
import { listen } from '@tauri-apps/api/event';
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Enhanced Device Loading Logic
|
||||||
|
- **Initial Load**: Still loads devices on component mount using `get_boards()`
|
||||||
|
- **Real-time Updates**: Added listener for `boards_changed` events from backend
|
||||||
|
- **Smart Selection**: Automatically handles device selection when devices are added/removed:
|
||||||
|
- If current device disconnects, automatically selects first available device
|
||||||
|
- If no device was selected and devices become available, selects the first one
|
||||||
|
- Properly cleans up event listeners on component unmount
|
||||||
|
|
||||||
|
#### Improved UI Display
|
||||||
|
- **Device Count**: Shows number of devices found in label
|
||||||
|
- **Connection Status**: Each device option shows:
|
||||||
|
- Status icon (🟢 Connected, 🟡 Connecting, 🔴 Disconnected)
|
||||||
|
- Device name and address
|
||||||
|
- Connection status text
|
||||||
|
- **Empty State**: Shows "Searching..." when no devices found
|
||||||
|
|
||||||
|
#### Type Safety Improvements
|
||||||
|
- Updated `BoardInfo` interface to match backend types
|
||||||
|
- Proper handling of `connect_status` union type
|
||||||
|
- Type-safe status checking functions
|
||||||
|
|
||||||
|
### 2. Backend Integration
|
||||||
|
The implementation leverages existing backend infrastructure:
|
||||||
|
- **UdpRpc Manager**: Continuously searches for devices via mDNS
|
||||||
|
- **Device Monitoring**: Checks device connectivity every second
|
||||||
|
- **Event Broadcasting**: Sends `boards_changed` events to frontend
|
||||||
|
- **Status Tracking**: Maintains real-time connection status for each device
|
||||||
|
|
||||||
|
## Technical Details
|
||||||
|
|
||||||
|
### Event Flow
|
||||||
|
1. Backend `UdpRpc` discovers devices via mDNS service discovery
|
||||||
|
2. Backend monitors device connectivity with periodic health checks
|
||||||
|
3. Backend broadcasts `boards_changed` events when device list changes
|
||||||
|
4. Frontend listens for events and updates UI automatically
|
||||||
|
5. Frontend handles device selection logic intelligently
|
||||||
|
|
||||||
|
### Connection Status Types
|
||||||
|
- `Connected`: Device is responding to ping requests
|
||||||
|
- `Connecting`: Device is in retry state (with retry count)
|
||||||
|
- `Disconnected`: Device is not responding
|
||||||
|
|
||||||
|
### Error Handling
|
||||||
|
- Graceful fallback if initial device load fails
|
||||||
|
- Proper cleanup of event listeners
|
||||||
|
- Maintains UI state consistency during device changes
|
||||||
|
|
||||||
|
## Benefits
|
||||||
|
1. **Real-time Updates**: No need to manually refresh device list
|
||||||
|
2. **Better UX**: Visual indicators for device status
|
||||||
|
3. **Automatic Recovery**: Handles device disconnections gracefully
|
||||||
|
4. **Type Safety**: Proper TypeScript types prevent runtime errors
|
||||||
|
5. **Performance**: Efficient event-driven updates instead of polling
|
||||||
|
|
||||||
|
## Implementation Status
|
||||||
|
✅ **Completed**: LED Strip Test device dropdown auto-refresh
|
||||||
|
✅ **Already Implemented**: Board Index page auto-refresh (was already working)
|
||||||
|
✅ **Type Safety**: Fixed TypeScript type definitions for BoardInfo
|
||||||
|
✅ **UI Improvements**: Added status indicators and device count display
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
To test the functionality:
|
||||||
|
1. Start the application with `npm run tauri dev`
|
||||||
|
2. Navigate to LED Strip Test page
|
||||||
|
3. Observe device list updates as devices come online/offline
|
||||||
|
4. Verify status indicators show correct connection states:
|
||||||
|
- 🟢 Connected devices
|
||||||
|
- 🟡 Connecting devices (with retry count)
|
||||||
|
- 🔴 Disconnected devices
|
||||||
|
5. Test device selection behavior when devices disconnect
|
||||||
|
6. Check that device count is displayed in the label
|
||||||
|
|
||||||
|
## Code Quality
|
||||||
|
- ✅ No TypeScript errors
|
||||||
|
- ✅ Proper event listener cleanup
|
||||||
|
- ✅ Type-safe status checking
|
||||||
|
- ✅ Consistent with existing codebase patterns
|
||||||
|
- ✅ Follows SolidJS best practices
|
||||||
|
|
||||||
|
## Future Enhancements
|
||||||
|
- Add device refresh button for manual refresh
|
||||||
|
- Show device discovery progress indicator
|
||||||
|
- Add device connection retry controls
|
||||||
|
- Display device ping latency information
|
||||||
|
- Add device connection history/logs
|
105
docs/device-auto-refresh-testing.md
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# Device Auto-Refresh Testing Guide
|
||||||
|
|
||||||
|
## Test Scenarios
|
||||||
|
|
||||||
|
### 1. Initial Load Test
|
||||||
|
**Expected Behavior**: Device list loads automatically when component mounts
|
||||||
|
|
||||||
|
**Steps**:
|
||||||
|
1. Start the application: `npm run tauri dev`
|
||||||
|
2. Navigate to LED Strip Test page
|
||||||
|
3. Observe the device dropdown
|
||||||
|
|
||||||
|
**Expected Results**:
|
||||||
|
- Device dropdown shows "Searching..." if no devices found
|
||||||
|
- Device dropdown shows device count if devices are found
|
||||||
|
- First available device is automatically selected
|
||||||
|
- Status icons appear next to device names
|
||||||
|
|
||||||
|
### 2. Device Discovery Test
|
||||||
|
**Expected Behavior**: New devices appear automatically when discovered
|
||||||
|
|
||||||
|
**Steps**:
|
||||||
|
1. Start with no devices connected
|
||||||
|
2. Connect a device to the network
|
||||||
|
3. Wait for device discovery (should be automatic)
|
||||||
|
|
||||||
|
**Expected Results**:
|
||||||
|
- Device count updates automatically
|
||||||
|
- New device appears in dropdown
|
||||||
|
- If no device was selected, new device gets selected automatically
|
||||||
|
- Status icon shows connection state
|
||||||
|
|
||||||
|
### 3. Device Disconnection Test
|
||||||
|
**Expected Behavior**: Disconnected devices are handled gracefully
|
||||||
|
|
||||||
|
**Steps**:
|
||||||
|
1. Start with connected devices
|
||||||
|
2. Select a device in the dropdown
|
||||||
|
3. Disconnect the selected device from network
|
||||||
|
4. Wait for connection timeout
|
||||||
|
|
||||||
|
**Expected Results**:
|
||||||
|
- Device status changes to disconnected (🔴)
|
||||||
|
- If device becomes unavailable, another device is selected automatically
|
||||||
|
- Device count updates
|
||||||
|
- UI remains responsive
|
||||||
|
|
||||||
|
### 4. Connection Status Test
|
||||||
|
**Expected Behavior**: Status indicators reflect actual device states
|
||||||
|
|
||||||
|
**Steps**:
|
||||||
|
1. Observe devices in different connection states
|
||||||
|
2. Check status icons and text
|
||||||
|
|
||||||
|
**Expected Results**:
|
||||||
|
- 🟢 "Connected" for responsive devices
|
||||||
|
- 🟡 "Connecting" for devices in retry state
|
||||||
|
- 🔴 "Disconnected" for unresponsive devices
|
||||||
|
- Status text matches icon state
|
||||||
|
|
||||||
|
### 5. UI Responsiveness Test
|
||||||
|
**Expected Behavior**: Interface remains responsive during device changes
|
||||||
|
|
||||||
|
**Steps**:
|
||||||
|
1. Rapidly connect/disconnect devices
|
||||||
|
2. Interact with other UI elements during device changes
|
||||||
|
3. Switch between pages and return
|
||||||
|
|
||||||
|
**Expected Results**:
|
||||||
|
- No UI freezing or lag
|
||||||
|
- Event listeners are properly cleaned up
|
||||||
|
- No memory leaks
|
||||||
|
- Smooth transitions
|
||||||
|
|
||||||
|
## Verification Checklist
|
||||||
|
|
||||||
|
- [ ] Device dropdown shows correct device count
|
||||||
|
- [ ] Status icons display correctly (🟢🟡🔴)
|
||||||
|
- [ ] Automatic device selection works
|
||||||
|
- [ ] Event listeners are cleaned up on component unmount
|
||||||
|
- [ ] No TypeScript errors in console
|
||||||
|
- [ ] No runtime errors in console
|
||||||
|
- [ ] Performance remains good with multiple devices
|
||||||
|
- [ ] UI updates smoothly without flickering
|
||||||
|
|
||||||
|
## Common Issues to Watch For
|
||||||
|
|
||||||
|
1. **Memory Leaks**: Event listeners not cleaned up
|
||||||
|
2. **Type Errors**: Incorrect BoardInfo type handling
|
||||||
|
3. **Selection Logic**: Device selection not updating correctly
|
||||||
|
4. **Performance**: UI lag during rapid device changes
|
||||||
|
5. **State Consistency**: UI state not matching actual device state
|
||||||
|
|
||||||
|
## Debug Information
|
||||||
|
|
||||||
|
Check browser console for:
|
||||||
|
- `boards_changed` events
|
||||||
|
- Device list updates
|
||||||
|
- Selection changes
|
||||||
|
- Any error messages
|
||||||
|
|
||||||
|
Check Tauri logs for:
|
||||||
|
- Device discovery messages
|
||||||
|
- Connection status changes
|
||||||
|
- mDNS service events
|
471
docs/hardware-protocol.md
Normal file
@ -0,0 +1,471 @@
|
|||||||
|
# LED Hardware Communication Protocol
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
UDP-based bidirectional protocol for communication between desktop application and ambient light hardware boards. The protocol supports LED color data transmission, device health monitoring, and remote control capabilities.
|
||||||
|
|
||||||
|
## Connection
|
||||||
|
|
||||||
|
- **Protocol**: UDP
|
||||||
|
- **Port**: 23042
|
||||||
|
- **Discovery**: mDNS (`_ambient_light._udp.local.`)
|
||||||
|
- **Example Board**: `192.168.31.206:23042`
|
||||||
|
|
||||||
|
## mDNS Service Discovery
|
||||||
|
|
||||||
|
### Service Registration (Hardware Side)
|
||||||
|
|
||||||
|
Hardware boards must register the following mDNS service:
|
||||||
|
|
||||||
|
- **Service Type**: `_ambient_light._udp.local.`
|
||||||
|
- **Port**: 23042
|
||||||
|
- **TXT Records**: Optional, can include device information
|
||||||
|
|
||||||
|
### Service Discovery (Desktop Side)
|
||||||
|
|
||||||
|
Desktop application continuously browses for `_ambient_light._udp.local.` services and automatically connects to discovered devices.
|
||||||
|
|
||||||
|
## Protocol Messages
|
||||||
|
|
||||||
|
The protocol uses different message headers to distinguish message types:
|
||||||
|
|
||||||
|
| Header | Direction | Purpose | Format |
|
||||||
|
|--------|-----------|---------|---------|
|
||||||
|
| 0x01 | Desktop → Hardware | Ping (Health Check) | `[0x01]` |
|
||||||
|
| 0x01 | Hardware → Desktop | Pong (Health Response) | `[0x01]` |
|
||||||
|
| 0x02 | Desktop → Hardware | LED Color Data | `[0x02][Offset_H][Offset_L][Color_Data...]` |
|
||||||
|
| 0x03 | Hardware → Desktop | Display Brightness Control | `[0x03][Display_Index][Brightness]` |
|
||||||
|
| 0x04 | Hardware → Desktop | Volume Control | `[0x04][Volume_Percent]` |
|
||||||
|
|
||||||
|
## Health Check Protocol (Ping/Pong)
|
||||||
|
|
||||||
|
### Desktop → Hardware (Ping)
|
||||||
|
|
||||||
|
```text
|
||||||
|
Byte 0: Header (0x01)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Hardware → Desktop (Pong)
|
||||||
|
|
||||||
|
```text
|
||||||
|
Byte 0: Header (0x01)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Behavior:**
|
||||||
|
|
||||||
|
- Desktop sends ping every 1 second to each connected device
|
||||||
|
- Hardware must respond with pong within 1 second
|
||||||
|
- Timeout or incorrect response triggers reconnection logic
|
||||||
|
- After 10 failed attempts, device is marked as disconnected
|
||||||
|
|
||||||
|
## LED Color Data Protocol
|
||||||
|
|
||||||
|
### Packet Format
|
||||||
|
|
||||||
|
```text
|
||||||
|
Byte 0: Header (0x02)
|
||||||
|
Byte 1: Offset High (upper 8 bits of data byte offset)
|
||||||
|
Byte 2: Offset Low (lower 8 bits of data byte offset)
|
||||||
|
Byte 3+: LED Color Data (variable length)
|
||||||
|
```
|
||||||
|
|
||||||
|
## LED Color Data
|
||||||
|
|
||||||
|
### RGB LEDs (3 bytes per LED)
|
||||||
|
|
||||||
|
```text
|
||||||
|
[R][G][B][R][G][B][R][G][B]...
|
||||||
|
```
|
||||||
|
|
||||||
|
### RGBW LEDs (4 bytes per LED)
|
||||||
|
|
||||||
|
```text
|
||||||
|
[R][G][B][W][R][G][B][W][R][G][B][W]...
|
||||||
|
```
|
||||||
|
|
||||||
|
All values are 0-255.
|
||||||
|
|
||||||
|
### Offset Calculation
|
||||||
|
|
||||||
|
The offset field specifies the starting byte position in the LED data buffer:
|
||||||
|
|
||||||
|
- **16-bit value**: Combines Offset High and Offset Low bytes (big-endian)
|
||||||
|
- **Range**: 0-65535 bytes supported
|
||||||
|
- **Purpose**: Allows partial updates of LED strip data at any byte position
|
||||||
|
|
||||||
|
**Example Calculations:**
|
||||||
|
|
||||||
|
- Byte position 0: `Offset High = 0x00, Offset Low = 0x00`
|
||||||
|
- Byte position 30: `Offset High = 0x00, Offset Low = 0x1E` (10 RGB LEDs × 3 bytes)
|
||||||
|
- Byte position 256: `Offset High = 0x01, Offset Low = 0x00`
|
||||||
|
- Byte position 1000: `Offset High = 0x03, Offset Low = 0xE8`
|
||||||
|
|
||||||
|
**LED Position to Byte Offset Conversion:**
|
||||||
|
|
||||||
|
- **RGB LEDs**: `byte_offset = led_position × 3`
|
||||||
|
- **RGBW LEDs**: `byte_offset = led_position × 4`
|
||||||
|
|
||||||
|
## LED Chip Specifications
|
||||||
|
|
||||||
|
### WS2812B (RGB)
|
||||||
|
|
||||||
|
- **Type**: RGB
|
||||||
|
- **Data Format**: 3 bytes per LED
|
||||||
|
- **Color Order**: G-R-B (Green, Red, Blue)
|
||||||
|
- **Voltage**: 5V
|
||||||
|
- **Protocol**: Single-wire serial
|
||||||
|
- **Timing**: 800kHz data rate
|
||||||
|
|
||||||
|
### SK6812 (RGB)
|
||||||
|
|
||||||
|
- **Type**: RGB
|
||||||
|
- **Data Format**: 3 bytes per LED
|
||||||
|
- **Color Order**: G-R-B (Green, Red, Blue)
|
||||||
|
- **Voltage**: 5V
|
||||||
|
- **Protocol**: Single-wire serial
|
||||||
|
- **Timing**: 800kHz data rate
|
||||||
|
- **Features**: Improved PWM linearity compared to WS2812B
|
||||||
|
|
||||||
|
### SK6812-RGBW
|
||||||
|
|
||||||
|
- **Type**: RGBW
|
||||||
|
- **Data Format**: 4 bytes per LED
|
||||||
|
- **Color Order**: G-R-B-W (Green, Red, Blue, White)
|
||||||
|
- **Voltage**: 5V
|
||||||
|
- **Protocol**: Single-wire serial
|
||||||
|
- **Timing**: 800kHz data rate
|
||||||
|
- **Features**: Dedicated white channel for better color mixing and higher brightness
|
||||||
|
|
||||||
|
## Color Calibration
|
||||||
|
|
||||||
|
Colors are calibrated before transmission:
|
||||||
|
|
||||||
|
**RGB:**
|
||||||
|
|
||||||
|
```rust
|
||||||
|
calibrated_r = (original_r * calibration_r) / 255
|
||||||
|
calibrated_g = (original_g * calibration_g) / 255
|
||||||
|
calibrated_b = (original_b * calibration_b) / 255
|
||||||
|
```
|
||||||
|
|
||||||
|
**RGBW:**
|
||||||
|
|
||||||
|
```rust
|
||||||
|
calibrated_r = (original_r * calibration_r) / 255
|
||||||
|
calibrated_g = (original_g * calibration_g) / 255
|
||||||
|
calibrated_b = (original_b * calibration_b) / 255
|
||||||
|
calibrated_w = calibration_w // Direct value
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hardware Control Protocol (Hardware → Desktop)
|
||||||
|
|
||||||
|
### Display Brightness Control
|
||||||
|
|
||||||
|
Hardware can send display brightness adjustment commands to the desktop:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Byte 0: Header (0x03)
|
||||||
|
Byte 1: Display Index (0-based display number)
|
||||||
|
Byte 2: Brightness (0-255, where 255 = 100% brightness)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:** Set display 0 to 50% brightness
|
||||||
|
|
||||||
|
```text
|
||||||
|
03 00 80
|
||||||
|
│ │ └─ Brightness (128 = ~50%)
|
||||||
|
│ └─ Display Index (0)
|
||||||
|
└─ Header (0x03)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Volume Control
|
||||||
|
|
||||||
|
Hardware can send system volume adjustment commands to the desktop:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Byte 0: Header (0x04)
|
||||||
|
Byte 1: Volume Percent (0-100)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:** Set system volume to 75%
|
||||||
|
|
||||||
|
```text
|
||||||
|
04 4B
|
||||||
|
│ └─ Volume (75%)
|
||||||
|
└─ Header (0x04)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Connection State Management
|
||||||
|
|
||||||
|
### Connection States
|
||||||
|
|
||||||
|
- **Unknown**: Initial state when device is first discovered
|
||||||
|
- **Connecting**: Device is being tested, includes retry count (1-10)
|
||||||
|
- **Connected**: Device is responding to ping requests normally
|
||||||
|
- **Disconnected**: Device failed to respond after 10 retry attempts
|
||||||
|
|
||||||
|
### State Transitions
|
||||||
|
|
||||||
|
```text
|
||||||
|
Unknown → Connecting(1) → Connected
|
||||||
|
↓ ↓ ↓
|
||||||
|
↓ Connecting(2-10) ↓
|
||||||
|
↓ ↓ ↓
|
||||||
|
└─→ Disconnected ←────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### Retry Logic
|
||||||
|
|
||||||
|
1. **Initial Connection**: When device discovered via mDNS
|
||||||
|
2. **Health Check Failure**: If ping timeout or wrong response
|
||||||
|
3. **Retry Attempts**: Up to 10 attempts with 1-second intervals
|
||||||
|
4. **Disconnection**: After 10 failed attempts, mark as disconnected
|
||||||
|
5. **Recovery**: Disconnected devices continue to receive ping attempts
|
||||||
|
|
||||||
|
## Packet Examples
|
||||||
|
|
||||||
|
### RGB Example
|
||||||
|
|
||||||
|
3 RGB LEDs starting at byte offset 0: Red, Green, Blue
|
||||||
|
|
||||||
|
```text
|
||||||
|
02 00 00 FF 00 00 00 FF 00 00 00 FF
|
||||||
|
│ │ │ └─────────────────────────── 9 bytes color data
|
||||||
|
│ │ └─ Offset Low (0 bytes)
|
||||||
|
│ └─ Offset High (0)
|
||||||
|
└─ Header (0x02)
|
||||||
|
```
|
||||||
|
|
||||||
|
### RGBW Example
|
||||||
|
|
||||||
|
2 RGBW LEDs starting at byte offset 40 (LED position 10): White, Warm White
|
||||||
|
|
||||||
|
```text
|
||||||
|
02 00 28 FF FF FF FF FF C8 96 C8
|
||||||
|
│ │ │ └─────────────────────── 8 bytes color data
|
||||||
|
│ │ └─ Offset Low (40 bytes = 0x28)
|
||||||
|
│ └─ Offset High (0)
|
||||||
|
└─ Header (0x02)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation Notes
|
||||||
|
|
||||||
|
- **Byte Order**: Big-endian for multi-byte values (offset field)
|
||||||
|
- **Delivery**: Fire-and-forget UDP (no acknowledgment required)
|
||||||
|
- **Hardware Role**: Simple UDP-to-LED bridge, no data processing
|
||||||
|
- **LED Type Logic**: Handled entirely on desktop side, not hardware
|
||||||
|
- **Mixed Types**: Same display can have both RGB and RGBW strips
|
||||||
|
- **Data Flow**: Desktop → UDP → Hardware → LED Strip (direct forward)
|
||||||
|
- **Color Order**: Hardware must handle color order conversion for different LED chips
|
||||||
|
- **LED Compatibility**: Supports WS2812B, SK6812, and SK6812-RGBW chips
|
||||||
|
|
||||||
|
## Hardware Implementation
|
||||||
|
|
||||||
|
The hardware board handles multiple protocol functions: UDP-to-WS2812 bridge for LED data, health monitoring, and optional control input capabilities.
|
||||||
|
|
||||||
|
### Required Functions
|
||||||
|
|
||||||
|
1. **mDNS Service Registration**: Advertise `_ambient_light._udp.local.` service
|
||||||
|
2. **UDP Server**: Listen on port 23042 for incoming packets
|
||||||
|
3. **Packet Processing**: Handle different message types based on header
|
||||||
|
4. **Health Monitoring**: Respond to ping requests with pong
|
||||||
|
5. **LED Control**: Forward color data to WS2812 strips
|
||||||
|
6. **Optional Control**: Send brightness/volume commands to desktop
|
||||||
|
|
||||||
|
### Packet Processing Logic
|
||||||
|
|
||||||
|
```c
|
||||||
|
void process_packet(uint8_t* data, size_t len) {
|
||||||
|
if (len < 1) return;
|
||||||
|
|
||||||
|
switch (data[0]) {
|
||||||
|
case 0x01: // Ping request
|
||||||
|
handle_ping(data, len);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x02: // LED color data
|
||||||
|
handle_led_data(data, len);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Unknown packet type, ignore
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_ping(uint8_t* data, size_t len) {
|
||||||
|
if (len != 1) return;
|
||||||
|
|
||||||
|
// Respond with pong
|
||||||
|
uint8_t pong = 0x01;
|
||||||
|
udp_send_response(&pong, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_led_data(uint8_t* data, size_t len) {
|
||||||
|
if (len < 3) return;
|
||||||
|
|
||||||
|
uint16_t byte_offset = (data[1] << 8) | data[2];
|
||||||
|
uint8_t* color_data = &data[3];
|
||||||
|
size_t color_len = len - 3;
|
||||||
|
|
||||||
|
// Direct forward to LED strip - supports WS2812B, SK6812, SK6812-RGBW
|
||||||
|
// byte_offset specifies the starting byte position in LED data buffer
|
||||||
|
// Color order conversion handled by LED driver library
|
||||||
|
led_strip_update(byte_offset, color_data, color_len);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Optional Control Features
|
||||||
|
|
||||||
|
Hardware can optionally send control commands to desktop:
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Send display brightness control
|
||||||
|
void send_brightness_control(uint8_t display_index, uint8_t brightness) {
|
||||||
|
uint8_t packet[3] = {0x03, display_index, brightness};
|
||||||
|
udp_send_to_desktop(packet, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send volume control
|
||||||
|
void send_volume_control(uint8_t volume_percent) {
|
||||||
|
uint8_t packet[2] = {0x04, volume_percent};
|
||||||
|
udp_send_to_desktop(packet, 2);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### LED Strip Driver Implementation
|
||||||
|
|
||||||
|
For SK6812-RGBW support, hardware must handle the G-R-B-W color order:
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Example LED strip update function for SK6812-RGBW
|
||||||
|
void led_strip_update(uint16_t offset, uint8_t* data, size_t len) {
|
||||||
|
// For SK6812-RGBW: data comes as [R][G][B][W] from desktop
|
||||||
|
// Must be reordered to [G][R][B][W] for the LED chip
|
||||||
|
|
||||||
|
size_t led_count = len / 4; // 4 bytes per RGBW LED
|
||||||
|
uint8_t* output_buffer = malloc(len);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < led_count; i++) {
|
||||||
|
uint8_t r = data[i * 4 + 0];
|
||||||
|
uint8_t g = data[i * 4 + 1];
|
||||||
|
uint8_t b = data[i * 4 + 2];
|
||||||
|
uint8_t w = data[i * 4 + 3];
|
||||||
|
|
||||||
|
// Reorder to G-R-B-W for SK6812-RGBW
|
||||||
|
output_buffer[i * 4 + 0] = g; // Green first
|
||||||
|
output_buffer[i * 4 + 1] = r; // Red second
|
||||||
|
output_buffer[i * 4 + 2] = b; // Blue third
|
||||||
|
output_buffer[i * 4 + 3] = w; // White fourth
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send to LED strip with proper timing
|
||||||
|
sk6812_rgbw_send(offset, output_buffer, len);
|
||||||
|
free(output_buffer);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Implementation Notes
|
||||||
|
|
||||||
|
- **Ping Response**: Must respond to ping (0x01) within 1 second
|
||||||
|
- **LED Data**: Direct forward to LED strip, with color order conversion if needed
|
||||||
|
- **Color Order**: SK6812-RGBW requires G-R-B-W order, desktop sends R-G-B-W
|
||||||
|
- **Control Commands**: Optional feature for hardware with input capabilities
|
||||||
|
- **mDNS Registration**: Essential for automatic device discovery
|
||||||
|
- **UDP Server**: Must handle concurrent connections from multiple desktops
|
||||||
|
- **LED Chip Support**: Must support WS2812B (RGB), SK6812 (RGB), and SK6812-RGBW
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Device Discovery Issues
|
||||||
|
|
||||||
|
**Device Not Found**:
|
||||||
|
|
||||||
|
- Verify mDNS service registration on hardware
|
||||||
|
- Check service type: `_ambient_light._udp.local.`
|
||||||
|
- Ensure port 23042 is accessible
|
||||||
|
- Verify network connectivity between desktop and hardware
|
||||||
|
|
||||||
|
**Device Shows as Disconnected**:
|
||||||
|
|
||||||
|
- Check ping/pong response implementation
|
||||||
|
- Verify hardware responds to 0x01 packets within 1 second
|
||||||
|
- Monitor network latency and packet loss
|
||||||
|
- Check UDP server implementation on hardware
|
||||||
|
|
||||||
|
### LED Control Issues
|
||||||
|
|
||||||
|
**No LED Updates**:
|
||||||
|
|
||||||
|
- Verify hardware processes 0x02 packets correctly
|
||||||
|
- Check WS2812 wiring and power supply
|
||||||
|
- Monitor packet reception on hardware side
|
||||||
|
- Verify byte offset calculations and LED strip configuration
|
||||||
|
|
||||||
|
**Wrong Colors**:
|
||||||
|
|
||||||
|
- Check color calibration settings on desktop
|
||||||
|
- Verify RGB/RGBW data format matches LED strip type
|
||||||
|
- Monitor color data in packets (bytes 3+)
|
||||||
|
- Check LED chip color order:
|
||||||
|
- WS2812B: G-R-B order
|
||||||
|
- SK6812: G-R-B order
|
||||||
|
- SK6812-RGBW: G-R-B-W order
|
||||||
|
- Ensure hardware converts R-G-B(-W) from desktop to correct chip order
|
||||||
|
|
||||||
|
**Flickering or Lag**:
|
||||||
|
|
||||||
|
- Monitor packet rate and network congestion
|
||||||
|
- Check power supply stability for LED strips
|
||||||
|
- Verify WS2812 data signal integrity
|
||||||
|
- Consider reducing update frequency
|
||||||
|
|
||||||
|
### Control Protocol Issues
|
||||||
|
|
||||||
|
**Brightness/Volume Control Not Working**:
|
||||||
|
|
||||||
|
- Verify hardware sends correct packet format (0x03/0x04)
|
||||||
|
- Check desktop receives and processes control packets
|
||||||
|
- Monitor packet transmission from hardware
|
||||||
|
- Verify display index and value ranges
|
||||||
|
|
||||||
|
### Connection State Issues
|
||||||
|
|
||||||
|
**Frequent Disconnections**:
|
||||||
|
|
||||||
|
- Check network stability and latency
|
||||||
|
- Verify ping response timing (< 1 second)
|
||||||
|
- Monitor retry logic and connection state transitions
|
||||||
|
- Check for UDP packet loss
|
||||||
|
|
||||||
|
**Stuck in Connecting State**:
|
||||||
|
|
||||||
|
- Verify ping/pong packet format
|
||||||
|
- Check hardware UDP server implementation
|
||||||
|
- Monitor ping response timing
|
||||||
|
- Verify network firewall settings
|
||||||
|
|
||||||
|
### Network Debugging
|
||||||
|
|
||||||
|
**Packet Monitoring**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Monitor UDP traffic on port 23042
|
||||||
|
tcpdump -i any -X port 23042
|
||||||
|
|
||||||
|
# Check mDNS service discovery
|
||||||
|
dns-sd -B _ambient_light._udp.local.
|
||||||
|
```
|
||||||
|
|
||||||
|
**Hardware Debug Output**:
|
||||||
|
|
||||||
|
- Log received packet headers and lengths
|
||||||
|
- Monitor ping/pong timing
|
||||||
|
- Track LED data processing
|
||||||
|
- Log mDNS service registration status
|
||||||
|
|
||||||
|
## Protocol Version
|
||||||
|
|
||||||
|
- **Current**: 1.0
|
||||||
|
- **Headers**: 0x01 (Ping/Pong), 0x02 (LED Data), 0x03 (Brightness), 0x04 (Volume)
|
||||||
|
- **Future**: Additional headers for new features, backward compatibility maintained
|
26
package.json
@ -1,7 +1,26 @@
|
|||||||
{
|
{
|
||||||
"name": "test-demo",
|
"name": "display-ambient-light",
|
||||||
"version": "0.0.0",
|
"version": "2.0.0-alpha",
|
||||||
"description": "",
|
"description": "A desktop application for controlling ambient lighting based on screen content, supporting WS2812B and SK6812 LED strips with real-time color synchronization.",
|
||||||
|
"author": "Ivan Li",
|
||||||
|
"homepage": "https://github.com/IvanLi-CN/display-ambient-light",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/IvanLi-CN/display-ambient-light.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"ambient-light",
|
||||||
|
"led-control",
|
||||||
|
"screen-sync",
|
||||||
|
"ws2812b",
|
||||||
|
"sk6812",
|
||||||
|
"tauri",
|
||||||
|
"desktop-app"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22.0.0",
|
||||||
|
"pnpm": ">=10.0.0"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@ -11,6 +30,7 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@solid-primitives/i18n": "^2.2.1",
|
||||||
"@solidjs/router": "^0.8.4",
|
"@solidjs/router": "^0.8.4",
|
||||||
"@tauri-apps/api": "^2.6.0",
|
"@tauri-apps/api": "^2.6.0",
|
||||||
"debug": "^4.4.1",
|
"debug": "^4.4.1",
|
||||||
|
12
pnpm-lock.yaml
generated
@ -8,6 +8,9 @@ importers:
|
|||||||
|
|
||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@solid-primitives/i18n':
|
||||||
|
specifier: ^2.2.1
|
||||||
|
version: 2.2.1(solid-js@1.9.7)
|
||||||
'@solidjs/router':
|
'@solidjs/router':
|
||||||
specifier: ^0.8.4
|
specifier: ^0.8.4
|
||||||
version: 0.8.4(solid-js@1.9.7)
|
version: 0.8.4(solid-js@1.9.7)
|
||||||
@ -424,6 +427,11 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@solid-primitives/i18n@2.2.1':
|
||||||
|
resolution: {integrity: sha512-TnTnE2Ku11MGYZ1JzhJ8pYscwg1fr9MteoYxPwsfxWfh9Jp5K7RRJncJn9BhOHvNLwROjqOHZ46PT7sPHqbcXw==}
|
||||||
|
peerDependencies:
|
||||||
|
solid-js: ^1.6.12
|
||||||
|
|
||||||
'@solidjs/router@0.8.4':
|
'@solidjs/router@0.8.4':
|
||||||
resolution: {integrity: sha512-Gi/WVoVseGMKS1DBdT3pNAMgOzEOp6Q3dpgNd2mW9GUEnVocPmtyBjDvXwN6m7tjSGsqqfqJFXk7bm1hxabSRw==}
|
resolution: {integrity: sha512-Gi/WVoVseGMKS1DBdT3pNAMgOzEOp6Q3dpgNd2mW9GUEnVocPmtyBjDvXwN6m7tjSGsqqfqJFXk7bm1hxabSRw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -1282,6 +1290,10 @@ snapshots:
|
|||||||
'@rollup/rollup-win32-x64-msvc@4.44.1':
|
'@rollup/rollup-win32-x64-msvc@4.44.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@solid-primitives/i18n@2.2.1(solid-js@1.9.7)':
|
||||||
|
dependencies:
|
||||||
|
solid-js: 1.9.7
|
||||||
|
|
||||||
'@solidjs/router@0.8.4(solid-js@1.9.7)':
|
'@solidjs/router@0.8.4(solid-js@1.9.7)':
|
||||||
dependencies:
|
dependencies:
|
||||||
solid-js: 1.9.7
|
solid-js: 1.9.7
|
||||||
|
77
src-tauri/Cargo.lock
generated
@ -41,6 +41,45 @@ dependencies = [
|
|||||||
"alloc-no-stdlib",
|
"alloc-no-stdlib",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ambient-light-control"
|
||||||
|
version = "2.0.0-alpha"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"color_space",
|
||||||
|
"core-foundation 0.9.4",
|
||||||
|
"core-graphics 0.22.3",
|
||||||
|
"coreaudio-rs",
|
||||||
|
"ddc-hi",
|
||||||
|
"dirs 5.0.1",
|
||||||
|
"display-info",
|
||||||
|
"env_logger",
|
||||||
|
"futures",
|
||||||
|
"futures-util",
|
||||||
|
"hex",
|
||||||
|
"image",
|
||||||
|
"itertools 0.10.5",
|
||||||
|
"log",
|
||||||
|
"mdns-sd",
|
||||||
|
"paris",
|
||||||
|
"percent-encoding",
|
||||||
|
"regex",
|
||||||
|
"screen-capture-kit",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha1",
|
||||||
|
"tauri",
|
||||||
|
"tauri-build",
|
||||||
|
"tauri-plugin-shell",
|
||||||
|
"time",
|
||||||
|
"tokio",
|
||||||
|
"tokio-stream",
|
||||||
|
"tokio-tungstenite",
|
||||||
|
"tokio-util",
|
||||||
|
"toml 0.7.8",
|
||||||
|
"url-build-parse",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "android-tzdata"
|
name = "android-tzdata"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -4398,44 +4437,6 @@ dependencies = [
|
|||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "test-demo"
|
|
||||||
version = "0.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"color_space",
|
|
||||||
"core-foundation 0.9.4",
|
|
||||||
"core-graphics 0.22.3",
|
|
||||||
"coreaudio-rs",
|
|
||||||
"ddc-hi",
|
|
||||||
"dirs 5.0.1",
|
|
||||||
"display-info",
|
|
||||||
"env_logger",
|
|
||||||
"futures",
|
|
||||||
"futures-util",
|
|
||||||
"hex",
|
|
||||||
"image",
|
|
||||||
"itertools 0.10.5",
|
|
||||||
"log",
|
|
||||||
"mdns-sd",
|
|
||||||
"paris",
|
|
||||||
"percent-encoding",
|
|
||||||
"regex",
|
|
||||||
"screen-capture-kit",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"sha1",
|
|
||||||
"tauri",
|
|
||||||
"tauri-build",
|
|
||||||
"tauri-plugin-shell",
|
|
||||||
"time",
|
|
||||||
"tokio",
|
|
||||||
"tokio-stream",
|
|
||||||
"tokio-tungstenite",
|
|
||||||
"toml 0.7.8",
|
|
||||||
"url-build-parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.69"
|
version = "1.0.69"
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "test-demo"
|
name = "ambient-light-control"
|
||||||
version = "0.0.0"
|
version = "2.0.0-alpha"
|
||||||
description = "A Tauri App"
|
description = "A desktop application for controlling ambient lighting based on screen content"
|
||||||
authors = ["you"]
|
authors = ["Ivan Li"]
|
||||||
license = ""
|
license = "MIT"
|
||||||
repository = ""
|
repository = "https://github.com/ivan/display-ambient-light"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@ -23,6 +23,7 @@ core-graphics = "0.22.3"
|
|||||||
display-info = "0.4.1"
|
display-info = "0.4.1"
|
||||||
anyhow = "1.0.69"
|
anyhow = "1.0.69"
|
||||||
tokio = {version = "1.26.0", features = ["full"] }
|
tokio = {version = "1.26.0", features = ["full"] }
|
||||||
|
tokio-util = "0.7"
|
||||||
paris = { version = "1.5", features = ["timestamps", "macros"] }
|
paris = { version = "1.5", features = ["timestamps", "macros"] }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
|
3
src-tauri/src-tauri/.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
# Generated by Cargo
|
|
||||||
# will have compiled files and executables
|
|
||||||
/target/
|
|
@ -1,26 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "app"
|
|
||||||
version = "0.1.0"
|
|
||||||
description = "A Tauri App"
|
|
||||||
authors = ["you"]
|
|
||||||
license = ""
|
|
||||||
repository = ""
|
|
||||||
default-run = "app"
|
|
||||||
edition = "2021"
|
|
||||||
rust-version = "1.60"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
tauri-build = { version = "1.5.6" }
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
serde_json = "1.0"
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
tauri = { version = "1.8.2" }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
|
||||||
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
|
|
||||||
# DO NOT REMOVE!!
|
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
|
@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
tauri_build::build()
|
|
||||||
}
|
|
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 49 KiB |
@ -1,8 +0,0 @@
|
|||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
tauri::Builder::default()
|
|
||||||
.run(tauri::generate_context!())
|
|
||||||
.expect("error while running tauri application");
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
{
|
|
||||||
"build": {
|
|
||||||
"beforeBuildCommand": "npm run build",
|
|
||||||
"beforeDevCommand": "npm run dev",
|
|
||||||
"devPath": "http://localhost:4000",
|
|
||||||
"distDir": "../dist"
|
|
||||||
},
|
|
||||||
"package": {
|
|
||||||
"productName": "Tauri App",
|
|
||||||
"version": "0.1.0"
|
|
||||||
},
|
|
||||||
"tauri": {
|
|
||||||
"allowlist": {
|
|
||||||
"all": false
|
|
||||||
},
|
|
||||||
"bundle": {
|
|
||||||
"active": true,
|
|
||||||
"category": "DeveloperTool",
|
|
||||||
"copyright": "",
|
|
||||||
"deb": {
|
|
||||||
"depends": []
|
|
||||||
},
|
|
||||||
"externalBin": [],
|
|
||||||
"icon": [
|
|
||||||
"icons/32x32.png",
|
|
||||||
"icons/128x128.png",
|
|
||||||
"icons/128x128@2x.png",
|
|
||||||
"icons/icon.icns",
|
|
||||||
"icons/icon.ico"
|
|
||||||
],
|
|
||||||
"identifier": "com.tauri.dev",
|
|
||||||
"longDescription": "",
|
|
||||||
"macOS": {
|
|
||||||
"entitlements": null,
|
|
||||||
"exceptionDomain": "",
|
|
||||||
"frameworks": [],
|
|
||||||
"providerShortName": null,
|
|
||||||
"signingIdentity": null
|
|
||||||
},
|
|
||||||
"resources": [],
|
|
||||||
"shortDescription": "",
|
|
||||||
"targets": "all",
|
|
||||||
"windows": {
|
|
||||||
"certificateThumbprint": null,
|
|
||||||
"digestAlgorithm": "sha256",
|
|
||||||
"timestampUrl": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": {
|
|
||||||
"csp": null
|
|
||||||
},
|
|
||||||
"updater": {
|
|
||||||
"active": false
|
|
||||||
},
|
|
||||||
"windows": [
|
|
||||||
{
|
|
||||||
"fullscreen": false,
|
|
||||||
"height": 600,
|
|
||||||
"resizable": true,
|
|
||||||
"title": "Tauri",
|
|
||||||
"width": 800
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,6 +16,18 @@ pub enum Border {
|
|||||||
Right,
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq)]
|
||||||
|
pub enum LedType {
|
||||||
|
WS2812B,
|
||||||
|
SK6812,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for LedType {
|
||||||
|
fn default() -> Self {
|
||||||
|
LedType::WS2812B
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||||
pub struct LedStripConfig {
|
pub struct LedStripConfig {
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
@ -23,6 +35,8 @@ pub struct LedStripConfig {
|
|||||||
pub display_id: u32,
|
pub display_id: u32,
|
||||||
pub start_pos: usize,
|
pub start_pos: usize,
|
||||||
pub len: usize,
|
pub len: usize,
|
||||||
|
#[serde(default)]
|
||||||
|
pub led_type: LedType,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||||
@ -30,6 +44,12 @@ pub struct ColorCalibration {
|
|||||||
r: f32,
|
r: f32,
|
||||||
g: f32,
|
g: f32,
|
||||||
b: f32,
|
b: f32,
|
||||||
|
#[serde(default = "default_w_value")]
|
||||||
|
w: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_w_value() -> f32 {
|
||||||
|
1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ColorCalibration {
|
impl ColorCalibration {
|
||||||
@ -40,6 +60,15 @@ impl ColorCalibration {
|
|||||||
(self.b * 255.0) as u8,
|
(self.b * 255.0) as u8,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_bytes_rgbw(&self) -> [u8; 4] {
|
||||||
|
[
|
||||||
|
(self.r * 255.0) as u8,
|
||||||
|
(self.g * 255.0) as u8,
|
||||||
|
(self.b * 255.0) as u8,
|
||||||
|
(self.w * 255.0) as u8,
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
@ -122,6 +151,7 @@ impl LedStripConfigGroup {
|
|||||||
},
|
},
|
||||||
start_pos: j + i * 4 * 30,
|
start_pos: j + i * 4 * 30,
|
||||||
len: 30,
|
len: 30,
|
||||||
|
led_type: LedType::WS2812B,
|
||||||
};
|
};
|
||||||
configs.push(item);
|
configs.push(item);
|
||||||
strips.push(item);
|
strips.push(item);
|
||||||
@ -136,6 +166,7 @@ impl LedStripConfigGroup {
|
|||||||
r: 1.0,
|
r: 1.0,
|
||||||
g: 1.0,
|
g: 1.0,
|
||||||
b: 1.0,
|
b: 1.0,
|
||||||
|
w: 1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -5,7 +5,7 @@ use tokio::{sync::OnceCell, task::yield_now};
|
|||||||
|
|
||||||
use crate::ambient_light::{config, LedStripConfigGroup};
|
use crate::ambient_light::{config, LedStripConfigGroup};
|
||||||
|
|
||||||
use super::{Border, SamplePointMapper, ColorCalibration};
|
use super::{Border, SamplePointMapper, ColorCalibration, LedType};
|
||||||
|
|
||||||
pub struct ConfigManager {
|
pub struct ConfigManager {
|
||||||
config: Arc<RwLock<LedStripConfigGroup>>,
|
config: Arc<RwLock<LedStripConfigGroup>>,
|
||||||
@ -94,6 +94,33 @@ impl ConfigManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn patch_led_strip_type(
|
||||||
|
&self,
|
||||||
|
display_id: u32,
|
||||||
|
border: Border,
|
||||||
|
led_type: LedType,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let mut config = self.config.write().await;
|
||||||
|
|
||||||
|
for strip in config.strips.iter_mut() {
|
||||||
|
if strip.display_id == display_id && strip.border == border {
|
||||||
|
strip.led_type = led_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let cloned_config = config.clone();
|
||||||
|
|
||||||
|
drop(config);
|
||||||
|
|
||||||
|
self.update(&cloned_config).await?;
|
||||||
|
|
||||||
|
self.config_update_sender
|
||||||
|
.send(cloned_config)
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to send config update: {}", e))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn move_strip_part(
|
pub async fn move_strip_part(
|
||||||
&self,
|
&self,
|
||||||
display_id: u32,
|
display_id: u32,
|
||||||
|
@ -18,7 +18,7 @@ use crate::{
|
|||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use super::{LedStripConfigGroup, SamplePointMapper};
|
use super::{LedStripConfigGroup, SamplePointMapper, LedStripConfig, ColorCalibration, LedType};
|
||||||
|
|
||||||
pub struct LedColorsPublisher {
|
pub struct LedColorsPublisher {
|
||||||
sorted_colors_rx: Arc<RwLock<watch::Receiver<Vec<u8>>>>,
|
sorted_colors_rx: Arc<RwLock<watch::Receiver<Vec<u8>>>>,
|
||||||
@ -26,6 +26,7 @@ pub struct LedColorsPublisher {
|
|||||||
colors_rx: Arc<RwLock<watch::Receiver<Vec<u8>>>>,
|
colors_rx: Arc<RwLock<watch::Receiver<Vec<u8>>>>,
|
||||||
colors_tx: Arc<RwLock<watch::Sender<Vec<u8>>>>,
|
colors_tx: Arc<RwLock<watch::Sender<Vec<u8>>>>,
|
||||||
inner_tasks_version: Arc<RwLock<usize>>,
|
inner_tasks_version: Arc<RwLock<usize>>,
|
||||||
|
test_mode_active: Arc<RwLock<bool>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LedColorsPublisher {
|
impl LedColorsPublisher {
|
||||||
@ -44,6 +45,7 @@ impl LedColorsPublisher {
|
|||||||
colors_rx: Arc::new(RwLock::new(rx)),
|
colors_rx: Arc::new(RwLock::new(rx)),
|
||||||
colors_tx: Arc::new(RwLock::new(tx)),
|
colors_tx: Arc::new(RwLock::new(tx)),
|
||||||
inner_tasks_version: Arc::new(RwLock::new(0)),
|
inner_tasks_version: Arc::new(RwLock::new(0)),
|
||||||
|
test_mode_active: Arc::new(RwLock::new(false)),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@ -56,6 +58,8 @@ impl LedColorsPublisher {
|
|||||||
bound_scale_factor: f32,
|
bound_scale_factor: f32,
|
||||||
mappers: Vec<SamplePointMapper>,
|
mappers: Vec<SamplePointMapper>,
|
||||||
display_colors_tx: broadcast::Sender<(u32, Vec<u8>)>,
|
display_colors_tx: broadcast::Sender<(u32, Vec<u8>)>,
|
||||||
|
strips: Vec<LedStripConfig>,
|
||||||
|
color_calibration: ColorCalibration,
|
||||||
) {
|
) {
|
||||||
let internal_tasks_version = self.inner_tasks_version.clone();
|
let internal_tasks_version = self.inner_tasks_version.clone();
|
||||||
let screenshot_manager = ScreenshotManager::global().await;
|
let screenshot_manager = ScreenshotManager::global().await;
|
||||||
@ -79,7 +83,14 @@ impl LedColorsPublisher {
|
|||||||
|
|
||||||
let mappers = mappers.clone();
|
let mappers = mappers.clone();
|
||||||
|
|
||||||
match Self::send_colors_by_display(colors, mappers).await {
|
// Check if test mode is active before sending normal colors
|
||||||
|
let test_mode_active = {
|
||||||
|
let publisher = LedColorsPublisher::global().await;
|
||||||
|
*publisher.test_mode_active.read().await
|
||||||
|
};
|
||||||
|
|
||||||
|
if !test_mode_active {
|
||||||
|
match Self::send_colors_by_display(colors, mappers, &strips, &color_calibration).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// log::info!("sent colors: #{: >15}", display_id);
|
// log::info!("sent colors: #{: >15}", display_id);
|
||||||
}
|
}
|
||||||
@ -87,6 +98,7 @@ impl LedColorsPublisher {
|
|||||||
warn!("Failed to send colors: #{: >15}\t{}", display_id, err);
|
warn!("Failed to send colors: #{: >15}\t{}", display_id, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match display_colors_tx.send((
|
match display_colors_tx.send((
|
||||||
display_id,
|
display_id,
|
||||||
@ -209,9 +221,9 @@ impl LedColorsPublisher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_config_change(&self, configs: LedStripConfigGroup) {
|
async fn handle_config_change(&self, original_configs: LedStripConfigGroup) {
|
||||||
let inner_tasks_version = self.inner_tasks_version.clone();
|
let inner_tasks_version = self.inner_tasks_version.clone();
|
||||||
let configs = Self::get_colors_configs(&configs).await;
|
let configs = Self::get_colors_configs(&original_configs).await;
|
||||||
|
|
||||||
if let Err(err) = configs {
|
if let Err(err) = configs {
|
||||||
warn!("Failed to get configs: {}", err);
|
warn!("Failed to get configs: {}", err);
|
||||||
@ -231,12 +243,22 @@ impl LedColorsPublisher {
|
|||||||
let display_id = sample_point_group.display_id;
|
let display_id = sample_point_group.display_id;
|
||||||
let sample_points = sample_point_group.points;
|
let sample_points = sample_point_group.points;
|
||||||
let bound_scale_factor = sample_point_group.bound_scale_factor;
|
let bound_scale_factor = sample_point_group.bound_scale_factor;
|
||||||
|
|
||||||
|
// Get strips for this display
|
||||||
|
let display_strips: Vec<LedStripConfig> = original_configs.strips
|
||||||
|
.iter()
|
||||||
|
.filter(|strip| strip.display_id == display_id)
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
|
|
||||||
self.start_one_display_colors_fetcher(
|
self.start_one_display_colors_fetcher(
|
||||||
display_id,
|
display_id,
|
||||||
sample_points,
|
sample_points,
|
||||||
bound_scale_factor,
|
bound_scale_factor,
|
||||||
sample_point_group.mappers,
|
sample_point_group.mappers,
|
||||||
display_colors_tx.clone(),
|
display_colors_tx.clone(),
|
||||||
|
display_strips,
|
||||||
|
original_configs.color_calibration,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -266,6 +288,8 @@ impl LedColorsPublisher {
|
|||||||
pub async fn send_colors_by_display(
|
pub async fn send_colors_by_display(
|
||||||
colors: Vec<LedColor>,
|
colors: Vec<LedColor>,
|
||||||
mappers: Vec<SamplePointMapper>,
|
mappers: Vec<SamplePointMapper>,
|
||||||
|
strips: &[LedStripConfig],
|
||||||
|
color_calibration: &ColorCalibration,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
// let color_len = colors.len();
|
// let color_len = colors.len();
|
||||||
let display_led_offset = mappers
|
let display_led_offset = mappers
|
||||||
@ -282,7 +306,7 @@ impl LedColorsPublisher {
|
|||||||
let udp_rpc = udp_rpc.as_ref().unwrap();
|
let udp_rpc = udp_rpc.as_ref().unwrap();
|
||||||
|
|
||||||
// let socket = UdpSocket::bind("0.0.0.0:0").await?;
|
// let socket = UdpSocket::bind("0.0.0.0:0").await?;
|
||||||
for group in mappers.clone() {
|
for (group_index, group) in mappers.clone().iter().enumerate() {
|
||||||
if (group.start.abs_diff(group.end)) > colors.len() {
|
if (group.start.abs_diff(group.end)) > colors.len() {
|
||||||
return Err(anyhow::anyhow!(
|
return Err(anyhow::anyhow!(
|
||||||
"get_sorted_colors: color_index out of range. color_index: {}, strip len: {}, colors.len(): {}",
|
"get_sorted_colors: color_index out of range. color_index: {}, strip len: {}, colors.len(): {}",
|
||||||
@ -293,7 +317,20 @@ impl LedColorsPublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let group_size = group.start.abs_diff(group.end);
|
let group_size = group.start.abs_diff(group.end);
|
||||||
let mut buffer = Vec::<u8>::with_capacity(group_size * 3);
|
|
||||||
|
// Find the corresponding LED strip config to get LED type
|
||||||
|
let led_type = if group_index < strips.len() {
|
||||||
|
strips[group_index].led_type
|
||||||
|
} else {
|
||||||
|
LedType::WS2812B // fallback to WS2812B
|
||||||
|
};
|
||||||
|
|
||||||
|
let bytes_per_led = match led_type {
|
||||||
|
LedType::WS2812B => 3,
|
||||||
|
LedType::SK6812 => 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut buffer = Vec::<u8>::with_capacity(group_size * bytes_per_led);
|
||||||
|
|
||||||
if group.end > group.start {
|
if group.end > group.start {
|
||||||
// Prevent integer underflow by using saturating subtraction
|
// Prevent integer underflow by using saturating subtraction
|
||||||
@ -310,12 +347,37 @@ impl LedColorsPublisher {
|
|||||||
|
|
||||||
for i in start_index..end_index {
|
for i in start_index..end_index {
|
||||||
if i < colors.len() {
|
if i < colors.len() {
|
||||||
let bytes = colors[i].as_bytes();
|
let bytes = match led_type {
|
||||||
buffer.append(&mut bytes.to_vec());
|
LedType::WS2812B => {
|
||||||
|
let calibration_bytes = color_calibration.to_bytes();
|
||||||
|
let color_bytes = colors[i].as_bytes();
|
||||||
|
// Apply calibration to RGB values
|
||||||
|
vec![
|
||||||
|
((color_bytes[0] as f32 * calibration_bytes[0] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[1] as f32 * calibration_bytes[1] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
LedType::SK6812 => {
|
||||||
|
let calibration_bytes = color_calibration.to_bytes_rgbw();
|
||||||
|
let color_bytes = colors[i].as_bytes();
|
||||||
|
// Apply calibration to RGB values and use calibrated W
|
||||||
|
vec![
|
||||||
|
((color_bytes[0] as f32 * calibration_bytes[0] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[1] as f32 * calibration_bytes[1] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8),
|
||||||
|
calibration_bytes[3], // W channel
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
buffer.extend_from_slice(&bytes);
|
||||||
} else {
|
} else {
|
||||||
log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len());
|
log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len());
|
||||||
// Add black color as fallback
|
// Add black color as fallback
|
||||||
buffer.append(&mut vec![0, 0, 0]);
|
match led_type {
|
||||||
|
LedType::WS2812B => buffer.extend_from_slice(&[0, 0, 0]),
|
||||||
|
LedType::SK6812 => buffer.extend_from_slice(&[0, 0, 0, 0]),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -333,20 +395,47 @@ impl LedColorsPublisher {
|
|||||||
|
|
||||||
for i in (start_index..end_index).rev() {
|
for i in (start_index..end_index).rev() {
|
||||||
if i < colors.len() {
|
if i < colors.len() {
|
||||||
let bytes = colors[i].as_bytes();
|
let bytes = match led_type {
|
||||||
buffer.append(&mut bytes.to_vec());
|
LedType::WS2812B => {
|
||||||
|
let calibration_bytes = color_calibration.to_bytes();
|
||||||
|
let color_bytes = colors[i].as_bytes();
|
||||||
|
// Apply calibration to RGB values
|
||||||
|
vec![
|
||||||
|
((color_bytes[0] as f32 * calibration_bytes[0] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[1] as f32 * calibration_bytes[1] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
LedType::SK6812 => {
|
||||||
|
let calibration_bytes = color_calibration.to_bytes_rgbw();
|
||||||
|
let color_bytes = colors[i].as_bytes();
|
||||||
|
// Apply calibration to RGB values and use calibrated W
|
||||||
|
vec![
|
||||||
|
((color_bytes[0] as f32 * calibration_bytes[0] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[1] as f32 * calibration_bytes[1] as f32 / 255.0) as u8),
|
||||||
|
((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8),
|
||||||
|
calibration_bytes[3], // W channel
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
buffer.extend_from_slice(&bytes);
|
||||||
} else {
|
} else {
|
||||||
log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len());
|
log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len());
|
||||||
// Add black color as fallback
|
// Add black color as fallback
|
||||||
buffer.append(&mut vec![0, 0, 0]);
|
match led_type {
|
||||||
|
LedType::WS2812B => buffer.extend_from_slice(&[0, 0, 0]),
|
||||||
|
LedType::SK6812 => buffer.extend_from_slice(&[0, 0, 0, 0]),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let offset = group.start.min(group.end);
|
// Calculate byte offset based on LED position and LED type
|
||||||
|
let led_offset = group.start.min(group.end);
|
||||||
|
let byte_offset = led_offset * bytes_per_led;
|
||||||
let mut tx_buffer = vec![2];
|
let mut tx_buffer = vec![2];
|
||||||
tx_buffer.push((offset >> 8) as u8);
|
tx_buffer.push((byte_offset >> 8) as u8);
|
||||||
tx_buffer.push((offset & 0xff) as u8);
|
tx_buffer.push((byte_offset & 0xff) as u8);
|
||||||
tx_buffer.append(&mut buffer);
|
tx_buffer.append(&mut buffer);
|
||||||
|
|
||||||
udp_rpc.send_to_all(&tx_buffer).await?;
|
udp_rpc.send_to_all(&tx_buffer).await?;
|
||||||
@ -455,6 +544,35 @@ impl LedColorsPublisher {
|
|||||||
pub async fn clone_colors_receiver(&self) -> watch::Receiver<Vec<u8>> {
|
pub async fn clone_colors_receiver(&self) -> watch::Receiver<Vec<u8>> {
|
||||||
self.colors_rx.read().await.clone()
|
self.colors_rx.read().await.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enable test mode - this will pause normal LED data publishing
|
||||||
|
pub async fn enable_test_mode(&self) {
|
||||||
|
let mut test_mode = self.test_mode_active.write().await;
|
||||||
|
*test_mode = true;
|
||||||
|
log::info!("Test mode enabled - normal LED publishing paused");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Disable test mode - this will resume normal LED data publishing
|
||||||
|
pub async fn disable_test_mode(&self) {
|
||||||
|
let mut test_mode = self.test_mode_active.write().await;
|
||||||
|
*test_mode = false;
|
||||||
|
log::info!("Test mode disabled - normal LED publishing resumed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Disable test mode with a delay to ensure clean transition
|
||||||
|
pub async fn disable_test_mode_with_delay(&self, delay_ms: u64) {
|
||||||
|
// Wait for the specified delay
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_millis(delay_ms)).await;
|
||||||
|
|
||||||
|
let mut test_mode = self.test_mode_active.write().await;
|
||||||
|
*test_mode = false;
|
||||||
|
log::info!("Test mode disabled with delay - normal LED publishing resumed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if test mode is currently active
|
||||||
|
pub async fn is_test_mode_active(&self) -> bool {
|
||||||
|
*self.test_mode_active.read().await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -43,6 +43,10 @@ impl LedColor {
|
|||||||
pub fn as_bytes (&self) -> [u8; 3] {
|
pub fn as_bytes (&self) -> [u8; 3] {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn as_bytes_rgbw(&self, w: u8) -> [u8; 4] {
|
||||||
|
[self.0[0], self.0[1], self.0[2], w]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for LedColor {
|
impl Serialize for LedColor {
|
||||||
|
243
src-tauri/src/led_test_effects.rs
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
use std::f64::consts::PI;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub enum TestEffectType {
|
||||||
|
FlowingRainbow,
|
||||||
|
GroupCounting,
|
||||||
|
SingleScan,
|
||||||
|
Breathing,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct TestEffectConfig {
|
||||||
|
pub effect_type: TestEffectType,
|
||||||
|
pub led_count: u32,
|
||||||
|
pub led_type: LedType,
|
||||||
|
pub speed: f64, // Speed multiplier
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub enum LedType {
|
||||||
|
WS2812B,
|
||||||
|
SK6812,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct LedTestEffects;
|
||||||
|
|
||||||
|
impl LedTestEffects {
|
||||||
|
/// Check if LED type supports white channel (RGBW)
|
||||||
|
fn is_rgbw_type(led_type: &LedType) -> bool {
|
||||||
|
matches!(led_type, LedType::SK6812)
|
||||||
|
}
|
||||||
|
/// Generate LED colors for a specific test effect at a given time
|
||||||
|
pub fn generate_colors(config: &TestEffectConfig, time_ms: u64) -> Vec<u8> {
|
||||||
|
let time_seconds = time_ms as f64 / 1000.0;
|
||||||
|
|
||||||
|
match config.effect_type {
|
||||||
|
TestEffectType::FlowingRainbow => {
|
||||||
|
Self::flowing_rainbow(config.led_count, config.led_type.clone(), time_seconds, config.speed)
|
||||||
|
}
|
||||||
|
TestEffectType::GroupCounting => {
|
||||||
|
Self::group_counting(config.led_count, config.led_type.clone())
|
||||||
|
}
|
||||||
|
TestEffectType::SingleScan => {
|
||||||
|
Self::single_scan(config.led_count, config.led_type.clone(), time_seconds, config.speed)
|
||||||
|
}
|
||||||
|
TestEffectType::Breathing => {
|
||||||
|
Self::breathing(config.led_count, config.led_type.clone(), time_seconds, config.speed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Flowing rainbow effect - smooth rainbow colors flowing along the strip
|
||||||
|
fn flowing_rainbow(led_count: u32, led_type: LedType, time: f64, speed: f64) -> Vec<u8> {
|
||||||
|
let mut buffer = Vec::new();
|
||||||
|
let time_offset = (time * speed * 60.0) % 360.0; // 60 degrees per second at speed 1.0
|
||||||
|
|
||||||
|
for i in 0..led_count {
|
||||||
|
// Create longer wavelength for smoother color transitions
|
||||||
|
let hue = ((i as f64 * 720.0 / led_count as f64) + time_offset) % 360.0;
|
||||||
|
let rgb = Self::hsv_to_rgb(hue, 1.0, 1.0);
|
||||||
|
|
||||||
|
buffer.push(rgb.0);
|
||||||
|
buffer.push(rgb.1);
|
||||||
|
buffer.push(rgb.2);
|
||||||
|
|
||||||
|
if Self::is_rgbw_type(&led_type) {
|
||||||
|
buffer.push(0); // White channel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Group counting effect - every 10 LEDs have different colors
|
||||||
|
fn group_counting(led_count: u32, led_type: LedType) -> Vec<u8> {
|
||||||
|
let mut buffer = Vec::new();
|
||||||
|
|
||||||
|
let group_colors = [
|
||||||
|
(255, 0, 0), // Red (1-10)
|
||||||
|
(0, 255, 0), // Green (11-20)
|
||||||
|
(0, 0, 255), // Blue (21-30)
|
||||||
|
(255, 255, 0), // Yellow (31-40)
|
||||||
|
(255, 0, 255), // Magenta (41-50)
|
||||||
|
(0, 255, 255), // Cyan (51-60)
|
||||||
|
(255, 128, 0), // Orange (61-70)
|
||||||
|
(128, 255, 0), // Lime (71-80)
|
||||||
|
(255, 255, 255), // White (81-90)
|
||||||
|
(128, 128, 128), // Gray (91-100)
|
||||||
|
];
|
||||||
|
|
||||||
|
for i in 0..led_count {
|
||||||
|
let group_index = (i / 10) % group_colors.len() as u32;
|
||||||
|
let color = group_colors[group_index as usize];
|
||||||
|
|
||||||
|
buffer.push(color.0);
|
||||||
|
buffer.push(color.1);
|
||||||
|
buffer.push(color.2);
|
||||||
|
|
||||||
|
if Self::is_rgbw_type(&led_type) {
|
||||||
|
buffer.push(0); // White channel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Single LED scan effect - one LED moves along the strip
|
||||||
|
fn single_scan(led_count: u32, led_type: LedType, time: f64, speed: f64) -> Vec<u8> {
|
||||||
|
let mut buffer = Vec::new();
|
||||||
|
let scan_period = 2.0 / speed; // 2 seconds per full scan at speed 1.0
|
||||||
|
let active_index = ((time / scan_period * led_count as f64) as u32) % led_count;
|
||||||
|
|
||||||
|
for i in 0..led_count {
|
||||||
|
if i == active_index {
|
||||||
|
// Bright white LED
|
||||||
|
buffer.push(255);
|
||||||
|
buffer.push(255);
|
||||||
|
buffer.push(255);
|
||||||
|
|
||||||
|
if Self::is_rgbw_type(&led_type) {
|
||||||
|
buffer.push(255); // White channel
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Off
|
||||||
|
buffer.push(0);
|
||||||
|
buffer.push(0);
|
||||||
|
buffer.push(0);
|
||||||
|
|
||||||
|
if Self::is_rgbw_type(&led_type) {
|
||||||
|
buffer.push(0); // White channel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Breathing effect - entire strip breathes with white light
|
||||||
|
fn breathing(led_count: u32, led_type: LedType, time: f64, speed: f64) -> Vec<u8> {
|
||||||
|
let mut buffer = Vec::new();
|
||||||
|
let breathing_period = 4.0 / speed; // 4 seconds per breath at speed 1.0
|
||||||
|
let brightness = ((time / breathing_period * 2.0 * PI).sin() * 0.5 + 0.5) * 255.0;
|
||||||
|
let brightness = brightness as u8;
|
||||||
|
|
||||||
|
for _i in 0..led_count {
|
||||||
|
buffer.push(brightness);
|
||||||
|
buffer.push(brightness);
|
||||||
|
buffer.push(brightness);
|
||||||
|
|
||||||
|
if Self::is_rgbw_type(&led_type) {
|
||||||
|
buffer.push(brightness); // White channel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert HSV to RGB
|
||||||
|
/// H: 0-360, S: 0-1, V: 0-1
|
||||||
|
/// Returns: (R, G, B) where each component is 0-255
|
||||||
|
fn hsv_to_rgb(h: f64, s: f64, v: f64) -> (u8, u8, u8) {
|
||||||
|
let c = v * s;
|
||||||
|
let x = c * (1.0 - ((h / 60.0) % 2.0 - 1.0).abs());
|
||||||
|
let m = v - c;
|
||||||
|
|
||||||
|
let (r_prime, g_prime, b_prime) = if h < 60.0 {
|
||||||
|
(c, x, 0.0)
|
||||||
|
} else if h < 120.0 {
|
||||||
|
(x, c, 0.0)
|
||||||
|
} else if h < 180.0 {
|
||||||
|
(0.0, c, x)
|
||||||
|
} else if h < 240.0 {
|
||||||
|
(0.0, x, c)
|
||||||
|
} else if h < 300.0 {
|
||||||
|
(x, 0.0, c)
|
||||||
|
} else {
|
||||||
|
(c, 0.0, x)
|
||||||
|
};
|
||||||
|
|
||||||
|
let r = ((r_prime + m) * 255.0).round() as u8;
|
||||||
|
let g = ((g_prime + m) * 255.0).round() as u8;
|
||||||
|
let b = ((b_prime + m) * 255.0).round() as u8;
|
||||||
|
|
||||||
|
(r, g, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hsv_to_rgb() {
|
||||||
|
// Test red
|
||||||
|
let (r, g, b) = LedTestEffects::hsv_to_rgb(0.0, 1.0, 1.0);
|
||||||
|
assert_eq!((r, g, b), (255, 0, 0));
|
||||||
|
|
||||||
|
// Test green
|
||||||
|
let (r, g, b) = LedTestEffects::hsv_to_rgb(120.0, 1.0, 1.0);
|
||||||
|
assert_eq!((r, g, b), (0, 255, 0));
|
||||||
|
|
||||||
|
// Test blue
|
||||||
|
let (r, g, b) = LedTestEffects::hsv_to_rgb(240.0, 1.0, 1.0);
|
||||||
|
assert_eq!((r, g, b), (0, 0, 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_flowing_rainbow() {
|
||||||
|
let config = TestEffectConfig {
|
||||||
|
effect_type: TestEffectType::FlowingRainbow,
|
||||||
|
led_count: 10,
|
||||||
|
led_type: LedType::RGB,
|
||||||
|
speed: 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let colors = LedTestEffects::generate_colors(&config, 0);
|
||||||
|
assert_eq!(colors.len(), 30); // 10 LEDs * 3 bytes each
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_group_counting() {
|
||||||
|
let config = TestEffectConfig {
|
||||||
|
effect_type: TestEffectType::GroupCounting,
|
||||||
|
led_count: 20,
|
||||||
|
led_type: LedType::RGB,
|
||||||
|
speed: 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let colors = LedTestEffects::generate_colors(&config, 0);
|
||||||
|
assert_eq!(colors.len(), 60); // 20 LEDs * 3 bytes each
|
||||||
|
|
||||||
|
// First 10 should be red
|
||||||
|
assert_eq!(colors[0], 255); // R
|
||||||
|
assert_eq!(colors[1], 0); // G
|
||||||
|
assert_eq!(colors[2], 0); // B
|
||||||
|
|
||||||
|
// Next 10 should be green
|
||||||
|
assert_eq!(colors[30], 0); // R
|
||||||
|
assert_eq!(colors[31], 255); // G
|
||||||
|
assert_eq!(colors[32], 0); // B
|
||||||
|
}
|
||||||
|
}
|
@ -4,15 +4,17 @@
|
|||||||
mod ambient_light;
|
mod ambient_light;
|
||||||
mod display;
|
mod display;
|
||||||
mod led_color;
|
mod led_color;
|
||||||
|
mod led_test_effects;
|
||||||
mod rpc;
|
mod rpc;
|
||||||
mod screenshot;
|
mod screenshot;
|
||||||
mod screenshot_manager;
|
mod screenshot_manager;
|
||||||
mod screen_stream;
|
mod screen_stream;
|
||||||
mod volume;
|
mod volume;
|
||||||
|
|
||||||
use ambient_light::{Border, ColorCalibration, LedStripConfig, LedStripConfigGroup};
|
use ambient_light::{Border, ColorCalibration, LedStripConfig, LedStripConfigGroup, LedType};
|
||||||
use display::{DisplayManager, DisplayState};
|
use display::{DisplayManager, DisplayState};
|
||||||
use display_info::DisplayInfo;
|
use display_info::DisplayInfo;
|
||||||
|
use led_test_effects::{LedTestEffects, TestEffectConfig, TestEffectType};
|
||||||
use paris::{error, info, warn};
|
use paris::{error, info, warn};
|
||||||
use rpc::{BoardInfo, UdpRpc};
|
use rpc::{BoardInfo, UdpRpc};
|
||||||
use screenshot::Screenshot;
|
use screenshot::Screenshot;
|
||||||
@ -24,6 +26,14 @@ use tauri::{Manager, Emitter, Runtime};
|
|||||||
use regex;
|
use regex;
|
||||||
use tauri::http::{Request, Response};
|
use tauri::http::{Request, Response};
|
||||||
use volume::VolumeManager;
|
use volume::VolumeManager;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
// Global static variables for LED test effect management
|
||||||
|
static EFFECT_HANDLE: tokio::sync::OnceCell<Arc<RwLock<Option<tokio::task::JoinHandle<()>>>>> =
|
||||||
|
tokio::sync::OnceCell::const_new();
|
||||||
|
static CANCEL_TOKEN: tokio::sync::OnceCell<Arc<RwLock<Option<tokio_util::sync::CancellationToken>>>> =
|
||||||
|
tokio::sync::OnceCell::const_new();
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(remote = "DisplayInfo")]
|
#[serde(remote = "DisplayInfo")]
|
||||||
struct DisplayInfoDef {
|
struct DisplayInfoDef {
|
||||||
@ -138,6 +148,20 @@ async fn patch_led_strip_len(display_id: u32, border: Border, delta_len: i8) ->
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn patch_led_strip_type(display_id: u32, border: Border, led_type: LedType) -> Result<(), String> {
|
||||||
|
let config_manager = ambient_light::ConfigManager::global().await;
|
||||||
|
config_manager
|
||||||
|
.patch_led_strip_type(display_id, border, led_type)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
error!("can not patch led strip type: {}", e);
|
||||||
|
e.to_string()
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn send_colors(offset: u16, buffer: Vec<u8>) -> Result<(), String> {
|
async fn send_colors(offset: u16, buffer: Vec<u8>) -> Result<(), String> {
|
||||||
ambient_light::LedColorsPublisher::send_colors(offset, buffer)
|
ambient_light::LedColorsPublisher::send_colors(offset, buffer)
|
||||||
@ -148,6 +172,193 @@ async fn send_colors(offset: u16, buffer: Vec<u8>) -> Result<(), String> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn send_test_colors_to_board(board_address: String, offset: u16, buffer: Vec<u8>) -> Result<(), String> {
|
||||||
|
use tokio::net::UdpSocket;
|
||||||
|
|
||||||
|
let socket = UdpSocket::bind("0.0.0.0:0").await.map_err(|e| {
|
||||||
|
error!("Failed to bind UDP socket: {}", e);
|
||||||
|
e.to_string()
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let mut packet = vec![0x02]; // Header
|
||||||
|
packet.push((offset >> 8) as u8); // Byte offset high
|
||||||
|
packet.push((offset & 0xff) as u8); // Byte offset low
|
||||||
|
packet.extend_from_slice(&buffer); // Color data
|
||||||
|
|
||||||
|
socket.send_to(&packet, &board_address).await.map_err(|e| {
|
||||||
|
error!("Failed to send test colors to board {}: {}", board_address, e);
|
||||||
|
e.to_string()
|
||||||
|
})?;
|
||||||
|
|
||||||
|
info!("Sent test colors to board {} with offset {} and {} bytes", board_address, offset, buffer.len());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn enable_test_mode() -> Result<(), String> {
|
||||||
|
let publisher = ambient_light::LedColorsPublisher::global().await;
|
||||||
|
publisher.enable_test_mode().await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn disable_test_mode() -> Result<(), String> {
|
||||||
|
info!("🔄 disable_test_mode command called from frontend");
|
||||||
|
let publisher = ambient_light::LedColorsPublisher::global().await;
|
||||||
|
publisher.disable_test_mode().await;
|
||||||
|
info!("✅ disable_test_mode command completed");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn is_test_mode_active() -> Result<bool, String> {
|
||||||
|
let publisher = ambient_light::LedColorsPublisher::global().await;
|
||||||
|
Ok(publisher.is_test_mode_active().await)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn start_led_test_effect(
|
||||||
|
board_address: String,
|
||||||
|
effect_config: TestEffectConfig,
|
||||||
|
update_interval_ms: u64,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
use tokio::time::{interval, Duration};
|
||||||
|
|
||||||
|
// Enable test mode first
|
||||||
|
let publisher = ambient_light::LedColorsPublisher::global().await;
|
||||||
|
publisher.enable_test_mode().await;
|
||||||
|
|
||||||
|
let handle_storage = EFFECT_HANDLE.get_or_init(|| async {
|
||||||
|
Arc::new(RwLock::new(None))
|
||||||
|
}).await;
|
||||||
|
|
||||||
|
let cancel_storage = CANCEL_TOKEN.get_or_init(|| async {
|
||||||
|
Arc::new(RwLock::new(None))
|
||||||
|
}).await;
|
||||||
|
|
||||||
|
// Stop any existing effect
|
||||||
|
{
|
||||||
|
let mut cancel_guard = cancel_storage.write().await;
|
||||||
|
if let Some(token) = cancel_guard.take() {
|
||||||
|
token.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut handle_guard = handle_storage.write().await;
|
||||||
|
if let Some(handle) = handle_guard.take() {
|
||||||
|
let _ = handle.await; // Wait for graceful shutdown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start new effect
|
||||||
|
let effect_config = Arc::new(effect_config);
|
||||||
|
let board_address = Arc::new(board_address);
|
||||||
|
let start_time = std::time::Instant::now();
|
||||||
|
|
||||||
|
// Create new cancellation token
|
||||||
|
let cancel_token = tokio_util::sync::CancellationToken::new();
|
||||||
|
let cancel_token_clone = cancel_token.clone();
|
||||||
|
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
let mut interval = interval(Duration::from_millis(update_interval_ms));
|
||||||
|
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
_ = interval.tick() => {
|
||||||
|
let elapsed_ms = start_time.elapsed().as_millis() as u64;
|
||||||
|
let colors = LedTestEffects::generate_colors(&effect_config, elapsed_ms);
|
||||||
|
|
||||||
|
// Send to board
|
||||||
|
if let Err(e) = send_test_colors_to_board_internal(&board_address, 0, colors).await {
|
||||||
|
error!("Failed to send test effect colors: {}", e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = cancel_token_clone.cancelled() => {
|
||||||
|
info!("LED test effect cancelled gracefully");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info!("LED test effect task ended");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Store the handle and cancel token
|
||||||
|
{
|
||||||
|
let mut handle_guard = handle_storage.write().await;
|
||||||
|
*handle_guard = Some(handle);
|
||||||
|
|
||||||
|
let mut cancel_guard = cancel_storage.write().await;
|
||||||
|
*cancel_guard = Some(cancel_token);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn stop_led_test_effect(board_address: String, led_count: u32, led_type: led_test_effects::LedType) -> Result<(), String> {
|
||||||
|
// Stop the effect task first
|
||||||
|
|
||||||
|
info!("🛑 Stopping LED test effect - board: {}", board_address);
|
||||||
|
|
||||||
|
// Cancel the task gracefully first
|
||||||
|
if let Some(cancel_storage) = CANCEL_TOKEN.get() {
|
||||||
|
let mut cancel_guard = cancel_storage.write().await;
|
||||||
|
if let Some(token) = cancel_guard.take() {
|
||||||
|
info!("🔄 Cancelling test effect task gracefully");
|
||||||
|
token.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for the task to finish
|
||||||
|
if let Some(handle_storage) = EFFECT_HANDLE.get() {
|
||||||
|
let mut handle_guard = handle_storage.write().await;
|
||||||
|
if let Some(handle) = handle_guard.take() {
|
||||||
|
info!("⏳ Waiting for test effect task to finish");
|
||||||
|
match handle.await {
|
||||||
|
Ok(_) => info!("✅ Test effect task finished successfully"),
|
||||||
|
Err(e) => warn!("⚠️ Test effect task finished with error: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Turn off all LEDs
|
||||||
|
let bytes_per_led = match led_type {
|
||||||
|
led_test_effects::LedType::WS2812B => 3,
|
||||||
|
led_test_effects::LedType::SK6812 => 4,
|
||||||
|
};
|
||||||
|
let buffer = vec![0u8; (led_count * bytes_per_led) as usize];
|
||||||
|
|
||||||
|
send_test_colors_to_board_internal(&board_address, 0, buffer).await
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
info!("💡 Sent LED off command");
|
||||||
|
|
||||||
|
// Disable test mode to resume normal publishing
|
||||||
|
let publisher = ambient_light::LedColorsPublisher::global().await;
|
||||||
|
publisher.disable_test_mode().await;
|
||||||
|
|
||||||
|
info!("🔄 Test mode disabled, normal publishing resumed");
|
||||||
|
info!("✅ LED test effect stopped completely");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Internal helper function
|
||||||
|
async fn send_test_colors_to_board_internal(board_address: &str, offset: u16, buffer: Vec<u8>) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
|
use tokio::net::UdpSocket;
|
||||||
|
|
||||||
|
let socket = UdpSocket::bind("0.0.0.0:0").await?;
|
||||||
|
|
||||||
|
let mut packet = vec![0x02]; // Header
|
||||||
|
packet.push((offset >> 8) as u8); // Byte offset high
|
||||||
|
packet.push((offset & 0xff) as u8); // Byte offset low
|
||||||
|
packet.extend_from_slice(&buffer); // Color data
|
||||||
|
|
||||||
|
socket.send_to(&packet, board_address).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn move_strip_part(
|
async fn move_strip_part(
|
||||||
display_id: u32,
|
display_id: u32,
|
||||||
@ -337,20 +548,7 @@ fn handle_ambient_light_protocol<R: Runtime>(
|
|||||||
async fn main() {
|
async fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
// Debug: Print available displays
|
// Initialize display info (removed debug output)
|
||||||
match display_info::DisplayInfo::all() {
|
|
||||||
Ok(displays) => {
|
|
||||||
println!("=== AVAILABLE DISPLAYS ===");
|
|
||||||
for (index, display) in displays.iter().enumerate() {
|
|
||||||
println!(" Display {}: ID={}, Scale={}, Width={}, Height={}",
|
|
||||||
index, display.id, display.scale_factor, display.width, display.height);
|
|
||||||
}
|
|
||||||
println!("=== END DISPLAYS ===");
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
println!("Error getting display info: {}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let screenshot_manager = ScreenshotManager::global().await;
|
let screenshot_manager = ScreenshotManager::global().await;
|
||||||
@ -383,7 +581,14 @@ async fn main() {
|
|||||||
get_led_strips_sample_points,
|
get_led_strips_sample_points,
|
||||||
get_one_edge_colors,
|
get_one_edge_colors,
|
||||||
patch_led_strip_len,
|
patch_led_strip_len,
|
||||||
|
patch_led_strip_type,
|
||||||
send_colors,
|
send_colors,
|
||||||
|
send_test_colors_to_board,
|
||||||
|
enable_test_mode,
|
||||||
|
disable_test_mode,
|
||||||
|
is_test_mode_active,
|
||||||
|
start_led_test_effect,
|
||||||
|
stop_led_test_effect,
|
||||||
move_strip_part,
|
move_strip_part,
|
||||||
reverse_led_strip_part,
|
reverse_led_strip_part,
|
||||||
set_color_calibration,
|
set_color_calibration,
|
||||||
|
@ -194,25 +194,42 @@ impl UdpRpc {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store previous board states to detect changes
|
||||||
|
let prev_boards = boards
|
||||||
|
.values()
|
||||||
|
.map(|it| async move { it.info.read().await.clone() });
|
||||||
|
let prev_boards = join_all(prev_boards).await;
|
||||||
|
|
||||||
|
// Check all boards
|
||||||
for board in boards.values() {
|
for board in boards.values() {
|
||||||
if let Err(err) = board.check().await {
|
if let Err(err) = board.check().await {
|
||||||
error!("failed to check board: {:?}", err);
|
error!("failed to check board: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tx_boards = boards
|
// Get current board states after check
|
||||||
|
let current_boards = boards
|
||||||
.values()
|
.values()
|
||||||
.map(|it| async move { it.info.read().await.clone() });
|
.map(|it| async move { it.info.read().await.clone() });
|
||||||
let tx_boards = join_all(tx_boards).await;
|
let current_boards = join_all(current_boards).await;
|
||||||
|
|
||||||
drop(boards);
|
drop(boards);
|
||||||
|
|
||||||
|
// Only send update if there are actual changes
|
||||||
|
let has_changes = prev_boards.len() != current_boards.len() ||
|
||||||
|
prev_boards.iter().zip(current_boards.iter()).any(|(prev, current)| {
|
||||||
|
prev.connect_status != current.connect_status ||
|
||||||
|
prev.ttl != current.ttl ||
|
||||||
|
prev.checked_at != current.checked_at
|
||||||
|
});
|
||||||
|
|
||||||
|
if has_changes {
|
||||||
let board_change_sender = self.boards_change_sender.clone();
|
let board_change_sender = self.boards_change_sender.clone();
|
||||||
if let Err(err) = board_change_sender.send(tx_boards) {
|
if let Err(err) = board_change_sender.send(current_boards) {
|
||||||
error!("failed to send board change: {:?}", err);
|
error!("failed to send board change: {:?}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(board_change_sender);
|
drop(board_change_sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2.0.0",
|
"$schema": "https://schema.tauri.app/config/2.0.0",
|
||||||
"productName": "test-demo",
|
"productName": "Ambient Light Control",
|
||||||
"version": "0.0.1",
|
"version": "2.0.0-alpha",
|
||||||
"identifier": "cc.ivanli.ambient-light.desktop",
|
"identifier": "cc.ivanli.ambient-light.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev",
|
"beforeDevCommand": "pnpm dev",
|
||||||
@ -23,7 +23,7 @@
|
|||||||
{
|
{
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"title": "test-demo",
|
"title": "Ambient Light Control",
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"height": 600
|
"height": 600
|
||||||
}
|
}
|
||||||
|
93
src/App.tsx
@ -1,67 +1,118 @@
|
|||||||
import { Routes, Route } from '@solidjs/router';
|
import { Routes, Route, useLocation, A } from '@solidjs/router';
|
||||||
import { LedStripConfiguration } from './components/led-strip-configuration/led-strip-configuration';
|
import { LedStripConfiguration } from './components/led-strip-configuration/led-strip-configuration';
|
||||||
import { WhiteBalance } from './components/white-balance/white-balance';
|
import { WhiteBalance } from './components/white-balance/white-balance';
|
||||||
import { createEffect } from 'solid-js';
|
import { LedStripTest } from './components/led-strip-test/led-strip-test';
|
||||||
|
import { createEffect, createSignal } from 'solid-js';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { setLedStripStore } from './stores/led-strip.store';
|
import { setLedStripStore } from './stores/led-strip.store';
|
||||||
import { LedStripConfigContainer } from './models/led-strip-config';
|
import { LedStripConfigContainer } from './models/led-strip-config';
|
||||||
import { InfoIndex } from './components/info/info-index';
|
import { InfoIndex } from './components/info/info-index';
|
||||||
import { DisplayStateIndex } from './components/displays/display-state-index';
|
import { DisplayStateIndex } from './components/displays/display-state-index';
|
||||||
|
import { useLanguage } from './i18n/index';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
const location = useLocation();
|
||||||
|
const [previousPath, setPreviousPath] = createSignal<string>('');
|
||||||
|
const { t, locale, setLocale } = useLanguage();
|
||||||
|
|
||||||
|
// Monitor route changes and cleanup LED tests when leaving the test page
|
||||||
|
createEffect(() => {
|
||||||
|
const currentPath = location.pathname;
|
||||||
|
const prevPath = previousPath();
|
||||||
|
|
||||||
|
// Check if we're leaving the LED test page
|
||||||
|
const isLeavingTestPage = prevPath === '/led-strip-test' && currentPath !== '/led-strip-test';
|
||||||
|
|
||||||
|
if (isLeavingTestPage) {
|
||||||
|
// The LED test component will handle stopping the test effect via onCleanup
|
||||||
|
// We just need to ensure test mode is disabled to resume normal LED publishing
|
||||||
|
invoke('disable_test_mode').catch((error) => {
|
||||||
|
console.error('Failed to disable test mode:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update previousPath after the condition check
|
||||||
|
setPreviousPath(currentPath);
|
||||||
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
invoke<LedStripConfigContainer>('read_config').then((config) => {
|
invoke<LedStripConfigContainer>('read_config').then((config) => {
|
||||||
console.log('App: read config', config);
|
|
||||||
setLedStripStore({
|
setLedStripStore({
|
||||||
strips: config.strips,
|
strips: config.strips,
|
||||||
mappers: config.mappers,
|
mappers: config.mappers,
|
||||||
colorCalibration: config.color_calibration,
|
colorCalibration: config.color_calibration,
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error('App: Failed to read config:', error);
|
console.error('Failed to read config:', error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="min-h-screen bg-base-100" data-theme="dark">
|
<div class="h-screen bg-base-100 flex flex-col" data-theme="dark">
|
||||||
{/* Navigation */}
|
{/* Fixed Navigation */}
|
||||||
<div class="navbar bg-base-200 shadow-lg">
|
<div class="navbar bg-base-200 shadow-lg flex-shrink-0 z-50">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
<div class="dropdown">
|
<div class="dropdown dropdown-hover">
|
||||||
<div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
|
<div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
|
||||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16"></path>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<ul tabindex="0" class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52">
|
<ul class="menu menu-sm dropdown-content z-[100] p-2 shadow bg-base-100 rounded-box w-52 border border-base-300">
|
||||||
<li><a href="/info" class="text-base-content">基本信息</a></li>
|
<li><A href="/info" class="text-base-content hover:bg-base-200">{t('nav.info')}</A></li>
|
||||||
<li><a href="/displays" class="text-base-content">显示器信息</a></li>
|
<li><A href="/displays" class="text-base-content hover:bg-base-200">{t('nav.displays')}</A></li>
|
||||||
<li><a href="/led-strips-configuration" class="text-base-content">灯条配置</a></li>
|
<li><A href="/led-strips-configuration" class="text-base-content hover:bg-base-200">{t('nav.ledConfiguration')}</A></li>
|
||||||
<li><a href="/white-balance" class="text-base-content">白平衡</a></li>
|
<li><A href="/white-balance" class="text-base-content hover:bg-base-200">{t('nav.whiteBalance')}</A></li>
|
||||||
|
<li><A href="/led-strip-test" class="text-base-content hover:bg-base-200">{t('nav.ledTest')}</A></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<a class="btn btn-ghost text-xl text-primary font-bold">环境光控制</a>
|
<a class="btn btn-ghost text-xl text-primary font-bold">{t('nav.title')}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-center hidden lg:flex">
|
<div class="navbar-center hidden lg:flex">
|
||||||
<ul class="menu menu-horizontal px-1">
|
<ul class="menu menu-horizontal px-1">
|
||||||
<li><a href="/info" class="btn btn-ghost text-base-content hover:text-primary">基本信息</a></li>
|
<li><A href="/info" class="btn btn-ghost text-base-content hover:text-primary">{t('nav.info')}</A></li>
|
||||||
<li><a href="/displays" class="btn btn-ghost text-base-content hover:text-primary">显示器信息</a></li>
|
<li><A href="/displays" class="btn btn-ghost text-base-content hover:text-primary">{t('nav.displays')}</A></li>
|
||||||
<li><a href="/led-strips-configuration" class="btn btn-ghost text-base-content hover:text-primary">灯条配置</a></li>
|
<li><A href="/led-strips-configuration" class="btn btn-ghost text-base-content hover:text-primary">{t('nav.ledConfiguration')}</A></li>
|
||||||
<li><a href="/white-balance" class="btn btn-ghost text-base-content hover:text-primary">白平衡</a></li>
|
<li><A href="/white-balance" class="btn btn-ghost text-base-content hover:text-primary">{t('nav.whiteBalance')}</A></li>
|
||||||
|
<li><A href="/led-strip-test" class="btn btn-ghost text-base-content hover:text-primary">{t('nav.ledTest')}</A></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
<div class="badge badge-primary badge-outline">v1.0</div>
|
<div class="dropdown dropdown-end dropdown-hover">
|
||||||
|
<div tabindex="0" role="button" class="btn btn-ghost btn-sm">
|
||||||
|
{locale() === 'zh-CN' ? '中文' : 'English'}
|
||||||
|
</div>
|
||||||
|
<ul class="dropdown-content z-[100] menu p-2 shadow bg-base-100 rounded-box w-32 border border-base-300">
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
class={`${locale() === 'zh-CN' ? 'active' : ''}`}
|
||||||
|
onClick={() => setLocale('zh-CN')}
|
||||||
|
>
|
||||||
|
中文
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
class={`${locale() === 'en-US' ? 'active' : ''}`}
|
||||||
|
onClick={() => setLocale('en-US')}
|
||||||
|
>
|
||||||
|
English
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="badge badge-primary badge-outline ml-2">v1.0</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main Content */}
|
{/* Main Content - fills remaining height */}
|
||||||
<main class="container mx-auto p-4">
|
<main class="flex-1 container mx-auto px-2 sm:px-4 py-4 max-w-full overflow-x-auto min-h-0">
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/info" component={InfoIndex} />
|
<Route path="/info" component={InfoIndex} />
|
||||||
<Route path="/displays" component={DisplayStateIndex} />
|
<Route path="/displays" component={DisplayStateIndex} />
|
||||||
<Route path="/led-strips-configuration" component={LedStripConfiguration} />
|
<Route path="/led-strips-configuration" component={LedStripConfiguration} />
|
||||||
<Route path="/white-balance" component={WhiteBalance} />
|
<Route path="/white-balance" component={WhiteBalance} />
|
||||||
|
<Route path="/led-strip-test" element={<LedStripTest />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, ParentComponent } from 'solid-js';
|
import { Component, ParentComponent } from 'solid-js';
|
||||||
import { DisplayState } from '../../models/display-state.model';
|
import { DisplayState } from '../../models/display-state.model';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
type DisplayStateCardProps = {
|
type DisplayStateCardProps = {
|
||||||
state: DisplayState;
|
state: DisplayState;
|
||||||
@ -19,48 +20,49 @@ const Item: ParentComponent<ItemProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const DisplayStateCard: Component<DisplayStateCardProps> = (props) => {
|
export const DisplayStateCard: Component<DisplayStateCardProps> = (props) => {
|
||||||
|
const { t } = useLanguage();
|
||||||
return (
|
return (
|
||||||
<div class="card bg-base-200 shadow-lg hover:shadow-xl transition-shadow duration-200">
|
<div class="card bg-base-200 shadow-lg hover:shadow-xl transition-shadow duration-200">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="card-title text-base mb-3 flex items-center justify-between">
|
<div class="card-title text-base mb-3 flex items-center justify-between">
|
||||||
<span>显示器状态</span>
|
<span>{t('displays.title')}</span>
|
||||||
<div class="badge badge-primary badge-outline">实时</div>
|
<div class="badge badge-primary badge-outline">{t('common.realtime')}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-3">
|
<div class="grid grid-cols-1 gap-3">
|
||||||
{/* 亮度信息 */}
|
{/* 亮度信息 */}
|
||||||
<div class="bg-base-100 rounded-lg p-3">
|
<div class="bg-base-100 rounded-lg p-3">
|
||||||
<h4 class="text-sm font-semibold text-base-content mb-2">亮度设置</h4>
|
<h4 class="text-sm font-semibold text-base-content mb-2">{t('displays.brightnessSettings')}</h4>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<Item label="当前亮度">{props.state.brightness}</Item>
|
<Item label={t('displays.currentBrightness')}>{props.state.brightness}</Item>
|
||||||
<Item label="最大亮度">{props.state.max_brightness}</Item>
|
<Item label={t('displays.maxBrightness')}>{props.state.max_brightness}</Item>
|
||||||
<Item label="最小亮度">{props.state.min_brightness}</Item>
|
<Item label={t('displays.minBrightness')}>{props.state.min_brightness}</Item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 对比度信息 */}
|
{/* 对比度信息 */}
|
||||||
<div class="bg-base-100 rounded-lg p-3">
|
<div class="bg-base-100 rounded-lg p-3">
|
||||||
<h4 class="text-sm font-semibold text-base-content mb-2">对比度设置</h4>
|
<h4 class="text-sm font-semibold text-base-content mb-2">{t('displays.contrastSettings')}</h4>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<Item label="当前对比度">{props.state.contrast}</Item>
|
<Item label={t('displays.currentContrast')}>{props.state.contrast}</Item>
|
||||||
<Item label="最大对比度">{props.state.max_contrast}</Item>
|
<Item label={t('displays.maxContrast')}>{props.state.max_contrast}</Item>
|
||||||
<Item label="最小对比度">{props.state.min_contrast}</Item>
|
<Item label={t('displays.minContrast')}>{props.state.min_contrast}</Item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 模式信息 */}
|
{/* 模式信息 */}
|
||||||
<div class="bg-base-100 rounded-lg p-3">
|
<div class="bg-base-100 rounded-lg p-3">
|
||||||
<h4 class="text-sm font-semibold text-base-content mb-2">模式设置</h4>
|
<h4 class="text-sm font-semibold text-base-content mb-2">{t('displays.modeSettings')}</h4>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<Item label="当前模式">{props.state.mode}</Item>
|
<Item label={t('displays.currentMode')}>{props.state.mode}</Item>
|
||||||
<Item label="最大模式">{props.state.max_mode}</Item>
|
<Item label={t('displays.maxMode')}>{props.state.max_mode}</Item>
|
||||||
<Item label="最小模式">{props.state.min_mode}</Item>
|
<Item label={t('displays.minMode')}>{props.state.min_mode}</Item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 更新时间 */}
|
{/* 更新时间 */}
|
||||||
<div class="text-xs text-base-content/50 text-center pt-2 border-t border-base-300">
|
<div class="text-xs text-base-content/50 text-center pt-2 border-t border-base-300">
|
||||||
最后更新: {props.state.last_modified_at.toLocaleString()}
|
{t('displays.lastModified')}: {props.state.last_modified_at.toLocaleString()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,11 +4,13 @@ import debug from 'debug';
|
|||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { DisplayState, RawDisplayState } from '../../models/display-state.model';
|
import { DisplayState, RawDisplayState } from '../../models/display-state.model';
|
||||||
import { DisplayStateCard } from './display-state-card';
|
import { DisplayStateCard } from './display-state-card';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
const logger = debug('app:components:displays:display-state-index');
|
const logger = debug('app:components:displays:display-state-index');
|
||||||
|
|
||||||
export const DisplayStateIndex: Component = () => {
|
export const DisplayStateIndex: Component = () => {
|
||||||
const [states, setStates] = createSignal<DisplayState[]>([]);
|
const [states, setStates] = createSignal<DisplayState[]>([]);
|
||||||
|
const { t } = useLanguage();
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
const unlisten = listen<RawDisplayState[]>('displays_changed', (ev) => {
|
const unlisten = listen<RawDisplayState[]>('displays_changed', (ev) => {
|
||||||
@ -38,10 +40,10 @@ export const DisplayStateIndex: Component = () => {
|
|||||||
return (
|
return (
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-2xl font-bold text-base-content">显示器状态</h1>
|
<h1 class="text-2xl font-bold text-base-content">{t('displays.title')}</h1>
|
||||||
<div class="stats shadow">
|
<div class="stats shadow">
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<div class="stat-title">显示器数量</div>
|
<div class="stat-title">{t('displays.displayCount')}</div>
|
||||||
<div class="stat-value text-primary">{states().length}</div>
|
<div class="stat-value text-primary">{states().length}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -63,8 +65,8 @@ export const DisplayStateIndex: Component = () => {
|
|||||||
{states().length === 0 && (
|
{states().length === 0 && (
|
||||||
<div class="text-center py-12">
|
<div class="text-center py-12">
|
||||||
<div class="text-6xl mb-4">🖥️</div>
|
<div class="text-6xl mb-4">🖥️</div>
|
||||||
<h3 class="text-lg font-semibold text-base-content mb-2">未检测到显示器</h3>
|
<h3 class="text-lg font-semibold text-base-content mb-2">{t('displays.noDisplaysFound')}</h3>
|
||||||
<p class="text-base-content/70">请检查显示器连接状态</p>
|
<p class="text-base-content/70">{t('displays.checkConnection')}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,11 +4,13 @@ import { listen } from '@tauri-apps/api/event';
|
|||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { BoardInfoPanel } from './board-info-panel';
|
import { BoardInfoPanel } from './board-info-panel';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
const logger = debug('app:components:info:board-index');
|
const logger = debug('app:components:info:board-index');
|
||||||
|
|
||||||
export const BoardIndex: Component = () => {
|
export const BoardIndex: Component = () => {
|
||||||
const [boards, setBoards] = createSignal<BoardInfo[]>([]);
|
const [boards, setBoards] = createSignal<BoardInfo[]>([]);
|
||||||
|
const { t } = useLanguage();
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
const unlisten = listen<BoardInfo[]>('boards_changed', (ev) => {
|
const unlisten = listen<BoardInfo[]>('boards_changed', (ev) => {
|
||||||
@ -28,10 +30,10 @@ export const BoardIndex: Component = () => {
|
|||||||
return (
|
return (
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-2xl font-bold text-base-content">设备信息</h1>
|
<h1 class="text-2xl font-bold text-base-content">{t('info.boardInfo')}</h1>
|
||||||
<div class="stats shadow">
|
<div class="stats shadow">
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<div class="stat-title">设备总数</div>
|
<div class="stat-title">{t('info.deviceCount')}</div>
|
||||||
<div class="stat-value text-primary">{boards().length}</div>
|
<div class="stat-value text-primary">{boards().length}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -53,8 +55,8 @@ export const BoardIndex: Component = () => {
|
|||||||
{boards().length === 0 && (
|
{boards().length === 0 && (
|
||||||
<div class="text-center py-12">
|
<div class="text-center py-12">
|
||||||
<div class="text-6xl mb-4">🔍</div>
|
<div class="text-6xl mb-4">🔍</div>
|
||||||
<h3 class="text-lg font-semibold text-base-content mb-2">未发现设备</h3>
|
<h3 class="text-lg font-semibold text-base-content mb-2">{t('info.noDevicesFound')}</h3>
|
||||||
<p class="text-base-content/70">请检查设备连接状态</p>
|
<p class="text-base-content/70">{t('info.checkConnection')}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, ParentComponent, createMemo } from 'solid-js';
|
import { Component, ParentComponent, createMemo } from 'solid-js';
|
||||||
import { BoardInfo } from '../../models/board-info.model';
|
import { BoardInfo } from '../../models/board-info.model';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
type ItemProps = {
|
type ItemProps = {
|
||||||
label: string;
|
label: string;
|
||||||
@ -15,13 +16,14 @@ const Item: ParentComponent<ItemProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
|
export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
|
||||||
|
const { t } = useLanguage();
|
||||||
const ttl = createMemo(() => {
|
const ttl = createMemo(() => {
|
||||||
if (props.board.connect_status !== 'Connected') {
|
if (props.board.connect_status !== 'Connected') {
|
||||||
return '--';
|
return '--';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.board.ttl == null) {
|
if (props.board.ttl == null) {
|
||||||
return 'timeout';
|
return t('info.timeout');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -37,7 +39,7 @@ export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('Connecting' in props.board.connect_status) {
|
if ('Connecting' in props.board.connect_status) {
|
||||||
return `Connecting (${props.board.connect_status.Connecting.toFixed(0)})`;
|
return `${t('info.connecting')} (${props.board.connect_status.Connecting.toFixed(0)})`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -60,10 +62,10 @@ export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
|
|||||||
<div class={statusBadgeClass()}>{connectStatus()}</div>
|
<div class={statusBadgeClass()}>{connectStatus()}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Item label="主机名">{props.board.host}</Item>
|
<Item label={t('info.hostname')}>{props.board.host}</Item>
|
||||||
<Item label="IP地址">{props.board.address}</Item>
|
<Item label={t('info.ipAddress')}>{props.board.address}</Item>
|
||||||
<Item label="端口">{props.board.port}</Item>
|
<Item label={t('info.port')}>{props.board.port}</Item>
|
||||||
<Item label="延迟">{ttl()}</Item>
|
<Item label={t('info.latency')}>{ttl()}</Item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, JSX, ParentComponent, splitProps } from 'solid-js';
|
import { Component, JSX, ParentComponent, splitProps } from 'solid-js';
|
||||||
import { DisplayInfo } from '../../models/display-info.model';
|
import { DisplayInfo } from '../../models/display-info.model';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
type DisplayInfoItemProps = {
|
type DisplayInfoItemProps = {
|
||||||
label: string;
|
label: string;
|
||||||
@ -20,26 +21,28 @@ type DisplayInfoPanelProps = {
|
|||||||
|
|
||||||
export const DisplayInfoPanel: Component<DisplayInfoPanelProps> = (props) => {
|
export const DisplayInfoPanel: Component<DisplayInfoPanelProps> = (props) => {
|
||||||
const [localProps, rootProps] = splitProps(props, ['display']);
|
const [localProps, rootProps] = splitProps(props, ['display']);
|
||||||
|
const { t } = useLanguage();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...rootProps} class={'card bg-base-100/95 backdrop-blur shadow-lg border border-base-300 ' + rootProps.class}>
|
<div {...rootProps} class={'card bg-base-100/95 backdrop-blur shadow-lg border border-base-300 ' + rootProps.class}>
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="card-title text-sm mb-3 flex items-center justify-between">
|
<div class="card-title text-sm mb-3 flex items-center justify-between">
|
||||||
<span class="text-base-content">显示器信息</span>
|
<span class="text-base-content">{t('displays.displayInfo')}</span>
|
||||||
{localProps.display.is_primary && (
|
{localProps.display.is_primary && (
|
||||||
<div class="badge badge-primary badge-sm">主显示器</div>
|
<div class="badge badge-primary badge-sm">{t('displays.isPrimary')}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<DisplayInfoItem label="ID">
|
<DisplayInfoItem label={t('displays.id')}>
|
||||||
<code class="bg-base-200 px-1 rounded text-xs">{localProps.display.id}</code>
|
<code class="bg-base-200 px-1 rounded text-xs">{localProps.display.id}</code>
|
||||||
</DisplayInfoItem>
|
</DisplayInfoItem>
|
||||||
<DisplayInfoItem label="位置">
|
<DisplayInfoItem label={t('displays.position')}>
|
||||||
({localProps.display.x}, {localProps.display.y})
|
({localProps.display.x}, {localProps.display.y})
|
||||||
</DisplayInfoItem>
|
</DisplayInfoItem>
|
||||||
<DisplayInfoItem label="尺寸">
|
<DisplayInfoItem label={t('displays.size')}>
|
||||||
{localProps.display.width} × {localProps.display.height}
|
{localProps.display.width} × {localProps.display.height}
|
||||||
</DisplayInfoItem>
|
</DisplayInfoItem>
|
||||||
<DisplayInfoItem label="缩放">
|
<DisplayInfoItem label={t('displays.scale')}>
|
||||||
{localProps.display.scale_factor}×
|
{localProps.display.scale_factor}×
|
||||||
</DisplayInfoItem>
|
</DisplayInfoItem>
|
||||||
</div>
|
</div>
|
||||||
|
@ -75,7 +75,7 @@ export const DisplayListContainer: ParentComponent = (props) => {
|
|||||||
createEffect(() => {});
|
createEffect(() => {});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section ref={root!} class="relative bg-gray-400/30" style={rootStyle()}>
|
<section ref={root!} class="relative bg-gray-400/30 h-full w-full" style={rootStyle()}>
|
||||||
<ol class="absolute" style={olStyle()}>
|
<ol class="absolute" style={olStyle()}>
|
||||||
{props.children}
|
{props.children}
|
||||||
</ol>
|
</ol>
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { Component, createMemo, For, JSX, splitProps } from 'solid-js';
|
import { Component, createMemo, For, JSX, splitProps, useContext } from 'solid-js';
|
||||||
import { DisplayInfo } from '../../models/display-info.model';
|
import { DisplayInfo } from '../../models/display-info.model';
|
||||||
import { ledStripStore } from '../../stores/led-strip.store';
|
import { ledStripStore } from '../../stores/led-strip.store';
|
||||||
import { Borders } from '../../constants/border';
|
import { Borders } from '../../constants/border';
|
||||||
|
import { LedType } from '../../models/led-strip-config';
|
||||||
|
import { LedStripConfigurationContext } from '../../contexts/led-strip-configuration.context';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
type LedCountControlItemProps = {
|
type LedCountControlItemProps = {
|
||||||
displayId: number;
|
displayId: number;
|
||||||
@ -11,6 +14,9 @@ type LedCountControlItemProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
|
const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
|
||||||
|
const [stripConfiguration, { setHoveredStripPart }] = useContext(LedStripConfigurationContext);
|
||||||
|
const { t } = useLanguage();
|
||||||
|
|
||||||
const config = createMemo(() => {
|
const config = createMemo(() => {
|
||||||
return ledStripStore.strips.find(
|
return ledStripStore.strips.find(
|
||||||
(s) => s.display_id === props.displayId && s.border === props.border
|
(s) => s.display_id === props.displayId && s.border === props.border
|
||||||
@ -65,8 +71,41 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLedTypeChange = (e: Event) => {
|
||||||
|
const target = e.target as HTMLSelectElement;
|
||||||
|
const newType = target.value as LedType;
|
||||||
|
|
||||||
|
invoke('patch_led_strip_type', {
|
||||||
|
displayId: props.displayId,
|
||||||
|
border: props.border,
|
||||||
|
ledType: newType,
|
||||||
|
}).catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onMouseEnter = () => {
|
||||||
|
setHoveredStripPart({
|
||||||
|
displayId: props.displayId,
|
||||||
|
border: props.border,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onMouseLeave = () => {
|
||||||
|
setHoveredStripPart(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="card bg-base-100 border border-base-300/50 p-2">
|
<div
|
||||||
|
class="card bg-base-100 border border-base-300/50 p-1.5 transition-all duration-200 cursor-pointer"
|
||||||
|
classList={{
|
||||||
|
'ring-2 ring-primary bg-primary/20 border-primary':
|
||||||
|
stripConfiguration.hoveredStripPart?.border === props.border &&
|
||||||
|
stripConfiguration.hoveredStripPart?.displayId === props.displayId,
|
||||||
|
}}
|
||||||
|
onMouseEnter={onMouseEnter}
|
||||||
|
onMouseLeave={onMouseLeave}
|
||||||
|
>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<span class="text-xs font-medium text-base-content">
|
<span class="text-xs font-medium text-base-content">
|
||||||
@ -74,19 +113,19 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-0.5">
|
||||||
<button
|
<button
|
||||||
class="btn btn-xs btn-circle btn-outline flex-shrink-0"
|
class="btn btn-xs btn-circle btn-outline flex-shrink-0 min-h-0 h-6 w-6"
|
||||||
onClick={handleDecrease}
|
onClick={handleDecrease}
|
||||||
disabled={!config() || (config()?.len || 0) <= 0}
|
disabled={!config() || (config()?.len || 0) <= 0}
|
||||||
title="减少LED数量"
|
title={t('ledConfig.decreaseLedCount')}
|
||||||
>
|
>
|
||||||
-
|
-
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
class="input input-xs flex-1 text-center min-w-0 text-sm font-medium [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
|
class="input input-xs flex-1 text-center min-w-0 text-xs font-medium [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none h-6 px-1"
|
||||||
value={config()?.len || 0}
|
value={config()?.len || 0}
|
||||||
min="0"
|
min="0"
|
||||||
max="1000"
|
max="1000"
|
||||||
@ -99,14 +138,26 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="btn btn-xs btn-circle btn-outline flex-shrink-0"
|
class="btn btn-xs btn-circle btn-outline flex-shrink-0 min-h-0 h-6 w-6"
|
||||||
onClick={handleIncrease}
|
onClick={handleIncrease}
|
||||||
disabled={!config() || (config()?.len || 0) >= 1000}
|
disabled={!config() || (config()?.len || 0) >= 1000}
|
||||||
title="增加LED数量"
|
title={t('ledConfig.increaseLedCount')}
|
||||||
>
|
>
|
||||||
+
|
+
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-1">
|
||||||
|
<select
|
||||||
|
class="select select-xs w-full text-xs h-6 min-h-0"
|
||||||
|
value={config()?.led_type || LedType.WS2812B}
|
||||||
|
onChange={handleLedTypeChange}
|
||||||
|
title={t('ledConfig.ledType')}
|
||||||
|
>
|
||||||
|
<option value={LedType.WS2812B}>WS2812B</option>
|
||||||
|
<option value={LedType.SK6812}>SK6812</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -114,27 +165,28 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
|
|||||||
|
|
||||||
type LedCountControlPanelProps = {
|
type LedCountControlPanelProps = {
|
||||||
display: DisplayInfo;
|
display: DisplayInfo;
|
||||||
} & JSX.HTMLAttributes<HTMLElement>;
|
} & JSX.HTMLAttributes<HTMLDivElement>;
|
||||||
|
|
||||||
export const LedCountControlPanel: Component<LedCountControlPanelProps> = (props) => {
|
export const LedCountControlPanel: Component<LedCountControlPanelProps> = (props) => {
|
||||||
const [localProps, rootProps] = splitProps(props, ['display']);
|
const [localProps, rootProps] = splitProps(props, ['display']);
|
||||||
|
const { t } = useLanguage();
|
||||||
|
|
||||||
const borders: { border: Borders; label: string }[] = [
|
const borders: { border: Borders; label: string }[] = [
|
||||||
{ border: 'Top', label: '上' },
|
{ border: 'Top', label: t('ledConfig.top') },
|
||||||
{ border: 'Bottom', label: '下' },
|
{ border: 'Bottom', label: t('ledConfig.bottom') },
|
||||||
{ border: 'Left', label: '左' },
|
{ border: 'Left', label: t('ledConfig.left') },
|
||||||
{ border: 'Right', label: '右' },
|
{ border: 'Right', label: t('ledConfig.right') },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...rootProps} class={'card bg-base-200 shadow-lg border border-base-300 ' + (rootProps.class || '')}>
|
<div {...rootProps} class={'card bg-base-200 shadow-lg border border-base-300 ' + (rootProps.class || '')}>
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-3">
|
||||||
<div class="card-title text-base mb-3 flex items-center justify-between">
|
<div class="card-title text-sm mb-2 flex items-center justify-between">
|
||||||
<span>LED数量控制</span>
|
<span>{t('ledConfig.ledCountControl')}</span>
|
||||||
<div class="badge badge-info badge-outline">显示器 {localProps.display.id}</div>
|
<div class="badge badge-info badge-outline text-xs">{t('ledConfig.display')} {localProps.display.id}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-4 gap-2">
|
<div class="grid grid-cols-2 sm:grid-cols-4 gap-2">
|
||||||
<For each={borders}>
|
<For each={borders}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<LedCountControlItem
|
<LedCountControlItem
|
||||||
@ -146,8 +198,8 @@ export const LedCountControlPanel: Component<LedCountControlPanelProps> = (props
|
|||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-xs text-base-content/50 mt-3 p-2 bg-base-300/50 rounded">
|
<div class="text-xs text-base-content/50 mt-2 p-1.5 bg-base-300/50 rounded">
|
||||||
💡 提示:点击 +/- 按钮或直接输入数值来调整LED数量(范围:0-1000)
|
💡 {t('ledConfig.controlTip')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,25 +13,25 @@ import {
|
|||||||
LedStripConfigurationContext,
|
LedStripConfigurationContext,
|
||||||
LedStripConfigurationContextType,
|
LedStripConfigurationContextType,
|
||||||
} from '../../contexts/led-strip-configuration.context';
|
} from '../../contexts/led-strip-configuration.context';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
|
|
||||||
export const LedStripConfiguration = () => {
|
export const LedStripConfiguration = () => {
|
||||||
|
const { t } = useLanguage();
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
invoke<string>('list_display_info').then((displays) => {
|
invoke<string>('list_display_info').then((displays) => {
|
||||||
const parsedDisplays = JSON.parse(displays);
|
const parsedDisplays = JSON.parse(displays);
|
||||||
console.log('LedStripConfiguration: Loaded displays:', parsedDisplays);
|
|
||||||
setDisplayStore({
|
setDisplayStore({
|
||||||
displays: parsedDisplays,
|
displays: parsedDisplays,
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error('LedStripConfiguration: Failed to load displays:', error);
|
console.error('Failed to load displays:', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
invoke<LedStripConfigContainer>('read_led_strip_configs').then((configs) => {
|
invoke<LedStripConfigContainer>('read_led_strip_configs').then((configs) => {
|
||||||
console.log('LedStripConfiguration: Loaded LED strip configs:', configs);
|
|
||||||
setLedStripStore(configs);
|
setLedStripStore(configs);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error('LedStripConfiguration: Failed to load LED strip configs:', error);
|
console.error('Failed to load LED strip configs:', error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,6 +86,7 @@ export const LedStripConfiguration = () => {
|
|||||||
LedStripConfigurationContextType[0]
|
LedStripConfigurationContextType[0]
|
||||||
>({
|
>({
|
||||||
selectedStripPart: null,
|
selectedStripPart: null,
|
||||||
|
hoveredStripPart: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const ledStripConfigurationContextValue: LedStripConfigurationContextType = [
|
const ledStripConfigurationContextValue: LedStripConfigurationContextType = [
|
||||||
@ -96,69 +97,75 @@ export const LedStripConfiguration = () => {
|
|||||||
selectedStripPart: v,
|
selectedStripPart: v,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setHoveredStripPart: (v) => {
|
||||||
|
setLedStripConfiguration({
|
||||||
|
hoveredStripPart: v,
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="space-y-6">
|
<div class="space-y-4">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-2xl font-bold text-base-content">灯条配置</h1>
|
<h1 class="text-xl font-bold text-base-content">{t('ledConfig.title')}</h1>
|
||||||
<div class="stats shadow">
|
<div class="stats shadow">
|
||||||
<div class="stat">
|
<div class="stat py-2 px-4">
|
||||||
<div class="stat-title">显示器数量</div>
|
<div class="stat-title text-xs">{t('displays.displayCount')}</div>
|
||||||
<div class="stat-value text-primary">{displayStore.displays.length}</div>
|
<div class="stat-value text-primary text-lg">{displayStore.displays.length}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LedStripConfigurationContext.Provider value={ledStripConfigurationContextValue}>
|
<LedStripConfigurationContext.Provider value={ledStripConfigurationContextValue}>
|
||||||
|
<div class="space-y-4">
|
||||||
{/* LED Strip Sorter Panel */}
|
{/* LED Strip Sorter Panel */}
|
||||||
<div class="card bg-base-200 shadow-lg">
|
<div class="card bg-base-200 shadow-lg">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-3">
|
||||||
<div class="card-title text-base mb-3">
|
<div class="card-title text-sm mb-2">
|
||||||
<span>灯条排序</span>
|
<span>{t('ledConfig.stripSorting')}</span>
|
||||||
<div class="badge badge-info badge-outline">实时预览</div>
|
<div class="badge badge-info badge-outline text-xs">{t('ledConfig.realtimePreview')}</div>
|
||||||
</div>
|
</div>
|
||||||
<LedStripPartsSorter />
|
<LedStripPartsSorter />
|
||||||
<div class="text-xs text-base-content/50 mt-2">
|
<div class="text-xs text-base-content/50 mt-2">
|
||||||
💡 提示:拖拽灯条段落来调整顺序,双击可反转方向
|
💡 {t('ledConfig.sortingTip')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Display Configuration Panel */}
|
{/* Display Configuration Panel - Auto height based on content */}
|
||||||
<div class="card bg-base-200 shadow-lg">
|
<div class="card bg-base-200 shadow-lg">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-3">
|
||||||
<div class="card-title text-base mb-3">
|
<div class="card-title text-sm mb-2">
|
||||||
<span>显示器配置</span>
|
<span>{t('ledConfig.displayConfiguration')}</span>
|
||||||
<div class="badge badge-secondary badge-outline">可视化编辑</div>
|
<div class="badge badge-secondary badge-outline text-xs">{t('ledConfig.visualEditor')}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="h-96 mb-4">
|
<div class="mb-3">
|
||||||
<DisplayListContainer>
|
<DisplayListContainer>
|
||||||
{displayStore.displays.map((display) => {
|
{displayStore.displays.map((display) => (
|
||||||
console.log('LedStripConfiguration: Rendering DisplayView for display:', display);
|
<DisplayView display={display} />
|
||||||
return <DisplayView display={display} />;
|
))}
|
||||||
})}
|
|
||||||
</DisplayListContainer>
|
</DisplayListContainer>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-base-content/50">
|
<div class="text-xs text-base-content/50">
|
||||||
💡 提示:悬停显示器查看详细信息,使用下方控制面板调整LED数量
|
💡 {t('ledConfig.displayTip')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* LED Count Control Panels */}
|
{/* LED Count Control Panels */}
|
||||||
<div class="space-y-4">
|
<div class="flex-shrink-0">
|
||||||
<div class="flex items-center gap-2 mb-3">
|
<div class="flex items-center gap-2 mb-2">
|
||||||
<h2 class="text-lg font-semibold text-base-content">LED数量控制</h2>
|
<h2 class="text-base font-semibold text-base-content">{t('ledConfig.ledCountControl')}</h2>
|
||||||
<div class="badge badge-info badge-outline">实时调整</div>
|
<div class="badge badge-info badge-outline text-xs">{t('ledConfig.realtimeAdjustment')}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div class="led-control-grid">
|
||||||
{displayStore.displays.map((display) => (
|
{displayStore.displays.map((display) => (
|
||||||
<LedCountControlPanel display={display} />
|
<LedCountControlPanel display={display} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</LedStripConfigurationContext.Provider>
|
</LedStripConfigurationContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -43,7 +43,7 @@ export const Pixel: Component<PixelProps> = (props) => {
|
|||||||
|
|
||||||
export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
||||||
const [localProps, rootProps] = splitProps(props, ['config']);
|
const [localProps, rootProps] = splitProps(props, ['config']);
|
||||||
const [stripConfiguration] = useContext(LedStripConfigurationContext);
|
const [stripConfiguration, { setHoveredStripPart }] = useContext(LedStripConfigurationContext);
|
||||||
|
|
||||||
const [colors, setColors] = createSignal<string[]>([]);
|
const [colors, setColors] = createSignal<string[]>([]);
|
||||||
|
|
||||||
@ -60,32 +60,16 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
console.log('🔍 LED: Strip config not found', {
|
|
||||||
displayId: localProps.config.display_id,
|
|
||||||
border: localProps.config.border,
|
|
||||||
availableStrips: ledStripStore.strips.length
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapper = ledStripStore.mappers[index];
|
const mapper = ledStripStore.mappers[index];
|
||||||
if (!mapper) {
|
if (!mapper) {
|
||||||
console.log('🔍 LED: Mapper not found', { index, mappersCount: ledStripStore.mappers.length });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const offset = mapper.start * 3;
|
const offset = mapper.start * 3;
|
||||||
|
|
||||||
console.log('🎨 LED: Updating colors', {
|
|
||||||
displayId: localProps.config.display_id,
|
|
||||||
border: localProps.config.border,
|
|
||||||
stripLength: localProps.config.len,
|
|
||||||
mapperPos: mapper.pos,
|
|
||||||
offset,
|
|
||||||
colorsArrayLength: ledStripStore.colors.length,
|
|
||||||
firstFewColors: Array.from(ledStripStore.colors.slice(offset, offset + 9))
|
|
||||||
});
|
|
||||||
|
|
||||||
const colors = new Array(localProps.config.len).fill(null).map((_, i) => {
|
const colors = new Array(localProps.config.len).fill(null).map((_, i) => {
|
||||||
const index = offset + i * 3;
|
const index = offset + i * 3;
|
||||||
const r = ledStripStore.colors[index] || 0;
|
const r = ledStripStore.colors[index] || 0;
|
||||||
@ -94,12 +78,6 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
return `rgb(${r}, ${g}, ${b})`;
|
return `rgb(${r}, ${g}, ${b})`;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('🎨 LED: Generated colors', {
|
|
||||||
border: localProps.config.border,
|
|
||||||
colorsCount: colors.length,
|
|
||||||
sampleColors: colors.slice(0, 3)
|
|
||||||
});
|
|
||||||
|
|
||||||
setColors(colors);
|
setColors(colors);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -124,14 +102,39 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onWheel = (e: WheelEvent) => {
|
||||||
|
if (localProps.config) {
|
||||||
|
invoke('patch_led_strip_len', {
|
||||||
|
displayId: localProps.config.display_id,
|
||||||
|
border: localProps.config.border,
|
||||||
|
deltaLen: e.deltaY > 0 ? 1 : -1,
|
||||||
|
})
|
||||||
|
.then(() => {})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onMouseEnter = () => {
|
||||||
|
if (localProps.config) {
|
||||||
|
setHoveredStripPart({
|
||||||
|
displayId: localProps.config.display_id,
|
||||||
|
border: localProps.config.border,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onMouseLeave = () => {
|
||||||
|
setHoveredStripPart(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
{...rootProps}
|
{...rootProps}
|
||||||
ref={setAnchor}
|
ref={setAnchor}
|
||||||
class={
|
class={
|
||||||
'flex rounded-full flex-nowrap justify-around items-center overflow-hidden bg-gray-800/20 border border-gray-600/30 min-h-[32px] min-w-[32px] ' +
|
'flex rounded-full flex-nowrap justify-around items-center overflow-hidden bg-gray-800/20 border border-gray-600/30 min-h-[12px] min-w-[12px] m-1 px-0.5 py-0.5 transition-all duration-200 ' +
|
||||||
rootProps.class
|
rootProps.class
|
||||||
}
|
}
|
||||||
classList={{
|
classList={{
|
||||||
@ -139,8 +142,13 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
stripConfiguration.selectedStripPart?.border === localProps.config?.border &&
|
stripConfiguration.selectedStripPart?.border === localProps.config?.border &&
|
||||||
stripConfiguration.selectedStripPart?.displayId ===
|
stripConfiguration.selectedStripPart?.displayId ===
|
||||||
localProps.config?.display_id,
|
localProps.config?.display_id,
|
||||||
|
'ring-2 ring-primary bg-primary/20 border-primary':
|
||||||
|
stripConfiguration.hoveredStripPart?.border === localProps.config?.border &&
|
||||||
|
stripConfiguration.hoveredStripPart?.displayId === localProps.config?.display_id,
|
||||||
}}
|
}}
|
||||||
|
onWheel={onWheel}
|
||||||
|
onMouseEnter={onMouseEnter}
|
||||||
|
onMouseLeave={onMouseLeave}
|
||||||
>
|
>
|
||||||
<For each={colors()}>{(item) => <Pixel color={item} />}</For>
|
<For each={colors()}>{(item) => <Pixel color={item} />}</For>
|
||||||
</section>
|
</section>
|
||||||
|
@ -29,7 +29,7 @@ const SorterItem: Component<{ strip: LedStripConfig; mapper: LedStripPixelMapper
|
|||||||
const [dragCurr, setDragCurr] = createSignal<{ x: number; y: number } | null>(null);
|
const [dragCurr, setDragCurr] = createSignal<{ x: number; y: number } | null>(null);
|
||||||
const [dragStartIndex, setDragStartIndex] = createSignal<number>(0);
|
const [dragStartIndex, setDragStartIndex] = createSignal<number>(0);
|
||||||
const [cellWidth, setCellWidth] = createSignal<number>(0);
|
const [cellWidth, setCellWidth] = createSignal<number>(0);
|
||||||
const [, { setSelectedStripPart }] = useContext(LedStripConfigurationContext);
|
const [stripConfiguration, { setSelectedStripPart, setHoveredStripPart }] = useContext(LedStripConfigurationContext);
|
||||||
const [rootWidth, setRootWidth] = createSignal<number>(0);
|
const [rootWidth, setRootWidth] = createSignal<number>(0);
|
||||||
|
|
||||||
let root: HTMLDivElement;
|
let root: HTMLDivElement;
|
||||||
@ -38,9 +38,6 @@ const SorterItem: Component<{ strip: LedStripConfig; mapper: LedStripPixelMapper
|
|||||||
if (targetStart === props.mapper.start) {
|
if (targetStart === props.mapper.start) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(
|
|
||||||
`moving strip part ${props.strip.display_id} ${props.strip.border} from ${props.mapper.start} to ${targetStart}`,
|
|
||||||
);
|
|
||||||
invoke('move_strip_part', {
|
invoke('move_strip_part', {
|
||||||
displayId: props.strip.display_id,
|
displayId: props.strip.display_id,
|
||||||
border: props.strip.border,
|
border: props.strip.border,
|
||||||
@ -151,6 +148,17 @@ const SorterItem: Component<{ strip: LedStripConfig; mapper: LedStripPixelMapper
|
|||||||
}).catch((err) => console.error(err));
|
}).catch((err) => console.error(err));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onMouseEnter = () => {
|
||||||
|
setHoveredStripPart({
|
||||||
|
displayId: props.strip.display_id,
|
||||||
|
border: props.strip.border,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onMouseLeave = () => {
|
||||||
|
setHoveredStripPart(null);
|
||||||
|
};
|
||||||
|
|
||||||
const setColor = (fullIndex: number, colorsIndex: number, fullLeds: string[]) => {
|
const setColor = (fullIndex: number, colorsIndex: number, fullLeds: string[]) => {
|
||||||
const colors = ledStripStore.colors;
|
const colors = ledStripStore.colors;
|
||||||
let c1 = `rgb(${Math.floor(colors[colorsIndex * 3] * 0.8)}, ${Math.floor(
|
let c1 = `rgb(${Math.floor(colors[colorsIndex * 3] * 0.8)}, ${Math.floor(
|
||||||
@ -162,7 +170,6 @@ const SorterItem: Component<{ strip: LedStripConfig; mapper: LedStripPixelMapper
|
|||||||
)}, ${Math.min(Math.floor(colors[colorsIndex * 3 + 2] * 1.2), 255)})`;
|
)}, ${Math.min(Math.floor(colors[colorsIndex * 3 + 2] * 1.2), 255)})`;
|
||||||
|
|
||||||
if (fullLeds.length <= fullIndex) {
|
if (fullLeds.length <= fullIndex) {
|
||||||
console.error('out of range', fullIndex, fullLeds.length);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,9 +228,16 @@ const SorterItem: Component<{ strip: LedStripConfig; mapper: LedStripPixelMapper
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class="flex mx-2 select-none cursor-ew-resize focus:cursor-ew-resize"
|
class="flex mx-2 select-none cursor-ew-resize focus:cursor-ew-resize transition-colors duration-200"
|
||||||
|
classList={{
|
||||||
|
'bg-primary/20 rounded-lg':
|
||||||
|
stripConfiguration.hoveredStripPart?.border === props.strip.border &&
|
||||||
|
stripConfiguration.hoveredStripPart?.displayId === props.strip.display_id,
|
||||||
|
}}
|
||||||
onPointerDown={onPointerDown}
|
onPointerDown={onPointerDown}
|
||||||
ondblclick={reverse}
|
ondblclick={reverse}
|
||||||
|
onMouseEnter={onMouseEnter}
|
||||||
|
onMouseLeave={onMouseLeave}
|
||||||
ref={root!}
|
ref={root!}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -43,50 +43,35 @@ export const ScreenViewWebSocket: Component<ScreenViewWebSocketProps> = (props)
|
|||||||
|
|
||||||
const connectWebSocket = () => {
|
const connectWebSocket = () => {
|
||||||
if (!isMounted) {
|
if (!isMounted) {
|
||||||
console.log('Component not mounted, skipping WebSocket connection');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wsUrl = `ws://127.0.0.1:8765`;
|
const wsUrl = `ws://127.0.0.1:8765`;
|
||||||
console.log('Connecting to WebSocket:', wsUrl, 'with displayId:', localProps.displayId);
|
|
||||||
|
|
||||||
setConnectionStatus('connecting');
|
setConnectionStatus('connecting');
|
||||||
websocket = new WebSocket(wsUrl);
|
websocket = new WebSocket(wsUrl);
|
||||||
websocket.binaryType = 'arraybuffer';
|
websocket.binaryType = 'arraybuffer';
|
||||||
console.log('WebSocket object created:', websocket);
|
|
||||||
|
|
||||||
websocket.onopen = () => {
|
websocket.onopen = () => {
|
||||||
console.log('WebSocket connected successfully!');
|
|
||||||
setConnectionStatus('connected');
|
setConnectionStatus('connected');
|
||||||
|
|
||||||
// Send initial configuration
|
// Send initial configuration
|
||||||
const config = {
|
const config = {
|
||||||
display_id: localProps.displayId,
|
display_id: localProps.displayId,
|
||||||
width: localProps.width || 320, // Reduced from 400 for better performance
|
width: localProps.width || 320,
|
||||||
height: localProps.height || 180, // Reduced from 225 for better performance
|
height: localProps.height || 180,
|
||||||
quality: localProps.quality || 50 // Reduced from 75 for faster compression
|
quality: localProps.quality || 50
|
||||||
};
|
};
|
||||||
console.log('Sending WebSocket configuration:', config);
|
|
||||||
websocket?.send(JSON.stringify(config));
|
websocket?.send(JSON.stringify(config));
|
||||||
};
|
};
|
||||||
|
|
||||||
websocket.onmessage = (event) => {
|
websocket.onmessage = (event) => {
|
||||||
console.log('🔍 WebSocket message received:', {
|
|
||||||
type: typeof event.data,
|
|
||||||
isArrayBuffer: event.data instanceof ArrayBuffer,
|
|
||||||
size: event.data instanceof ArrayBuffer ? event.data.byteLength : 'N/A'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (event.data instanceof ArrayBuffer) {
|
if (event.data instanceof ArrayBuffer) {
|
||||||
console.log('📦 Processing ArrayBuffer frame, size:', event.data.byteLength);
|
|
||||||
handleJpegFrame(new Uint8Array(event.data));
|
handleJpegFrame(new Uint8Array(event.data));
|
||||||
} else {
|
|
||||||
console.log('⚠️ Received non-ArrayBuffer data:', event.data);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
websocket.onclose = (event) => {
|
websocket.onclose = (event) => {
|
||||||
console.log('WebSocket closed:', event.code, event.reason);
|
|
||||||
setConnectionStatus('disconnected');
|
setConnectionStatus('disconnected');
|
||||||
websocket = null;
|
websocket = null;
|
||||||
|
|
||||||
@ -100,7 +85,6 @@ export const ScreenViewWebSocket: Component<ScreenViewWebSocketProps> = (props)
|
|||||||
};
|
};
|
||||||
|
|
||||||
websocket.onerror = (error) => {
|
websocket.onerror = (error) => {
|
||||||
console.error('WebSocket error:', error);
|
|
||||||
setConnectionStatus('error');
|
setConnectionStatus('error');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -204,7 +188,6 @@ export const ScreenViewWebSocket: Component<ScreenViewWebSocketProps> = (props)
|
|||||||
|
|
||||||
// Initialize canvas and resize observer
|
// Initialize canvas and resize observer
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.log('ScreenViewWebSocket mounted with displayId:', localProps.displayId);
|
|
||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
setCtx(context);
|
setCtx(context);
|
||||||
|
|
||||||
@ -217,7 +200,6 @@ export const ScreenViewWebSocket: Component<ScreenViewWebSocketProps> = (props)
|
|||||||
resizeObserver.observe(root);
|
resizeObserver.observe(root);
|
||||||
|
|
||||||
// Connect WebSocket
|
// Connect WebSocket
|
||||||
console.log('About to connect WebSocket...');
|
|
||||||
connectWebSocket();
|
connectWebSocket();
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
@ -227,17 +209,7 @@ export const ScreenViewWebSocket: Component<ScreenViewWebSocketProps> = (props)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Debug function to list displays
|
|
||||||
const debugDisplays = async () => {
|
|
||||||
try {
|
|
||||||
const result = await invoke('list_display_info');
|
|
||||||
console.log('Available displays:', result);
|
|
||||||
alert(`Available displays: ${result}`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to get display info:', error);
|
|
||||||
alert(`Error: ${error}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Status indicator
|
// Status indicator
|
||||||
const getStatusColor = () => {
|
const getStatusColor = () => {
|
||||||
@ -275,13 +247,6 @@ export const ScreenViewWebSocket: Component<ScreenViewWebSocketProps> = (props)
|
|||||||
{connectionStatus() === 'connected' && (
|
{connectionStatus() === 'connected' && (
|
||||||
<span>| {fps()} FPS | {frameCount()} frames</span>
|
<span>| {fps()} FPS | {frameCount()} frames</span>
|
||||||
)}
|
)}
|
||||||
<button
|
|
||||||
onClick={debugDisplays}
|
|
||||||
class="ml-2 px-1 py-0.5 bg-blue-600 hover:bg-blue-700 rounded text-xs"
|
|
||||||
title="Debug: Show available displays"
|
|
||||||
>
|
|
||||||
Debug
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{rootProps.children}
|
{rootProps.children}
|
||||||
|
415
src/components/led-strip-test/led-strip-test.tsx
Normal file
@ -0,0 +1,415 @@
|
|||||||
|
import { createSignal, createEffect, For, Show, onCleanup } from 'solid-js';
|
||||||
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
import { listen } from '@tauri-apps/api/event';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
|
interface BoardInfo {
|
||||||
|
fullname: string;
|
||||||
|
host: string;
|
||||||
|
address: string;
|
||||||
|
port: number;
|
||||||
|
connect_status: 'Connected' | 'Disconnected' | { Connecting: number };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestPattern {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
effect_type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestEffectConfig {
|
||||||
|
effect_type: string;
|
||||||
|
led_count: number;
|
||||||
|
led_type: string;
|
||||||
|
speed: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LedStripTest = () => {
|
||||||
|
const { t } = useLanguage();
|
||||||
|
const [boards, setBoards] = createSignal<BoardInfo[]>([]);
|
||||||
|
const [selectedBoard, setSelectedBoard] = createSignal<BoardInfo | null>(null);
|
||||||
|
const [ledCount, setLedCount] = createSignal(60);
|
||||||
|
const [ledType, setLedType] = createSignal<'WS2812B' | 'SK6812'>('WS2812B');
|
||||||
|
const [isRunning, setIsRunning] = createSignal(false);
|
||||||
|
const [currentPattern, setCurrentPattern] = createSignal<TestPattern | null>(null);
|
||||||
|
const [animationSpeed, setAnimationSpeed] = createSignal(33); // ~30fps
|
||||||
|
|
||||||
|
// Temporary input values for better UX
|
||||||
|
const [ledCountInput, setLedCountInput] = createSignal('60');
|
||||||
|
const [animationSpeedInput, setAnimationSpeedInput] = createSignal('33');
|
||||||
|
|
||||||
|
// Input handlers for LED count
|
||||||
|
const handleLedCountInput = (e: Event) => {
|
||||||
|
const target = e.target as HTMLInputElement;
|
||||||
|
setLedCountInput(target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLedCountBlur = (e: Event) => {
|
||||||
|
const target = e.target as HTMLInputElement;
|
||||||
|
const value = parseInt(target.value);
|
||||||
|
if (!isNaN(value) && value >= 1 && value <= 1000) {
|
||||||
|
setLedCount(value);
|
||||||
|
setLedCountInput(value.toString());
|
||||||
|
} else {
|
||||||
|
// Reset to current valid value
|
||||||
|
setLedCountInput(ledCount().toString());
|
||||||
|
target.value = ledCount().toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLedCountKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
handleLedCountBlur(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Input handlers for animation speed
|
||||||
|
const handleAnimationSpeedInput = (e: Event) => {
|
||||||
|
const target = e.target as HTMLInputElement;
|
||||||
|
setAnimationSpeedInput(target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAnimationSpeedBlur = (e: Event) => {
|
||||||
|
const target = e.target as HTMLInputElement;
|
||||||
|
const value = parseInt(target.value);
|
||||||
|
if (!isNaN(value) && value >= 16 && value <= 200) {
|
||||||
|
setAnimationSpeed(value);
|
||||||
|
setAnimationSpeedInput(value.toString());
|
||||||
|
} else {
|
||||||
|
// Reset to current valid value
|
||||||
|
setAnimationSpeedInput(animationSpeed().toString());
|
||||||
|
target.value = animationSpeed().toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAnimationSpeedKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
handleAnimationSpeedBlur(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sync input values with actual values
|
||||||
|
createEffect(() => {
|
||||||
|
setLedCountInput(ledCount().toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
setAnimationSpeedInput(animationSpeed().toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load available boards and listen for changes
|
||||||
|
createEffect(() => {
|
||||||
|
// Initial load
|
||||||
|
invoke<BoardInfo[]>('get_boards').then((boardList) => {
|
||||||
|
setBoards(boardList);
|
||||||
|
if (boardList.length > 0 && !selectedBoard()) {
|
||||||
|
setSelectedBoard(boardList[0]);
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error('Failed to load boards:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for board changes
|
||||||
|
const unlisten = listen<BoardInfo[]>('boards_changed', (event) => {
|
||||||
|
const boardList = event.payload;
|
||||||
|
setBoards(boardList);
|
||||||
|
|
||||||
|
// If currently selected board is no longer available, select the first available one
|
||||||
|
const currentBoard = selectedBoard();
|
||||||
|
if (currentBoard) {
|
||||||
|
const stillExists = boardList.find(board =>
|
||||||
|
board.host === currentBoard.host &&
|
||||||
|
board.address === currentBoard.address &&
|
||||||
|
board.port === currentBoard.port
|
||||||
|
);
|
||||||
|
|
||||||
|
if (stillExists) {
|
||||||
|
// Update to the new board object to reflect any status changes
|
||||||
|
setSelectedBoard(stillExists);
|
||||||
|
} else {
|
||||||
|
// Current board is no longer available, select first available or null
|
||||||
|
setSelectedBoard(boardList.length > 0 ? boardList[0] : null);
|
||||||
|
}
|
||||||
|
} else if (boardList.length > 0) {
|
||||||
|
// No board was selected, select the first one
|
||||||
|
setSelectedBoard(boardList[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cleanup listener when effect is disposed
|
||||||
|
onCleanup(() => {
|
||||||
|
unlisten.then((unlistenFn) => unlistenFn());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cleanup when component is unmounted
|
||||||
|
onCleanup(() => {
|
||||||
|
if (isRunning() && selectedBoard()) {
|
||||||
|
// Stop the test effect in backend
|
||||||
|
invoke('stop_led_test_effect', {
|
||||||
|
boardAddress: `${selectedBoard()!.address}:${selectedBoard()!.port}`,
|
||||||
|
ledCount: ledCount(),
|
||||||
|
ledType: ledType()
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error('Failed to stop test during cleanup:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update local state immediately
|
||||||
|
setIsRunning(false);
|
||||||
|
setCurrentPattern(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Test patterns
|
||||||
|
const testPatterns: TestPattern[] = [
|
||||||
|
{
|
||||||
|
name: t('ledTest.flowingRainbow'),
|
||||||
|
description: t('ledTest.flowingRainbowDesc'),
|
||||||
|
effect_type: 'FlowingRainbow'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: t('ledTest.groupCounting'),
|
||||||
|
description: t('ledTest.groupCountingDesc'),
|
||||||
|
effect_type: 'GroupCounting'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: t('ledTest.singleScan'),
|
||||||
|
description: t('ledTest.singleScanDesc'),
|
||||||
|
effect_type: 'SingleScan'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: t('ledTest.breathing'),
|
||||||
|
description: t('ledTest.breathingDesc'),
|
||||||
|
effect_type: 'Breathing'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Test effect management - now handled by Rust backend
|
||||||
|
|
||||||
|
const startTest = async (pattern: TestPattern) => {
|
||||||
|
if (isRunning()) {
|
||||||
|
await stopTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedBoard()) {
|
||||||
|
console.error('No board selected');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const effectConfig: TestEffectConfig = {
|
||||||
|
effect_type: pattern.effect_type,
|
||||||
|
led_count: ledCount(),
|
||||||
|
led_type: ledType(),
|
||||||
|
speed: 1.0 / (animationSpeed() / 50) // Convert animation speed to effect speed
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start the test effect in Rust backend
|
||||||
|
await invoke('start_led_test_effect', {
|
||||||
|
boardAddress: `${selectedBoard()!.address}:${selectedBoard()!.port}`,
|
||||||
|
effectConfig: effectConfig,
|
||||||
|
updateIntervalMs: animationSpeed()
|
||||||
|
});
|
||||||
|
|
||||||
|
setCurrentPattern(pattern);
|
||||||
|
setIsRunning(true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to start test effect:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopTest = async () => {
|
||||||
|
if (!selectedBoard()) {
|
||||||
|
setIsRunning(false);
|
||||||
|
setCurrentPattern(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Stop the test effect in Rust backend
|
||||||
|
await invoke('stop_led_test_effect', {
|
||||||
|
boardAddress: `${selectedBoard()!.address}:${selectedBoard()!.port}`,
|
||||||
|
ledCount: ledCount(),
|
||||||
|
ledType: ledType()
|
||||||
|
});
|
||||||
|
|
||||||
|
// Only update UI state after successful backend call
|
||||||
|
setIsRunning(false);
|
||||||
|
setCurrentPattern(null);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to stop test effect:', error);
|
||||||
|
// Still update UI state even if backend call fails
|
||||||
|
setIsRunning(false);
|
||||||
|
setCurrentPattern(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="container mx-auto p-6 space-y-6">
|
||||||
|
<div class="card bg-base-200 shadow-xl">
|
||||||
|
<div class="card-body">
|
||||||
|
<h2 class="card-title text-2xl mb-4">{t('ledTest.title')}</h2>
|
||||||
|
|
||||||
|
{/* Hardware Selection */}
|
||||||
|
<div class="form-control w-full max-w-xs">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text">{t('ledTest.selectHardwareBoard')}</span>
|
||||||
|
<span class="label-text-alt">
|
||||||
|
{boards().length > 0 ? `${boards().length} ${t('ledTest.devicesFound')}` : t('ledTest.searching')}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
class="select select-bordered w-full max-w-xs"
|
||||||
|
value={selectedBoard()?.host || ''}
|
||||||
|
onChange={(e) => {
|
||||||
|
const board = boards().find(b => b.host === e.target.value);
|
||||||
|
setSelectedBoard(board || null);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option disabled value="">
|
||||||
|
{boards().length > 0 ? t('ledTest.chooseBoard') : t('ledTest.noBoardsFound')}
|
||||||
|
</option>
|
||||||
|
<For each={boards()}>
|
||||||
|
{(board) => {
|
||||||
|
const getStatusIcon = (status: BoardInfo['connect_status']) => {
|
||||||
|
if (status === 'Connected') return '🟢';
|
||||||
|
if (typeof status === 'object' && 'Connecting' in status) return '🟡';
|
||||||
|
return '🔴';
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatusText = (status: BoardInfo['connect_status']) => {
|
||||||
|
if (status === 'Connected') return t('ledTest.connected');
|
||||||
|
if (typeof status === 'object' && 'Connecting' in status) return t('ledTest.connecting');
|
||||||
|
return t('ledTest.disconnected');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<option value={board.host}>
|
||||||
|
{getStatusIcon(board.connect_status)} {board.host} ({board.address}:{board.port}) - {getStatusText(board.connect_status)}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</For>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* LED Configuration */}
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mt-4">
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text">{t('ledTest.ledCount')}</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
class="input input-bordered w-full text-center text-lg"
|
||||||
|
value={ledCountInput()}
|
||||||
|
min="1"
|
||||||
|
max="1000"
|
||||||
|
onInput={handleLedCountInput}
|
||||||
|
onBlur={handleLedCountBlur}
|
||||||
|
onKeyDown={handleLedCountKeyDown}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text">{t('ledTest.ledType')}</span>
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
class="select select-bordered w-full"
|
||||||
|
value={ledType()}
|
||||||
|
onChange={(e) => setLedType(e.target.value as 'WS2812B' | 'SK6812')}
|
||||||
|
>
|
||||||
|
<option value="WS2812B">WS2812B</option>
|
||||||
|
<option value="SK6812">SK6812</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text">{t('ledTest.animationSpeed')}</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
class="input input-bordered w-full text-center"
|
||||||
|
value={animationSpeedInput()}
|
||||||
|
min="16"
|
||||||
|
max="200"
|
||||||
|
step="1"
|
||||||
|
onInput={handleAnimationSpeedInput}
|
||||||
|
onBlur={handleAnimationSpeedBlur}
|
||||||
|
onKeyDown={handleAnimationSpeedKeyDown}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Test Patterns */}
|
||||||
|
<div class="card bg-base-200 shadow-xl">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3 class="card-title text-xl mb-4">Test Patterns</h3>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<For each={testPatterns}>
|
||||||
|
{(pattern) => (
|
||||||
|
<div class="card bg-base-100 shadow-md">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title text-lg">{pattern.name}</h4>
|
||||||
|
<p class="text-sm opacity-70 mb-4">{pattern.description}</p>
|
||||||
|
|
||||||
|
<div class="card-actions justify-end">
|
||||||
|
<Show
|
||||||
|
when={currentPattern() === pattern && isRunning()}
|
||||||
|
fallback={
|
||||||
|
<button
|
||||||
|
class="btn btn-primary"
|
||||||
|
onClick={() => startTest(pattern)}
|
||||||
|
disabled={!selectedBoard()}
|
||||||
|
>
|
||||||
|
{t('ledTest.startTestButton')}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="btn btn-error"
|
||||||
|
onClick={() => stopTest()}
|
||||||
|
>
|
||||||
|
{t('ledTest.stopTest')}
|
||||||
|
</button>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Show when={isRunning()}>
|
||||||
|
<div class="alert alert-info mt-4">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||||
|
</svg>
|
||||||
|
<span>Test pattern "{currentPattern()?.name}" is running on {selectedBoard()?.host}</span>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
<Show when={!selectedBoard()}>
|
||||||
|
<div class="alert alert-warning mt-4">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L3.732 16c-.77.833.192 2.5 1.732 2.5z" />
|
||||||
|
</svg>
|
||||||
|
<span>Please select a hardware board to start testing</span>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -5,6 +5,16 @@ type Props = {
|
|||||||
} & JSX.HTMLAttributes<HTMLInputElement>;
|
} & JSX.HTMLAttributes<HTMLInputElement>;
|
||||||
|
|
||||||
export const ColorSlider: Component<Props> = (props) => {
|
export const ColorSlider: Component<Props> = (props) => {
|
||||||
|
const handleMouseDown = (e: MouseEvent) => {
|
||||||
|
// 阻止事件冒泡到父元素,避免触发面板拖拽
|
||||||
|
e.stopPropagation();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseMove = (e: MouseEvent) => {
|
||||||
|
// 阻止事件冒泡到父元素
|
||||||
|
e.stopPropagation();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
@ -17,6 +27,8 @@ export const ColorSlider: Component<Props> = (props) => {
|
|||||||
'range range-primary w-full bg-gradient-to-r ' +
|
'range range-primary w-full bg-gradient-to-r ' +
|
||||||
props.class
|
props.class
|
||||||
}
|
}
|
||||||
|
onMouseDown={handleMouseDown}
|
||||||
|
onMouseMove={handleMouseMove}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,7 @@ import { BiRegularReset } from 'solid-icons/bi';
|
|||||||
import { BsFullscreen, BsFullscreenExit } from 'solid-icons/bs';
|
import { BsFullscreen, BsFullscreenExit } from 'solid-icons/bs';
|
||||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||||
import transparentBg from '../../assets/transparent-grid-background.svg?url';
|
import transparentBg from '../../assets/transparent-grid-background.svg?url';
|
||||||
|
import { useLanguage } from '../../i18n/index';
|
||||||
|
|
||||||
const Value: Component<{ value: number }> = (props) => {
|
const Value: Component<{ value: number }> = (props) => {
|
||||||
return (
|
return (
|
||||||
@ -20,6 +21,7 @@ const Value: Component<{ value: number }> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const WhiteBalance = () => {
|
export const WhiteBalance = () => {
|
||||||
|
const { t } = useLanguage();
|
||||||
const [isFullscreen, setIsFullscreen] = createSignal(false);
|
const [isFullscreen, setIsFullscreen] = createSignal(false);
|
||||||
const [panelPosition, setPanelPosition] = createSignal({ x: 0, y: 0 });
|
const [panelPosition, setPanelPosition] = createSignal({ x: 0, y: 0 });
|
||||||
const [isDragging, setIsDragging] = createSignal(false);
|
const [isDragging, setIsDragging] = createSignal(false);
|
||||||
@ -38,7 +40,7 @@ export const WhiteBalance = () => {
|
|||||||
setIsFullscreen(true);
|
setIsFullscreen(true);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to auto enter fullscreen:', error);
|
// Silently handle fullscreen error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,13 +58,17 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
// 拖拽处理函数
|
// 拖拽处理函数
|
||||||
const handleMouseDown = (e: MouseEvent) => {
|
const handleMouseDown = (e: MouseEvent) => {
|
||||||
|
// 确保只有在标题栏区域点击时才触发拖拽
|
||||||
setIsDragging(true);
|
setIsDragging(true);
|
||||||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
const panelRect = (e.currentTarget as HTMLElement).closest('.fixed')?.getBoundingClientRect();
|
||||||
|
if (panelRect) {
|
||||||
setDragOffset({
|
setDragOffset({
|
||||||
x: e.clientX - rect.left,
|
x: e.clientX - panelRect.left,
|
||||||
y: e.clientY - rect.top
|
y: e.clientY - panelRect.top
|
||||||
});
|
});
|
||||||
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseMove = (e: MouseEvent) => {
|
const handleMouseMove = (e: MouseEvent) => {
|
||||||
@ -101,7 +107,6 @@ export const WhiteBalance = () => {
|
|||||||
const unlisten = listen('config_changed', (event) => {
|
const unlisten = listen('config_changed', (event) => {
|
||||||
const { strips, mappers, color_calibration } =
|
const { strips, mappers, color_calibration } =
|
||||||
event.payload as LedStripConfigContainer;
|
event.payload as LedStripConfigContainer;
|
||||||
console.log(event.payload);
|
|
||||||
setLedStripStore({
|
setLedStripStore({
|
||||||
strips,
|
strips,
|
||||||
mappers,
|
mappers,
|
||||||
@ -121,9 +126,9 @@ export const WhiteBalance = () => {
|
|||||||
const calibration = { ...ledStripStore.colorCalibration };
|
const calibration = { ...ledStripStore.colorCalibration };
|
||||||
calibration[key] = value;
|
calibration[key] = value;
|
||||||
setLedStripStore('colorCalibration', calibration);
|
setLedStripStore('colorCalibration', calibration);
|
||||||
invoke('set_color_calibration', { calibration }).catch((error) =>
|
invoke('set_color_calibration', { calibration }).catch(() => {
|
||||||
console.log(error),
|
// Silently handle error
|
||||||
);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleFullscreen = async () => {
|
const toggleFullscreen = async () => {
|
||||||
@ -138,7 +143,7 @@ export const WhiteBalance = () => {
|
|||||||
setPanelPosition({ x: 0, y: 0 });
|
setPanelPosition({ x: 0, y: 0 });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to toggle fullscreen:', error);
|
// Silently handle fullscreen error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,7 +161,9 @@ export const WhiteBalance = () => {
|
|||||||
const reset = () => {
|
const reset = () => {
|
||||||
invoke('set_color_calibration', {
|
invoke('set_color_calibration', {
|
||||||
calibration: new ColorCalibration(),
|
calibration: new ColorCalibration(),
|
||||||
}).catch((error) => console.log(error));
|
}).catch(() => {
|
||||||
|
// Silently handle error
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -165,19 +172,19 @@ export const WhiteBalance = () => {
|
|||||||
{!isFullscreen() && (
|
{!isFullscreen() && (
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-2xl font-bold text-base-content">白平衡调节</h1>
|
<h1 class="text-2xl font-bold text-base-content">{t('whiteBalance.title')}</h1>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<button class="btn btn-outline btn-sm" onClick={toggleFullscreen} title="进入全屏">
|
<button class="btn btn-outline btn-sm" onClick={toggleFullscreen} title={t('common.fullscreen')}>
|
||||||
<BsFullscreen size={16} />
|
<BsFullscreen size={16} />
|
||||||
全屏
|
{t('common.fullscreen')}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-outline btn-sm" onClick={reset} title="重置到100%">
|
<button class="btn btn-outline btn-sm" onClick={reset} title={t('common.reset')}>
|
||||||
<BiRegularReset size={16} />
|
<BiRegularReset size={16} />
|
||||||
重置
|
{t('common.reset')}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-primary btn-sm" onClick={exit} title="返回">
|
<button class="btn btn-primary btn-sm" onClick={exit} title={t('whiteBalance.back')}>
|
||||||
<VsClose size={16} />
|
<VsClose size={16} />
|
||||||
返回
|
{t('whiteBalance.back')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -187,8 +194,8 @@ export const WhiteBalance = () => {
|
|||||||
<div class="card bg-base-200 shadow-lg">
|
<div class="card bg-base-200 shadow-lg">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="card-title text-base mb-3">
|
<div class="card-title text-base mb-3">
|
||||||
<span>颜色测试</span>
|
<span>{t('whiteBalance.colorTest')}</span>
|
||||||
<div class="badge badge-info badge-outline">点击测试</div>
|
<div class="badge badge-info badge-outline">{t('whiteBalance.clickToTest')}</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="aspect-square rounded-lg overflow-hidden border border-base-300"
|
class="aspect-square rounded-lg overflow-hidden border border-base-300"
|
||||||
@ -199,7 +206,7 @@ export const WhiteBalance = () => {
|
|||||||
<TestColorsBg />
|
<TestColorsBg />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-base-content/50 mt-2">
|
<div class="text-xs text-base-content/50 mt-2">
|
||||||
💡 提示:点击颜色块进行单色测试,再次点击返回多色模式
|
💡 {t('whiteBalance.colorTestTip')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -208,14 +215,14 @@ export const WhiteBalance = () => {
|
|||||||
<div class="card bg-base-200 shadow-lg">
|
<div class="card bg-base-200 shadow-lg">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="card-title text-base mb-3">
|
<div class="card-title text-base mb-3">
|
||||||
<span>RGB调节</span>
|
<span>{t('whiteBalance.rgbAdjustment')}</span>
|
||||||
<div class="badge badge-secondary badge-outline">实时调节</div>
|
<div class="badge badge-secondary badge-outline">{t('whiteBalance.realtimeAdjustment')}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-red-500">红色 (R)</span>
|
<span class="label-text font-semibold text-red-500">{t('whiteBalance.redChannel')}</span>
|
||||||
<Value value={ledStripStore.colorCalibration.r} />
|
<Value value={ledStripStore.colorCalibration.r} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider
|
<ColorSlider
|
||||||
@ -232,7 +239,7 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-green-500">绿色 (G)</span>
|
<span class="label-text font-semibold text-green-500">{t('whiteBalance.greenChannel')}</span>
|
||||||
<Value value={ledStripStore.colorCalibration.g} />
|
<Value value={ledStripStore.colorCalibration.g} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider
|
<ColorSlider
|
||||||
@ -249,7 +256,7 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-blue-500">蓝色 (B)</span>
|
<span class="label-text font-semibold text-blue-500">{t('whiteBalance.blueChannel')}</span>
|
||||||
<Value value={ledStripStore.colorCalibration.b} />
|
<Value value={ledStripStore.colorCalibration.b} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider
|
<ColorSlider
|
||||||
@ -266,10 +273,19 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-base-content/70">白色 (W)</span>
|
<span class="label-text font-semibold text-amber-500">{t('whiteBalance.whiteChannel')}</span>
|
||||||
<div class="badge badge-outline badge-sm">暂未启用</div>
|
<Value value={ledStripStore.colorCalibration.w} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider class="from-yellow-50 to-cyan-50" disabled />
|
<ColorSlider
|
||||||
|
class="from-amber-100 to-amber-50"
|
||||||
|
value={ledStripStore.colorCalibration.w}
|
||||||
|
onInput={(ev) =>
|
||||||
|
updateColorCalibration(
|
||||||
|
'w',
|
||||||
|
(ev.target as HTMLInputElement).valueAsNumber ?? 1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -277,37 +293,37 @@ export const WhiteBalance = () => {
|
|||||||
<div class="collapse collapse-arrow bg-base-100 mt-4">
|
<div class="collapse collapse-arrow bg-base-100 mt-4">
|
||||||
<input type="checkbox" />
|
<input type="checkbox" />
|
||||||
<div class="collapse-title text-sm font-medium text-base-content/80">
|
<div class="collapse-title text-sm font-medium text-base-content/80">
|
||||||
💡 白平衡调节使用说明
|
💡 {t('whiteBalance.usageInstructions')}
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse-content text-xs text-base-content/70 space-y-3">
|
<div class="collapse-content text-xs text-base-content/70 space-y-3">
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<p class="font-semibold text-primary">🎯 推荐使用方法:</p>
|
<p class="font-semibold text-primary">{t('whiteBalance.recommendedMethod')}</p>
|
||||||
<ol class="list-decimal list-inside space-y-1 ml-2">
|
<ol class="list-decimal list-inside space-y-1 ml-2">
|
||||||
<li>点击上方"全屏"按钮进入全屏模式</li>
|
<li>{t('whiteBalance.fullscreenTip')}</li>
|
||||||
<li>全屏模式下屏幕边缘会显示彩色条带</li>
|
<li>{t('whiteBalance.dragTip')}</li>
|
||||||
<li>将RGB控制面板拖拽到合适位置</li>
|
<li>{t('whiteBalance.dragPanelTip')}</li>
|
||||||
<li>对比LED灯条颜色与屏幕边缘颜色</li>
|
<li>{t('whiteBalance.compareColorsTip')}</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<p class="font-semibold text-secondary">🔧 调节技巧:</p>
|
<p class="font-semibold text-secondary">{t('whiteBalance.adjustmentTips')}</p>
|
||||||
<ul class="list-disc list-inside space-y-1 ml-2">
|
<ul class="list-disc list-inside space-y-1 ml-2">
|
||||||
<li><span class="text-red-500 font-medium">红色偏强</span>:降低R值,LED会减少红色成分</li>
|
<li>{t('whiteBalance.redStrong')}</li>
|
||||||
<li><span class="text-green-500 font-medium">绿色偏强</span>:降低G值,LED会减少绿色成分</li>
|
<li>{t('whiteBalance.greenStrong')}</li>
|
||||||
<li><span class="text-blue-500 font-medium">蓝色偏强</span>:降低B值,LED会减少蓝色成分</li>
|
<li>{t('whiteBalance.blueStrong')}</li>
|
||||||
<li><span class="text-base-content font-medium">白色发黄</span>:适当提高B值,降低R/G值</li>
|
<li>{t('whiteBalance.whiteYellow')}</li>
|
||||||
<li><span class="text-base-content font-medium">白色发蓝</span>:适当降低B值,提高R/G值</li>
|
<li>{t('whiteBalance.whiteBlue')}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<p class="font-semibold text-accent">📋 对比方法:</p>
|
<p class="font-semibold text-accent">{t('whiteBalance.comparisonMethod')}</p>
|
||||||
<ul class="list-disc list-inside space-y-1 ml-2">
|
<ul class="list-disc list-inside space-y-1 ml-2">
|
||||||
<li>重点观察白色区域,确保LED白光与屏幕白色一致</li>
|
<li>{t('whiteBalance.whiteComparison')}</li>
|
||||||
<li>检查彩色区域,确保LED颜色饱和度合适</li>
|
<li>{t('whiteBalance.colorComparison')}</li>
|
||||||
<li>在不同环境光下测试,确保效果稳定</li>
|
<li>{t('whiteBalance.environmentTest')}</li>
|
||||||
<li>调节完成后可点击"重置"按钮恢复默认值</li>
|
<li>{t('whiteBalance.resetNote')}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -328,22 +344,24 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
{/* 可拖拽的RGB控制面板 */}
|
{/* 可拖拽的RGB控制面板 */}
|
||||||
<div
|
<div
|
||||||
class="fixed w-80 bg-base-200/95 backdrop-blur-sm rounded-lg shadow-xl z-60 cursor-move select-none"
|
class="fixed w-80 bg-base-200/95 backdrop-blur-sm rounded-lg shadow-xl z-60 select-none"
|
||||||
style={{
|
style={{
|
||||||
left: `${panelPosition().x}px`,
|
left: `${panelPosition().x}px`,
|
||||||
top: `${panelPosition().y}px`,
|
top: `${panelPosition().y}px`,
|
||||||
transform: 'none'
|
transform: 'none'
|
||||||
}}
|
}}
|
||||||
onMouseDown={handleMouseDown}
|
|
||||||
>
|
>
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="card-title text-base mb-3 flex justify-between items-center">
|
<div
|
||||||
|
class="card-title text-base mb-3 flex justify-between items-center cursor-move"
|
||||||
|
onMouseDown={handleMouseDown}
|
||||||
|
>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span class="text-xs opacity-60">⋮⋮</span>
|
<span class="text-xs opacity-60">⋮⋮</span>
|
||||||
<span>RGB调节</span>
|
<span>{t('whiteBalance.rgbAdjustment')}</span>
|
||||||
<div class="badge badge-secondary badge-outline">可拖拽</div>
|
<div class="badge badge-secondary badge-outline">{t('whiteBalance.draggable')}</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-ghost btn-xs" onClick={toggleFullscreen} title="退出全屏">
|
<button class="btn btn-ghost btn-xs cursor-pointer" onClick={toggleFullscreen} title={t('whiteBalance.exitFullscreen')}>
|
||||||
<BsFullscreenExit size={14} />
|
<BsFullscreenExit size={14} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -351,7 +369,7 @@ export const WhiteBalance = () => {
|
|||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-red-500">红色 (R)</span>
|
<span class="label-text font-semibold text-red-500">{t('whiteBalance.redChannel')}</span>
|
||||||
<Value value={ledStripStore.colorCalibration.r} />
|
<Value value={ledStripStore.colorCalibration.r} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider
|
<ColorSlider
|
||||||
@ -368,7 +386,7 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-green-500">绿色 (G)</span>
|
<span class="label-text font-semibold text-green-500">{t('whiteBalance.greenChannel')}</span>
|
||||||
<Value value={ledStripStore.colorCalibration.g} />
|
<Value value={ledStripStore.colorCalibration.g} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider
|
<ColorSlider
|
||||||
@ -385,7 +403,7 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-blue-500">蓝色 (B)</span>
|
<span class="label-text font-semibold text-blue-500">{t('whiteBalance.blueChannel')}</span>
|
||||||
<Value value={ledStripStore.colorCalibration.b} />
|
<Value value={ledStripStore.colorCalibration.b} />
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider
|
<ColorSlider
|
||||||
@ -402,25 +420,42 @@ export const WhiteBalance = () => {
|
|||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<span class="label-text font-semibold text-base-content/70">白色 (W)</span>
|
<span class="label-text font-semibold text-amber-500">{t('whiteBalance.whiteChannel')}</span>
|
||||||
<div class="badge badge-outline badge-sm">暂未启用</div>
|
<Value value={ledStripStore.colorCalibration.w} />
|
||||||
|
</label>
|
||||||
|
<ColorSlider
|
||||||
|
class="from-amber-100 to-amber-50"
|
||||||
|
value={ledStripStore.colorCalibration.w}
|
||||||
|
onInput={(ev) =>
|
||||||
|
updateColorCalibration(
|
||||||
|
'w',
|
||||||
|
(ev.target as HTMLInputElement).valueAsNumber ?? 1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text font-semibold text-base-content/70">{t('whiteBalance.whiteChannel')}</span>
|
||||||
|
<div class="badge badge-outline badge-sm">{t('whiteBalance.notEnabled')}</div>
|
||||||
</label>
|
</label>
|
||||||
<ColorSlider class="from-yellow-50 to-cyan-50" disabled />
|
<ColorSlider class="from-yellow-50 to-cyan-50" disabled />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-xs text-base-content/60 mt-3 p-2 bg-base-300/50 rounded">
|
<div class="text-xs text-base-content/60 mt-3 p-2 bg-base-300/50 rounded">
|
||||||
💡 对比屏幕边缘颜色与LED灯条,调节RGB滑块使颜色一致
|
💡 {t('whiteBalance.fullscreenComparisonTip')}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex gap-2 mt-4">
|
<div class="flex gap-2 mt-4">
|
||||||
<button class="btn btn-outline btn-sm flex-1" onClick={reset} title="重置到100%">
|
<button class="btn btn-outline btn-sm flex-1" onClick={reset} title={t('common.reset')}>
|
||||||
<BiRegularReset size={14} />
|
<BiRegularReset size={14} />
|
||||||
重置
|
{t('common.reset')}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-primary btn-sm flex-1" onClick={exit} title="返回">
|
<button class="btn btn-primary btn-sm flex-1" onClick={exit} title={t('whiteBalance.back')}>
|
||||||
<VsClose size={14} />
|
<VsClose size={14} />
|
||||||
返回
|
{t('whiteBalance.back')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,9 +7,14 @@ export type LedStripConfigurationContextType = [
|
|||||||
displayId: number;
|
displayId: number;
|
||||||
border: Borders;
|
border: Borders;
|
||||||
} | null;
|
} | null;
|
||||||
|
hoveredStripPart: {
|
||||||
|
displayId: number;
|
||||||
|
border: Borders;
|
||||||
|
} | null;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
setSelectedStripPart: (v: { displayId: number; border: Borders } | null) => void;
|
setSelectedStripPart: (v: { displayId: number; border: Borders } | null) => void;
|
||||||
|
setHoveredStripPart: (v: { displayId: number; border: Borders } | null) => void;
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -17,8 +22,10 @@ export const LedStripConfigurationContext =
|
|||||||
createContext<LedStripConfigurationContextType>([
|
createContext<LedStripConfigurationContextType>([
|
||||||
{
|
{
|
||||||
selectedStripPart: null,
|
selectedStripPart: null,
|
||||||
|
hoveredStripPart: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
setSelectedStripPart: () => {},
|
setSelectedStripPart: () => {},
|
||||||
|
setHoveredStripPart: () => { },
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
79
src/i18n/index.tsx
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import { createSignal, createContext, useContext, ParentComponent, createEffect } from 'solid-js';
|
||||||
|
import { Language, TranslationDict } from './types';
|
||||||
|
import { zhCN } from './locales/zh-CN';
|
||||||
|
import { enUS } from './locales/en-US';
|
||||||
|
|
||||||
|
// Available translations
|
||||||
|
const translations: Record<Language, TranslationDict> = {
|
||||||
|
'zh-CN': zhCN,
|
||||||
|
'en-US': enUS,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create locale signal
|
||||||
|
const [locale, setLocale] = createSignal<Language>('zh-CN');
|
||||||
|
|
||||||
|
// Translation function
|
||||||
|
const t = (key: string): string => {
|
||||||
|
const keys = key.split('.');
|
||||||
|
let value: any = translations[locale()];
|
||||||
|
|
||||||
|
for (const k of keys) {
|
||||||
|
if (value && typeof value === 'object' && k in value) {
|
||||||
|
value = value[k];
|
||||||
|
} else {
|
||||||
|
return key; // Return key if translation not found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof value === 'string' ? value : key;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Language context for managing language state
|
||||||
|
interface LanguageContextType {
|
||||||
|
locale: () => Language;
|
||||||
|
setLocale: (lang: Language) => void;
|
||||||
|
t: (key: string) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LanguageContext = createContext<LanguageContextType>();
|
||||||
|
|
||||||
|
// Language provider component
|
||||||
|
export const LanguageProvider: ParentComponent = (props) => {
|
||||||
|
// Load saved language preference from localStorage
|
||||||
|
createEffect(() => {
|
||||||
|
const savedLang = localStorage.getItem('app-language') as Language;
|
||||||
|
if (savedLang && (savedLang === 'zh-CN' || savedLang === 'en-US')) {
|
||||||
|
setLocale(savedLang);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save language preference when it changes
|
||||||
|
createEffect(() => {
|
||||||
|
localStorage.setItem('app-language', locale());
|
||||||
|
});
|
||||||
|
|
||||||
|
const contextValue: LanguageContextType = {
|
||||||
|
locale,
|
||||||
|
setLocale,
|
||||||
|
t,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LanguageContext.Provider value={contextValue}>
|
||||||
|
{props.children}
|
||||||
|
</LanguageContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Hook to use language context
|
||||||
|
export const useLanguage = () => {
|
||||||
|
const context = useContext(LanguageContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useLanguage must be used within a LanguageProvider');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Export types and utilities
|
||||||
|
export type { Language, TranslationDict };
|
||||||
|
export { translations };
|
234
src/i18n/locales/en-US.ts
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
import { TranslationDict } from '../types';
|
||||||
|
|
||||||
|
export const enUS: TranslationDict = {
|
||||||
|
nav: {
|
||||||
|
title: 'Ambient Light Control',
|
||||||
|
info: 'System Info',
|
||||||
|
displays: 'Display Info',
|
||||||
|
ledConfiguration: 'LED Configuration',
|
||||||
|
whiteBalance: 'White Balance',
|
||||||
|
ledTest: 'LED Test',
|
||||||
|
},
|
||||||
|
|
||||||
|
common: {
|
||||||
|
version: 'Version',
|
||||||
|
primary: 'Primary',
|
||||||
|
save: 'Save',
|
||||||
|
cancel: 'Cancel',
|
||||||
|
reset: 'Reset',
|
||||||
|
close: 'Close',
|
||||||
|
fullscreen: 'Fullscreen',
|
||||||
|
exitFullscreen: 'Exit Fullscreen',
|
||||||
|
loading: 'Loading...',
|
||||||
|
error: 'Error',
|
||||||
|
success: 'Success',
|
||||||
|
warning: 'Warning',
|
||||||
|
confirm: 'Confirm',
|
||||||
|
delete: 'Delete',
|
||||||
|
edit: 'Edit',
|
||||||
|
add: 'Add',
|
||||||
|
remove: 'Remove',
|
||||||
|
enable: 'Enable',
|
||||||
|
disable: 'Disable',
|
||||||
|
start: 'Start',
|
||||||
|
stop: 'Stop',
|
||||||
|
test: 'Test',
|
||||||
|
apply: 'Apply',
|
||||||
|
refresh: 'Refresh',
|
||||||
|
realtime: 'Real-time',
|
||||||
|
},
|
||||||
|
|
||||||
|
info: {
|
||||||
|
title: 'System Information',
|
||||||
|
boardInfo: 'Device Information',
|
||||||
|
systemInfo: 'System Information',
|
||||||
|
deviceName: 'Device Name',
|
||||||
|
ipAddress: 'IP Address',
|
||||||
|
macAddress: 'MAC Address',
|
||||||
|
firmwareVersion: 'Firmware Version',
|
||||||
|
hardwareVersion: 'Hardware Version',
|
||||||
|
uptime: 'Uptime',
|
||||||
|
status: 'Status',
|
||||||
|
connected: 'Connected',
|
||||||
|
disconnected: 'Disconnected',
|
||||||
|
lastSeen: 'Last Seen',
|
||||||
|
port: 'Port',
|
||||||
|
latency: 'Latency',
|
||||||
|
hostname: 'Hostname',
|
||||||
|
deviceCount: 'Device Count',
|
||||||
|
noDevicesFound: 'No Devices Found',
|
||||||
|
checkConnection: 'Please check device connection status',
|
||||||
|
// Device status
|
||||||
|
timeout: 'Timeout',
|
||||||
|
connecting: 'Connecting',
|
||||||
|
},
|
||||||
|
|
||||||
|
displays: {
|
||||||
|
title: 'Display Status',
|
||||||
|
count: 'Display Count',
|
||||||
|
noDisplays: 'No displays detected',
|
||||||
|
checkConnection: 'Please check display connection',
|
||||||
|
displayInfo: 'Display Information',
|
||||||
|
resolution: 'Resolution',
|
||||||
|
refreshRate: 'Refresh Rate',
|
||||||
|
colorDepth: 'Color Depth',
|
||||||
|
isPrimary: 'Primary Display',
|
||||||
|
position: 'Position',
|
||||||
|
size: 'Size',
|
||||||
|
scaleFactor: 'Scale Factor',
|
||||||
|
lastModified: 'Last Modified',
|
||||||
|
displayCount: 'Display Count',
|
||||||
|
noDisplaysFound: 'No displays detected',
|
||||||
|
brightnessSettings: 'Brightness Settings',
|
||||||
|
currentBrightness: 'Current Brightness',
|
||||||
|
maxBrightness: 'Max Brightness',
|
||||||
|
minBrightness: 'Min Brightness',
|
||||||
|
contrastSettings: 'Contrast Settings',
|
||||||
|
currentContrast: 'Current Contrast',
|
||||||
|
maxContrast: 'Max Contrast',
|
||||||
|
minContrast: 'Min Contrast',
|
||||||
|
modeSettings: 'Mode Settings',
|
||||||
|
currentMode: 'Current Mode',
|
||||||
|
maxMode: 'Max Mode',
|
||||||
|
minMode: 'Min Mode',
|
||||||
|
// Display info panel specific
|
||||||
|
id: 'ID',
|
||||||
|
scale: 'Scale',
|
||||||
|
},
|
||||||
|
|
||||||
|
ledConfig: {
|
||||||
|
title: 'LED Strip Configuration',
|
||||||
|
displaySelection: 'Display Selection',
|
||||||
|
ledStripConfig: 'LED Strip Configuration',
|
||||||
|
ledCount: 'LED Count',
|
||||||
|
ledType: 'LED Type',
|
||||||
|
position: 'Position',
|
||||||
|
top: 'Top',
|
||||||
|
bottom: 'Bottom',
|
||||||
|
left: 'Left',
|
||||||
|
right: 'Right',
|
||||||
|
preview: 'Preview',
|
||||||
|
configuration: 'Configuration',
|
||||||
|
sorter: 'Sorter',
|
||||||
|
moveUp: 'Move Up',
|
||||||
|
moveDown: 'Move Down',
|
||||||
|
reverse: 'Reverse',
|
||||||
|
rgb: 'RGB',
|
||||||
|
rgbw: 'RGBW',
|
||||||
|
segments: 'Segments',
|
||||||
|
totalLeds: 'Total LEDs',
|
||||||
|
saveConfig: 'Save Configuration',
|
||||||
|
loadConfig: 'Load Configuration',
|
||||||
|
stripSorting: 'LED Strip Sorting',
|
||||||
|
realtimePreview: 'Real-time Preview',
|
||||||
|
sortingTip: 'Tip: Drag LED strip segments to adjust order, double-click to reverse direction',
|
||||||
|
displayConfiguration: 'Display Configuration',
|
||||||
|
visualEditor: 'Visual Editor',
|
||||||
|
displayTip: 'Tip: Hover over displays for detailed information, use control panel below to adjust LED count',
|
||||||
|
ledCountControl: 'LED Count Control',
|
||||||
|
realtimeAdjustment: 'Real-time Adjustment',
|
||||||
|
decreaseLedCount: 'Decrease LED Count',
|
||||||
|
increaseLedCount: 'Increase LED Count',
|
||||||
|
display: 'Display',
|
||||||
|
controlTip: 'Tip: Click +/- buttons or input values directly to adjust LED count (Range: 0-1000)',
|
||||||
|
},
|
||||||
|
|
||||||
|
whiteBalance: {
|
||||||
|
title: 'White Balance Adjustment',
|
||||||
|
colorCalibration: 'Color Calibration',
|
||||||
|
redChannel: 'Red (R)',
|
||||||
|
greenChannel: 'Green (G)',
|
||||||
|
blueChannel: 'Blue (B)',
|
||||||
|
whiteChannel: 'White (W)',
|
||||||
|
brightness: 'Brightness',
|
||||||
|
temperature: 'Temperature',
|
||||||
|
resetToDefault: 'Reset to Default',
|
||||||
|
fullscreenMode: 'Fullscreen Mode',
|
||||||
|
normalMode: 'Normal Mode',
|
||||||
|
instructions: 'Instructions',
|
||||||
|
helpText: 'Adjust RGB values to match screen colors with actual LED strip colors',
|
||||||
|
compareColors: 'Compare Colors',
|
||||||
|
adjustValues: 'Adjust Values',
|
||||||
|
dragToMove: 'Drag to Move Panel',
|
||||||
|
back: 'Back',
|
||||||
|
colorTest: 'Color Test',
|
||||||
|
clickToTest: 'Click to Test',
|
||||||
|
colorTestTip: 'Tip: Click color blocks for single color test, click again to return to multi-color mode',
|
||||||
|
rgbAdjustment: 'RGB Adjustment',
|
||||||
|
realtimeAdjustment: 'Real-time Adjustment',
|
||||||
|
usageInstructions: 'White Balance Adjustment Instructions',
|
||||||
|
recommendedMethod: '🎯 Recommended Method:',
|
||||||
|
adjustmentTips: '🔧 Adjustment Tips:',
|
||||||
|
comparisonMethod: '📋 Comparison Method:',
|
||||||
|
fullscreenTip: 'Click "Fullscreen" button above to enter fullscreen mode',
|
||||||
|
dragTip: 'Color strips will be displayed at screen edges in fullscreen mode',
|
||||||
|
redStrong: 'Red too strong: Lower R value to reduce red component in LEDs',
|
||||||
|
greenStrong: 'Green too strong: Lower G value to reduce green component in LEDs',
|
||||||
|
blueStrong: 'Blue too strong: Lower B value to reduce blue component in LEDs',
|
||||||
|
whiteYellow: 'White appears yellow: Increase B value, decrease R/G values',
|
||||||
|
whiteBlue: 'White appears blue: Decrease B value, increase R/G values',
|
||||||
|
whiteComparison: 'Focus on white areas, ensure LED white light matches screen white',
|
||||||
|
colorComparison: 'Check color areas, ensure LED color saturation is appropriate',
|
||||||
|
environmentTest: 'Test under different ambient lighting to ensure stable results',
|
||||||
|
resetNote: 'Click "Reset" button to restore default values after adjustment',
|
||||||
|
fullscreenComparisonTip: 'Compare screen edge colors with LED strips, adjust RGB sliders to match colors',
|
||||||
|
draggable: 'Draggable',
|
||||||
|
exitFullscreen: 'Exit Fullscreen',
|
||||||
|
notEnabled: 'Not Enabled',
|
||||||
|
// Missing white balance instructions
|
||||||
|
dragPanelTip: 'Drag the RGB control panel to a suitable position',
|
||||||
|
compareColorsTip: 'Compare LED strip colors with screen edge colors',
|
||||||
|
},
|
||||||
|
|
||||||
|
ledTest: {
|
||||||
|
title: 'LED Strip Test',
|
||||||
|
testEffects: 'Test Effects',
|
||||||
|
staticColor: 'Static Color',
|
||||||
|
rainbow: 'Rainbow',
|
||||||
|
breathing: 'Breathing',
|
||||||
|
wave: 'Wave',
|
||||||
|
chase: 'Chase',
|
||||||
|
twinkle: 'Twinkle',
|
||||||
|
fire: 'Fire',
|
||||||
|
speed: 'Speed',
|
||||||
|
brightness: 'Brightness',
|
||||||
|
color: 'Color',
|
||||||
|
startTest: 'Start Test',
|
||||||
|
stopTest: 'Stop Test',
|
||||||
|
testRunning: 'Test Running',
|
||||||
|
testStopped: 'Test Stopped',
|
||||||
|
selectEffect: 'Select Effect',
|
||||||
|
effectSettings: 'Effect Settings',
|
||||||
|
flowingRainbow: 'Flowing Rainbow',
|
||||||
|
flowingRainbowDesc: 'Rainbow flowing light for testing LED strip direction',
|
||||||
|
groupCounting: 'Group Counting',
|
||||||
|
groupCountingDesc: 'Different colors for every ten LEDs to quickly count LED quantity',
|
||||||
|
singleScan: 'Single Scan',
|
||||||
|
singleScanDesc: 'Light up each LED individually for precise position testing',
|
||||||
|
breathingDesc: 'Breathing effect for the entire LED strip to test overall brightness',
|
||||||
|
// LED test form labels
|
||||||
|
ledCount: 'LED Count',
|
||||||
|
ledType: 'LED Type',
|
||||||
|
animationSpeed: 'Animation Speed (ms)',
|
||||||
|
startTestButton: 'Start Test',
|
||||||
|
// Hardware selection
|
||||||
|
selectHardwareBoard: 'Select Hardware Board',
|
||||||
|
devicesFound: 'device(s) found',
|
||||||
|
searching: 'Searching...',
|
||||||
|
chooseBoard: 'Choose a board',
|
||||||
|
noBoardsFound: 'No boards found',
|
||||||
|
connected: 'Connected',
|
||||||
|
connecting: 'Connecting',
|
||||||
|
disconnected: 'Disconnected',
|
||||||
|
},
|
||||||
|
|
||||||
|
errors: {
|
||||||
|
failedToLoad: 'Failed to load',
|
||||||
|
failedToSave: 'Failed to save',
|
||||||
|
failedToConnect: 'Failed to connect',
|
||||||
|
invalidConfiguration: 'Invalid configuration',
|
||||||
|
deviceNotFound: 'Device not found',
|
||||||
|
networkError: 'Network error',
|
||||||
|
unknownError: 'Unknown error',
|
||||||
|
},
|
||||||
|
};
|
234
src/i18n/locales/zh-CN.ts
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
import { TranslationDict } from '../types';
|
||||||
|
|
||||||
|
export const zhCN: TranslationDict = {
|
||||||
|
nav: {
|
||||||
|
title: '环境光控制',
|
||||||
|
info: '基本信息',
|
||||||
|
displays: '显示器信息',
|
||||||
|
ledConfiguration: '灯条配置',
|
||||||
|
whiteBalance: '白平衡',
|
||||||
|
ledTest: '灯带测试',
|
||||||
|
},
|
||||||
|
|
||||||
|
common: {
|
||||||
|
version: '版本',
|
||||||
|
primary: '主要',
|
||||||
|
save: '保存',
|
||||||
|
cancel: '取消',
|
||||||
|
reset: '重置',
|
||||||
|
close: '关闭',
|
||||||
|
fullscreen: '全屏',
|
||||||
|
exitFullscreen: '退出全屏',
|
||||||
|
loading: '加载中...',
|
||||||
|
error: '错误',
|
||||||
|
success: '成功',
|
||||||
|
warning: '警告',
|
||||||
|
confirm: '确认',
|
||||||
|
delete: '删除',
|
||||||
|
edit: '编辑',
|
||||||
|
add: '添加',
|
||||||
|
remove: '移除',
|
||||||
|
enable: '启用',
|
||||||
|
disable: '禁用',
|
||||||
|
start: '开始',
|
||||||
|
stop: '停止',
|
||||||
|
test: '测试',
|
||||||
|
apply: '应用',
|
||||||
|
refresh: '刷新',
|
||||||
|
realtime: '实时',
|
||||||
|
},
|
||||||
|
|
||||||
|
info: {
|
||||||
|
title: '基本信息',
|
||||||
|
boardInfo: '设备信息',
|
||||||
|
systemInfo: '系统信息',
|
||||||
|
deviceName: '设备名称',
|
||||||
|
ipAddress: 'IP地址',
|
||||||
|
macAddress: 'MAC地址',
|
||||||
|
firmwareVersion: '固件版本',
|
||||||
|
hardwareVersion: '硬件版本',
|
||||||
|
uptime: '运行时间',
|
||||||
|
status: '状态',
|
||||||
|
connected: '已连接',
|
||||||
|
disconnected: '已断开',
|
||||||
|
lastSeen: '最后连接',
|
||||||
|
port: '端口',
|
||||||
|
latency: '延迟',
|
||||||
|
hostname: '主机名',
|
||||||
|
deviceCount: '设备总数',
|
||||||
|
noDevicesFound: '未发现设备',
|
||||||
|
checkConnection: '请检查设备连接状态',
|
||||||
|
// Device status
|
||||||
|
timeout: '超时',
|
||||||
|
connecting: '连接中',
|
||||||
|
},
|
||||||
|
|
||||||
|
displays: {
|
||||||
|
title: '显示器状态',
|
||||||
|
count: '显示器数量',
|
||||||
|
noDisplays: '未检测到显示器',
|
||||||
|
checkConnection: '请检查显示器连接状态',
|
||||||
|
displayInfo: '显示器信息',
|
||||||
|
resolution: '分辨率',
|
||||||
|
refreshRate: '刷新率',
|
||||||
|
colorDepth: '色深',
|
||||||
|
isPrimary: '主显示器',
|
||||||
|
position: '位置',
|
||||||
|
size: '尺寸',
|
||||||
|
scaleFactor: '缩放比例',
|
||||||
|
lastModified: '最后修改',
|
||||||
|
displayCount: '显示器数量',
|
||||||
|
noDisplaysFound: '未检测到显示器',
|
||||||
|
brightnessSettings: '亮度设置',
|
||||||
|
currentBrightness: '当前亮度',
|
||||||
|
maxBrightness: '最大亮度',
|
||||||
|
minBrightness: '最小亮度',
|
||||||
|
contrastSettings: '对比度设置',
|
||||||
|
currentContrast: '当前对比度',
|
||||||
|
maxContrast: '最大对比度',
|
||||||
|
minContrast: '最小对比度',
|
||||||
|
modeSettings: '模式设置',
|
||||||
|
currentMode: '当前模式',
|
||||||
|
maxMode: '最大模式',
|
||||||
|
minMode: '最小模式',
|
||||||
|
// Display info panel specific
|
||||||
|
id: 'ID',
|
||||||
|
scale: '缩放',
|
||||||
|
},
|
||||||
|
|
||||||
|
ledConfig: {
|
||||||
|
title: '灯条配置',
|
||||||
|
displaySelection: '显示器选择',
|
||||||
|
ledStripConfig: '灯条配置',
|
||||||
|
ledCount: '灯珠数量',
|
||||||
|
ledType: '灯珠类型',
|
||||||
|
position: '位置',
|
||||||
|
top: '顶部',
|
||||||
|
bottom: '底部',
|
||||||
|
left: '左侧',
|
||||||
|
right: '右侧',
|
||||||
|
preview: '预览',
|
||||||
|
configuration: '配置',
|
||||||
|
sorter: '排序器',
|
||||||
|
moveUp: '上移',
|
||||||
|
moveDown: '下移',
|
||||||
|
reverse: '反转',
|
||||||
|
rgb: 'RGB',
|
||||||
|
rgbw: 'RGBW',
|
||||||
|
segments: '段数',
|
||||||
|
totalLeds: '总灯珠数',
|
||||||
|
saveConfig: '保存配置',
|
||||||
|
loadConfig: '加载配置',
|
||||||
|
stripSorting: '灯条排序',
|
||||||
|
realtimePreview: '实时预览',
|
||||||
|
sortingTip: '提示:拖拽灯条段落来调整顺序,双击可反转方向',
|
||||||
|
displayConfiguration: '显示器配置',
|
||||||
|
visualEditor: '可视化编辑',
|
||||||
|
displayTip: '提示:悬停显示器查看详细信息,使用下方控制面板调整LED数量',
|
||||||
|
ledCountControl: 'LED数量控制',
|
||||||
|
realtimeAdjustment: '实时调整',
|
||||||
|
decreaseLedCount: '减少LED数量',
|
||||||
|
increaseLedCount: '增加LED数量',
|
||||||
|
display: '显示器',
|
||||||
|
controlTip: '提示:点击 +/- 按钮或直接输入数值来调整LED数量(范围:0-1000)',
|
||||||
|
},
|
||||||
|
|
||||||
|
whiteBalance: {
|
||||||
|
title: '白平衡调节',
|
||||||
|
colorCalibration: '颜色校准',
|
||||||
|
redChannel: '红色 (R)',
|
||||||
|
greenChannel: '绿色 (G)',
|
||||||
|
blueChannel: '蓝色 (B)',
|
||||||
|
whiteChannel: '白色 (W)',
|
||||||
|
brightness: '亮度',
|
||||||
|
temperature: '色温',
|
||||||
|
resetToDefault: '重置为默认值',
|
||||||
|
fullscreenMode: '全屏模式',
|
||||||
|
normalMode: '普通模式',
|
||||||
|
instructions: '使用说明',
|
||||||
|
helpText: '调整RGB值以匹配屏幕颜色与LED灯条的实际颜色',
|
||||||
|
compareColors: '比较颜色',
|
||||||
|
adjustValues: '调整数值',
|
||||||
|
dragToMove: '拖拽移动面板',
|
||||||
|
back: '返回',
|
||||||
|
colorTest: '颜色测试',
|
||||||
|
clickToTest: '点击测试',
|
||||||
|
colorTestTip: '提示:点击颜色块进行单色测试,再次点击返回多色模式',
|
||||||
|
rgbAdjustment: 'RGB调节',
|
||||||
|
realtimeAdjustment: '实时调节',
|
||||||
|
usageInstructions: '白平衡调节使用说明',
|
||||||
|
recommendedMethod: '🎯 推荐使用方法:',
|
||||||
|
adjustmentTips: '🔧 调节技巧:',
|
||||||
|
comparisonMethod: '📋 对比方法:',
|
||||||
|
fullscreenTip: '点击上方"全屏"按钮进入全屏模式',
|
||||||
|
dragTip: '全屏模式下屏幕边缘会显示彩色条带',
|
||||||
|
redStrong: '红色偏强:降低R值,LED会减少红色成分',
|
||||||
|
greenStrong: '绿色偏强:降低G值,LED会减少绿色成分',
|
||||||
|
blueStrong: '蓝色偏强:降低B值,LED会减少蓝色成分',
|
||||||
|
whiteYellow: '白色发黄:适当提高B值,降低R/G值',
|
||||||
|
whiteBlue: '白色发蓝:适当降低B值,提高R/G值',
|
||||||
|
whiteComparison: '重点观察白色区域,确保LED白光与屏幕白色一致',
|
||||||
|
colorComparison: '检查彩色区域,确保LED颜色饱和度合适',
|
||||||
|
environmentTest: '在不同环境光下测试,确保效果稳定',
|
||||||
|
resetNote: '调节完成后可点击"重置"按钮恢复默认值',
|
||||||
|
fullscreenComparisonTip: '对比屏幕边缘颜色与LED灯条,调节RGB滑块使颜色一致',
|
||||||
|
draggable: '可拖拽',
|
||||||
|
exitFullscreen: '退出全屏',
|
||||||
|
notEnabled: '暂未启用',
|
||||||
|
// Missing white balance instructions
|
||||||
|
dragPanelTip: '将RGB控制面板拖拽到合适位置',
|
||||||
|
compareColorsTip: '对比LED灯条颜色与屏幕边缘颜色',
|
||||||
|
},
|
||||||
|
|
||||||
|
ledTest: {
|
||||||
|
title: 'LED灯带测试',
|
||||||
|
testEffects: '测试效果',
|
||||||
|
staticColor: '静态颜色',
|
||||||
|
rainbow: '彩虹',
|
||||||
|
breathing: '呼吸',
|
||||||
|
wave: '波浪',
|
||||||
|
chase: '追逐',
|
||||||
|
twinkle: '闪烁',
|
||||||
|
fire: '火焰',
|
||||||
|
speed: '速度',
|
||||||
|
brightness: '亮度',
|
||||||
|
color: '颜色',
|
||||||
|
startTest: '开始测试',
|
||||||
|
stopTest: '停止测试',
|
||||||
|
testRunning: '测试运行中',
|
||||||
|
testStopped: '测试已停止',
|
||||||
|
selectEffect: '选择效果',
|
||||||
|
effectSettings: '效果设置',
|
||||||
|
flowingRainbow: '流光效果',
|
||||||
|
flowingRainbowDesc: '彩虹色流光,用于测试灯带方向',
|
||||||
|
groupCounting: '十个一组计数',
|
||||||
|
groupCountingDesc: '每十个LED一组不同颜色,用于快速计算灯珠数量',
|
||||||
|
singleScan: '单色扫描',
|
||||||
|
singleScanDesc: '单个LED依次点亮,用于精确测试每个LED位置',
|
||||||
|
breathingDesc: '整条灯带呼吸效果,用于测试整体亮度',
|
||||||
|
// LED test form labels
|
||||||
|
ledCount: 'LED数量',
|
||||||
|
ledType: 'LED类型',
|
||||||
|
animationSpeed: '动画速度 (ms)',
|
||||||
|
startTestButton: '开始测试',
|
||||||
|
// Hardware selection
|
||||||
|
selectHardwareBoard: '选择硬件板',
|
||||||
|
devicesFound: '个设备',
|
||||||
|
searching: '搜索中...',
|
||||||
|
chooseBoard: '选择设备',
|
||||||
|
noBoardsFound: '未找到设备',
|
||||||
|
connected: '已连接',
|
||||||
|
connecting: '连接中',
|
||||||
|
disconnected: '已断开',
|
||||||
|
},
|
||||||
|
|
||||||
|
errors: {
|
||||||
|
failedToLoad: '加载失败',
|
||||||
|
failedToSave: '保存失败',
|
||||||
|
failedToConnect: '连接失败',
|
||||||
|
invalidConfiguration: '配置无效',
|
||||||
|
deviceNotFound: '设备未找到',
|
||||||
|
networkError: '网络错误',
|
||||||
|
unknownError: '未知错误',
|
||||||
|
},
|
||||||
|
};
|
242
src/i18n/types.ts
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
export type Language = 'zh-CN' | 'en-US';
|
||||||
|
|
||||||
|
export interface TranslationDict {
|
||||||
|
// Navigation
|
||||||
|
nav: {
|
||||||
|
title: string;
|
||||||
|
info: string;
|
||||||
|
displays: string;
|
||||||
|
ledConfiguration: string;
|
||||||
|
whiteBalance: string;
|
||||||
|
ledTest: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Common UI elements
|
||||||
|
common: {
|
||||||
|
version: string;
|
||||||
|
primary: string;
|
||||||
|
save: string;
|
||||||
|
cancel: string;
|
||||||
|
reset: string;
|
||||||
|
close: string;
|
||||||
|
fullscreen: string;
|
||||||
|
exitFullscreen: string;
|
||||||
|
loading: string;
|
||||||
|
error: string;
|
||||||
|
success: string;
|
||||||
|
warning: string;
|
||||||
|
confirm: string;
|
||||||
|
delete: string;
|
||||||
|
edit: string;
|
||||||
|
add: string;
|
||||||
|
remove: string;
|
||||||
|
enable: string;
|
||||||
|
disable: string;
|
||||||
|
start: string;
|
||||||
|
stop: string;
|
||||||
|
test: string;
|
||||||
|
apply: string;
|
||||||
|
refresh: string;
|
||||||
|
realtime: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Info page
|
||||||
|
info: {
|
||||||
|
title: string;
|
||||||
|
boardInfo: string;
|
||||||
|
systemInfo: string;
|
||||||
|
deviceName: string;
|
||||||
|
ipAddress: string;
|
||||||
|
macAddress: string;
|
||||||
|
firmwareVersion: string;
|
||||||
|
hardwareVersion: string;
|
||||||
|
uptime: string;
|
||||||
|
status: string;
|
||||||
|
connected: string;
|
||||||
|
disconnected: string;
|
||||||
|
lastSeen: string;
|
||||||
|
port: string;
|
||||||
|
latency: string;
|
||||||
|
hostname: string;
|
||||||
|
deviceCount: string;
|
||||||
|
noDevicesFound: string;
|
||||||
|
checkConnection: string;
|
||||||
|
// Device status
|
||||||
|
timeout: string;
|
||||||
|
connecting: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Display page
|
||||||
|
displays: {
|
||||||
|
title: string;
|
||||||
|
count: string;
|
||||||
|
noDisplays: string;
|
||||||
|
checkConnection: string;
|
||||||
|
displayInfo: string;
|
||||||
|
resolution: string;
|
||||||
|
refreshRate: string;
|
||||||
|
colorDepth: string;
|
||||||
|
isPrimary: string;
|
||||||
|
position: string;
|
||||||
|
size: string;
|
||||||
|
scaleFactor: string;
|
||||||
|
lastModified: string;
|
||||||
|
displayCount: string;
|
||||||
|
noDisplaysFound: string;
|
||||||
|
brightnessSettings: string;
|
||||||
|
currentBrightness: string;
|
||||||
|
maxBrightness: string;
|
||||||
|
minBrightness: string;
|
||||||
|
contrastSettings: string;
|
||||||
|
currentContrast: string;
|
||||||
|
maxContrast: string;
|
||||||
|
minContrast: string;
|
||||||
|
modeSettings: string;
|
||||||
|
currentMode: string;
|
||||||
|
maxMode: string;
|
||||||
|
minMode: string;
|
||||||
|
// Display info panel specific
|
||||||
|
id: string;
|
||||||
|
scale: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// LED Strip Configuration
|
||||||
|
ledConfig: {
|
||||||
|
title: string;
|
||||||
|
displaySelection: string;
|
||||||
|
ledStripConfig: string;
|
||||||
|
ledCount: string;
|
||||||
|
ledType: string;
|
||||||
|
position: string;
|
||||||
|
top: string;
|
||||||
|
bottom: string;
|
||||||
|
left: string;
|
||||||
|
right: string;
|
||||||
|
preview: string;
|
||||||
|
configuration: string;
|
||||||
|
sorter: string;
|
||||||
|
moveUp: string;
|
||||||
|
moveDown: string;
|
||||||
|
reverse: string;
|
||||||
|
rgb: string;
|
||||||
|
rgbw: string;
|
||||||
|
segments: string;
|
||||||
|
totalLeds: string;
|
||||||
|
saveConfig: string;
|
||||||
|
loadConfig: string;
|
||||||
|
stripSorting: string;
|
||||||
|
realtimePreview: string;
|
||||||
|
sortingTip: string;
|
||||||
|
displayConfiguration: string;
|
||||||
|
visualEditor: string;
|
||||||
|
displayTip: string;
|
||||||
|
ledCountControl: string;
|
||||||
|
realtimeAdjustment: string;
|
||||||
|
decreaseLedCount: string;
|
||||||
|
increaseLedCount: string;
|
||||||
|
display: string;
|
||||||
|
controlTip: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// White Balance
|
||||||
|
whiteBalance: {
|
||||||
|
title: string;
|
||||||
|
colorCalibration: string;
|
||||||
|
redChannel: string;
|
||||||
|
greenChannel: string;
|
||||||
|
blueChannel: string;
|
||||||
|
whiteChannel: string;
|
||||||
|
brightness: string;
|
||||||
|
temperature: string;
|
||||||
|
resetToDefault: string;
|
||||||
|
fullscreenMode: string;
|
||||||
|
normalMode: string;
|
||||||
|
instructions: string;
|
||||||
|
helpText: string;
|
||||||
|
compareColors: string;
|
||||||
|
adjustValues: string;
|
||||||
|
dragToMove: string;
|
||||||
|
back: string;
|
||||||
|
colorTest: string;
|
||||||
|
clickToTest: string;
|
||||||
|
colorTestTip: string;
|
||||||
|
rgbAdjustment: string;
|
||||||
|
realtimeAdjustment: string;
|
||||||
|
usageInstructions: string;
|
||||||
|
recommendedMethod: string;
|
||||||
|
adjustmentTips: string;
|
||||||
|
comparisonMethod: string;
|
||||||
|
fullscreenTip: string;
|
||||||
|
dragTip: string;
|
||||||
|
redStrong: string;
|
||||||
|
greenStrong: string;
|
||||||
|
blueStrong: string;
|
||||||
|
whiteYellow: string;
|
||||||
|
whiteBlue: string;
|
||||||
|
whiteComparison: string;
|
||||||
|
colorComparison: string;
|
||||||
|
environmentTest: string;
|
||||||
|
resetNote: string;
|
||||||
|
fullscreenComparisonTip: string;
|
||||||
|
draggable: string;
|
||||||
|
exitFullscreen: string;
|
||||||
|
notEnabled: string;
|
||||||
|
// Missing white balance instructions
|
||||||
|
dragPanelTip: string;
|
||||||
|
compareColorsTip: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// LED Test
|
||||||
|
ledTest: {
|
||||||
|
title: string;
|
||||||
|
testEffects: string;
|
||||||
|
staticColor: string;
|
||||||
|
rainbow: string;
|
||||||
|
breathing: string;
|
||||||
|
wave: string;
|
||||||
|
chase: string;
|
||||||
|
twinkle: string;
|
||||||
|
fire: string;
|
||||||
|
speed: string;
|
||||||
|
brightness: string;
|
||||||
|
color: string;
|
||||||
|
startTest: string;
|
||||||
|
stopTest: string;
|
||||||
|
testRunning: string;
|
||||||
|
testStopped: string;
|
||||||
|
selectEffect: string;
|
||||||
|
effectSettings: string;
|
||||||
|
flowingRainbow: string;
|
||||||
|
flowingRainbowDesc: string;
|
||||||
|
groupCounting: string;
|
||||||
|
groupCountingDesc: string;
|
||||||
|
singleScan: string;
|
||||||
|
singleScanDesc: string;
|
||||||
|
breathingDesc: string;
|
||||||
|
// LED test form labels
|
||||||
|
ledCount: string;
|
||||||
|
ledType: string;
|
||||||
|
animationSpeed: string;
|
||||||
|
startTestButton: string;
|
||||||
|
// Hardware selection
|
||||||
|
selectHardwareBoard: string;
|
||||||
|
devicesFound: string;
|
||||||
|
searching: string;
|
||||||
|
chooseBoard: string;
|
||||||
|
noBoardsFound: string;
|
||||||
|
connected: string;
|
||||||
|
connecting: string;
|
||||||
|
disconnected: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Error messages
|
||||||
|
errors: {
|
||||||
|
failedToLoad: string;
|
||||||
|
failedToSave: string;
|
||||||
|
failedToConnect: string;
|
||||||
|
invalidConfiguration: string;
|
||||||
|
deviceNotFound: string;
|
||||||
|
networkError: string;
|
||||||
|
unknownError: string;
|
||||||
|
};
|
||||||
|
}
|
@ -4,12 +4,15 @@ import { render } from "solid-js/web";
|
|||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import { Router } from '@solidjs/router';
|
import { Router } from '@solidjs/router';
|
||||||
|
import { LanguageProvider } from './i18n/index';
|
||||||
|
|
||||||
render(
|
render(
|
||||||
() => (
|
() => (
|
||||||
|
<LanguageProvider>
|
||||||
<Router>
|
<Router>
|
||||||
<App />
|
<App />
|
||||||
</Router>
|
</Router>
|
||||||
|
</LanguageProvider>
|
||||||
),
|
),
|
||||||
document.getElementById('root') as HTMLElement,
|
document.getElementById('root') as HTMLElement,
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import { Borders } from '../constants/border';
|
import { Borders } from '../constants/border';
|
||||||
|
|
||||||
|
export enum LedType {
|
||||||
|
WS2812B = 'WS2812B',
|
||||||
|
SK6812 = 'SK6812',
|
||||||
|
}
|
||||||
|
|
||||||
export type LedStripPixelMapper = {
|
export type LedStripPixelMapper = {
|
||||||
start: number;
|
start: number;
|
||||||
end: number;
|
end: number;
|
||||||
@ -10,6 +15,7 @@ export class ColorCalibration {
|
|||||||
r: number = 1;
|
r: number = 1;
|
||||||
g: number = 1;
|
g: number = 1;
|
||||||
b: number = 1;
|
b: number = 1;
|
||||||
|
w: number = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LedStripConfigContainer = {
|
export type LedStripConfigContainer = {
|
||||||
@ -23,5 +29,6 @@ export class LedStripConfig {
|
|||||||
public readonly display_id: number,
|
public readonly display_id: number,
|
||||||
public readonly border: Borders,
|
public readonly border: Borders,
|
||||||
public len: number,
|
public len: number,
|
||||||
|
public led_type: LedType = LedType.WS2812B,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,24 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
@config "../tailwind.config.js";
|
@config "../tailwind.config.js";
|
||||||
|
|
||||||
|
/* Custom responsive styles for small windows */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.container {
|
||||||
|
max-width: 100%;
|
||||||
|
padding-left: 0.5rem;
|
||||||
|
padding-right: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure LED control panels are responsive */
|
||||||
|
.led-control-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.led-control-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|