Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3437ea473e | ||
|
|
33334455cb | ||
|
|
0893b8a0c5 | ||
|
|
5523b18da6 | ||
|
|
809e99469d | ||
|
|
53d8938cd2 | ||
|
|
1e6d5e4c45 | ||
|
|
97d710c7bb | ||
|
|
84cfa82be3 | ||
|
|
503fb7e7b5 | ||
|
|
73291b65ac | ||
|
|
9322729294 | ||
|
|
0544703dc6 | ||
|
|
91402af140 | ||
|
|
8ccb066d1f | ||
|
|
0f41e348c2 | ||
|
|
61a310516b | ||
|
|
c4288d4542 | ||
|
|
a267911cc3 | ||
|
|
e6f05a18dd | ||
|
|
7a4d543561 | ||
|
|
5b00cd578b | ||
|
|
c7250d51ae | ||
|
|
726b6fd4fd | ||
|
|
ed08cf855a | ||
|
|
dc23bbaf5b | ||
|
|
ce15563aee | ||
|
|
7245e09cd7 | ||
|
|
89da044474 | ||
|
|
6efdc2771d | ||
|
|
041fbcd724 | ||
|
|
43056411dd | ||
|
|
b5ee91e44c | ||
|
|
7eac2726ad | ||
|
|
50b8dc2980 | ||
|
|
c076998cec | ||
|
|
2fa7ceb099 | ||
|
|
b5a0907b49 | ||
|
|
c901d304d7 | ||
|
|
246f051b0e |
@@ -0,0 +1,2 @@
|
|||||||
|
*.FCBak
|
||||||
|
*.stl
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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>.
|
||||||
@@ -20,3 +20,5 @@ uploadfs:
|
|||||||
update:
|
update:
|
||||||
pio -f -c vim update
|
pio -f -c vim update
|
||||||
|
|
||||||
|
cleanESlabs:
|
||||||
|
rm -rf .pio/libdeps/esp32-s3-devkitc-1/eslabsCurses
|
||||||
|
|||||||
@@ -1,5 +1,51 @@
|
|||||||
RX 18 -> yellow -> green
|
# CDashDisplay
|
||||||
TX 19 -> blue -> white
|
The 'C' is for Cheap.
|
||||||
|
|
||||||
|
This project uses a cheap yellow display (ESP32-8048S043) as its foundation. It
|
||||||
|
can be acquired for round 30-40€ on Aliexpress, for example.
|
||||||
|
|
||||||
|
Currently I have a way to mount it on a G29 because its what I have.
|
||||||
|
|
||||||
|
To drive it I one of my other projects: [ESDI](https://github.com/ESilva15/ESDI)
|
||||||
|
|
||||||
|
## Many thanks
|
||||||
|
- to [mgaman/ESP32-4827S043-LVGL](https://github.com/mgaman/ESP32-4827S043-LVGL):
|
||||||
|
don't remember exactly how but it helped me understand how to set up this ESP32
|
||||||
|
for development.
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Assembly
|
||||||
|
It requires a very simple modification to the G29. The display will seat between
|
||||||
|
the base and the steering wheel and for the stock G29 paddles to remain functional,
|
||||||
|
the steering wheel must be spaced.
|
||||||
|
|
||||||
|
I used simple spacers that I had laying around with OD≃8mm and ID≃5mm. They will
|
||||||
|
go on the screws that screw the wheel to the base:
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
# Roadmap
|
||||||
|
- [ ] Simhub support
|
||||||
|
- [ ] Better layout tooling
|
||||||
|
- [ ] Dynamic layout/data
|
||||||
|
|
||||||
|
|
||||||
|
### Development
|
||||||
|
#### Debugging wires
|
||||||
|
| CYD | Serial Cable |
|
||||||
|
| -------------- | ------------ |
|
||||||
|
| Yellow [RX 18] | Green |
|
||||||
|
| Blue [TX 19] | White |
|
||||||
|
|
||||||
|
|
||||||
|
The `RX18` and `TX19` pins are the `IO18` and `IO19` pins on the board and
|
||||||
|
probably are labeled as `UART1` and `USB`.
|
||||||
|
|
||||||
|
|
||||||
|
This is the `Serial2` we define on `main.cpp` currently.
|
||||||
|
Then we listen to it with something like ``.
|
||||||
|
|
||||||
### Cool fonts I like:
|
### Cool fonts I like:
|
||||||
- u8g2_font_bubble_tr (really cool for splash screens)
|
- u8g2_font_bubble_tr (really cool for splash screens)
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 196 KiB |
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ili9488CursesUI",
|
|
||||||
"version": "0.1.1",
|
|
||||||
"description": "Simple UI for creating interfaces with the ili9488 and arduinos",
|
|
||||||
"keywords": "ili9488, pro micro, curses",
|
|
||||||
"repository":
|
|
||||||
{
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/ESilva15/ili9488CursesUI"
|
|
||||||
},
|
|
||||||
"authors":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "Eduardo Silva",
|
|
||||||
"maintainer": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"Adafruit_GFX_Library": "~1.11.3",
|
|
||||||
"Adafruit_BusIO": "1.16.1"
|
|
||||||
},
|
|
||||||
"frameworks": "*",
|
|
||||||
"platforms": "*"
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
#include "UIBar.h"
|
|
||||||
#include "UIDrawing.h"
|
|
||||||
|
|
||||||
UIBar::UIBar(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
|
||||||
char *title)
|
|
||||||
: UIElement(d, dims, decor, title) {}
|
|
||||||
|
|
||||||
void UIBar::Update(char *v) {
|
|
||||||
unsigned long time = millis();
|
|
||||||
if ((time - this->lastUpdate) <= this->refreshRate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Conver the string to an integer
|
|
||||||
uint32_t newVal = atoi(v);
|
|
||||||
|
|
||||||
if (this->value == newVal) {
|
|
||||||
// If the value hasn't changed we do not need to re-render
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->DrawBar(&this->value, &newVal);
|
|
||||||
this->value = newVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIBar::DrawBar(uint32_t *oldValue, uint32_t *newValue) {
|
|
||||||
// We can help identifying cur RPM visually by using different
|
|
||||||
// colors on the bar, for example, at a given distance of the ideal shift
|
|
||||||
// we can change the color gradually
|
|
||||||
|
|
||||||
// If the new value is larger than the old one
|
|
||||||
// we just paint a new rectangle
|
|
||||||
// If the new value is smaller than the old one
|
|
||||||
// we have to delete a chunk of the old rectangle
|
|
||||||
int16_t startX = 0;
|
|
||||||
int16_t len = 0;
|
|
||||||
uint16_t colour = WHITE;
|
|
||||||
|
|
||||||
if (*newValue > *oldValue) { // Increment the bar
|
|
||||||
int32_t newV =
|
|
||||||
(*newValue * (uint32_t)(this->dims.width - 4)) / (this->range * 1000);
|
|
||||||
int32_t oldV =
|
|
||||||
(this->value * (uint32_t)(this->dims.width - 4)) / (this->range * 1000);
|
|
||||||
|
|
||||||
startX = oldV;
|
|
||||||
len = newV - oldV;
|
|
||||||
|
|
||||||
} else { // Decrement the bar
|
|
||||||
int32_t newV =
|
|
||||||
(*newValue * (uint32_t)(this->dims.width - 4)) / (this->range * 1000);
|
|
||||||
int32_t oldV =
|
|
||||||
(this->value * (uint32_t)(this->dims.width - 4)) / (this->range * 1000);
|
|
||||||
|
|
||||||
startX = newV;
|
|
||||||
len = oldV - newV;
|
|
||||||
colour = BLACK;
|
|
||||||
}
|
|
||||||
this->display->fillRect(this->dims.x + 2 + startX, this->dims.y + 2, len,
|
|
||||||
this->dims.height - 4, colour);
|
|
||||||
|
|
||||||
this->value = *newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIBar::renderBlank() {
|
|
||||||
this->display->setCursor(this->dims.x, this->dims.y);
|
|
||||||
this->display->print("!RANGE");
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIBar::Box() {
|
|
||||||
// If the range was not set, we cannot draw our ruler
|
|
||||||
if (this->range <= 0) {
|
|
||||||
this->renderBlank();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bounding box for the bar
|
|
||||||
this->display->drawRect(this->dims.x, this->dims.y, this->dims.width,
|
|
||||||
this->dims.height, RED);
|
|
||||||
|
|
||||||
// Now we can draw the scale (this should be easy to modify if needed)
|
|
||||||
// dividirs will be the range of the tach - 8 = 8000rpm
|
|
||||||
|
|
||||||
// Calculate step size as a float for accurate positioning
|
|
||||||
float step = (float)this->dims.width / this->range;
|
|
||||||
for (int k = 0; k <= this->range; k++) {
|
|
||||||
uint16_t x = round(k * step) + this->dims.x;
|
|
||||||
|
|
||||||
// To ensure it doesn't go beyond the bounding box
|
|
||||||
if (x >= this->dims.x + this->dims.width) {
|
|
||||||
x = this->dims.x + this->dims.width - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->display->setTextColor(RED);
|
|
||||||
this->display->drawFastVLine(x, this->dims.y + this->dims.height, 7, RED);
|
|
||||||
|
|
||||||
char legend[5];
|
|
||||||
sprintf(legend, "%d", k);
|
|
||||||
this->display->setCursor(x - (CHR_WIDTH(this->decor->textSize) / 2),
|
|
||||||
this->dims.y + this->dims.height + 7 + 2);
|
|
||||||
this->display->setTextColor(WHITE);
|
|
||||||
this->display->setTextSize(this->decor->textSize);
|
|
||||||
this->display->print(legend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#ifndef _UI_BAR
|
|
||||||
#define _UI_BAR
|
|
||||||
|
|
||||||
#include "UIComponent.h"
|
|
||||||
|
|
||||||
struct UIBar : UIElement {
|
|
||||||
// This might be the only when where its more efficient to have the data
|
|
||||||
// as integers instead
|
|
||||||
uint32_t value = 0; // current tach value
|
|
||||||
uint8_t range = 0; // define the tach range, ie: 8 for 8000rpm
|
|
||||||
|
|
||||||
UIBar(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor, char *title);
|
|
||||||
|
|
||||||
void Update(char *val);
|
|
||||||
void DrawBar(uint32_t *oldValue, uint32_t *newValue);
|
|
||||||
void renderBlank();
|
|
||||||
void Box();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
#include "UIComponent.h"
|
|
||||||
// #include "u8g2.h"
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "HardwareSerial.h"
|
|
||||||
#include "UIDrawing.h"
|
|
||||||
// #include <U8g2lib.h>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#define DEBUG 1
|
|
||||||
|
|
||||||
UIElement::UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
|
||||||
char *title)
|
|
||||||
: display(d), dims(dims), decor(decor), title(title) {}
|
|
||||||
|
|
||||||
UIDimensions::UIDimensions(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
|
||||||
: x(x), y(y), width(w), height(h) {}
|
|
||||||
|
|
||||||
int16_t UIElement::getContentAreaX0() {
|
|
||||||
if (this->decor->hasBorder) {
|
|
||||||
return this->dims.x + DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->dims.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t UIElement::getContentAreaY0() {
|
|
||||||
if (this->decor->hasBorder) {
|
|
||||||
return this->dims.y + this->getTitleAreaHeight() +
|
|
||||||
DEFAULT_TITLE_CONTENT_SPACING;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->dims.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t UIElement::getContentAreaHeight() {
|
|
||||||
return this->dims.height - (DEFAULT_MARGIN * 2) - DEFAULT_BORDER_THICKNESS -
|
|
||||||
this->getTitleAreaHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t UIElement::getContentAreaWidth() {
|
|
||||||
return this->dims.width - ((DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN) * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t UIElement::getTitleAreaX0() {
|
|
||||||
return this->dims.x + DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t UIElement::getTitleAreaY0() { return this->dims.y; }
|
|
||||||
|
|
||||||
uint16_t UIElement::getTitleAreaHeight() {
|
|
||||||
int16_t x = 0, y = 0;
|
|
||||||
uint16_t w = 0, h = 0;
|
|
||||||
|
|
||||||
this->display->setTextSize(this->decor->titleSize);
|
|
||||||
this->display->getTextBounds((const char *)this->title, 0, 0, &x, &y, &w, &h);
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t UIElement::getTitleAreaWidth() {
|
|
||||||
int16_t x = 0, y = 0;
|
|
||||||
uint16_t w = 0, h = 0;
|
|
||||||
|
|
||||||
this->display->setTextSize(this->decor->titleSize);
|
|
||||||
this->display->getTextBounds((const char *)this->title, 0, 0, &x, &y, &w, &h);
|
|
||||||
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::replaceString(char *oldVal, char *newVal) {
|
|
||||||
size_t newValLen = strlen(newVal);
|
|
||||||
size_t oldValLen = strlen(oldVal);
|
|
||||||
|
|
||||||
// It crashs somewhere around here
|
|
||||||
int16_t x0 = this->getContentAreaX0();
|
|
||||||
int16_t y0 = this->getContentAreaY0(); // <- Crashes here
|
|
||||||
// Before here
|
|
||||||
|
|
||||||
this->display->setTextSize(this->decor->textSize);
|
|
||||||
|
|
||||||
// If the new value is shorter, delete the extra in advance
|
|
||||||
if (oldValLen > newValLen) {
|
|
||||||
// If the old value is longer than the new value, we have to delete the
|
|
||||||
// extra of the old value, which is whatever starts at the new value len
|
|
||||||
for (size_t start = newValLen; start < oldValLen; start++) {
|
|
||||||
this->display->setCursor(x0 + start * (CHR_WIDTH(this->decor->textSize)),
|
|
||||||
y0);
|
|
||||||
this->display->setTextColor(this->decor->bgColor);
|
|
||||||
this->display->print(oldVal[start]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t k = 0; k < newValLen; k++) {
|
|
||||||
if (k <= oldValLen) {
|
|
||||||
if (oldVal[k] != newVal[k]) {
|
|
||||||
this->display->setCursor(x0 + k * (CHR_WIDTH(this->decor->textSize)),
|
|
||||||
y0 + 0);
|
|
||||||
this->display->setTextColor(this->decor->bgColor);
|
|
||||||
this->display->print(oldVal[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->display->setCursor(x0 + k * (CHR_WIDTH(this->decor->textSize)),
|
|
||||||
y0 + 0);
|
|
||||||
this->display->setTextColor(this->decor->fgColor);
|
|
||||||
this->display->print(newVal[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
#ifndef __UI_COMPONENT
|
|
||||||
#define __UI_COMPONENT
|
|
||||||
|
|
||||||
#include "Arduino_GFX.h"
|
|
||||||
#include "UIDecorations.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
enum ComponentType {
|
|
||||||
STRING,
|
|
||||||
TABLE,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UIDimensions {
|
|
||||||
uint16_t x = 0, y = 0;
|
|
||||||
uint16_t width = 0, height = 0;
|
|
||||||
|
|
||||||
UIDimensions(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UIElement {
|
|
||||||
Arduino_GFX *display;
|
|
||||||
UIDimensions dims;
|
|
||||||
UIDecorations *decor;
|
|
||||||
char *title;
|
|
||||||
uint64_t lastUpdate = 0;
|
|
||||||
uint16_t refreshRate = 0;
|
|
||||||
ComponentType type;
|
|
||||||
|
|
||||||
UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
|
||||||
char *Title);
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
int16_t getContentAreaX0();
|
|
||||||
int16_t getContentAreaY0();
|
|
||||||
uint16_t getContentAreaHeight();
|
|
||||||
uint16_t getContentAreaWidth();
|
|
||||||
int16_t getTitleAreaX0();
|
|
||||||
int16_t getTitleAreaY0();
|
|
||||||
uint16_t getTitleAreaHeight();
|
|
||||||
uint16_t getTitleAreaWidth();
|
|
||||||
|
|
||||||
// Positioning
|
|
||||||
void horizontalCenter(UIElement *reference);
|
|
||||||
void verticalCenter(UIElement *reference);
|
|
||||||
void placeBelow(UIElement *reference);
|
|
||||||
void placeRight(UIElement *reference);
|
|
||||||
void placeLeft(UIElement *reference);
|
|
||||||
|
|
||||||
// Drawing
|
|
||||||
void drawBox();
|
|
||||||
void noBox();
|
|
||||||
void replaceString(char *oldVal, char *newVal);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#include "UIDecorations.h"
|
|
||||||
|
|
||||||
UIDecorations::UIDecorations() {}
|
|
||||||
UIDecorations::UIDecorations(uint16_t bg, uint16_t fg, uint16_t title,
|
|
||||||
uint16_t border, uint8_t titleSize,
|
|
||||||
uint8_t textSize) {}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#ifndef __UI_DECORATIONS
|
|
||||||
#define __UI_DECORATIONS
|
|
||||||
|
|
||||||
#include "UIDrawing.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
struct UIDecorations {
|
|
||||||
bool hasBorder = true;
|
|
||||||
uint16_t bgColor = MAIN_BG_COLOR, fgColor = MAIN_FG_COLOR;
|
|
||||||
uint16_t titleColor = MAIN_FG_COLOR, borderColor = RED;
|
|
||||||
uint8_t titleSize = 2, textSize = 4;
|
|
||||||
|
|
||||||
UIDecorations();
|
|
||||||
UIDecorations(uint16_t bg, uint16_t fg, uint16_t title, uint16_t border,
|
|
||||||
uint8_t titleSize, uint8_t textSize);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
#include "UIDrawing.h"
|
|
||||||
#include "Arduino_GFX.h"
|
|
||||||
#include "HardwareSerial.h"
|
|
||||||
#include "UIComponent.h"
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* On the placement functions, change 5 to a variable or something
|
|
||||||
*/
|
|
||||||
|
|
||||||
// #define DEBUG
|
|
||||||
|
|
||||||
uint16_t calculateHeight(int16_t titleSize, int16_t textSize, int16_t nLines) {
|
|
||||||
return CHR_HEIGHT(titleSize) + CHR_HEIGHT(textSize) +
|
|
||||||
DEFAULT_TITLE_CONTENT_SPACING +
|
|
||||||
(2 * (DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t calculateWidth(int16_t textSize, int16_t nChars) {
|
|
||||||
return CHR_WIDTH(textSize) * nChars +
|
|
||||||
(2 * (DEFAULT_MARGIN + DEFAULT_BORDER_THICKNESS));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::horizontalCenter(UIElement *ref) {
|
|
||||||
uint16_t middlePoint = 0;
|
|
||||||
|
|
||||||
if (ref != nullptr) {
|
|
||||||
Serial2.println("We are here indeed!");
|
|
||||||
middlePoint = ref->dims.x + (ref->dims.width / 2);
|
|
||||||
} else {
|
|
||||||
middlePoint = this->display->width() / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->dims.x = middlePoint - (this->dims.width / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can add a mode of alignment here, center, left, right, whatever
|
|
||||||
void UIElement::placeBelow(UIElement *ref) {
|
|
||||||
// For now the default alignment will be left until I need some other
|
|
||||||
this->dims.x = ref->dims.x;
|
|
||||||
this->dims.y = ref->dims.y + ref->dims.height + 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::placeRight(UIElement *ref) {
|
|
||||||
this->dims.x = ref->dims.x + ref->dims.width + 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::placeLeft(UIElement *ref) {
|
|
||||||
this->dims.x = ref->dims.x - this->dims.width - 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIElement::drawBox() {
|
|
||||||
// This is the border rectangle
|
|
||||||
if (this->decor->hasBorder) {
|
|
||||||
for (int k = 0; k < DEFAULT_BORDER_THICKNESS; k++) {
|
|
||||||
this->display->drawRect(
|
|
||||||
this->dims.x + k, this->dims.y + k, this->dims.width - (k * 2),
|
|
||||||
this->dims.height - (k * 2), this->decor->borderColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For debugging purpouses
|
|
||||||
// title area
|
|
||||||
int16_t x = 0, y = 0;
|
|
||||||
uint16_t w = 0, h = 0;
|
|
||||||
|
|
||||||
// U8G2 u8g2; // No display pin setup needed since we're only using font data
|
|
||||||
// u8g2.setFont(u8g2_font_9x18_tf);
|
|
||||||
// int ascent = u8g2.getAscent();
|
|
||||||
|
|
||||||
h = this->getTitleAreaHeight();
|
|
||||||
uint16_t titleAreaWidth = this->getTitleAreaWidth();
|
|
||||||
int16_t titleTopLeftX = this->getTitleAreaX0();
|
|
||||||
#ifdef DEBUG
|
|
||||||
// Title area bounds
|
|
||||||
this->display->drawRect(titleTopLeftX, this->getTitleAreaY0(), titleAreaWidth,
|
|
||||||
h, GREEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// content area
|
|
||||||
x = this->getContentAreaX0();
|
|
||||||
y = this->getContentAreaY0();
|
|
||||||
w = this->getContentAreaWidth();
|
|
||||||
h = this->getContentAreaHeight();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
// Content area bounds
|
|
||||||
this->display->drawRect(x, y, w, h, BLUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (this->decor->hasBorder) {
|
|
||||||
// Remove the border line behind the title
|
|
||||||
this->display->fillRect(titleTopLeftX - DEFAULT_MARGIN, this->dims.y,
|
|
||||||
titleAreaWidth + DEFAULT_MARGIN,
|
|
||||||
DEFAULT_BORDER_THICKNESS, MAIN_BG_COLOR);
|
|
||||||
|
|
||||||
// Render the title
|
|
||||||
this->display->setCursor(titleTopLeftX, this->dims.y);
|
|
||||||
this->display->print(this->title);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
// Element bounds
|
|
||||||
this->display->drawRect(this->dims.x, this->dims.y, this->dims.width,
|
|
||||||
this->dims.height, PURPLE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#ifndef __CURSES_UI_VISUALS
|
|
||||||
#define __CURSES_UI_VISUALS
|
|
||||||
|
|
||||||
#include <Arduino_GFX.h>
|
|
||||||
|
|
||||||
#define RIGHT 0
|
|
||||||
#define INVERTED 1
|
|
||||||
#define LEFT 2
|
|
||||||
#define NORMAL 3
|
|
||||||
|
|
||||||
#define DEFAULT_BORDER_THICKNESS 3
|
|
||||||
#define DEFAULT_TITLE_CONTENT_SPACING 3
|
|
||||||
#define DEFAULT_MARGIN 3
|
|
||||||
|
|
||||||
#define MAIN_BG_COLOR RGB565(20, 10, 10)
|
|
||||||
#define MAIN_FG_COLOR RGB565(255, 255, 255)
|
|
||||||
|
|
||||||
#define CHR_WIDTH(size) (6 * size)
|
|
||||||
#define CHR_HEIGHT(size) (8 * size)
|
|
||||||
#define CHR_SPACE(size) (size)
|
|
||||||
|
|
||||||
uint16_t calculateHeight(int16_t titleSize, int16_t textSize, int16_t nLines);
|
|
||||||
uint16_t calculateWidth(int16_t textSize, int16_t nChars);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#include "UIString.h"
|
|
||||||
#include "HardwareSerial.h"
|
|
||||||
#include "UIComponent.h"
|
|
||||||
#include <Arduino_GFX.h>
|
|
||||||
|
|
||||||
UIString::UIString() : UIElement(nullptr, {0, 0, 0, 0}, nullptr, (char *)"") {
|
|
||||||
this->type = STRING;
|
|
||||||
memset(this->value, 0, this->bufferSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
UIString::UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
|
||||||
char *title)
|
|
||||||
: UIElement(d, dims, decor, title) {
|
|
||||||
this->type = STRING;
|
|
||||||
memset(this->value, 0, this->bufferSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIString::Update(const char *v) {
|
|
||||||
uint64_t time = millis();
|
|
||||||
if ((time - this->lastUpdate) <= this->refreshRate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the value is larger than our buffer - should add a way of knowing we
|
|
||||||
// got an error here
|
|
||||||
if (strlen(v) >= this->bufferSize) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the value hasn't changed we do not need to re-render
|
|
||||||
if (strcmp(this->value, v) == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char newVal[this->bufferSize];
|
|
||||||
memset(newVal, 0, this->bufferSize);
|
|
||||||
// strncpy(newVal, v, this->bufferSize - 1);
|
|
||||||
sprintf(newVal, "%s", v);
|
|
||||||
|
|
||||||
char oldVal[this->bufferSize];
|
|
||||||
memset(oldVal, 0, this->bufferSize);
|
|
||||||
// strncpy(oldVal, v, this->bufferSize - 1);
|
|
||||||
sprintf(oldVal, "%s", this->value);
|
|
||||||
|
|
||||||
// Figure out the x0 and y0 for the text
|
|
||||||
replaceString(oldVal, newVal);
|
|
||||||
strncpy(this->value, v, this->bufferSize);
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#ifndef __UI_STRING
|
|
||||||
#define __UI_STRING
|
|
||||||
|
|
||||||
#include "UIComponent.h"
|
|
||||||
|
|
||||||
// Representation of single line strings
|
|
||||||
struct UIString : UIElement {
|
|
||||||
static const size_t bufferSize = 64;
|
|
||||||
char value[bufferSize];
|
|
||||||
|
|
||||||
UIString();
|
|
||||||
UIString(Arduino_GFX *d, UIDimensions dims, UIDecorations *decor,
|
|
||||||
char *title);
|
|
||||||
void Update(const char *value);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
#include "UITable.h"
|
|
||||||
#include "HardwareSerial.h"
|
|
||||||
#include "UIDecorations.h"
|
|
||||||
#include "UIDrawing.h"
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
UITable::UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor,
|
|
||||||
int nRows, int nCols, int *colWidths, char *title)
|
|
||||||
: UIElement(gfx, dims, decor, title) {
|
|
||||||
this->type = TABLE;
|
|
||||||
this->nRows = nRows;
|
|
||||||
this->nColumns = nCols;
|
|
||||||
this->tableData = new UIString *[this->nRows * this->nColumns];
|
|
||||||
this->colWidths = colWidths;
|
|
||||||
|
|
||||||
// Default decoration for every cell
|
|
||||||
this->decor->textSize = 2;
|
|
||||||
|
|
||||||
for (int k = 0; k < ROWS * COLUMNS; k++) {
|
|
||||||
UIDecorations *cellDecor = new UIDecorations();
|
|
||||||
cellDecor->textSize = this->decor->textSize;
|
|
||||||
|
|
||||||
UIDimensions dims = {0, 0, 0, 0};
|
|
||||||
|
|
||||||
this->tableData[k] = new UIString(display, dims, cellDecor, (char *)"");
|
|
||||||
}
|
|
||||||
|
|
||||||
int cellH = CHR_HEIGHT(this->decor->textSize) + CELL_MARGIN;
|
|
||||||
|
|
||||||
// Initialize the table dimensions
|
|
||||||
//// Calculate the height
|
|
||||||
this->dims.height = ROWS * cellH + this->getTitleAreaHeight() +
|
|
||||||
DEFAULT_MARGIN + DEFAULT_BORDER_THICKNESS;
|
|
||||||
|
|
||||||
//// Calculate the width
|
|
||||||
for (int c = 0; c < this->nColumns; c++) {
|
|
||||||
this->dims.width +=
|
|
||||||
(CHR_WIDTH(this->decor->textSize) + CELL_MARGIN) * this->colWidths[c];
|
|
||||||
}
|
|
||||||
this->dims.width += (DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN) * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t UITable::getContentAreaHeight() {
|
|
||||||
return this->dims.height - (DEFAULT_MARGIN * 2) - DEFAULT_BORDER_THICKNESS -
|
|
||||||
this->getTitleAreaHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This was hardcoded for the relative and had a warning for that but
|
|
||||||
* I recon its dynamic enough for now
|
|
||||||
*/
|
|
||||||
void UITable::setup() {
|
|
||||||
int cellH = CHR_HEIGHT(this->decor->textSize) + CELL_MARGIN;
|
|
||||||
|
|
||||||
// Initialize the cells
|
|
||||||
uint16_t yOffset = this->getContentAreaY0();
|
|
||||||
for (int r = 0; r < ROWS; r++) {
|
|
||||||
int16_t xOffset = this->getContentAreaX0();
|
|
||||||
for (int c = 0; c < COLUMNS; c++) {
|
|
||||||
this->tableData[r * COLUMNS + c]->refreshRate = this->refreshRate;
|
|
||||||
this->tableData[r * COLUMNS + c]->decor->textSize = this->decor->textSize;
|
|
||||||
this->tableData[r * COLUMNS + c]->decor->hasBorder = false;
|
|
||||||
this->tableData[r * COLUMNS + c]->dims.x = xOffset + CELL_MARGIN;
|
|
||||||
this->tableData[r * COLUMNS + c]->dims.y = (cellH * r) + yOffset;
|
|
||||||
this->tableData[r * COLUMNS + c]->dims.height = cellH;
|
|
||||||
this->tableData[r * COLUMNS + c]->dims.width =
|
|
||||||
this->colWidths[c] * (CHR_WIDTH(this->decor->textSize) + CELL_MARGIN);
|
|
||||||
memset(this->tableData[r * COLUMNS + c]->value, 0,
|
|
||||||
this->tableData[r * COLUMNS + c]->bufferSize);
|
|
||||||
|
|
||||||
xOffset +=
|
|
||||||
this->colWidths[c] * (CHR_WIDTH(this->decor->textSize) + CELL_MARGIN);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
this->tableData[r * COLUMNS + c]->drawBox();
|
|
||||||
this->tableData[r * COLUMNS + c]->Update("---");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef __UI_TABLE
|
|
||||||
#define __UI_TABLE
|
|
||||||
|
|
||||||
#include "Arduino_GFX.h"
|
|
||||||
#include "UIComponent.h"
|
|
||||||
#include "UIString.h"
|
|
||||||
|
|
||||||
#define COLUMNS 3
|
|
||||||
#define ROWS 5
|
|
||||||
#define CELL_MARGIN 2
|
|
||||||
|
|
||||||
/* Very shitty table element, only works for the relative as of now
|
|
||||||
*/
|
|
||||||
struct UITable : UIElement {
|
|
||||||
// will hold rows * columns UIStrings to fill the table
|
|
||||||
int nRows = 0;
|
|
||||||
int nColumns = 0;
|
|
||||||
int *colWidths;
|
|
||||||
UIString **tableData;
|
|
||||||
|
|
||||||
UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor, int nR,
|
|
||||||
int nC, int *cWidth, char *t);
|
|
||||||
|
|
||||||
// void Update(StandingLine standings[5]);
|
|
||||||
void setup();
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
uint16_t getContentAreaHeight();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -17,6 +17,15 @@ build_flags = -Iinclude/
|
|||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-mfix-esp32-psram-cache-issue
|
-mfix-esp32-psram-cache-issue
|
||||||
-std=gnu++17
|
-std=gnu++17
|
||||||
|
-DLOG_LEVEL=LOG_LEVEL_INFO
|
||||||
|
|
||||||
|
build_unflags = -std=gnu++11
|
||||||
# -Ilib/u8g2/csrc
|
# -Ilib/u8g2/csrc
|
||||||
# -Ilib/u8g2/cppsrc
|
# -Ilib/u8g2/cppsrc
|
||||||
board_build.arduino.memory_type = qio_opi
|
board_build.arduino.memory_type = qio_opi
|
||||||
|
|
||||||
|
lib_deps =
|
||||||
|
../lib/embeslogger/
|
||||||
|
../lib/eslabsCurses/
|
||||||
|
|
||||||
|
lib_extra_dirs = ../lib
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "commands.h"
|
||||||
|
|
||||||
|
char* CommandToStr(Command id) {
|
||||||
|
switch(id) {
|
||||||
|
case CmdRequestID:
|
||||||
|
return (char*)"CmdRequestID";
|
||||||
|
case CmdAckID:
|
||||||
|
return (char*)"CmdAckID";
|
||||||
|
case CmdCreateWindow:
|
||||||
|
return (char*)"CmdCreateWindow";
|
||||||
|
case CmdDestroyWindow:
|
||||||
|
return (char*)"CmdDestroyWindow";
|
||||||
|
case CmdUpdateWinDims:
|
||||||
|
return (char*)"CmdUpdateWinDims";
|
||||||
|
case CMDData:
|
||||||
|
return (char*)"CMDData";
|
||||||
|
default:
|
||||||
|
return (char*)"CmdUnknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __COMMANDS__
|
||||||
|
#define __COMMANDS__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum : uint8_t {
|
||||||
|
CmdUnknown = 0,
|
||||||
|
CmdRequestID = 1,
|
||||||
|
CmdAckID = 2,
|
||||||
|
CmdCreateWindow = 3,
|
||||||
|
CmdDestroyWindow = 4,
|
||||||
|
CmdUpdateWinDims = 5, // NOTE: change this to a move cmd instead
|
||||||
|
CmdUpdateWin = 6,
|
||||||
|
CMDData = 7,
|
||||||
|
} Command;
|
||||||
|
|
||||||
|
char* CommandToStr(Command id);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include "communication.h"
|
||||||
|
|
||||||
|
uint8_t CRC8(const uint8_t *data, size_t len) {
|
||||||
|
uint8_t crc = 0x00;
|
||||||
|
while (len--) {
|
||||||
|
crc = pgm_read_byte(&crc8_table[crc ^ *data++]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#ifndef __COMMUNICATION__
|
||||||
|
#define __COMMUNICATION__
|
||||||
|
|
||||||
|
#include "pgmspace.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
const byte STX = 0x02;
|
||||||
|
const byte ETX = 0x03;
|
||||||
|
const byte ACK = 0x06;
|
||||||
|
|
||||||
|
static const uint8_t crc8_table[256] PROGMEM = {
|
||||||
|
0x00,0x07,0x0E,0x09,0x1C,0x1B,0x12,0x15,
|
||||||
|
0x38,0x3F,0x36,0x31,0x24,0x23,0x2A,0x2D,
|
||||||
|
0x70,0x77,0x7E,0x79,0x6C,0x6B,0x62,0x65,
|
||||||
|
0x48,0x4F,0x46,0x41,0x54,0x53,0x5A,0x5D,
|
||||||
|
0xE0,0xE7,0xEE,0xE9,0xFC,0xFB,0xF2,0xF5,
|
||||||
|
0xD8,0xDF,0xD6,0xD1,0xC4,0xC3,0xCA,0xCD,
|
||||||
|
0x90,0x97,0x9E,0x99,0x8C,0x8B,0x82,0x85,
|
||||||
|
0xA8,0xAF,0xA6,0xA1,0xB4,0xB3,0xBA,0xBD,
|
||||||
|
0xC7,0xC0,0xC9,0xCE,0xDB,0xDC,0xD5,0xD2,
|
||||||
|
0xFF,0xF8,0xF1,0xF6,0xE3,0xE4,0xED,0xEA,
|
||||||
|
0xB7,0xB0,0xB9,0xBE,0xAB,0xAC,0xA5,0xA2,
|
||||||
|
0x8F,0x88,0x81,0x86,0x93,0x94,0x9D,0x9A,
|
||||||
|
0x27,0x20,0x29,0x2E,0x3B,0x3C,0x35,0x32,
|
||||||
|
0x1F,0x18,0x11,0x16,0x03,0x04,0x0D,0x0A,
|
||||||
|
0x57,0x50,0x59,0x5E,0x4B,0x4C,0x45,0x42,
|
||||||
|
0x6F,0x68,0x61,0x66,0x73,0x74,0x7D,0x7A,
|
||||||
|
0x89,0x8E,0x87,0x80,0x95,0x92,0x9B,0x9C,
|
||||||
|
0xB1,0xB6,0xBF,0xB8,0xAD,0xAA,0xA3,0xA4,
|
||||||
|
0xF9,0xFE,0xF7,0xF0,0xE5,0xE2,0xEB,0xEC,
|
||||||
|
0xC1,0xC6,0xCF,0xC8,0xDD,0xDA,0xD3,0xD4,
|
||||||
|
0x69,0x6E,0x67,0x60,0x75,0x72,0x7B,0x7C,
|
||||||
|
0x51,0x56,0x5F,0x58,0x4D,0x4A,0x43,0x44,
|
||||||
|
0x19,0x1E,0x17,0x10,0x05,0x02,0x0B,0x0C,
|
||||||
|
0x21,0x26,0x2F,0x28,0x3D,0x3A,0x33,0x34,
|
||||||
|
0x4E,0x49,0x40,0x47,0x52,0x55,0x5C,0x5B,
|
||||||
|
0x76,0x71,0x78,0x7F,0x6A,0x6D,0x64,0x63,
|
||||||
|
0x3E,0x39,0x30,0x37,0x22,0x25,0x2C,0x2B,
|
||||||
|
0x06,0x01,0x08,0x0F,0x1A,0x1D,0x14,0x13,
|
||||||
|
0xAE,0xA9,0xA0,0xA7,0xB2,0xB5,0xBC,0xBB,
|
||||||
|
0x96,0x91,0x98,0x9F,0x8A,0x8D,0x84,0x83,
|
||||||
|
0xDE,0xD9,0xD0,0xD7,0xC2,0xC5,0xCC,0xCB,
|
||||||
|
0xE6,0xE1,0xE8,0xEF,0xFA,0xFD,0xF4,0xF3
|
||||||
|
};
|
||||||
|
uint8_t CRC8(const uint8_t *data, size_t len);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include "packets.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
void initIdentificationPacket(IdentificationPacket* packet, const char* name,
|
||||||
|
uint8_t id) {
|
||||||
|
memset(packet, 0, sizeof(*packet));
|
||||||
|
|
||||||
|
packet->StartMarker = 0x02; // Start of text
|
||||||
|
packet->EndMarker = 0x03; // End of text
|
||||||
|
packet->DeviceID = id;
|
||||||
|
packet->PktType = identificationPacket;
|
||||||
|
|
||||||
|
// snprintf(packet->deviceName, sizeof(packet->deviceName), "%s", name);
|
||||||
|
strncpy(packet->deviceName, name, strlen(name));
|
||||||
|
packet->deviceName[strlen(name)] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void initWindowIDReply(WindowIDReply* pkt, int16_t id) {
|
||||||
|
memset(pkt, 0, sizeof(*pkt));
|
||||||
|
|
||||||
|
pkt->StarMarker = 0x02;
|
||||||
|
pkt->EndMarker = 0x03;
|
||||||
|
pkt->wID = id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef __PACKETS__
|
||||||
|
#define __PACKETS__
|
||||||
|
|
||||||
|
#include "UIDimensions.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef uint8_t PacketType;
|
||||||
|
const uint8_t identificationPacket = 0;
|
||||||
|
|
||||||
|
struct __attribute__((packed)) IdentificationPacket {
|
||||||
|
char StartMarker;
|
||||||
|
uint8_t DeviceID;
|
||||||
|
PacketType PktType;
|
||||||
|
char deviceName[32];
|
||||||
|
char EndMarker;
|
||||||
|
};
|
||||||
|
|
||||||
|
void initIdentificationPacket(IdentificationPacket* packet, const char* name,
|
||||||
|
uint8_t id);
|
||||||
|
|
||||||
|
struct __attribute__((packed)) NewWindowBody {
|
||||||
|
char StartMarker;
|
||||||
|
uint16_t x0;
|
||||||
|
uint16_t y0;
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
char title[32];
|
||||||
|
char EndMarker;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __attribute__((packed)) WindowIDReply {
|
||||||
|
char StarMarker;
|
||||||
|
int16_t wID;
|
||||||
|
char EndMarker;
|
||||||
|
};
|
||||||
|
|
||||||
|
void initWindowIDReply(WindowIDReply* pkt, int16_t id);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
#include "walkieTalkie.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "communication/commands.h"
|
||||||
|
#include "communication/communication.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
namespace WalkieTalkie {
|
||||||
|
static inline void WaitingSTXRoutine(byte *b) {
|
||||||
|
LOG_TRACE(F("First byte is: %d\n"), *b);
|
||||||
|
if (*b == STX) {
|
||||||
|
state = RecvCMD;
|
||||||
|
resetBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void ResetStateMachine() {
|
||||||
|
state = WaitingSTX;
|
||||||
|
resetBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void RecvCMDRoutine(byte *b) {
|
||||||
|
LOG_TRACE(F("Reading the command byte\n"));
|
||||||
|
|
||||||
|
uint8_t cmdVal = Command(*b);
|
||||||
|
if (cmdVal == 0 || cmdVal > CMDData) {
|
||||||
|
LOG_TRACE(F("Invalid CMD byte: 0x%02x. Resetting parser.\n"), cmdVal);
|
||||||
|
ResetStateMachine();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_TRACE(F(" Command: %d\n"), *b);
|
||||||
|
tempCommand = (Command)cmdVal;
|
||||||
|
state = RecvLen;
|
||||||
|
|
||||||
|
resetBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void RecvLenRoutine(byte *b) {
|
||||||
|
LOG_TRACE(F("Reading the len\n"));
|
||||||
|
buffer[bufferIndex++] = *b;
|
||||||
|
// we are currently using a int16_t for the len so: 2 bytes
|
||||||
|
if (bufferIndex > 1) {
|
||||||
|
len = buffer[0] | (buffer[1] << 8);
|
||||||
|
|
||||||
|
if (len > 2056 || len == 0) {
|
||||||
|
LOG_WARN(F("Corrupt length received: %d. Resetting parser.\n"), len);
|
||||||
|
ResetStateMachine();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_TRACE(F("Len: %d\n"), len);
|
||||||
|
state = RecvPayload;
|
||||||
|
resetBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void RecvPayloadRoutine(uint8_t *payload, byte *b) {
|
||||||
|
LOG_TRACE(F("Reading payload: %-.3d %s 0x%02x\n"), bufferIndex, " - ", *b);
|
||||||
|
|
||||||
|
buffer[bufferIndex++] = *b;
|
||||||
|
if (bufferIndex == len) {
|
||||||
|
// put the buffer data somewhere
|
||||||
|
memcpy(payload, buffer, len);
|
||||||
|
state = RecvCRC;
|
||||||
|
resetBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int RecvCRCRoutine(byte *b) {
|
||||||
|
crc = *b;
|
||||||
|
LOG_TRACE(F("Reacing CRC: %d\n"), crc);
|
||||||
|
|
||||||
|
state = RecvETX;
|
||||||
|
resetBuffer();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int RecvETXRoutine(Command *command, uint8_t *payload, byte *b) {
|
||||||
|
LOG_TRACE(F("READING ETX\n"));
|
||||||
|
state = WaitingSTX;
|
||||||
|
|
||||||
|
uint8_t computedCRC = CRC8(payload, len);
|
||||||
|
if (*b != ETX) {
|
||||||
|
LOG_TRACE(F("Failure, last byte was: %d\n"), *b);
|
||||||
|
return -1;
|
||||||
|
} else if (crc != computedCRC) {
|
||||||
|
LOG_TRACE(F("CRC don't match. Expected: %d, got: %d\n"), crc, computedCRC);
|
||||||
|
return -2;
|
||||||
|
} else {
|
||||||
|
*command = tempCommand;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t RecvStream(Command *command, uint8_t *payload, uint16_t payloadMax) {
|
||||||
|
if (state != WaitingSTX && (millis() - lastByteTime > SERIAL_TIMEOUT_MS)) {
|
||||||
|
state = WaitingSTX;
|
||||||
|
resetBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (Serial.available() > 0) {
|
||||||
|
lastByteTime = millis();
|
||||||
|
uint8_t byte = Serial.read();
|
||||||
|
|
||||||
|
switch(state) {
|
||||||
|
case WaitingSTX: {
|
||||||
|
WaitingSTXRoutine(&byte);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RecvCMD: {
|
||||||
|
RecvCMDRoutine(&byte);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RecvLen: {
|
||||||
|
RecvLenRoutine(&byte);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RecvPayload: {
|
||||||
|
RecvPayloadRoutine(payload, &byte);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RecvCRC: {
|
||||||
|
RecvCRCRoutine(&byte);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RecvETX: {
|
||||||
|
return RecvETXRoutine(command, payload, &byte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#ifndef __WALKIE_TALKIE__
|
||||||
|
#define __WALKIE_TALKIE__
|
||||||
|
|
||||||
|
#include "communication/commands.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
namespace WalkieTalkie {
|
||||||
|
typedef enum {
|
||||||
|
WaitingSTX = 0,
|
||||||
|
RecvCMD = 1,
|
||||||
|
RecvLen = 2,
|
||||||
|
RecvPayload = 3,
|
||||||
|
RecvCRC = 4,
|
||||||
|
RecvETX = 5,
|
||||||
|
} RecvState;
|
||||||
|
|
||||||
|
static uint8_t tempLenBuffer[2];
|
||||||
|
inline uint8_t buffer[4096];
|
||||||
|
inline int16_t bufferIndex = 0;
|
||||||
|
inline RecvState state = WaitingSTX;
|
||||||
|
inline int16_t len = 0;
|
||||||
|
inline uint8_t crc = 0;
|
||||||
|
inline Command tempCommand = CmdUnknown;
|
||||||
|
// Timing control
|
||||||
|
inline int64_t lastByteTime = 0;
|
||||||
|
inline int64_t SERIAL_TIMEOUT_MS = 15;
|
||||||
|
|
||||||
|
inline static void resetBuffer() {
|
||||||
|
bufferIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ACKPacket {
|
||||||
|
uint8_t StartMarker;
|
||||||
|
uint8_t ACK;
|
||||||
|
uint8_t EndMarker;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename PacketType>
|
||||||
|
void SendData(PacketType *packet) {
|
||||||
|
Serial.write((uint8_t*)packet, sizeof(*packet));
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t RecvStream(Command *command, uint8_t *payload, uint16_t payloadMax);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#include "data.h"
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
uint8_t packetBuffer[sizeof(DataPacket)] = {0};
|
|
||||||
int bufferIndex = 0;
|
|
||||||
bool isReceiving = false;
|
|
||||||
|
|
||||||
void SendDataRequest() {
|
|
||||||
DataReq req = {5};
|
|
||||||
Serial.write((uint8_t *)&req, sizeof(req));
|
|
||||||
Serial.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
int RecvDataPacket(DataPacket *p) {
|
|
||||||
while (Serial.available() > 0) {
|
|
||||||
uint8_t byte = Serial.read();
|
|
||||||
|
|
||||||
if (!isReceiving) {
|
|
||||||
if (byte == 0x02) {
|
|
||||||
isReceiving = true;
|
|
||||||
bufferIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
packetBuffer[bufferIndex++] = byte;
|
|
||||||
|
|
||||||
if (bufferIndex >= sizeof(DataPacket)) {
|
|
||||||
Serial.flush();
|
|
||||||
bufferIndex = 0;
|
|
||||||
isReceiving = false;
|
|
||||||
|
|
||||||
memcpy(p, packetBuffer, sizeof(DataPacket));
|
|
||||||
|
|
||||||
if (p->EndMarker != 0x03) {
|
|
||||||
// Serial2.println(F("\r////////////// DATA IS MALFORMED
|
|
||||||
// //////////////"));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
// for(int k = 0; k < sizeof(DataPacket); k++) {
|
|
||||||
// if (k % 8 == 0) {
|
|
||||||
// Serial2.printf("\r\n");
|
|
||||||
// }
|
|
||||||
// Serial2.printf(" 0x%02x", packetBuffer[k]);
|
|
||||||
// }
|
|
||||||
// Serial2.printf("\r\n");
|
|
||||||
|
|
||||||
// Serial2.printf("%d / %d [%2d] || %d / %d [%2d]\n\n\r",
|
|
||||||
// ESP.getFreeHeap(),
|
|
||||||
// ESP.getHeapSize(),
|
|
||||||
// (int)(((float)(ESP.getHeapSize() - ESP.getFreeHeap()) /
|
|
||||||
// ESP.getHeapSize()) *
|
|
||||||
// 100),
|
|
||||||
// ESP.getFreePsram(), ESP.getPsramSize(),
|
|
||||||
// (int)(((float)(ESP.getPsramSize() - ESP.getFreePsram())
|
|
||||||
// /
|
|
||||||
// ESP.getPsramSize()) *
|
|
||||||
// 100));
|
|
||||||
|
|
||||||
// debugDataPacket(&packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugDataPacket(DataPacket *p) {
|
|
||||||
Serial2.printf("\rSize: %zu\n", sizeof(struct DataPacket));
|
|
||||||
Serial2.printf("\rStartMarker: 0x%02x\n", p->StartMarker);
|
|
||||||
Serial2.printf("\rSpeed: %s\n", p->speed);
|
|
||||||
Serial2.printf("\rGear: %s\n", p->gear);
|
|
||||||
Serial2.printf("\rRPM: %s\n", p->rpm);
|
|
||||||
Serial2.printf("\rLapNumber: %s\n", p->LapNumber);
|
|
||||||
Serial2.printf("\rcurrLapTime: %s\n", p->currLapTime);
|
|
||||||
Serial2.printf("\rlastLapTime: %s\n", p->lastLapTime);
|
|
||||||
Serial2.printf("\rfuelEst: %s\n", p->FuelEst);
|
|
||||||
Serial2.printf("\rStandings:\n");
|
|
||||||
for (int k = 0; k < 5; k++) {
|
|
||||||
Serial2.printf("\r Lap: %s\n", p->standings[k].Lap);
|
|
||||||
Serial2.printf("\r DriverName: %s\n", p->standings[k].DriverName);
|
|
||||||
Serial2.printf("\r TimeBehind: %s\n", p->standings[k].TimeBehindString);
|
|
||||||
}
|
|
||||||
Serial2.printf("\rEndMarker: 0x%02x\n\n", p->EndMarker);
|
|
||||||
}
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
#ifndef __DASH_DISPLAY_DATA
|
|
||||||
#define __DASH_DISPLAY_DATA
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
struct DataReq {
|
|
||||||
uint8_t type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Car data
|
|
||||||
const int speedLen = 5;
|
|
||||||
const int gearLen = 3;
|
|
||||||
const int rpmLen = 6;
|
|
||||||
const int brakeBiasLen = 6;
|
|
||||||
|
|
||||||
// Lap data
|
|
||||||
const int lapNumberLen = 5;
|
|
||||||
const int DeltaToBestLapLen = 6;
|
|
||||||
const int bestLapTimeLen = 10;
|
|
||||||
const int currLapTimeLen = 10;
|
|
||||||
const int lastLapTimeLen = 10;
|
|
||||||
|
|
||||||
// Fuel data
|
|
||||||
const int FuelTankLen = 15;
|
|
||||||
const int FuelEstLen = 15;
|
|
||||||
|
|
||||||
const int LapStringLen = 4;
|
|
||||||
const int DriverNameLen = 24;
|
|
||||||
const int TimeBehindStringLen = 8;
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
struct StandingLine {
|
|
||||||
char Lap[LapStringLen];
|
|
||||||
char DriverName[DriverNameLen];
|
|
||||||
char TimeBehindString[TimeBehindStringLen];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DataPacket {
|
|
||||||
uint8_t StartMarker;
|
|
||||||
char speed[speedLen];
|
|
||||||
char gear[gearLen];
|
|
||||||
char rpm[rpmLen];
|
|
||||||
char brakeBias[brakeBiasLen];
|
|
||||||
char LapNumber[lapNumberLen];
|
|
||||||
char DeltaToBestLap[DeltaToBestLapLen];
|
|
||||||
char bestLapTime[bestLapTimeLen];
|
|
||||||
char currLapTime[currLapTimeLen];
|
|
||||||
char lastLapTime[lastLapTimeLen];
|
|
||||||
char FuelEst[FuelEstLen];
|
|
||||||
StandingLine standings[5];
|
|
||||||
uint8_t EndMarker;
|
|
||||||
};
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
void DebugDataPacket(DataPacket *p);
|
|
||||||
int RecvDataPacket(DataPacket *p);
|
|
||||||
void SendDataRequest();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
#define PWM_FREQUENCY 5000
|
#define PWM_FREQUENCY 5000
|
||||||
#define PWM_RESOLUTION 12
|
#define PWM_RESOLUTION 12
|
||||||
|
|
||||||
#define SCREEN_ORIENTATION 2
|
#define SCREEN_ORIENTATION 4
|
||||||
#define SCREEN_LANDSCAPE
|
#define SCREEN_LANDSCAPE
|
||||||
|
|
||||||
/* More display class:
|
/* More display class:
|
||||||
|
|||||||
+173
-216
@@ -9,14 +9,24 @@ to have more ways to run analytics
|
|||||||
|
|
||||||
#include "Arduino_GFX.h"
|
#include "Arduino_GFX.h"
|
||||||
#include "HardwareSerial.h"
|
#include "HardwareSerial.h"
|
||||||
|
#include "UIComponent.h"
|
||||||
#include "UIDecorations.h"
|
#include "UIDecorations.h"
|
||||||
|
#include "UIDimensions.h"
|
||||||
#include "UIDrawing.h"
|
#include "UIDrawing.h"
|
||||||
|
#include "UIScreen.h"
|
||||||
|
#include "communication/commands.h"
|
||||||
|
#include "communication/packets.h"
|
||||||
|
#include "communication/walkieTalkie.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "values.h"
|
||||||
|
#include "windowPool.h"
|
||||||
|
#include "methods/methods.h"
|
||||||
|
// #include "UIDrawing.h"
|
||||||
#include "UIString.h"
|
#include "UIString.h"
|
||||||
#include "UITable.h"
|
// #include "UITable.h"
|
||||||
#include "data.h"
|
|
||||||
#include "displaySetup.h"
|
#include "displaySetup.h"
|
||||||
#include "esp32-hal-psram.h"
|
#include "esp32-hal-psram.h"
|
||||||
#include "ui.h"
|
// #include "ui.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Arduino_GFX_Library.h>
|
#include <Arduino_GFX_Library.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -25,6 +35,9 @@ to have more ways to run analytics
|
|||||||
// #include <nvs.h>
|
// #include <nvs.h>
|
||||||
// #include <nvs_flash.h>
|
// #include <nvs_flash.h>
|
||||||
|
|
||||||
|
#define ESLABS_DEVICE_ID 0x01
|
||||||
|
#define ESLABS_DEVICE_NAME "ESLabs CDashDisplay"
|
||||||
|
|
||||||
#define UART1_TX 19
|
#define UART1_TX 19
|
||||||
#define UART1_RX 18
|
#define UART1_RX 18
|
||||||
|
|
||||||
@@ -43,238 +56,182 @@ Arduino_ESP32RGBPanel *panel = new Arduino_ESP32RGBPanel(
|
|||||||
//
|
//
|
||||||
Arduino_GFX *gfx = new Arduino_RGB_Display(TFT_HOR_RES, TFT_VER_RES, panel, 16);
|
Arduino_GFX *gfx = new Arduino_RGB_Display(TFT_HOR_RES, TFT_VER_RES, panel, 16);
|
||||||
|
|
||||||
// HardwareSerial debugSerial(1);
|
Curses::Screen mainScreen(gfx, UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES),
|
||||||
|
UIDecorations());
|
||||||
|
|
||||||
// UIelements
|
// UIelements
|
||||||
DashUI *ui = new DashUI();
|
// UIDecorations *gearTextDecor = new UIDecorations();
|
||||||
UIDecorations *rpmBarDecor = new UIDecorations();
|
// UIString gearText(gfx, UIDimensions(0, 0, 0, 0), gearTextDecor, (char
|
||||||
UIDecorations *rpmTextDecor = new UIDecorations();
|
// *)"Gear");
|
||||||
UIDecorations *speedTextDecor = new UIDecorations();
|
//
|
||||||
UIDecorations *gearTextDecor = new UIDecorations();
|
// UIElement mainWindow(
|
||||||
UIDecorations *lapDeltaDecor = new UIDecorations();
|
// gfx,
|
||||||
UIDecorations *bestLapDecor = new UIDecorations();
|
// UIDimensions(0, 0, TFT_HOR_RES, TFT_VER_RES),
|
||||||
UIDecorations *lastLapDecor = new UIDecorations();
|
// gearTextDecor,
|
||||||
UIDecorations *curLapDecor = new UIDecorations();
|
// (char*)"MAIN WINDOW"
|
||||||
UIDecorations *fuelTankDecor = new UIDecorations();
|
// );
|
||||||
UIDecorations *fuelConsumptionDecor = new UIDecorations();
|
|
||||||
UIDecorations *brakeBiasDecor = new UIDecorations();
|
|
||||||
UIDecorations *relativeDecor = new UIDecorations();
|
|
||||||
|
|
||||||
UIBar rpmBar(gfx, UIDimensions(0, 0, 0, 0), rpmBarDecor, (char *)"Tach");
|
|
||||||
UIString rpmText(gfx, UIDimensions(0, 0, 0, 0), rpmTextDecor, (char *)"RPM");
|
|
||||||
UIString speedText(gfx, UIDimensions(0, 0, 0, 0), speedTextDecor,
|
|
||||||
(char *)"Speed");
|
|
||||||
UIString gearText(gfx, UIDimensions(0, 0, 0, 0), rpmTextDecor, (char *)"Gear");
|
|
||||||
|
|
||||||
UIString lapDelta(gfx, UIDimensions(0, 0, 0, 0), lapDeltaDecor,
|
|
||||||
(char *)"Delta");
|
|
||||||
UIString bestLap(gfx, UIDimensions(0, 0, 0, 0), bestLapDecor,
|
|
||||||
(char *)"Best Lap");
|
|
||||||
UIString lastLap(gfx, UIDimensions(0, 0, 0, 0), lastLapDecor,
|
|
||||||
(char *)"Last Lap");
|
|
||||||
UIString curLap(gfx, UIDimensions(0, 0, 0, 0), curLapDecor, (char *)"Cur. Lap");
|
|
||||||
UIString fuelTank(gfx, UIDimensions(0, 0, 0, 0), fuelTankDecor,
|
|
||||||
(char *)"Fuel Tank");
|
|
||||||
UIString fuelConsumption(gfx, UIDimensions(0, 0, 0, 0), fuelConsumptionDecor,
|
|
||||||
(char *)"Fuel Consumption");
|
|
||||||
UIString brakeBias(gfx, UIDimensions(0, 0, 0, 0), brakeBiasDecor,
|
|
||||||
(char *)"Brakes");
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
psramInit();
|
psramInit();
|
||||||
|
Serial.setRxBufferSize(8192);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Initialize the debug serial object
|
// Initialize the debug serial object
|
||||||
Serial2.begin(115200, SERIAL_8N1, UART1_RX, UART1_TX);
|
Logger::Initialize(UART1_RX, UART1_TX);
|
||||||
Serial2.flush();
|
|
||||||
|
|
||||||
Serial2.print(F("\r=== ESP32 SimRacing DashDisplay ===\r\n"));
|
LOG_INFO(F("=== ESP32 SimRacing DashDisplay ===\r\n"));
|
||||||
|
LOG_INFO(F("* Initiating display\r\n"));
|
||||||
|
|
||||||
Serial2.print(F("* Initiating display\r\n"));
|
|
||||||
initialDisplaySetup(gfx);
|
initialDisplaySetup(gfx);
|
||||||
|
|
||||||
// Setup the relative
|
// Only setup the main screen after initializing the Serial2
|
||||||
// Define the width of the columns in number of chars
|
mainScreen.Setup("Main Window");
|
||||||
int *colW = (int *)malloc(sizeof(int) * 3);
|
UIElement *mainWindow = mainScreen.mainWindowHandle;
|
||||||
colW[0] = 3;
|
mainWindow->drawBox();
|
||||||
colW[1] = 18;
|
|
||||||
colW[2] = 9;
|
|
||||||
UITable *relative =
|
|
||||||
new UITable(gfx, UIDimensions(250, 250, 0, 0), relativeDecor, 5, 3, colW,
|
|
||||||
(char *)"Relative");
|
|
||||||
relativeDecor->textSize = 2;
|
|
||||||
relative->dims.x = gfx->width() - relative->dims.width;
|
|
||||||
relative->dims.y = gfx->height() - relative->dims.height;
|
|
||||||
relative->refreshRate = 750;
|
|
||||||
relative->setup();
|
|
||||||
relative->drawBox();
|
|
||||||
ui->relative = relative;
|
|
||||||
|
|
||||||
// Setup the rpmBar box
|
delay(500);
|
||||||
rpmBarDecor->textSize = 3;
|
LOG_INFO(F("* Ready for loop"));
|
||||||
rpmBar.dims.height = 50;
|
}
|
||||||
rpmBar.dims.width = 450;
|
|
||||||
rpmBar.horizontalCenter(nullptr);
|
const uint16_t PayloadMax = 2056;
|
||||||
rpmBar.dims.x += 10;
|
uint8_t payload[PayloadMax] = {0};
|
||||||
rpmBar.range = 8;
|
char lineBuffer[64]; // Enough for "XX XX XX XX XX XX XX XX "
|
||||||
rpmBar.refreshRate = 50;
|
//
|
||||||
ui->barTacho = &rpmBar;
|
void print_memory_stats() {
|
||||||
ui->barTacho->Box();
|
multi_heap_info_t info;
|
||||||
ui->barTacho->Update((char*)"");
|
|
||||||
|
// MALLOC_CAP_8BIT ensures we are looking at memory capable of
|
||||||
// Setup the rpmText box
|
// storing data (Internal RAM + PSRAM if available)
|
||||||
rpmTextDecor->textSize = 7;
|
heap_caps_get_info(&info, MALLOC_CAP_8BIT);
|
||||||
rpmText.dims.height =
|
|
||||||
calculateHeight(rpmTextDecor->titleSize, rpmTextDecor->textSize, 1);
|
size_t total_free = info.total_free_bytes;
|
||||||
rpmText.dims.width = calculateWidth(rpmTextDecor->textSize, 5);
|
size_t total_allocated = info.total_allocated_bytes;
|
||||||
rpmText.placeBelow(&rpmBar);
|
size_t total_size = total_free + total_allocated;
|
||||||
rpmText.horizontalCenter(&rpmBar);
|
size_t min_free = info.minimum_free_bytes; // "Low water mark"
|
||||||
rpmText.dims.y += 40; // We gotta fix how the bar declares its height instead
|
|
||||||
// of doing this here
|
LOG_INFO(F("Memory Stats:\r\n"));
|
||||||
rpmText.refreshRate = 100;
|
LOG_INFO(F(" Total: %u bytes\r\n"), total_size);
|
||||||
ui->digiTacho = &rpmText;
|
LOG_INFO(F(" Used: %u bytes\r\n"), total_allocated);
|
||||||
ui->digiTacho->drawBox();
|
LOG_INFO(F(" Free: %u bytes\r\n"), total_free);
|
||||||
ui->digiTacho->Update("-----");
|
LOG_INFO(F(" Min Free: %u bytes (Historic peak usage)\r\n"), min_free);
|
||||||
|
|
||||||
// Setup the speedText box
|
|
||||||
speedTextDecor->textSize = 4;
|
|
||||||
speedText.dims.height =
|
|
||||||
calculateHeight(speedTextDecor->titleSize, speedTextDecor->textSize, 1);
|
|
||||||
speedText.dims.width = calculateWidth(speedTextDecor->textSize, 4);
|
|
||||||
speedText.placeBelow(&rpmBar);
|
|
||||||
speedText.placeRight(&rpmText);
|
|
||||||
speedText.dims.y += 40; // We gotta fix how the bar declares its height
|
|
||||||
// instead of doing this here
|
|
||||||
ui->digiSpeedo = &speedText;
|
|
||||||
ui->digiSpeedo->drawBox();
|
|
||||||
ui->digiSpeedo->Update("---");
|
|
||||||
|
|
||||||
// Setup the gear text box
|
|
||||||
gearTextDecor->textSize = 7;
|
|
||||||
gearText.dims.height =
|
|
||||||
calculateHeight(gearTextDecor->titleSize, gearTextDecor->textSize, 1);
|
|
||||||
gearText.dims.width = calculateWidth(gearTextDecor->textSize, 2);
|
|
||||||
gearText.dims.y = rpmText.dims.height + 5;
|
|
||||||
gearText.placeLeft(&rpmText);
|
|
||||||
ui->digiGear = &gearText;
|
|
||||||
ui->digiGear->drawBox();
|
|
||||||
ui->digiGear->Update("-");
|
|
||||||
|
|
||||||
// Setup the lap delta box
|
|
||||||
lapDeltaDecor->textSize = 3;
|
|
||||||
lapDelta.dims.height =
|
|
||||||
calculateHeight(lapDeltaDecor->titleSize, lapDeltaDecor->textSize, 1);
|
|
||||||
lapDelta.dims.width = calculateWidth(lapDeltaDecor->textSize, 6);
|
|
||||||
lapDelta.placeBelow(&rpmText);
|
|
||||||
lapDelta.horizontalCenter(&rpmText);
|
|
||||||
ui->lapDelta = &lapDelta;
|
|
||||||
ui->lapDelta->drawBox();
|
|
||||||
ui->lapDelta->Update("--.-");
|
|
||||||
|
|
||||||
// Setup the best lap box
|
|
||||||
bestLapDecor->textSize = 3;
|
|
||||||
bestLap.dims.height =
|
|
||||||
calculateHeight(bestLapDecor->titleSize, bestLapDecor->textSize, 1);
|
|
||||||
bestLap.dims.width = calculateWidth(bestLapDecor->textSize, 8);
|
|
||||||
ui->bestLap = &bestLap;
|
|
||||||
ui->bestLap->drawBox();
|
|
||||||
ui->bestLap->Update("--:--.--");
|
|
||||||
|
|
||||||
// Setup the last lap box
|
|
||||||
lastLapDecor->textSize = 3;
|
|
||||||
lastLap.dims.height =
|
|
||||||
calculateHeight(lastLapDecor->titleSize, lastLapDecor->textSize, 1);
|
|
||||||
lastLap.dims.width = calculateWidth(lastLapDecor->textSize, 8);
|
|
||||||
lastLap.placeBelow(&bestLap);
|
|
||||||
ui->lastLap = &lastLap;
|
|
||||||
ui->lastLap->drawBox();
|
|
||||||
ui->lastLap->Update("--:--.--");
|
|
||||||
|
|
||||||
// Setup the cur lap box
|
|
||||||
curLapDecor->textSize = 3;
|
|
||||||
curLap.dims.height =
|
|
||||||
calculateHeight(curLapDecor->titleSize, curLapDecor->textSize, 1);
|
|
||||||
curLap.dims.width = calculateWidth(curLapDecor->textSize, 8);
|
|
||||||
curLap.placeBelow(&lastLap);
|
|
||||||
ui->curLap = &curLap;
|
|
||||||
ui->curLap->drawBox();
|
|
||||||
ui->curLap->Update("--:--.--");
|
|
||||||
|
|
||||||
// Fuel tank
|
|
||||||
fuelTankDecor->textSize = 3;
|
|
||||||
fuelTank.dims.height =
|
|
||||||
calculateHeight(fuelTankDecor->titleSize, fuelTankDecor->textSize, 1);
|
|
||||||
fuelTank.dims.width = calculateWidth(fuelTankDecor->textSize, 12);
|
|
||||||
fuelTank.placeBelow(&curLap);
|
|
||||||
ui->fuelTank = &fuelTank;
|
|
||||||
ui->fuelTank->drawBox();
|
|
||||||
ui->fuelTank->Update("--- / ---");
|
|
||||||
|
|
||||||
// Fuel consumption
|
|
||||||
fuelConsumptionDecor->textSize = 3;
|
|
||||||
fuelConsumption.dims.height = calculateHeight(
|
|
||||||
fuelConsumptionDecor->titleSize, fuelConsumptionDecor->textSize, 1);
|
|
||||||
fuelConsumption.dims.width =
|
|
||||||
calculateWidth(fuelConsumptionDecor->textSize, 12);
|
|
||||||
fuelConsumption.placeBelow(&fuelTank);
|
|
||||||
ui->fuelConsumption = &fuelConsumption;
|
|
||||||
ui->fuelConsumption->drawBox();
|
|
||||||
ui->fuelConsumption->Update("--.- | --.-");
|
|
||||||
|
|
||||||
// Brake bias
|
|
||||||
brakeBiasDecor->textSize = 3;
|
|
||||||
brakeBias.dims.height =
|
|
||||||
calculateHeight(brakeBiasDecor->titleSize, brakeBiasDecor->textSize, 1);
|
|
||||||
brakeBias.dims.width = calculateWidth(brakeBiasDecor->textSize, 5);
|
|
||||||
brakeBias.placeBelow(&fuelConsumption);
|
|
||||||
ui->brakeBias = &brakeBias;
|
|
||||||
ui->brakeBias->drawBox();
|
|
||||||
ui->brakeBias->Update("--.-");
|
|
||||||
|
|
||||||
// const char *words[] = {"hel", "wor", "why", "is", "thi", "hap", "to",
|
|
||||||
// "me"};
|
|
||||||
//
|
|
||||||
// int wIndex = 0;
|
|
||||||
// while (1) {
|
|
||||||
// for (int row = 0; row < ROWS; row++) {
|
|
||||||
// for (int col = 0; col < COLUMNS; col++) {
|
|
||||||
// ui->relative->tableData[row * COLUMNS +
|
|
||||||
// col]->Update(words[wIndex++]); if (wIndex >= 8) {
|
|
||||||
// wIndex = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// nvs_handle_t handle;
|
|
||||||
// nvs_open("storage", NVS_READWRITE, &handle);
|
|
||||||
// nvs_set_i32(handle, "counter", 42);
|
|
||||||
// nvs_commit(handle);
|
|
||||||
// nvs_close(handle);
|
|
||||||
|
|
||||||
Serial2.println("* Ready for loop");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t lastDataRead = 0;
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
// Request data here
|
uint64_t cur = millis();
|
||||||
SendDataRequest();
|
|
||||||
|
|
||||||
// Receive data
|
Command cmd = CmdUnknown;
|
||||||
DataPacket telemetryPacket;
|
|
||||||
int res = RecvDataPacket(&telemetryPacket);
|
|
||||||
|
|
||||||
if (res == 0) {
|
if (Serial.available() > 0) {
|
||||||
ui->Update(&telemetryPacket);
|
int16_t resp = WalkieTalkie::RecvStream(&cmd, payload, PayloadMax);
|
||||||
|
if (resp < 0) {
|
||||||
|
LOG_WARN(F("Failed to receive data from serial"));
|
||||||
|
return;
|
||||||
|
} else if (resp == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lastDataRead = millis();
|
LOG_DEBUG(F("Command: %s\n"), CommandToStr(cmd));
|
||||||
}
|
LOG_DEBUG(F("Response Payload Len: %d\n"), resp);
|
||||||
|
|
||||||
// If no data is received for 5 seconds, reset the display
|
// print_memory_stats();
|
||||||
if (millis() - lastDataRead >= 5000) {
|
|
||||||
// ui.speedometer->Update(0);
|
switch(cmd) {
|
||||||
// ui.numberTach->Update(0);
|
case CmdRequestID:
|
||||||
// ui.gear->Update(0);
|
IdentificationPacket papers;
|
||||||
// ui.barTach->Update(0);
|
initIdentificationPacket(&papers, ESLABS_DEVICE_NAME, ESLABS_DEVICE_ID);
|
||||||
|
WalkieTalkie::SendData(&papers);
|
||||||
|
break;
|
||||||
|
case CmdCreateWindow: {
|
||||||
|
int8_t newWindowID = Window::Create(payload, &mainScreen);
|
||||||
|
if (newWindowID < 0) {
|
||||||
|
LOG_WARN(F("Failed to add new window!\n"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO(F("Successfully added a new window: %d\n"), newWindowID);
|
||||||
|
|
||||||
|
// Now we return the ID of this new window - esdi should expect it
|
||||||
|
WindowIDReply wID;
|
||||||
|
initWindowIDReply(&wID, newWindowID);
|
||||||
|
WalkieTalkie::SendData(&wID);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CmdUpdateWinDims: {
|
||||||
|
LOG_INFO(F("Updating Win DIMS\n"));
|
||||||
|
bool res = Window::UpdateDims(payload, &mainScreen);
|
||||||
|
if (!res) {
|
||||||
|
LOG_WARN(F("Failed to update window dims\n"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
case CmdUpdateWin: {
|
||||||
|
LOG_INFO(F("UPDATEING WINDOW\n"));
|
||||||
|
bool res = Window::UpdateWindow(payload, &mainScreen);
|
||||||
|
if (!res) {
|
||||||
|
LOG_WARN(F("Failed to update window\n"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CmdDestroyWindow: {
|
||||||
|
uint8_t destroyedWinID = Window::Destroy(payload, &mainScreen);
|
||||||
|
if (destroyedWinID < 0) {
|
||||||
|
LOG_WARN(F("Failed to destroy window\n"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO(F("Succesfully destroyed window: %d\n"), destroyedWinID);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMDData: {
|
||||||
|
LOG_DEBUG(F("Data Received: %d bytes\r\n"), resp);
|
||||||
|
|
||||||
|
// int pos = 0;
|
||||||
|
// for (int k = 0; k < resp; k++) {
|
||||||
|
// // Write 2 hex digits and a space to our local buffer
|
||||||
|
// // %02X ensures leading zeros (e.g., 0A instead of A)
|
||||||
|
// pos += sprintf(lineBuffer + pos, "%02X ", payload[k]);
|
||||||
|
//
|
||||||
|
// // Every 8 bytes OR if it's the very last byte in the payload
|
||||||
|
// if ((k + 1) % 8 == 0 || k == resp - 1) {
|
||||||
|
// // Send the completed line to the logger
|
||||||
|
// // We use LOG_DEBUG or similar so we don't spam [WARN] on every line
|
||||||
|
// LOG_DEBUG(F("%s\r\n"), lineBuffer);
|
||||||
|
//
|
||||||
|
// // Reset buffer position for the next line
|
||||||
|
// pos = 0;
|
||||||
|
// memset(lineBuffer, 0, sizeof(lineBuffer));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// LOG_DEBUG(F("\r\n"));
|
||||||
|
|
||||||
|
Data::Parse(payload, resp, &mainScreen);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
LOG_ERROR(F("Command: %s\n"), CommandToStr(cmd));
|
||||||
|
LOG_ERROR(F("Unknown Command: `%02X` has not been implemented yet.\n"), cmd);
|
||||||
|
int pos = 0;
|
||||||
|
for (int k = 0; k < resp; k++) {
|
||||||
|
// Write 2 hex digits and a space to our local buffer
|
||||||
|
// %02X ensures leading zeros (e.g., 0A instead of A)
|
||||||
|
pos += sprintf(lineBuffer + pos, "%02X ", payload[k]);
|
||||||
|
|
||||||
|
// Every 8 bytes OR if it's the very last byte in the payload
|
||||||
|
if ((k + 1) % 8 == 0 || k == resp - 1) {
|
||||||
|
// Send the completed line to the logger
|
||||||
|
// We use LOG_DEBUG or similar so we don't spam [WARN] on every line
|
||||||
|
LOG_WARN(F("%s\r\n"), lineBuffer);
|
||||||
|
|
||||||
|
// Reset buffer position for the next line
|
||||||
|
pos = 0;
|
||||||
|
memset(lineBuffer, 0, sizeof(lineBuffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG_WARN(F("\r\n"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,342 @@
|
|||||||
|
#include "methods.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "UIBar.h"
|
||||||
|
#include "UIDecorations.h"
|
||||||
|
#include "UIDrawing.h"
|
||||||
|
#include "communication/packets.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "UIComponent.h"
|
||||||
|
#include "UIScreen.h"
|
||||||
|
#include "values.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
// Window creation
|
||||||
|
void printUIDimsPacket(UIDimensions *dims) {
|
||||||
|
LOG_INFO(F(" Dimensions:\n"));
|
||||||
|
LOG_INFO(F(" X0 : %d\n"), dims->x);
|
||||||
|
LOG_INFO(F(" Y0 : %d\n"), dims->y);
|
||||||
|
LOG_INFO(F(" Width : %d\n"), dims->width);
|
||||||
|
LOG_INFO(F(" Height: %d\n"), dims->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printUIDecorPacket(UIDecorations *decor) {
|
||||||
|
LOG_INFO(F(" Decorations:\n"));
|
||||||
|
LOG_INFO(F(" HasBorder : %d\n"), decor->hasBorder);
|
||||||
|
LOG_INFO(F(" BGColour : %d\n"), decor->bgColor);
|
||||||
|
LOG_INFO(F(" FGColour : %d\n"), decor->fgColor);
|
||||||
|
LOG_INFO(F(" TitleColour : %d\n"), decor->titleColor);
|
||||||
|
LOG_INFO(F(" BorderColour: %d\n"), decor->borderColor);
|
||||||
|
LOG_INFO(F(" TitleSize : %d\n"), decor->titleSize);
|
||||||
|
LOG_INFO(F(" TextSize : %d\n"), decor->textSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printUIOptionsPacket(UIWindowOpts* opts) {
|
||||||
|
LOG_INFO(F(" Options:\n"));
|
||||||
|
LOG_INFO(F(" ShowID : %d\n"), opts->ShowID);
|
||||||
|
LOG_INFO(F(" Type : %d\n"), opts->WinType);
|
||||||
|
LOG_INFO(F(" PreviewValue: %s\n"), opts->PreviewValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printUIWindowPacket(UICreateWindowPacket *win) {
|
||||||
|
LOG_INFO(F("New window:\n"));
|
||||||
|
printUIDimsPacket(&win->dims);
|
||||||
|
printUIDecorPacket(&win->decor);
|
||||||
|
printUIOptionsPacket(&win->opts);
|
||||||
|
LOG_INFO(F(" Title: %s\n"), win->title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printUpdateDimsPacket(UpdateDimsPacket *pkt) {
|
||||||
|
LOG_INFO(F("NEW DIMENSIONS:\n"));
|
||||||
|
LOG_INFO(F(" TARGET WINDOW: %d\n"), pkt->wID);
|
||||||
|
printUIDimsPacket(&pkt->dims);
|
||||||
|
}
|
||||||
|
|
||||||
|
UICreateWindowPacket::UICreateWindowPacket() {}
|
||||||
|
|
||||||
|
void setTitleWithOpts(UICreateWindowPacket* win, UIElement* elem, int16_t ID) {
|
||||||
|
if (win->opts.ShowID == ShowIDTrue) {
|
||||||
|
elem->SetTitle((char *)"%s [%2d]", (const char *)win->title, ID);
|
||||||
|
} else {
|
||||||
|
elem->SetTitle((char *)"%s", (const char *)win->title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t Create(uint8_t *payload, Curses::Screen *mainScreen) {
|
||||||
|
// Load the payload into a struct
|
||||||
|
UICreateWindowPacket win;
|
||||||
|
// Maybe find a better way to copy this - if we had metadata to the payload
|
||||||
|
// for example
|
||||||
|
memcpy((void*)&win, payload, sizeof(UICreateWindowPacket));
|
||||||
|
printUIWindowPacket(&win);
|
||||||
|
|
||||||
|
UIElement *mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
int16_t childID = mainWindow->AddChild((ComponentType)win.opts.WinType);
|
||||||
|
if (childID < 0) {
|
||||||
|
LOG_DEBUG(F("COULD NOT ADD CHILD\r\n"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIElement *childComponent = mainWindow->GetChild(childID);
|
||||||
|
|
||||||
|
setTitleWithOpts(&win, childComponent, childID);
|
||||||
|
|
||||||
|
// This are universal things
|
||||||
|
childComponent->SetUIDecorations(win.decor);
|
||||||
|
childComponent->SetUIDimensions(UIDimensions(win.dims.x, win.dims.y,
|
||||||
|
win.dims.width, win.dims.height));
|
||||||
|
childComponent->SetDisplay(mainScreen->display);
|
||||||
|
|
||||||
|
// NOTE: if I move to a composition style thing I guess I can do all this
|
||||||
|
// setup at start up time.
|
||||||
|
// I can also just have a base void* chunk of data with options I send to
|
||||||
|
// each UI type and the UI type handles it somehow, we'll see
|
||||||
|
// Handle each type of window
|
||||||
|
switch ((ComponentType)win.opts.WinType) {
|
||||||
|
case STRING:
|
||||||
|
LOG_DEBUG(F("Setting up the STRING type UIWindow\r\n"));
|
||||||
|
childComponent->drawBox();
|
||||||
|
break;
|
||||||
|
case BAR: {
|
||||||
|
LOG_DEBUG(F("Setting up the BAR type UIWindow\r\n"));
|
||||||
|
UIBar* bar = (UIBar*)childComponent;
|
||||||
|
|
||||||
|
bar->range = 9;
|
||||||
|
bar->drawBox();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
childComponent->Update(win.opts.PreviewValue, true);
|
||||||
|
|
||||||
|
return childID;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateDims(uint8_t *payload, Curses::Screen *mainScreen) {
|
||||||
|
UpdateDimsPacket pkt;
|
||||||
|
memcpy((void*)&pkt, payload, sizeof(UpdateDimsPacket));
|
||||||
|
printUpdateDimsPacket(&pkt);
|
||||||
|
|
||||||
|
UIElement *mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
UIElement* win = mainWindow->GetChild(pkt.wID);
|
||||||
|
if (win == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the old window
|
||||||
|
fillRect(win->dims.x, win->dims.y, win->dims.width,
|
||||||
|
win->dims.height, win->decor.bgColor, win->display);
|
||||||
|
|
||||||
|
// Update the windows dimensions
|
||||||
|
win->dims = pkt.dims;
|
||||||
|
|
||||||
|
LOG_DEBUG(F("Win Type is: %d\r\n"), win->type);
|
||||||
|
|
||||||
|
// Redraw the window
|
||||||
|
switch ((ComponentType)win->type) {
|
||||||
|
case STRING:
|
||||||
|
win->drawBox();
|
||||||
|
break;
|
||||||
|
case BAR:
|
||||||
|
{
|
||||||
|
LOG_DEBUG(F("Updating UIBar dimensions\r\n"));
|
||||||
|
UIBar* bar = (UIBar*)win;
|
||||||
|
bar->drawBox();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
win->Redraw();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateWindow(uint8_t *payload, Curses::Screen *mainScreen) {
|
||||||
|
UIUpdateWindowPacket pkt;
|
||||||
|
memcpy((void*)&pkt, payload, sizeof(UICreateWindowPacket));
|
||||||
|
|
||||||
|
printUIWindowPacket(&pkt.data);
|
||||||
|
|
||||||
|
UIElement* mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
UIElement* win = mainWindow->GetChild(pkt.WinID);
|
||||||
|
if (win == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the old window
|
||||||
|
fillRect(win->dims.x, win->dims.y, win->dims.width,
|
||||||
|
win->dims.height, win->decor.bgColor, win->display);
|
||||||
|
|
||||||
|
// Update the windows dimensons, decor and title
|
||||||
|
win->dims = pkt.data.dims;
|
||||||
|
win->decor = pkt.data.decor;
|
||||||
|
setTitleWithOpts(&pkt.data, win, pkt.WinID);
|
||||||
|
|
||||||
|
switch ((ComponentType)win->type) {
|
||||||
|
case STRING:
|
||||||
|
win->drawBox();
|
||||||
|
break;
|
||||||
|
case BAR:
|
||||||
|
{
|
||||||
|
LOG_DEBUG(F("Updating UIBar\r\n"));
|
||||||
|
UIBar* bar = (UIBar*)win;
|
||||||
|
bar->drawBox();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
win->Update(pkt.data.opts.PreviewValue, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Window destruction
|
||||||
|
void printUIDestroyWindowPacket(UIDestroyWindowPacket *win) {
|
||||||
|
LOG_INFO(F("Destroy window:\n"));
|
||||||
|
LOG_INFO(F(" WinID: %d\n"), win->WinID);
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t Destroy(uint8_t *payload, Curses::Screen *mainScreen) {
|
||||||
|
UIDestroyWindowPacket win;
|
||||||
|
memcpy(&win, payload, sizeof(UIDestroyWindowPacket));
|
||||||
|
printUIDestroyWindowPacket(&win);
|
||||||
|
|
||||||
|
UIElement *mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
mainWindow->RemoveChild(win.WinID);
|
||||||
|
|
||||||
|
return win.WinID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
char buffer[128];
|
||||||
|
char strValue[128];
|
||||||
|
|
||||||
|
uint8_t Parse(uint8_t *payload, size_t payloadSize, Curses::Screen* mainScreen) {
|
||||||
|
uint16_t curPos = 0;
|
||||||
|
|
||||||
|
for (; curPos < payloadSize;) {
|
||||||
|
// Get the data type from the current position
|
||||||
|
int16_t wID;
|
||||||
|
memcpy(&wID, payload + curPos, 2);
|
||||||
|
curPos += 2;
|
||||||
|
|
||||||
|
uint8_t type = payload[curPos];
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case DataTypeUINT8: {
|
||||||
|
uint8_t value = payload[curPos + 1];
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
|
||||||
|
sprintf(buffer, "%d", value);
|
||||||
|
|
||||||
|
curPos += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeINT8: {
|
||||||
|
int8_t value = (int8_t)payload[curPos + 1];
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
|
||||||
|
sprintf(buffer, "%d", value);
|
||||||
|
|
||||||
|
curPos += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeUINT16: {
|
||||||
|
uint16_t value;
|
||||||
|
memcpy(&value, payload + curPos + 1, 2);
|
||||||
|
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%d", value);
|
||||||
|
|
||||||
|
curPos += 3; // 1 (Type) + 2 (Value)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeINT16: {
|
||||||
|
int16_t value;
|
||||||
|
memcpy(&value, payload + curPos + 1, 2);
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%d", value);
|
||||||
|
|
||||||
|
curPos += 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeUINT32: {
|
||||||
|
uint32_t value;
|
||||||
|
memcpy(&value, payload + curPos + 1, 4);
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%d", value);
|
||||||
|
|
||||||
|
curPos += 5; // 1 (Type) + 4 (Value)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeINT32: {
|
||||||
|
int32_t value;
|
||||||
|
memcpy(&value, payload + curPos + 1, 4);
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%d", value);
|
||||||
|
|
||||||
|
curPos += 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeUINT64: {
|
||||||
|
uint64_t value;
|
||||||
|
memcpy(&value, payload + curPos + 1, 8);
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%ld", value);
|
||||||
|
|
||||||
|
curPos += 9; // 1 (Type) + 8 (Value)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeINT64: {
|
||||||
|
int64_t value;
|
||||||
|
memcpy(&value, payload + curPos + 1, 8);
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %d\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%ld", value);
|
||||||
|
|
||||||
|
curPos += 9;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeCHAR: {
|
||||||
|
uint8_t value = payload[curPos + 1];
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %c\r\n"), type, wID, value);
|
||||||
|
sprintf(buffer, "%c", value);
|
||||||
|
|
||||||
|
curPos += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataTypeSTRING: {
|
||||||
|
// Strings have: Type (1), Len (1), Data (Len)
|
||||||
|
uint8_t len = payload[curPos + 1];
|
||||||
|
memcpy(strValue, payload + curPos + 2, len);
|
||||||
|
strValue[len] = '\0'; // Null terminator
|
||||||
|
//
|
||||||
|
LOG_DEBUG(F("[0x%02X] RECEIVED [%2d]: %s\r\n"), type, wID, strValue);
|
||||||
|
sprintf(buffer, "%s", strValue);
|
||||||
|
|
||||||
|
curPos += (2 + len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// If we hit an unknown type, we are desynced.
|
||||||
|
// Better to stop than to read garbage.
|
||||||
|
LOG_ERROR(F("Unknown Type 0x%02X at pos %d\r\n"), type, curPos);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the window value here
|
||||||
|
UIElement* mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
UIElement* win = mainWindow->GetChild(wID);
|
||||||
|
if (win == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
win->Update(buffer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
#ifndef __METHODS__
|
||||||
|
#define __METHODS__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "UIScreen.h"
|
||||||
|
#include "UIDimensions.h"
|
||||||
|
#include "UIDecorations.h"
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
const uint8_t ShowIDFalse = 0;
|
||||||
|
const uint8_t ShowIDTrue = 1;
|
||||||
|
|
||||||
|
struct UIWindowOpts {
|
||||||
|
uint8_t ShowID;
|
||||||
|
uint8_t WinType;
|
||||||
|
// NOTE: I recon we need to change this yo
|
||||||
|
char PreviewValue[32];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Window creation
|
||||||
|
struct UICreateWindowPacket {
|
||||||
|
UIDimensions dims;
|
||||||
|
UIDecorations decor;
|
||||||
|
UIWindowOpts opts;
|
||||||
|
char title[32]; // Note: we optimize this type of data transfer if necessary
|
||||||
|
// we are sending 32 - len(title) extra bytes everytime
|
||||||
|
|
||||||
|
UICreateWindowPacket();
|
||||||
|
};
|
||||||
|
|
||||||
|
void printUIWindowPacket(UICreateWindowPacket *win);
|
||||||
|
int8_t Create(uint8_t *payload, Curses::Screen *mainScreen);
|
||||||
|
|
||||||
|
// Window destruction
|
||||||
|
struct UIDestroyWindowPacket {
|
||||||
|
int16_t WinID;
|
||||||
|
};
|
||||||
|
|
||||||
|
void printUIDestroyWindowPacket(UIDestroyWindowPacket *win);
|
||||||
|
int8_t Destroy(uint8_t *payload, Curses::Screen *mainScreen);
|
||||||
|
|
||||||
|
// NOTE: if I make the window update send these fields with the current
|
||||||
|
// values I can reduce the code for this to a single struct instead I reckon
|
||||||
|
// Window Dimensions Updates
|
||||||
|
struct UpdateDimsPacket {
|
||||||
|
int16_t wID;
|
||||||
|
UIDimensions dims;
|
||||||
|
};
|
||||||
|
|
||||||
|
void printUpdateDimsPacket(UpdateDimsPacket *pkt);
|
||||||
|
bool UpdateDims(uint8_t *payload, Curses::Screen *mainScreen);
|
||||||
|
|
||||||
|
struct UIUpdateWindowPacket {
|
||||||
|
int16_t WinID;
|
||||||
|
UICreateWindowPacket data;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool UpdateWindow(uint8_t *payload, Curses::Screen *mainScreen);
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Screen {
|
||||||
|
struct UICreateScreenPacket{
|
||||||
|
uint16_t x0;
|
||||||
|
uint16_t y0;
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
char title[32]; // Note: we optimize this type of data transfer if necessary
|
||||||
|
// we are sending 32 - len(title) extra bytes everytime
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
typedef uint8_t DataType;
|
||||||
|
const DataType DataTypeUINT8 = 0;
|
||||||
|
const DataType DataTypeINT8 = 1;
|
||||||
|
const DataType DataTypeUINT16 = 2;
|
||||||
|
const DataType DataTypeINT16 = 3;
|
||||||
|
const DataType DataTypeUINT32 = 4;
|
||||||
|
const DataType DataTypeINT32 = 5;
|
||||||
|
const DataType DataTypeUINT64 = 6;
|
||||||
|
const DataType DataTypeINT64 = 7;
|
||||||
|
const DataType DataTypeSTRING = 8;
|
||||||
|
const DataType DataTypeCHAR = 9;
|
||||||
|
|
||||||
|
uint8_t Parse(uint8_t *payload, size_t payloadSize, Curses::Screen* mainScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+26
-27
@@ -1,27 +1,26 @@
|
|||||||
#include "ui.h"
|
// #include "ui.h"
|
||||||
#include "HardwareSerial.h"
|
// #include "HardwareSerial.h"
|
||||||
#include "data.h"
|
// #include <cstdint>
|
||||||
#include <cstdint>
|
//
|
||||||
|
// DashUI::DashUI() {}
|
||||||
DashUI::DashUI() {}
|
//
|
||||||
|
// void DashUI::Update(DataPacket *p) {
|
||||||
void DashUI::Update(DataPacket *p) {
|
// this->barTacho->Update(p->rpm);
|
||||||
this->barTacho->Update(p->rpm);
|
// this->digiTacho->Update(p->rpm);
|
||||||
this->digiTacho->Update(p->rpm);
|
// this->digiSpeedo->Update(p->speed);
|
||||||
this->digiSpeedo->Update(p->speed);
|
// this->digiGear->Update(p->gear);
|
||||||
this->digiGear->Update(p->gear);
|
// this->lapDelta->Update(p->DeltaToBestLap);
|
||||||
this->lapDelta->Update(p->DeltaToBestLap);
|
// this->bestLap->Update(p->bestLapTime);
|
||||||
this->bestLap->Update(p->bestLapTime);
|
// this->curLap->Update(p->currLapTime);
|
||||||
this->curLap->Update(p->currLapTime);
|
// this->lastLap->Update(p->lastLapTime);
|
||||||
this->lastLap->Update(p->lastLapTime);
|
// this->fuelConsumption->Update(p->FuelEst);
|
||||||
this->fuelConsumption->Update(p->FuelEst);
|
// this->brakeBias->Update(p->brakeBias);
|
||||||
this->brakeBias->Update(p->brakeBias);
|
//
|
||||||
|
// for (int row = 0; row < ROWS; row++) {
|
||||||
for (int row = 0; row < ROWS; row++) {
|
// this->relative->tableData[row * COLUMNS + 0]->Update(p->standings[row].Lap);
|
||||||
this->relative->tableData[row * COLUMNS + 0]->Update(p->standings[row].Lap);
|
// this->relative->tableData[row * COLUMNS + 1]->Update(
|
||||||
this->relative->tableData[row * COLUMNS + 1]->Update(
|
// p->standings[row].DriverName);
|
||||||
p->standings[row].DriverName);
|
// this->relative->tableData[row * COLUMNS + 2]->Update(
|
||||||
this->relative->tableData[row * COLUMNS + 2]->Update(
|
// p->standings[row].TimeBehindString);
|
||||||
p->standings[row].TimeBehindString);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
#ifndef __DASH_DISPLAY_UI
|
// #ifndef __DASH_DISPLAY_UI
|
||||||
#define __DASH_DISPLAY_UI
|
// #define __DASH_DISPLAY_UI
|
||||||
|
//
|
||||||
#include "Arduino_GFX.h"
|
// #include "Arduino_GFX.h"
|
||||||
#include "UIString.h"
|
// #include "UIString.h"
|
||||||
#include "UITable.h"
|
// #include "UITable.h"
|
||||||
#include "UIBar.h"
|
// #include "UIBar.h"
|
||||||
#include "data.h"
|
// #include "data.h"
|
||||||
|
//
|
||||||
struct DashUI {
|
// struct DashUI {
|
||||||
UIBar *barTacho;
|
// UIBar *barTacho;
|
||||||
UIString *digiTacho;
|
// UIString *digiTacho;
|
||||||
UIString *digiSpeedo;
|
// UIString *digiSpeedo;
|
||||||
UIString *digiGear;
|
// UIString *digiGear;
|
||||||
UIString *lapDelta;
|
// UIString *lapDelta;
|
||||||
UIString *bestLap;
|
// UIString *bestLap;
|
||||||
UIString *lastLap;
|
// UIString *lastLap;
|
||||||
UIString *curLap;
|
// UIString *curLap;
|
||||||
UIString *fuelTank;
|
// UIString *fuelTank;
|
||||||
UIString *fuelConsumption;
|
// UIString *fuelConsumption;
|
||||||
UIString *brakeBias;
|
// UIString *brakeBias;
|
||||||
UITable *relative;
|
// UITable *relative;
|
||||||
|
//
|
||||||
DashUI();
|
// DashUI();
|
||||||
void Update(DataPacket *p);
|
// void Update(DataPacket *p);
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
#endif
|
// #endif
|
||||||
|
|||||||
Reference in New Issue
Block a user