15 Commits

Author SHA1 Message Date
ca8d4a3d36 feat: upgrade to version 2.0.0-alpha with mainstream dependencies
- Update application version to 2.0.0-alpha
- Update application name to 'Ambient Light Control'
- Upgrade Node.js requirement to >=22.0.0 (current LTS)
- Upgrade pnpm requirement to >=10.0.0 (current stable)
- Update all GitHub Actions workflows to use Node.js 22 and pnpm 10
- Update README.md with current version requirements
- Add comprehensive project metadata to package.json
- Remove obsolete src-tauri/src-tauri directory structure
- Update Cargo.toml with proper project information
2025-07-09 20:05:38 +08:00
a49306517e style: optimize LED strip component styling with proper margins and padding 2025-07-09 16:59:07 +08:00
142332730f fix: update 0x02 protocol to use byte offset instead of LED position offset 2025-07-09 16:59:07 +08:00
5f5824721e docs: add MIT license and update README with license information 2025-07-09 16:59:07 +08:00
7e70fb9d8d fix: resolve input field clearing issue in LED strip test page 2025-07-09 16:59:07 +08:00
93de5dd39a fix: resolve dropdown menu gap issue 2025-07-09 16:59:07 +08:00
953cb24a3b fix: resolve i18n implementation issues 2025-07-09 16:59:07 +08:00
a8f2b93de0 refactor: complete LED type system simplification 2025-07-09 16:59:07 +08:00
2d502fcd6c refactor: simplify LED type system to support only WS2812B and SK6812 chips 2025-07-09 16:59:07 +08:00
2c6b777fa6 feat: implement comprehensive i18n internationalization support
- Add custom i18n infrastructure with TypeScript support
- Support Chinese (zh-CN) and English (en-US) languages
- Implement language switching with localStorage persistence
- Update all components with translation keys:
  * System info components (board-info-panel, board-index)
  * Display management components (display-state-index, display-state-card)
  * LED strip configuration components (led-strip-configuration, led-count-control-panel)
  * White balance component with detailed usage instructions
  * LED test component with test pattern descriptions
- Add comprehensive translation coverage for:
  * Navigation menus and page titles
  * Common UI elements (buttons, status, actions)
  * Hardware information and connection status
  * Display configuration options
  * LED strip settings and controls
  * White balance adjustment instructions and tips
  * LED test modes and descriptions
  * Error messages and status indicators
- Features:
  * Dynamic language switching without app restart
  * Type-safe translation keys with full TypeScript support
  * Modular design for easy language extension
  * Responsive UI updates using SolidJS reactivity
2025-07-08 16:55:12 +08:00
4a3d7681d6 Fix layout spacing issues in LED strip configuration
- Remove forced height expansion from display configuration panel
- Change layout from flex-based to space-based for natural content sizing
- Eliminate large empty spaces between configuration sections
- Improve overall UI compactness and visual flow
2025-07-08 03:19:06 +08:00
2834b7fe57 Optimize responsive layout for LED count control interface
- Improve grid layout responsiveness from md:grid-cols-2 to lg:grid-cols-2
- Add responsive LED control items with grid-cols-2 sm:grid-cols-4
- Reduce padding and spacing for better small window display
- Optimize button and input sizes with compact styling
- Add custom CSS for small screen handling (<640px and <600px)
- Implement auto-fit grid layout with minmax(280px, 1fr)
- Enhance main container with overflow-x-auto and responsive padding
- Reduce overall page spacing and card body padding for compact display
2025-07-08 03:02:24 +08:00
c57f52ea74 Improve white balance panel drag functionality
- Fix drag event handling to only trigger on title bar area
- Prevent color slider interactions from triggering panel drag
- Add event propagation control for better user experience
- Improve cursor styling for interactive elements
2025-07-08 02:46:44 +08:00
9f37b4043c Fix device selection reset issue in LED Strip Testing
- Fix frontend device selection state management to properly update selected board when boards_changed event is triggered
- Optimize backend board status checking to only emit boards_changed events when there are actual changes
- Prevent unnecessary UI updates and improve performance

Fixes issue where device selection would reset to unselected state shortly after selection
2025-07-08 02:46:24 +08:00
92349eebb6 Fix hamburger menu button click issue
- Add dropdown-hover class for better interaction
- Add onClick handler to ensure proper focus management
- Increase z-index from z-[1] to z-[100] to prevent overlay issues
- Remove conflicting tabindex from menu items
- Add border and hover effects for better visual feedback
2025-07-07 19:20:05 +08:00
58 changed files with 2134 additions and 449 deletions

View File

@@ -43,13 +43,13 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

View File

@@ -25,13 +25,13 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
@@ -85,12 +85,12 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
- name: Install frontend dependencies
run: pnpm install

View File

@@ -24,12 +24,12 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
@@ -86,12 +86,12 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

View File

@@ -110,13 +110,13 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

674
LICENSE Normal file
View 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>.

View File

@@ -56,12 +56,13 @@ A desktop application built with Tauri 2.0 for ambient light control, supporting
2. **Install Node.js and pnpm**
```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
nvm install node
nvm install 22
nvm use 22
# Install pnpm
npm install -g pnpm
# Install pnpm 10+
npm install -g pnpm@latest
```
3. **Install Tauri CLI**
@@ -170,7 +171,7 @@ desktop/
## 📄 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

View File

@@ -64,8 +64,8 @@ Byte 0: Header (0x01)
```text
Byte 0: Header (0x02)
Byte 1: Offset High (upper 8 bits of LED start position)
Byte 2: Offset Low (lower 8 bits of LED start position)
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)
```
@@ -85,6 +85,57 @@ Byte 3+: LED Color Data (variable length)
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:
@@ -175,24 +226,24 @@ Unknown → Connecting(1) → Connected
### RGB Example
3 RGB LEDs starting at position 0: Red, Green, Blue
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)
│ │ └─ Offset Low (0 bytes)
│ └─ Offset High (0)
└─ Header (0x02)
```
### RGBW Example
2 RGBW LEDs starting at position 10: White, Warm White
2 RGBW LEDs starting at byte offset 40 (LED position 10): White, Warm White
```text
02 00 0A FF FF FF FF FF C8 96 C8
02 00 28 FF FF FF FF FF C8 96 C8
│ │ │ └─────────────────────── 8 bytes color data
│ │ └─ Offset Low (10)
│ │ └─ Offset Low (40 bytes = 0x28)
│ └─ Offset High (0)
└─ Header (0x02)
```
@@ -201,10 +252,12 @@ Unknown → Connecting(1) → Connected
- **Byte Order**: Big-endian for multi-byte values (offset field)
- **Delivery**: Fire-and-forget UDP (no acknowledgment required)
- **Hardware Role**: Simple UDP-to-WS2812 bridge, no data processing
- **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 → WS2812 (direct forward)
- **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
@@ -251,12 +304,14 @@ void handle_ping(uint8_t* data, size_t len) {
void handle_led_data(uint8_t* data, size_t len) {
if (len < 3) return;
uint16_t offset = (data[1] << 8) | data[2];
uint16_t byte_offset = (data[1] << 8) | data[2];
uint8_t* color_data = &data[3];
size_t color_len = len - 3;
// Direct forward to WS2812 - no RGB/RGBW distinction needed
ws2812_update(offset, color_data, color_len);
// 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);
}
```
@@ -278,13 +333,47 @@ void send_volume_control(uint8_t volume_percent) {
}
```
### 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 WS2812, no processing required
- **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
@@ -311,14 +400,18 @@ void send_volume_control(uint8_t volume_percent) {
- Verify hardware processes 0x02 packets correctly
- Check WS2812 wiring and power supply
- Monitor packet reception on hardware side
- Verify offset calculations and LED strip configuration
- 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 WS2812 color order (GRB vs RGB)
- 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**:

View File

@@ -1,7 +1,26 @@
{
"name": "test-demo",
"version": "0.0.0",
"description": "",
"name": "display-ambient-light",
"version": "2.0.0-alpha",
"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": {
"start": "vite",
"dev": "vite",
@@ -11,6 +30,7 @@
},
"license": "MIT",
"dependencies": {
"@solid-primitives/i18n": "^2.2.1",
"@solidjs/router": "^0.8.4",
"@tauri-apps/api": "^2.6.0",
"debug": "^4.4.1",

12
pnpm-lock.yaml generated
View File

@@ -8,6 +8,9 @@ importers:
.:
dependencies:
'@solid-primitives/i18n':
specifier: ^2.2.1
version: 2.2.1(solid-js@1.9.7)
'@solidjs/router':
specifier: ^0.8.4
version: 0.8.4(solid-js@1.9.7)
@@ -424,6 +427,11 @@ packages:
cpu: [x64]
os: [win32]
'@solid-primitives/i18n@2.2.1':
resolution: {integrity: sha512-TnTnE2Ku11MGYZ1JzhJ8pYscwg1fr9MteoYxPwsfxWfh9Jp5K7RRJncJn9BhOHvNLwROjqOHZ46PT7sPHqbcXw==}
peerDependencies:
solid-js: ^1.6.12
'@solidjs/router@0.8.4':
resolution: {integrity: sha512-Gi/WVoVseGMKS1DBdT3pNAMgOzEOp6Q3dpgNd2mW9GUEnVocPmtyBjDvXwN6m7tjSGsqqfqJFXk7bm1hxabSRw==}
peerDependencies:
@@ -1282,6 +1290,10 @@ snapshots:
'@rollup/rollup-win32-x64-msvc@4.44.1':
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)':
dependencies:
solid-js: 1.9.7

78
src-tauri/Cargo.lock generated
View File

@@ -41,6 +41,45 @@ dependencies = [
"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]]
name = "android-tzdata"
version = "0.1.1"
@@ -4398,45 +4437,6 @@ dependencies = [
"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",
"tokio-util",
"toml 0.7.8",
"url-build-parse",
]
[[package]]
name = "thiserror"
version = "1.0.69"

View File

@@ -1,10 +1,10 @@
[package]
name = "test-demo"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
name = "ambient-light-control"
version = "2.0.0-alpha"
description = "A desktop application for controlling ambient lighting based on screen content"
authors = ["Ivan Li"]
license = "MIT"
repository = "https://github.com/ivan/display-ambient-light"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -1,3 +0,0 @@
# Generated by Cargo
# will have compiled files and executables
/target/

View File

@@ -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" ]

View File

@@ -1,3 +0,0 @@
fn main() {
tauri_build::build()
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -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");
}

View File

@@ -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
}
]
}
}

View File

@@ -18,13 +18,13 @@ pub enum Border {
#[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq)]
pub enum LedType {
RGB,
RGBW,
WS2812B,
SK6812,
}
impl Default for LedType {
fn default() -> Self {
LedType::RGB
LedType::WS2812B
}
}
@@ -151,7 +151,7 @@ impl LedStripConfigGroup {
},
start_pos: j + i * 4 * 30,
len: 30,
led_type: LedType::RGB,
led_type: LedType::WS2812B,
};
configs.push(item);
strips.push(item);

View File

@@ -322,12 +322,12 @@ impl LedColorsPublisher {
let led_type = if group_index < strips.len() {
strips[group_index].led_type
} else {
LedType::RGB // fallback to RGB
LedType::WS2812B // fallback to WS2812B
};
let bytes_per_led = match led_type {
LedType::RGB => 3,
LedType::RGBW => 4,
LedType::WS2812B => 3,
LedType::SK6812 => 4,
};
let mut buffer = Vec::<u8>::with_capacity(group_size * bytes_per_led);
@@ -348,7 +348,7 @@ impl LedColorsPublisher {
for i in start_index..end_index {
if i < colors.len() {
let bytes = match led_type {
LedType::RGB => {
LedType::WS2812B => {
let calibration_bytes = color_calibration.to_bytes();
let color_bytes = colors[i].as_bytes();
// Apply calibration to RGB values
@@ -358,7 +358,7 @@ impl LedColorsPublisher {
((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8),
]
}
LedType::RGBW => {
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
@@ -375,8 +375,8 @@ impl LedColorsPublisher {
log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len());
// Add black color as fallback
match led_type {
LedType::RGB => buffer.extend_from_slice(&[0, 0, 0]),
LedType::RGBW => buffer.extend_from_slice(&[0, 0, 0, 0]),
LedType::WS2812B => buffer.extend_from_slice(&[0, 0, 0]),
LedType::SK6812 => buffer.extend_from_slice(&[0, 0, 0, 0]),
}
}
}
@@ -396,7 +396,7 @@ impl LedColorsPublisher {
for i in (start_index..end_index).rev() {
if i < colors.len() {
let bytes = match led_type {
LedType::RGB => {
LedType::WS2812B => {
let calibration_bytes = color_calibration.to_bytes();
let color_bytes = colors[i].as_bytes();
// Apply calibration to RGB values
@@ -406,7 +406,7 @@ impl LedColorsPublisher {
((color_bytes[2] as f32 * calibration_bytes[2] as f32 / 255.0) as u8),
]
}
LedType::RGBW => {
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
@@ -423,17 +423,19 @@ impl LedColorsPublisher {
log::warn!("Index {} out of bounds for colors array of length {}", i, colors.len());
// Add black color as fallback
match led_type {
LedType::RGB => buffer.extend_from_slice(&[0, 0, 0]),
LedType::RGBW => buffer.extend_from_slice(&[0, 0, 0, 0]),
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];
tx_buffer.push((offset >> 8) as u8);
tx_buffer.push((offset & 0xff) as u8);
tx_buffer.push((byte_offset >> 8) as u8);
tx_buffer.push((byte_offset & 0xff) as u8);
tx_buffer.append(&mut buffer);
udp_rpc.send_to_all(&tx_buffer).await?;

View File

@@ -19,13 +19,17 @@ pub struct TestEffectConfig {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum LedType {
RGB,
RGBW,
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;
@@ -60,7 +64,7 @@ impl LedTestEffects {
buffer.push(rgb.1);
buffer.push(rgb.2);
if matches!(led_type, LedType::RGBW) {
if Self::is_rgbw_type(&led_type) {
buffer.push(0); // White channel
}
}
@@ -93,7 +97,7 @@ impl LedTestEffects {
buffer.push(color.1);
buffer.push(color.2);
if matches!(led_type, LedType::RGBW) {
if Self::is_rgbw_type(&led_type) {
buffer.push(0); // White channel
}
}
@@ -114,7 +118,7 @@ impl LedTestEffects {
buffer.push(255);
buffer.push(255);
if matches!(led_type, LedType::RGBW) {
if Self::is_rgbw_type(&led_type) {
buffer.push(255); // White channel
}
} else {
@@ -123,7 +127,7 @@ impl LedTestEffects {
buffer.push(0);
buffer.push(0);
if matches!(led_type, LedType::RGBW) {
if Self::is_rgbw_type(&led_type) {
buffer.push(0); // White channel
}
}
@@ -144,7 +148,7 @@ impl LedTestEffects {
buffer.push(brightness);
buffer.push(brightness);
if matches!(led_type, LedType::RGBW) {
if Self::is_rgbw_type(&led_type) {
buffer.push(brightness); // White channel
}
}

View File

@@ -182,8 +182,8 @@ async fn send_test_colors_to_board(board_address: String, offset: u16, buffer: V
})?;
let mut packet = vec![0x02]; // Header
packet.push((offset >> 8) as u8); // Offset high
packet.push((offset & 0xff) as u8); // Offset low
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| {
@@ -324,8 +324,8 @@ async fn stop_led_test_effect(board_address: String, led_count: u32, led_type: l
// Turn off all LEDs
let bytes_per_led = match led_type {
led_test_effects::LedType::RGB => 3,
led_test_effects::LedType::RGBW => 4,
led_test_effects::LedType::WS2812B => 3,
led_test_effects::LedType::SK6812 => 4,
};
let buffer = vec![0u8; (led_count * bytes_per_led) as usize];
@@ -351,8 +351,8 @@ async fn send_test_colors_to_board_internal(board_address: &str, offset: u16, bu
let socket = UdpSocket::bind("0.0.0.0:0").await?;
let mut packet = vec![0x02]; // Header
packet.push((offset >> 8) as u8); // Offset high
packet.push((offset & 0xff) as u8); // Offset low
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?;

View File

@@ -194,25 +194,42 @@ impl UdpRpc {
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() {
if let Err(err) = board.check().await {
error!("failed to check board: {:?}", err);
}
}
let tx_boards = boards
// Get current board states after check
let current_boards = boards
.values()
.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);
// 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();
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);
}
drop(board_change_sender);
}
}
}
}

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2.0.0",
"productName": "test-demo",
"version": "0.0.1",
"productName": "Ambient Light Control",
"version": "2.0.0-alpha",
"identifier": "cc.ivanli.ambient-light.desktop",
"build": {
"beforeDevCommand": "pnpm dev",
@@ -23,7 +23,7 @@
{
"fullscreen": false,
"resizable": true,
"title": "test-demo",
"title": "Ambient Light Control",
"width": 800,
"height": 600
}

View File

@@ -8,10 +8,12 @@ import { setLedStripStore } from './stores/led-strip.store';
import { LedStripConfigContainer } from './models/led-strip-config';
import { InfoIndex } from './components/info/info-index';
import { DisplayStateIndex } from './components/displays/display-state-index';
import { useLanguage } from './i18n/index';
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(() => {
@@ -46,42 +48,65 @@ function App() {
});
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">
{/* Fixed Navigation */}
<div class="navbar bg-base-200 shadow-lg fixed top-0 left-0 right-0 z-50">
<div class="navbar bg-base-200 shadow-lg flex-shrink-0 z-50">
<div class="navbar-start">
<div class="dropdown">
<div class="dropdown dropdown-hover">
<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">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16"></path>
</svg>
</div>
<ul tabindex="0" class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52">
<li><A href="/info" class="text-base-content"></A></li>
<li><A href="/displays" class="text-base-content"></A></li>
<li><A href="/led-strips-configuration" class="text-base-content"></A></li>
<li><A href="/white-balance" class="text-base-content"></A></li>
<li><A href="/led-strip-test" class="text-base-content"></A></li>
<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 hover:bg-base-200">{t('nav.info')}</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 hover:bg-base-200">{t('nav.ledConfiguration')}</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>
</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 class="navbar-center hidden lg:flex">
<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="/displays" 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"></A></li>
<li><A href="/white-balance" class="btn btn-ghost text-base-content hover:text-primary"></A></li>
<li><A href="/led-strip-test" 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">{t('nav.displays')}</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">{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>
</div>
<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>
{/* Main Content with top padding to account for fixed navbar */}
<main class="container mx-auto p-4 pt-20">
{/* Main Content - fills remaining height */}
<main class="flex-1 container mx-auto px-2 sm:px-4 py-4 max-w-full overflow-x-auto min-h-0">
<Routes>
<Route path="/info" component={InfoIndex} />
<Route path="/displays" component={DisplayStateIndex} />

View File

@@ -1,5 +1,6 @@
import { Component, ParentComponent } from 'solid-js';
import { DisplayState } from '../../models/display-state.model';
import { useLanguage } from '../../i18n/index';
type DisplayStateCardProps = {
state: DisplayState;
@@ -19,48 +20,49 @@ const Item: ParentComponent<ItemProps> = (props) => {
};
export const DisplayStateCard: Component<DisplayStateCardProps> = (props) => {
const { t } = useLanguage();
return (
<div class="card bg-base-200 shadow-lg hover:shadow-xl transition-shadow duration-200">
<div class="card-body p-4">
<div class="card-title text-base mb-3 flex items-center justify-between">
<span></span>
<div class="badge badge-primary badge-outline"></div>
<span>{t('displays.title')}</span>
<div class="badge badge-primary badge-outline">{t('common.realtime')}</div>
</div>
<div class="grid grid-cols-1 gap-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">
<Item label="当前亮度">{props.state.brightness}</Item>
<Item label="最大亮度">{props.state.max_brightness}</Item>
<Item label="最小亮度">{props.state.min_brightness}</Item>
<Item label={t('displays.currentBrightness')}>{props.state.brightness}</Item>
<Item label={t('displays.maxBrightness')}>{props.state.max_brightness}</Item>
<Item label={t('displays.minBrightness')}>{props.state.min_brightness}</Item>
</div>
</div>
{/* 对比度信息 */}
<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">
<Item label="当前对比度">{props.state.contrast}</Item>
<Item label="最大对比度">{props.state.max_contrast}</Item>
<Item label="最小对比度">{props.state.min_contrast}</Item>
<Item label={t('displays.currentContrast')}>{props.state.contrast}</Item>
<Item label={t('displays.maxContrast')}>{props.state.max_contrast}</Item>
<Item label={t('displays.minContrast')}>{props.state.min_contrast}</Item>
</div>
</div>
{/* 模式信息 */}
<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">
<Item label="当前模式">{props.state.mode}</Item>
<Item label="最大模式">{props.state.max_mode}</Item>
<Item label="最小模式">{props.state.min_mode}</Item>
<Item label={t('displays.currentMode')}>{props.state.mode}</Item>
<Item label={t('displays.maxMode')}>{props.state.max_mode}</Item>
<Item label={t('displays.minMode')}>{props.state.min_mode}</Item>
</div>
</div>
{/* 更新时间 */}
<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>

View File

@@ -4,11 +4,13 @@ import debug from 'debug';
import { invoke } from '@tauri-apps/api/core';
import { DisplayState, RawDisplayState } from '../../models/display-state.model';
import { DisplayStateCard } from './display-state-card';
import { useLanguage } from '../../i18n/index';
const logger = debug('app:components:displays:display-state-index');
export const DisplayStateIndex: Component = () => {
const [states, setStates] = createSignal<DisplayState[]>([]);
const { t } = useLanguage();
createEffect(() => {
const unlisten = listen<RawDisplayState[]>('displays_changed', (ev) => {
@@ -38,10 +40,10 @@ export const DisplayStateIndex: Component = () => {
return (
<div class="space-y-6">
<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="stat">
<div class="stat-title"></div>
<div class="stat-title">{t('displays.displayCount')}</div>
<div class="stat-value text-primary">{states().length}</div>
</div>
</div>
@@ -63,8 +65,8 @@ export const DisplayStateIndex: Component = () => {
{states().length === 0 && (
<div class="text-center py-12">
<div class="text-6xl mb-4">🖥</div>
<h3 class="text-lg font-semibold text-base-content mb-2"></h3>
<p class="text-base-content/70"></p>
<h3 class="text-lg font-semibold text-base-content mb-2">{t('displays.noDisplaysFound')}</h3>
<p class="text-base-content/70">{t('displays.checkConnection')}</p>
</div>
)}
</div>

View File

@@ -4,11 +4,13 @@ import { listen } from '@tauri-apps/api/event';
import debug from 'debug';
import { invoke } from '@tauri-apps/api/core';
import { BoardInfoPanel } from './board-info-panel';
import { useLanguage } from '../../i18n/index';
const logger = debug('app:components:info:board-index');
export const BoardIndex: Component = () => {
const [boards, setBoards] = createSignal<BoardInfo[]>([]);
const { t } = useLanguage();
createEffect(() => {
const unlisten = listen<BoardInfo[]>('boards_changed', (ev) => {
@@ -28,10 +30,10 @@ export const BoardIndex: Component = () => {
return (
<div class="space-y-6">
<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="stat">
<div class="stat-title"></div>
<div class="stat-title">{t('info.deviceCount')}</div>
<div class="stat-value text-primary">{boards().length}</div>
</div>
</div>
@@ -53,8 +55,8 @@ export const BoardIndex: Component = () => {
{boards().length === 0 && (
<div class="text-center py-12">
<div class="text-6xl mb-4">🔍</div>
<h3 class="text-lg font-semibold text-base-content mb-2"></h3>
<p class="text-base-content/70"></p>
<h3 class="text-lg font-semibold text-base-content mb-2">{t('info.noDevicesFound')}</h3>
<p class="text-base-content/70">{t('info.checkConnection')}</p>
</div>
)}
</div>

View File

@@ -1,5 +1,6 @@
import { Component, ParentComponent, createMemo } from 'solid-js';
import { BoardInfo } from '../../models/board-info.model';
import { useLanguage } from '../../i18n/index';
type ItemProps = {
label: string;
@@ -15,13 +16,14 @@ const Item: ParentComponent<ItemProps> = (props) => {
};
export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
const { t } = useLanguage();
const ttl = createMemo(() => {
if (props.board.connect_status !== 'Connected') {
return '--';
}
if (props.board.ttl == null) {
return 'timeout';
return t('info.timeout');
}
return (
@@ -37,7 +39,7 @@ export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => {
}
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>
<div class="space-y-2">
<Item label="主机名">{props.board.host}</Item>
<Item label="IP地址">{props.board.address}</Item>
<Item label="端口">{props.board.port}</Item>
<Item label="延迟">{ttl()}</Item>
<Item label={t('info.hostname')}>{props.board.host}</Item>
<Item label={t('info.ipAddress')}>{props.board.address}</Item>
<Item label={t('info.port')}>{props.board.port}</Item>
<Item label={t('info.latency')}>{ttl()}</Item>
</div>
</div>
</div>

View File

@@ -1,5 +1,6 @@
import { Component, JSX, ParentComponent, splitProps } from 'solid-js';
import { DisplayInfo } from '../../models/display-info.model';
import { useLanguage } from '../../i18n/index';
type DisplayInfoItemProps = {
label: string;
@@ -20,26 +21,28 @@ type DisplayInfoPanelProps = {
export const DisplayInfoPanel: Component<DisplayInfoPanelProps> = (props) => {
const [localProps, rootProps] = splitProps(props, ['display']);
const { t } = useLanguage();
return (
<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-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 && (
<div class="badge badge-primary badge-sm"></div>
<div class="badge badge-primary badge-sm">{t('displays.isPrimary')}</div>
)}
</div>
<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>
</DisplayInfoItem>
<DisplayInfoItem label="位置">
<DisplayInfoItem label={t('displays.position')}>
({localProps.display.x}, {localProps.display.y})
</DisplayInfoItem>
<DisplayInfoItem label="尺寸">
<DisplayInfoItem label={t('displays.size')}>
{localProps.display.width} × {localProps.display.height}
</DisplayInfoItem>
<DisplayInfoItem label="缩放">
<DisplayInfoItem label={t('displays.scale')}>
{localProps.display.scale_factor}×
</DisplayInfoItem>
</div>

View File

@@ -75,7 +75,7 @@ export const DisplayListContainer: ParentComponent = (props) => {
createEffect(() => {});
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()}>
{props.children}
</ol>

View File

@@ -5,6 +5,7 @@ import { ledStripStore } from '../../stores/led-strip.store';
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 = {
displayId: number;
@@ -14,6 +15,7 @@ type LedCountControlItemProps = {
const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
const [stripConfiguration, { setHoveredStripPart }] = useContext(LedStripConfigurationContext);
const { t } = useLanguage();
const config = createMemo(() => {
return ledStripStore.strips.find(
@@ -95,7 +97,7 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
return (
<div
class="card bg-base-100 border border-base-300/50 p-2 transition-all duration-200 cursor-pointer"
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 &&
@@ -111,19 +113,19 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
</span>
</div>
<div class="flex items-center gap-1">
<div class="flex items-center gap-0.5">
<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}
disabled={!config() || (config()?.len || 0) <= 0}
title="减少LED数量"
title={t('ledConfig.decreaseLedCount')}
>
-
</button>
<input
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}
min="0"
max="1000"
@@ -136,10 +138,10 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
/>
<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}
disabled={!config() || (config()?.len || 0) >= 1000}
title="增加LED数量"
title={t('ledConfig.increaseLedCount')}
>
+
</button>
@@ -147,13 +149,13 @@ const LedCountControlItem: Component<LedCountControlItemProps> = (props) => {
<div class="mt-1">
<select
class="select select-xs w-full text-xs"
value={config()?.led_type || LedType.RGB}
class="select select-xs w-full text-xs h-6 min-h-0"
value={config()?.led_type || LedType.WS2812B}
onChange={handleLedTypeChange}
title="LED类型"
title={t('ledConfig.ledType')}
>
<option value={LedType.RGB}>RGB</option>
<option value={LedType.RGBW}>RGBW</option>
<option value={LedType.WS2812B}>WS2812B</option>
<option value={LedType.SK6812}>SK6812</option>
</select>
</div>
</div>
@@ -167,23 +169,24 @@ type LedCountControlPanelProps = {
export const LedCountControlPanel: Component<LedCountControlPanelProps> = (props) => {
const [localProps, rootProps] = splitProps(props, ['display']);
const { t } = useLanguage();
const borders: { border: Borders; label: string }[] = [
{ border: 'Top', label: '上' },
{ border: 'Bottom', label: '下' },
{ border: 'Left', label: '左' },
{ border: 'Right', label: '右' },
{ border: 'Top', label: t('ledConfig.top') },
{ border: 'Bottom', label: t('ledConfig.bottom') },
{ border: 'Left', label: t('ledConfig.left') },
{ border: 'Right', label: t('ledConfig.right') },
];
return (
<div {...rootProps} class={'card bg-base-200 shadow-lg border border-base-300 ' + (rootProps.class || '')}>
<div class="card-body p-4">
<div class="card-title text-base mb-3 flex items-center justify-between">
<span>LED数量控制</span>
<div class="badge badge-info badge-outline"> {localProps.display.id}</div>
<div class="card-body p-3">
<div class="card-title text-sm mb-2 flex items-center justify-between">
<span>{t('ledConfig.ledCountControl')}</span>
<div class="badge badge-info badge-outline text-xs">{t('ledConfig.display')} {localProps.display.id}</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}>
{(item) => (
<LedCountControlItem
@@ -195,8 +198,8 @@ export const LedCountControlPanel: Component<LedCountControlPanelProps> = (props
</For>
</div>
<div class="text-xs text-base-content/50 mt-3 p-2 bg-base-300/50 rounded">
💡 +/- LED0-1000
<div class="text-xs text-base-content/50 mt-2 p-1.5 bg-base-300/50 rounded">
💡 {t('ledConfig.controlTip')}
</div>
</div>
</div>

View File

@@ -13,9 +13,11 @@ import {
LedStripConfigurationContext,
LedStripConfigurationContextType,
} from '../../contexts/led-strip-configuration.context';
import { useLanguage } from '../../i18n/index';
export const LedStripConfiguration = () => {
const { t } = useLanguage();
createEffect(() => {
invoke<string>('list_display_info').then((displays) => {
const parsedDisplays = JSON.parse(displays);
@@ -104,40 +106,41 @@ export const LedStripConfiguration = () => {
];
return (
<div class="space-y-6">
<div class="space-y-4">
<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="stat">
<div class="stat-title"></div>
<div class="stat-value text-primary">{displayStore.displays.length}</div>
<div class="stat py-2 px-4">
<div class="stat-title text-xs">{t('displays.displayCount')}</div>
<div class="stat-value text-primary text-lg">{displayStore.displays.length}</div>
</div>
</div>
</div>
<LedStripConfigurationContext.Provider value={ledStripConfigurationContextValue}>
<div class="space-y-4">
{/* LED Strip Sorter Panel */}
<div class="card bg-base-200 shadow-lg">
<div class="card-body p-4">
<div class="card-title text-base mb-3">
<span></span>
<div class="badge badge-info badge-outline"></div>
<div class="card-body p-3">
<div class="card-title text-sm mb-2">
<span>{t('ledConfig.stripSorting')}</span>
<div class="badge badge-info badge-outline text-xs">{t('ledConfig.realtimePreview')}</div>
</div>
<LedStripPartsSorter />
<div class="text-xs text-base-content/50 mt-2">
💡
💡 {t('ledConfig.sortingTip')}
</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-body p-4">
<div class="card-title text-base mb-3">
<span></span>
<div class="badge badge-secondary badge-outline"></div>
<div class="card-body p-3">
<div class="card-title text-sm mb-2">
<span>{t('ledConfig.displayConfiguration')}</span>
<div class="badge badge-secondary badge-outline text-xs">{t('ledConfig.visualEditor')}</div>
</div>
<div class="h-96 mb-4">
<div class="mb-3">
<DisplayListContainer>
{displayStore.displays.map((display) => (
<DisplayView display={display} />
@@ -145,23 +148,24 @@ export const LedStripConfiguration = () => {
</DisplayListContainer>
</div>
<div class="text-xs text-base-content/50">
💡 使LED数量
💡 {t('ledConfig.displayTip')}
</div>
</div>
</div>
{/* LED Count Control Panels */}
<div class="space-y-4">
<div class="flex items-center gap-2 mb-3">
<h2 class="text-lg font-semibold text-base-content">LED数量控制</h2>
<div class="badge badge-info badge-outline"></div>
<div class="flex-shrink-0">
<div class="flex items-center gap-2 mb-2">
<h2 class="text-base font-semibold text-base-content">{t('ledConfig.ledCountControl')}</h2>
<div class="badge badge-info badge-outline text-xs">{t('ledConfig.realtimeAdjustment')}</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="led-control-grid">
{displayStore.displays.map((display) => (
<LedCountControlPanel display={display} />
))}
</div>
</div>
</div>
</LedStripConfigurationContext.Provider>
</div>
);

View File

@@ -43,7 +43,7 @@ export const Pixel: Component<PixelProps> = (props) => {
export const LedStripPart: Component<LedStripPartProps> = (props) => {
const [localProps, rootProps] = splitProps(props, ['config']);
const [stripConfiguration] = useContext(LedStripConfigurationContext);
const [stripConfiguration, { setHoveredStripPart }] = useContext(LedStripConfigurationContext);
const [colors, setColors] = createSignal<string[]>([]);
@@ -116,12 +116,25 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
}
};
const onMouseEnter = () => {
if (localProps.config) {
setHoveredStripPart({
displayId: localProps.config.display_id,
border: localProps.config.border,
});
}
};
const onMouseLeave = () => {
setHoveredStripPart(null);
};
return (
<section
{...rootProps}
ref={setAnchor}
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
}
classList={{
@@ -129,8 +142,13 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
stripConfiguration.selectedStripPart?.border === localProps.config?.border &&
stripConfiguration.selectedStripPart?.displayId ===
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>
</section>

View File

@@ -1,6 +1,7 @@
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;
@@ -24,14 +25,78 @@ interface TestEffectConfig {
}
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<'RGB' | 'RGBW'>('RGB');
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
@@ -58,7 +123,10 @@ export const LedStripTest = () => {
board.port === currentBoard.port
);
if (!stillExists) {
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);
}
@@ -97,23 +165,23 @@ export const LedStripTest = () => {
// Test patterns
const testPatterns: TestPattern[] = [
{
name: '流光效果',
description: '彩虹色流光,用于测试灯带方向',
name: t('ledTest.flowingRainbow'),
description: t('ledTest.flowingRainbowDesc'),
effect_type: 'FlowingRainbow'
},
{
name: '十个一组计数',
description: '每十个LED一组不同颜色用于快速计算灯珠数量',
name: t('ledTest.groupCounting'),
description: t('ledTest.groupCountingDesc'),
effect_type: 'GroupCounting'
},
{
name: '单色扫描',
description: '单个LED依次点亮用于精确测试每个LED位置',
name: t('ledTest.singleScan'),
description: t('ledTest.singleScanDesc'),
effect_type: 'SingleScan'
},
{
name: '呼吸灯',
description: '整条灯带呼吸效果,用于测试整体亮度',
name: t('ledTest.breathing'),
description: t('ledTest.breathingDesc'),
effect_type: 'Breathing'
}
];
@@ -186,14 +254,14 @@ export const LedStripTest = () => {
<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">LED Strip Testing</h2>
<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">Select Hardware Board</span>
<span class="label-text">{t('ledTest.selectHardwareBoard')}</span>
<span class="label-text-alt">
{boards().length > 0 ? `${boards().length} device(s) found` : 'Searching...'}
{boards().length > 0 ? `${boards().length} ${t('ledTest.devicesFound')}` : t('ledTest.searching')}
</span>
</label>
<select
@@ -205,7 +273,7 @@ export const LedStripTest = () => {
}}
>
<option disabled value="">
{boards().length > 0 ? 'Choose a board' : 'No boards found'}
{boards().length > 0 ? t('ledTest.chooseBoard') : t('ledTest.noBoardsFound')}
</option>
<For each={boards()}>
{(board) => {
@@ -216,9 +284,9 @@ export const LedStripTest = () => {
};
const getStatusText = (status: BoardInfo['connect_status']) => {
if (status === 'Connected') return 'Connected';
if (typeof status === 'object' && 'Connecting' in status) return 'Connecting';
return 'Disconnected';
if (status === 'Connected') return t('ledTest.connected');
if (typeof status === 'object' && 'Connecting' in status) return t('ledTest.connecting');
return t('ledTest.disconnected');
};
return (
@@ -235,44 +303,48 @@ export const LedStripTest = () => {
<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">LED Count</span>
<span class="label-text">{t('ledTest.ledCount')}</span>
</label>
<input
type="number"
class="input input-bordered w-full text-center text-lg"
value={ledCount()}
value={ledCountInput()}
min="1"
max="1000"
onInput={(e) => setLedCount(parseInt(e.target.value) || 60)}
onInput={handleLedCountInput}
onBlur={handleLedCountBlur}
onKeyDown={handleLedCountKeyDown}
/>
</div>
<div class="form-control">
<label class="label">
<span class="label-text">LED Type</span>
<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 'RGB' | 'RGBW')}
onChange={(e) => setLedType(e.target.value as 'WS2812B' | 'SK6812')}
>
<option value="RGB">RGB</option>
<option value="RGBW">RGBW</option>
<option value="WS2812B">WS2812B</option>
<option value="SK6812">SK6812</option>
</select>
</div>
<div class="form-control">
<label class="label">
<span class="label-text">Animation Speed (ms)</span>
<span class="label-text">{t('ledTest.animationSpeed')}</span>
</label>
<input
type="number"
class="input input-bordered w-full text-center"
value={animationSpeed()}
value={animationSpeedInput()}
min="16"
max="200"
step="1"
onInput={(e) => setAnimationSpeed(parseInt(e.target.value) || 33)}
onInput={handleAnimationSpeedInput}
onBlur={handleAnimationSpeedBlur}
onKeyDown={handleAnimationSpeedKeyDown}
/>
</div>
</div>
@@ -301,7 +373,7 @@ export const LedStripTest = () => {
onClick={() => startTest(pattern)}
disabled={!selectedBoard()}
>
Start Test
{t('ledTest.startTestButton')}
</button>
}
>
@@ -309,7 +381,7 @@ export const LedStripTest = () => {
class="btn btn-error"
onClick={() => stopTest()}
>
Stop Test
{t('ledTest.stopTest')}
</button>
</Show>
</div>

View File

@@ -5,6 +5,16 @@ type Props = {
} & JSX.HTMLAttributes<HTMLInputElement>;
export const ColorSlider: Component<Props> = (props) => {
const handleMouseDown = (e: MouseEvent) => {
// 阻止事件冒泡到父元素,避免触发面板拖拽
e.stopPropagation();
};
const handleMouseMove = (e: MouseEvent) => {
// 阻止事件冒泡到父元素
e.stopPropagation();
};
return (
<input
type="range"
@@ -17,6 +27,8 @@ export const ColorSlider: Component<Props> = (props) => {
'range range-primary w-full bg-gradient-to-r ' +
props.class
}
onMouseDown={handleMouseDown}
onMouseMove={handleMouseMove}
/>
);
};

View File

@@ -10,6 +10,7 @@ import { BiRegularReset } from 'solid-icons/bi';
import { BsFullscreen, BsFullscreenExit } from 'solid-icons/bs';
import { getCurrentWindow } from '@tauri-apps/api/window';
import transparentBg from '../../assets/transparent-grid-background.svg?url';
import { useLanguage } from '../../i18n/index';
const Value: Component<{ value: number }> = (props) => {
return (
@@ -20,6 +21,7 @@ const Value: Component<{ value: number }> = (props) => {
};
export const WhiteBalance = () => {
const { t } = useLanguage();
const [isFullscreen, setIsFullscreen] = createSignal(false);
const [panelPosition, setPanelPosition] = createSignal({ x: 0, y: 0 });
const [isDragging, setIsDragging] = createSignal(false);
@@ -56,13 +58,17 @@ export const WhiteBalance = () => {
// 拖拽处理函数
const handleMouseDown = (e: MouseEvent) => {
// 确保只有在标题栏区域点击时才触发拖拽
setIsDragging(true);
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
const panelRect = (e.currentTarget as HTMLElement).closest('.fixed')?.getBoundingClientRect();
if (panelRect) {
setDragOffset({
x: e.clientX - rect.left,
y: e.clientY - rect.top
x: e.clientX - panelRect.left,
y: e.clientY - panelRect.top
});
}
e.preventDefault();
e.stopPropagation();
};
const handleMouseMove = (e: MouseEvent) => {
@@ -166,19 +172,19 @@ export const WhiteBalance = () => {
{!isFullscreen() && (
<div class="space-y-6">
<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">
<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} />
{t('common.fullscreen')}
</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} />
{t('common.reset')}
</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} />
{t('whiteBalance.back')}
</button>
</div>
</div>
@@ -188,8 +194,8 @@ export const WhiteBalance = () => {
<div class="card bg-base-200 shadow-lg">
<div class="card-body p-4">
<div class="card-title text-base mb-3">
<span></span>
<div class="badge badge-info badge-outline"></div>
<span>{t('whiteBalance.colorTest')}</span>
<div class="badge badge-info badge-outline">{t('whiteBalance.clickToTest')}</div>
</div>
<div
class="aspect-square rounded-lg overflow-hidden border border-base-300"
@@ -200,7 +206,7 @@ export const WhiteBalance = () => {
<TestColorsBg />
</div>
<div class="text-xs text-base-content/50 mt-2">
💡
💡 {t('whiteBalance.colorTestTip')}
</div>
</div>
</div>
@@ -209,14 +215,14 @@ export const WhiteBalance = () => {
<div class="card bg-base-200 shadow-lg">
<div class="card-body p-4">
<div class="card-title text-base mb-3">
<span>RGB调节</span>
<div class="badge badge-secondary badge-outline"></div>
<span>{t('whiteBalance.rgbAdjustment')}</span>
<div class="badge badge-secondary badge-outline">{t('whiteBalance.realtimeAdjustment')}</div>
</div>
<div class="space-y-4">
<div class="form-control">
<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} />
</label>
<ColorSlider
@@ -233,7 +239,7 @@ export const WhiteBalance = () => {
<div class="form-control">
<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} />
</label>
<ColorSlider
@@ -250,7 +256,7 @@ export const WhiteBalance = () => {
<div class="form-control">
<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} />
</label>
<ColorSlider
@@ -267,7 +273,7 @@ export const WhiteBalance = () => {
<div class="form-control">
<label class="label">
<span class="label-text font-semibold text-amber-500"> (W)</span>
<span class="label-text font-semibold text-amber-500">{t('whiteBalance.whiteChannel')}</span>
<Value value={ledStripStore.colorCalibration.w} />
</label>
<ColorSlider
@@ -287,37 +293,37 @@ export const WhiteBalance = () => {
<div class="collapse collapse-arrow bg-base-100 mt-4">
<input type="checkbox" />
<div class="collapse-title text-sm font-medium text-base-content/80">
💡 使
💡 {t('whiteBalance.usageInstructions')}
</div>
<div class="collapse-content text-xs text-base-content/70 space-y-3">
<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">
<li>"全屏"</li>
<li></li>
<li>RGB控制面板拖拽到合适位置</li>
<li>LED灯条颜色与屏幕边缘颜色</li>
<li>{t('whiteBalance.fullscreenTip')}</li>
<li>{t('whiteBalance.dragTip')}</li>
<li>{t('whiteBalance.dragPanelTip')}</li>
<li>{t('whiteBalance.compareColorsTip')}</li>
</ol>
</div>
<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">
<li><span class="text-red-500 font-medium"></span>R值LED会减少红色成分</li>
<li><span class="text-green-500 font-medium">绿</span>G值LED会减少绿色成分</li>
<li><span class="text-blue-500 font-medium"></span>B值LED会减少蓝色成分</li>
<li><span class="text-base-content font-medium"></span>B值R/G值</li>
<li><span class="text-base-content font-medium"></span>B值R/G值</li>
<li>{t('whiteBalance.redStrong')}</li>
<li>{t('whiteBalance.greenStrong')}</li>
<li>{t('whiteBalance.blueStrong')}</li>
<li>{t('whiteBalance.whiteYellow')}</li>
<li>{t('whiteBalance.whiteBlue')}</li>
</ul>
</div>
<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">
<li>LED白光与屏幕白色一致</li>
<li>LED颜色饱和度合适</li>
<li></li>
<li>"重置"</li>
<li>{t('whiteBalance.whiteComparison')}</li>
<li>{t('whiteBalance.colorComparison')}</li>
<li>{t('whiteBalance.environmentTest')}</li>
<li>{t('whiteBalance.resetNote')}</li>
</ul>
</div>
</div>
@@ -338,22 +344,24 @@ export const WhiteBalance = () => {
{/* 可拖拽的RGB控制面板 */}
<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={{
left: `${panelPosition().x}px`,
top: `${panelPosition().y}px`,
transform: 'none'
}}
onMouseDown={handleMouseDown}
>
<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">
<span class="text-xs opacity-60"></span>
<span>RGB调节</span>
<div class="badge badge-secondary badge-outline"></div>
<span>{t('whiteBalance.rgbAdjustment')}</span>
<div class="badge badge-secondary badge-outline">{t('whiteBalance.draggable')}</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} />
</button>
</div>
@@ -361,7 +369,7 @@ export const WhiteBalance = () => {
<div class="space-y-4">
<div class="form-control">
<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} />
</label>
<ColorSlider
@@ -378,7 +386,7 @@ export const WhiteBalance = () => {
<div class="form-control">
<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} />
</label>
<ColorSlider
@@ -395,7 +403,7 @@ export const WhiteBalance = () => {
<div class="form-control">
<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} />
</label>
<ColorSlider
@@ -412,7 +420,7 @@ export const WhiteBalance = () => {
<div class="form-control">
<label class="label">
<span class="label-text font-semibold text-amber-500"> (W)</span>
<span class="label-text font-semibold text-amber-500">{t('whiteBalance.whiteChannel')}</span>
<Value value={ledStripStore.colorCalibration.w} />
</label>
<ColorSlider
@@ -429,25 +437,25 @@ export const WhiteBalance = () => {
<div class="form-control">
<label class="label">
<span class="label-text font-semibold text-base-content/70"> (W)</span>
<div class="badge badge-outline badge-sm"></div>
<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>
<ColorSlider class="from-yellow-50 to-cyan-50" disabled />
</div>
</div>
<div class="text-xs text-base-content/60 mt-3 p-2 bg-base-300/50 rounded">
💡 LED灯条RGB滑块使颜色一致
💡 {t('whiteBalance.fullscreenComparisonTip')}
</div>
<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} />
{t('common.reset')}
</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} />
{t('whiteBalance.back')}
</button>
</div>
</div>

79
src/i18n/index.tsx Normal file
View 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
View 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
View 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
View 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;
};
}

View File

@@ -4,12 +4,15 @@ import { render } from "solid-js/web";
import "./styles.css";
import App from "./App";
import { Router } from '@solidjs/router';
import { LanguageProvider } from './i18n/index';
render(
() => (
<LanguageProvider>
<Router>
<App />
</Router>
</LanguageProvider>
),
document.getElementById('root') as HTMLElement,
);

View File

@@ -1,8 +1,8 @@
import { Borders } from '../constants/border';
export enum LedType {
RGB = 'RGB',
RGBW = 'RGBW',
WS2812B = 'WS2812B',
SK6812 = 'SK6812',
}
export type LedStripPixelMapper = {
@@ -29,6 +29,6 @@ export class LedStripConfig {
public readonly display_id: number,
public readonly border: Borders,
public len: number,
public led_type: LedType = LedType.RGB,
public led_type: LedType = LedType.WS2812B,
) {}
}

View File

@@ -1,2 +1,24 @@
@import "tailwindcss";
@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;
}
}