Porównaj commity

...

31 Commity
v0.2 ... main

Autor SHA1 Wiadomość Data
dgatf 8d1ad4903e Delete files 2023-10-17 06:48:13 -04:00
Daniel Gorbea 6b27a3a53d Update to v0.3 2022-03-06 23:15:49 -05:00
DanielGeA 78d468c5e0 Add Android icon 2021-11-24 16:38:20 -05:00
DanielGeA 40c0440578 Cosmetics 2021-11-24 12:05:14 -05:00
DanielGeA d1b5d9540b Update image 2021-11-24 12:01:49 -05:00
DanielGeA f07ddf3cfc Upgrade to Qml gui (#1)
* Upgrade to qml gui

* Remove binaries

* Update image

* Update image

* Some fixes

* Delete oscilloscope_win_resource.rc

* Update

* Update image

* Update

* Update

* Update

* Update

* Remove console and avoid double free

* Some fixes

* Fix menu

* Cosmetics

* Upgrade to qml gui

* Update image

* Some fixes

* Delete oscilloscope_win_resource.rc

* Update

* Update image

* Update

* Update

* Update

* Update

* Remove console and avoid double free

* Some fixes

* Fix menu

* Cosmetics
2021-11-24 11:58:23 -05:00
DanielGeA d74659643b Cosmetics 2021-11-20 22:34:10 -05:00
DanielGeA 38af7c34d6 Remove binaries 2021-11-20 22:22:43 -05:00
DanielGeA 04950b5fa8 Cosmetics 2021-11-20 22:08:36 -05:00
DanielGeA ef8d708148 Fix linux binary 2021-11-20 18:49:13 -05:00
Daniel Gorbea b6b7a0b05c Fix exit icon 2021-11-07 20:38:01 -05:00
Daniel Gorbea dfb4adf042 Cosmetics 2021-11-07 19:33:13 -05:00
Daniel Gorbea 8c2e58b82b Add Android support 2021-11-07 19:30:55 -05:00
DanielGeA 2d83e05126 Delete debug_terminal 2021-11-03 23:39:46 -05:00
Daniel Gorbea 7c63b3cc00 Improve gui 2021-11-03 23:35:26 -05:00
Daniel Gorbea 96ecf69372 Update images 2021-11-03 22:44:39 -05:00
Daniel Gorbea 860f1a3016 Improve gui 2021-11-03 22:41:25 -05:00
Daniel Gorbea 87d4df5d67 Improve gui 2021-11-03 17:52:55 -05:00
Daniel Gorbea b24442cf00 Update 2021-11-01 13:44:48 -05:00
Daniel Gorbea 4fa2865460 Update 2021-11-01 13:42:35 -05:00
Daniel Gorbea c6b02e3f2b Update 2021-10-31 07:42:01 -05:00
Daniel Gorbea 601fbfd162 Update 2021-10-30 23:17:09 -05:00
Daniel Gorbea a478211509 Update 2021-10-30 23:15:08 -05:00
Daniel Gorbea e9972685a4 Update 2021-10-30 17:03:51 -05:00
Daniel Gorbea 6eb9a35a86 Update 2021-10-30 16:48:15 -05:00
Daniel Gorbea d20c792961 Update 2021-10-30 16:39:02 -05:00
Daniel Gorbea 6752913ceb Update 2021-10-30 16:35:42 -05:00
Daniel Gorbea 7fb759369c Update 2021-10-30 16:33:57 -05:00
Daniel Gorbea 195803eb1a Update 2021-10-30 16:03:06 -05:00
Daniel Gorbea 9a957e0077 Add image 2021-10-29 19:24:35 -05:00
DanielGeA ca6e7871ea Delete oscilloscope.pro.user 2021-10-29 19:14:23 -05:00
70 zmienionych plików z 3312 dodań i 1601 usunięć

675
LICENSE 100644
Wyświetl plik

@ -0,0 +1,675 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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:
{{ project }} Copyright (C) {{ year }} {{ organization }}
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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

Wyświetl plik

@ -1 +1,55 @@
# Oscilloscope Serial
An oscilloscope application that reads the values at serial port generated by an Arduino board and based on the value of the analog pin A0 (A5 for Leonardo)
<p align="center"><img src="./images/img1.png" width="600"><br>
<i>Main window</i><br><br></p>
<p align="center"><img src="./images/img2.png" width="300"><br>
<i>Settings</i><br><br></p>
<p align="center"><img src="./images/img3.jpg" width="400"><br>
<i>Main window Android</i><br><br></p>
The Arduino sketch is optimized for AVR ATmega MCUs with 26μs sampling resolution. For other boards the resolution is 200μs. Voltage resolution is 20mV.
Flash _oscilloscope_. In the Oscilloscope app configure the serial port. By default 1000000bps, 8bits and no parity. Interval is 26μs for AVR ATmega and 200μs for other MCUs. Any source (1byte) at serial is valid.
You can connect any signal up to 5 volts to the analog pin A0. For signals over 5V a voltage divider is needed.
For ATmega boards it is defined a PWM signal at pin OC1B. To test the Oscilloscope app connect pin OC1B to pin A0/A5
Adjust PWM signal with PWM_FREQ and PWM_DUTY. Default is 1000Hz, 50% duty.
Pin OC1B location:
- Uno: pin 10 (PB2)
- Leonardo: pin 10 (PB6)
- ATmega2560: pin 12 (PB6)
Find binaries [here](https://github.com/dgatf/Oscilloscope/releases)
Or build from sources:
- install qt (>=5.15)
- cd to src/qt folder
- qmake
- make
Supported OS:
- Linux
- Windows
- Android
- MacOS (untested)
## Change log:
v0.3
- Minor fixes
[v0.2](https://github.com/dgatf/Oscilloscope/releases/tag/v0.2)
- Upgrade to qml gui
- Add csv export
- Improve android support
[v0.1](https://github.com/dgatf/Oscilloscope/releases/tag/v0.1)
- Initial release

BIN
images/img1.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 33 KiB

BIN
images/img2.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 30 KiB

BIN
images/img3.jpg 100755

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 348 KiB

Wyświetl plik

@ -1,31 +1,240 @@
//uint8_t val = 5;
#define serial Serial
/* PWM signal */
#define PWM_FREQ 20000 // HZ (1000HZ=1ms)
#define PWM_DUTY 0.5 // %/100
/* Capture buffer */
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__)
#define BUFFER_LEN 1500
#endif
#if defined(__AVR_ATmega32U4__)
#define BUFFER_LEN 2000
#endif
#if defined(__AVR_ATmega2560__)
#define BUFFER_LEN 5000
#endif
/* Data bits */
#define DATABITS 8 // 8, (4), 1
/* ADC Prescaler */
#define PRESCALER 32 // 32, 16, 8, (4)
/* Mode */
#define REALTIME 0
#define CAPTURE 1
#define MODE REALTIME // REALTIME, CAPTURE
#define MS_TO_COMP(SCALER) (F_CPU / (SCALER * 1000.0))
volatile bool isBufferFull = false;
volatile uint8_t buffer[BUFFER_LEN];
void (*ADC_vect_handlerP)() = NULL;
ISR(ADC_vect)
{
if (ADC_vect_handlerP)
ADC_vect_handlerP();
/*static uint16_t contByte = 0;
buffer[contByte] = ADCH;
if (contByte == BUFFER_LEN)
{
isBufferFull = true;
contByte = 0;
ADCSRA &= ~_BV(ADIE);
}
contByte++;*/
}
/* Capture */
void capture_8b()
{
static uint16_t contByte = 0;
buffer[contByte] = ADCH;
if (contByte == BUFFER_LEN)
{
isBufferFull = true;
contByte = 0;
ADCSRA &= ~_BV(ADIE);
}
contByte++;
}
void capture_4b()
{
static uint16_t contByte = 0;
static bool newByte = false;
if (newByte)
{
buffer[contByte] |= (ADCH & 0xF0);
contByte++;
}
else
buffer[contByte] = ADCH >> 4;
if (contByte == BUFFER_LEN)
{
isBufferFull = true;
contByte = 0;
ADCSRA &= ~_BV(ADIE);
}
newByte = !newByte;
}
void capture_1b()
{
static uint16_t contByte = 0;
static uint8_t data = 0;
static uint8_t contBit = 0;
data |= (ADCH & 0x80);
contBit++;
if (contBit == 8)
{
buffer[contByte] = data;
contBit = 0;
contByte++;
}
if (contByte == BUFFER_LEN)
{
isBufferFull = true;
contByte = 0;
ADCSRA &= ~_BV(ADIE);
}
data >>= 1;
}
/* Realtime */
void realtime_8b()
{
serial.write((uint8_t)ADCH);
}
void realtime_4b()
{
static uint8_t data = 0;
static bool sendByte = false;
if (sendByte)
serial.write(data | (ADCH & 0xF0));
else
data = ADCH >> 4;
sendByte = !sendByte;
}
void realtime_1b()
{
static uint8_t data = 0;
static uint8_t cont;
data |= (ADCH & 0x80);
cont++;
if (cont == 8)
{
serial.write(data);
data = 0;
cont = 0;
}
data >>= 1;
}
void sendData()
{
for (uint16_t i = 0; i < BUFFER_LEN; i++) {
while (!serial.availableForWrite());
serial.write(buffer[i]);
}
isBufferFull = false;
delay(2000);
ADCSRA |= _BV(ADIE);
}
void setup() {
pinMode(A0, INPUT);
Serial.begin(1000000);
//DDRB |= _BV(DDB3);
//TCCR2A = _BV(COM2A1) | _BV(COM2A0) | _BV(WGM21) | _BV(WGM20);
//TCCR2B = _BV(WGM22) | _BV(CS22)| _BV(CS21) | _BV(CS20);
//OCR2A = 120;
/*
ADC init
Capture time: F_CPU / ADC_PRESCALER / 13 ADC TICKS: (1 byte at 1000000 = 10us)
Prescaler 32: 1.6M / 32 / 13 = 38461 -> 1 / 38461 = 26 us -> realtime 8 data bits
Prescaler 16: 1.6M / 16 / 13 = 76923 -> 1 / 76923 = 13 us -> realtime 4 data bits
Prescaler 8: 1.6M / 8 / 13 = 153846 -> 1 / 153846 = 6.5 us -> capture
Prescaler 4: 1.6M / 4 / 13 = 307692-> 1 / 307692 = 3.25 us -> too fast
Prescaler 2: 1.6M / 2 / 13 = 615385-> 1 / 615385 = 1.62 us -> too fast
*/
switch (PRESCALER)
{
case 4:
ADCSRA = _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS1);
break;
case 8:
ADCSRA = _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS1) | _BV(ADPS0);
break;
case 16:
ADCSRA = _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS2);
break;
case 32:
ADCSRA = _BV(ADEN) | _BV(ADATE) | _BV(ADIE) | _BV(ADPS2) | _BV(ADPS0);
break;
}
ADMUX = _BV(REFS0) | _BV(ADLAR);
ADCSRB = 0;
ADCSRA |= _BV(ADSC);
DDRB |= _BV(DDB2);
TCCR1A = _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11); // scaler 8
if (MODE == REALTIME)
{
serial.begin(1000000, SERIAL_8N1);
if (DATABITS == 8)
ADC_vect_handlerP = realtime_8b;
if (DATABITS == 4)
ADC_vect_handlerP = realtime_4b;
if (DATABITS == 1)
ADC_vect_handlerP = realtime_1b;
}
if (MODE == CAPTURE)
{
serial.begin(115200, SERIAL_8N1);
if (DATABITS == 8)
ADC_vect_handlerP = capture_8b;
if (DATABITS == 4)
ADC_vect_handlerP = capture_4b;
if (DATABITS == 1)
ADC_vect_handlerP = capture_1b;
}
/* PWM signal is available at pin OC1B. To test the Oscilloscope app connect pin OC1B to pin A0
Adjust PWM signal with PWM_FREQ and PWM_DUTY. Default: PWM 1000Hz, 50% DUTY
Pin OC1B:
Uno: pin 10 (PB2)
Leonardo: pin 10 (PB6)
ATmega2560: pin 12 (PB6)
*/
#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__)
DDRB |= _BV(DDB6);
#else
DDRB |= _BV(DDB2);
#endif
TCCR1A = _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11); // scaler 8
TCCR1A |= _BV(COM1B1);
// PWM signal
OCR1A = 1000.0 / PWM_FREQ * MS_TO_COMP(8);
OCR1B = PWM_DUTY * OCR1A;
/* // sinus signal (1Hz)
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // scaler 1
OCR1A = 1000.0 / 38000 * MS_TO_COMP(8);
OCR1B = PWM_DUTY * OCR1A;*/
//TIMSK1 = OCIE1A;
TCCR1A |= _BV(COM1B1);
OCR1A = 10 * MS_TO_COMP(8);
OCR1B = 0.5 * OCR1A;
}
void loop() {
static uint16_t ts = 0;
if ((uint16_t)micros() - ts > 100)
{
ts = micros();
uint8_t val = analogRead(A0) >> 2;
Serial.write(val);
}
if (isBufferFull)
sendData();
}

Wyświetl plik

@ -0,0 +1,22 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
Item {
Column {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 20
padding: 40
Image {
source: "res/oscilloscope_120x64.bmp"
anchors.horizontalCenter: parent.horizontalCenter
}
Label {
text: "Oscilloscope Serial v" + oscilloscope.getVersion()
anchors.horizontalCenter: parent.horizontalCenter
}
Label {
text: "DanielGeA, ©2021"
anchors.horizontalCenter: parent.horizontalCenter
}
}
}

141
src/qt/MainItem.qml 100644
Wyświetl plik

@ -0,0 +1,141 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.15
import QtQuick.Window 2.3
Item {
property alias statusText : statusLabel.text
property string statusTextPermanent: statusLabel.textPermanent
property alias imageSource : image.source
property alias columns: controls.columns
ColumnLayout {
id: column
anchors.fill: parent
GridLayout {
id: grid
Layout.fillWidth: true
columns: 2
Image {
id: image
source: "image://imgProvider"
Layout.fillWidth: true
Layout.fillHeight: true
cache: false
sourceSize.width: width
sourceSize.height: height
}
Slider {
id: verticalSlider
orientation: Qt.Vertical
Layout.maximumWidth: 30
Layout.fillHeight: true
from: -30
to: 30
stepSize: 5
snapMode: "SnapAlways"
background: Rectangle {
color: "#c0bfbc"
width: 5
anchors.horizontalCenter: parent.horizontalCenter
}
onValueChanged: oscilloscope.setVAdjust(200 * value / (to - from))
}
Slider {
value: 0
Layout.fillWidth: true
from: -55
to: 55
stepSize: 5
snapMode: "SnapAlways"
background: Rectangle {
color: "#c0bfbc"
height: 5
width: parent.width
anchors.verticalCenter: parent.verticalCenter
}
onValueChanged: oscilloscope.setHAdjust(200 * value / (to - from))
}
}
// desktop / device horiz: 2,2,2
// device vertical: 1,2,2
GridLayout {
id: controls
columns: Screen.width > Screen.height ? 2 : 1
GridLayout {
columns: 2
ComboBox {
id: vDivCombo
textRole: "text"
valueRole: "value"
Layout.fillWidth: true
model: ListModel {
id: vDivList
ListElement { text: "2V/d"; value: 2000 }
ListElement { text: "1V/d"; value: 1000 }
ListElement { text: "500mV/d"; value: 500 }
ListElement { text: "100mV/d"; value: 100 }
}
currentIndex: 1
onCurrentValueChanged: oscilloscope.setVDiv(currentValue)
}
ComboBox {
id: hDivCombo
textRole: "text"
valueRole: "value"
Layout.fillWidth: true
model: ListModel {
id: hDivList
ListElement { text: "10ms/d"; value: 10000 }
ListElement { text: "5ms/d"; value: 5000 }
ListElement { text: "1ms/d"; value: 1000 }
ListElement { text: "500μs/d"; value: 500 }
ListElement { text: "400μs/d"; value: 400 }
ListElement { text: "300μs/d"; value: 300 }
ListElement { text: "200μs/d"; value: 200 }
ListElement { text: "100μs/d"; value: 100 }
ListElement { text: "50μs/d"; value: 50 }
}
currentIndex: 2
onCurrentValueChanged: oscilloscope.setHDiv(currentValue)
}
}
GridLayout {
columns: 3
ComboBox {
id: triggerTypeCombo
Layout.fillWidth: true
model: ListModel {
id: triggerTypeList
ListElement { text: "None" }
ListElement { text: "Rising" }
ListElement { text: "Falling" }
}
currentIndex: 1
onCurrentTextChanged: oscilloscope.setTriggerType(currentIndex)
}
SpinBox {
id: triggerValueSpin
editable: true
Layout.fillWidth: true
from: 0
to: 5000
value: 1000
onValueChanged: oscilloscope.setTriggerValue(value)
}
Label {
text: "mV"
}
}
}
Label {
id: statusLabel
Layout.preferredWidth: parent.width
elide: Text.ElideRight
property string textPermanent: "Disconnected"
text: "Disconnected" }
}
}

Wyświetl plik

@ -0,0 +1,251 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
Item {
property alias backgroundColor: backgroundRect.color
property alias gridColor: gridRect.color
property alias signalColor: signalRect.color
property alias textColor: textRect.color
property alias colorsVisible: colors.visible
function fillPorts() {
portnames.clear()
const infos = oscilloscope.fillPortsInfo()
for (var i = 0; i < infos.length; i++) {
portnames.append({"text":infos[i]})
}
if (portname.find(settings.portname) === -1)
portname.currentIndex = 0
else
portname.currentIndex = portname.find(settings.portname)
}
Component.onCompleted: {
fillPorts()
if (baudrate.find(settings.baudrate) === -1)
settings.baudrate = baudrate.currentText
else
baudrate.currentIndex = baudrate.find(settings.baudrate)
if (databits.find(settings.databits) === -1)
settings.databits = databits.currentText
else
databits.currentIndex = databits.find(settings.databits)
if (parity.find(settings.parity) === -1)
settings.parity = parity.currentText
else
parity.currentIndex = parity.find(settings.parity)
if (settings.interval === "")
settings.interval = interval.value
else
interval.value = parseInt(settings.interval)
if (settings.backgroundColor === "")
settings.backgroundColor = backgroundRect.color
else
backgroundRect.color = settings.backgroundColor
if (settings.gridColor === "")
settings.gridColor = gridRect.color
else
gridRect.color = settings.gridColor
if (settings.signalColor === "")
settings.signalColor = signalRect.color
else
signalRect.color = settings.signalColor
if (settings.textColor === "")
settings.textColor = textRect.color
else
textRect.color = settings.textColor
settings.portname = Qt.binding(function() { return portname.currentText })
settings.baudrate = Qt.binding(function() { return baudrate.currentText })
settings.databits = Qt.binding(function() { return databits.currentText })
settings.parity = Qt.binding(function() { return parity.currentText })
settings.interval = Qt.binding(function() { return interval.value })
settings.backgroundColor = Qt.binding(function() { return backgroundRect.color })
settings.gridColor = Qt.binding(function() { return gridRect.color })
settings.signalColor = Qt.binding(function() { return signalRect.color })
settings.textColor = Qt.binding(function() { return textRect.color })
}
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columns: 1
GroupBox {
title: "Serial Port"
Layout.fillWidth: true
GridLayout {
anchors.fill: parent
columns: 2
Label { text: "Port " }
ComboBox {
id: portname
Layout.fillWidth: true
model: ListModel {
id: portnames
}
currentIndex: 0
}
Label { text: "Baudrate" }
ComboBox {
id: baudrate
Layout.fillWidth: true
model: ListModel {
ListElement { text: "9600" }
ListElement { text: "19200" }
ListElement { text: "38400" }
ListElement { text: "57600" }
ListElement { text: "115200" }
ListElement { text: "230400" }
ListElement { text: "500000" }
ListElement { text: "1000000" }
}
currentIndex: 8
}
Label { text: "Data bits" }
ComboBox {
id: databits
Layout.fillWidth: true
model: ListModel {
ListElement { text: "5" }
ListElement { text: "6" }
ListElement { text: "7" }
ListElement { text: "8" }
}
currentIndex: 3
}
Label { text: "Parity" }
ComboBox {
id: parity
Layout.fillWidth: true
model: ListModel {
ListElement { text: "None" }
ListElement { text: "Even" }
ListElement { text: "Odd" }
}
currentIndex: 0
}
Label { text: "Interval (μs)" }
SpinBox {
id: interval
Layout.fillWidth: true
value: 2600
from: 0
to: 100 * 100
editable: true
property int decimals: 2
property real realValue: value / 100
validator: DoubleValidator {
bottom: Math.min(interval.from, interval.to)
top: Math.max(interval.from, interval.to)
}
textFromValue: function(value, locale) {
return Number(value / 100).toLocaleString(locale, 'f', interval.decimals)
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * 100
}
}
}
}
GroupBox {
id: colors
title: "Colors"
Layout.fillWidth: true
GridLayout {
columns: 2
Button {
text: "Default colors"
Layout.fillWidth: true
onClicked: {
backgroundRect.color = '#000000'
gridRect.color = '#77767b'
signalRect.color = '#33d17a'
textRect.color = '#f9f06b'
}
}
Label {}
Button {
id: background
text: "Background"
Layout.fillWidth: true
onClicked: { colorDialog.open(); colorDialog.setting = "background" }
}
Rectangle {
id: backgroundRect
color: '#000000'
Layout.fillWidth: true
Layout.minimumWidth: 50
Layout.minimumHeight: background.height
Component.onCompleted: oscilloscope.setBackgroundColor(color)
onColorChanged: oscilloscope.setBackgroundColor(color)
}
Button {
id: grid
text: "Grid"
Layout.fillWidth: true
onClicked: { colorDialog.open(); colorDialog.setting = "grid" }
}
Rectangle {
id: gridRect
color: '#77767b'
Layout.fillWidth: true
Layout.minimumWidth: 50
Layout.minimumHeight: grid.height
Component.onCompleted: oscilloscope.setGridColor(color)
onColorChanged: oscilloscope.setGridColor(color)
}
Button {
id: signal
text: "Signal"
Layout.fillWidth: true
onClicked: { colorDialog.open(); colorDialog.setting = "signal" }
}
Rectangle {
id: signalRect
color: '#33d17a'
Layout.fillWidth: true
Layout.minimumWidth: 50
Layout.minimumHeight: signal.height
Component.onCompleted: oscilloscope.setSignalColor(color)
onColorChanged: oscilloscope.setSignalColor(color)
}
Button {
id: text
text: "Text"
Layout.fillWidth: true
onClicked: { colorDialog.open(); colorDialog.setting = "text" }
}
Rectangle {
id: textRect
color: '#f9f06b'
Layout.fillWidth: true
Layout.minimumWidth: 50
Layout.minimumHeight: text.height
Component.onCompleted: oscilloscope.setTextColor(color)
onColorChanged: oscilloscope.setTextColor(color)
}
}
}
}
}
/*##^##
Designer {
D{i:0;autoSize:true;formeditorZoom:0.5;height:480;width:640}
}
##^##*/

Wyświetl plik

@ -1,14 +0,0 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
}
AboutDialog::~AboutDialog()
{
delete ui;
}

Wyświetl plik

@ -1,22 +0,0 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H
#include <QDialog>
namespace Ui {
class AboutDialog;
}
class AboutDialog : public QDialog
{
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = nullptr);
~AboutDialog();
private:
Ui::AboutDialog *ui;
};
#endif // ABOUTDIALOG_H

Wyświetl plik

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>481</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Este programa viene SIN NINGUNA GARANTÍA.
Consulte la Licencia Pública General de GNU, versión 3 o posterior para obtener más detalles.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="lbImage">
<property name="geometry">
<rect>
<x>190</x>
<y>140</y>
<width>121</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/oscilloscope.bmp</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>170</x>
<y>40</y>
<width>171</width>
<height>19</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Oscilloscope Serial</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>220</x>
<y>70</y>
<width>66</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>190</x>
<y>100</y>
<width>121</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>Daniel GeA, 2021</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>

Wyświetl plik

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.2" android:versionCode="2" android:installLocation="auto">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- %%INSERT_FEATURES -->
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Oscilloscope" android:extractNativeLibs="true" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Oscilloscope" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
are done populating your window with content. -->
<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
</manifest>

Wyświetl plik

@ -0,0 +1,79 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.github.mik3y:usb-serial-for-android:3.4.3'
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion '28.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
tasks.withType(JavaCompile) {
options.incremental = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
}

Wyświetl plik

@ -0,0 +1,14 @@
# Project-wide Gradle settings.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# Gradle caching allows reusing the build artifacts from a previous
# build with the same inputs. However, over time, the cache size will
# grow. Uncomment the following line to enable it.
#org.gradle.caching=true
android.useAndroidX=true
android.enableJetifier=true

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
src/qt/android/gradlew vendored 100755
Wyświetl plik

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
src/qt/android/gradlew.bat vendored 100644
Wyświetl plik

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 475 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 834 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 612 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 649 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.4 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.3 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.4 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 6.8 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 12 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 18 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 717 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 879 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 353 B

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 5.8 MiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.8 MiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 374 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 150 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 343 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 350 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.0 KiB

Wyświetl plik

@ -0,0 +1,22 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.14</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
not be edited manually. -->
<array name="bundled_libs">
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="load_local_libs">
<!-- %%INSERT_LOCAL_LIBS%% -->
</array>
</resources>

Wyświetl plik

@ -0,0 +1,131 @@
package org.qtproject.qt;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;
import java.io.IOException;
import java.util.List;
import java.util.Arrays;
import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialPort;
import com.hoho.android.usbserial.driver.UsbSerialProber;
import com.hoho.android.usbserial.util.SerialInputOutputManager;
public class UsbSerialInterface implements SerialInputOutputManager.Listener
{
private static native void sendBuffer(byte[] buffer);
private static native void sendStatus(int status, String msg);
enum Status { CONNECTED, DISCONNECTED, PERMISSION_NOT_GRANTED, ERROR_CONNECTING, ERROR_OPENING, CONNECTION_LOST, DRIVER_NOT_FOUND, PERMISSION_REQUESTED };
UsbManager manager;
UsbSerialDriver driver;
UsbSerialPort port;
UsbDeviceConnection connection;
SerialInputOutputManager ioManager;
List<UsbSerialDriver> availableDrivers;
int baudrate;
int databits;
int stopbits;
int parity;
private static final String ACTION_USB_PERMISSION = "com.example.usbserial.USB_PERMISSION";
public void sendStatus(int status)
{
sendStatus(status, "");
}
public void closeConnection()
{
connection.close();
}
public List drivers(Context context)
{
manager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager);
return availableDrivers;
}
public void openConnection(Context context, String name, int baudrate, int databits, int stopbits, int parity)
{
this.baudrate = baudrate;
this.databits = databits;
this.stopbits = stopbits;
this.parity = parity;
driver = null;
for (int i = 0; i < availableDrivers.size(); i++) {
if (availableDrivers.get(i).toString().contains(name))
driver = availableDrivers.get(i);
}
if (driver == null) {
sendStatus(Status.DRIVER_NOT_FOUND.ordinal());
return;
}
PendingIntent pi = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0);
context.registerReceiver(receiver, new IntentFilter(ACTION_USB_PERMISSION));
manager.requestPermission(driver.getDevice(), pi);
sendStatus(Status.PERMISSION_REQUESTED.ordinal());
}
public void configConnection()
{
connection = manager.openDevice(driver.getDevice());
if (connection == null) {
sendStatus(Status.ERROR_CONNECTING.ordinal());
return;
}
port = driver.getPorts().get(0);
try {
port.open(connection);
port.setParameters(baudrate,databits,stopbits, parity);
} catch (IOException e) {
e.printStackTrace();
sendStatus(Status.ERROR_OPENING.ordinal());
return;
}
ioManager = new SerialInputOutputManager(port, this);
ioManager.start();
sendStatus(Status.CONNECTED.ordinal(), port.toString());
}
@Override
public void onNewData(byte[] data)
{
sendBuffer(data);
}
@Override
public void onRunError(Exception e)
{
sendStatus(Status.CONNECTION_LOST.ordinal());
}
public final BroadcastReceiver receiver = new BroadcastReceiver()
{
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (ACTION_USB_PERMISSION.equals(action)) {
synchronized (context) {
UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
if (device != null) {
configConnection();
}
} else {
sendStatus(Status.PERMISSION_NOT_GRANTED.ordinal());
}
}
}
}
};
}

Wyświetl plik

@ -1,9 +0,0 @@
QT_ASSUME_STDERR_HAS_CONSOLE=1
export QT_ASSUME_STDERR_HAS_CONSOLE
creo que no hace falta:
QT_LOGGING_TO_CONSOLE=1
export QT_LOGGING_TO_CONSOLE

Wyświetl plik

@ -1,11 +1,47 @@
#include "mainwindow.h"
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
#include <QQuickStyle>
#include "oscilloscope.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QApplication app(argc, argv);
QQmlApplicationEngine engine;
Oscilloscope *oscilloscope = new Oscilloscope(app.devicePixelRatio());
#ifdef Q_OS_ANDROID
const QUrl url(QStringLiteral("qrc:/mainwindow_device.qml"));
QQuickStyle::setStyle("Material");
#else
const QUrl url(QStringLiteral("qrc:/mainwindow.qml"));
QQuickStyle::setStyle("Fusion");
#endif
QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QCoreApplication::quit);
app.setWindowIcon(QIcon(":res/oscilloscope.png"));
app.setOrganizationName("DanielGeA");
app.setOrganizationDomain("DanielGeA");
engine.rootContext()->setContextProperty("oscilloscope", oscilloscope);
engine.addImageProvider(QLatin1String("imgProvider"), oscilloscope);
engine.load(url);
return app.exec();
}

Wyświetl plik

@ -1,303 +0,0 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "settingsdialog.h"
#include "aboutdialog.h"
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow),
m_serial(new QSerialPort(this)),
m_pixmap(new QPixmap(500, 400)),
m_paint(new QPainter(m_pixmap)),
m_ui_settings(new SettingsDialog()),
m_ui_about(new AboutDialog())
{
ui->setupUi(this);
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(exitApp()));
connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settings()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
connect(ui->btOpen, SIGNAL(released()), this, SLOT(openSerialPort()));
connect(ui->btClose, SIGNAL(released()), this, SLOT(closeSerialPort()));
connect(m_serial, &QSerialPort::readyRead, this, &MainWindow::readData);
connect(ui->sbTrigger, SIGNAL(valueChanged(double)), this, SLOT(updateTrigger()));
connect(ui->rbNone, SIGNAL(clicked()), this, SLOT(updateTriggerType()));
connect(ui->rbRising, SIGNAL(clicked()), this, SLOT(updateTriggerType()));
connect(ui->rbFalling, SIGNAL(clicked()), this, SLOT(updateTriggerType()));
connect(ui->rbV20, SIGNAL(clicked()), this, SLOT(updateVdiv()));
connect(ui->rbV10, SIGNAL(clicked()), this, SLOT(updateVdiv()));
connect(ui->rbV5, SIGNAL(clicked()), this, SLOT(updateVdiv()));
connect(ui->rbV1, SIGNAL(clicked()), this, SLOT(updateVdiv()));
connect(ui->rbH100, SIGNAL(clicked()), this, SLOT(updateHdiv()));
connect(ui->rbH50, SIGNAL(clicked()), this, SLOT(updateHdiv()));
connect(ui->rbH10, SIGNAL(clicked()), this, SLOT(updateHdiv()));
connect(ui->rbH5, SIGNAL(clicked()), this, SLOT(updateHdiv()));
//connect(ui->rbH1, SIGNAL(clicked()), this, SLOT(updateHdiv()));
connect(ui->rbH1, &QRadioButton::clicked, this, &MainWindow::updateHdiv);
ui->rbV10->setChecked(true);
ui->rbH10->setChecked(true);
ui->sbTrigger->setValue(trigger);
ui->lbPic->setMinimumSize(300, 225);
drawBackground();
ui->lbPic->setPixmap(*m_pixmap);
qInfo() << "INIT";
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
QMainWindow::resizeEvent(event);
m_paint->end();
*m_pixmap = m_pixmap->scaled(ui->lbPic->width(), ui->lbPic->height(), Qt::IgnoreAspectRatio);
m_paint->begin(m_pixmap);
drawBackground();
ui->lbPic->setPixmap(*m_pixmap);
}
void MainWindow::drawBackground()
{
uint16_t height = m_pixmap->height();
uint16_t width = m_pixmap->width();
m_paint->fillRect(0, 0, width, height, QColor(255, 255, 255, 255));
QFont font = m_paint->font();
font.setPixelSize(15);
font.setBold(true);
m_paint->setFont(font);
m_paint->setPen(QColor(0, 0, 100, 255));
m_paint->drawText(5, height - 5, "V/div=" + QString::number(vDiv) + " ms/div=" + QString::number(timeLenght / 10) + " Vmax=" + QString::number((float)maxValue / 0xFF * 5, 'f',
3) + " Vmin=" + QString::number((float)minValue / 0xFF * 5));
// 0 volts line
m_paint->setPen(QColor(0, 100, 0, 50));
float voltPos = (float)ui->slVolt->value() / (ui->slVolt->maximum() - ui->slVolt->minimum()) * 0.50;
uint16_t yPos = m_pixmap->height();
yPos = yPos * 5 / volt + m_pixmap->height() * (6 - 5 / vDiv) / 6 / 2;
m_paint->drawLine(0, yPos + m_pixmap->height() * voltPos, m_pixmap->width(), yPos + m_pixmap->height() * voltPos);
m_paint->setPen(QColor(0, 0, 0, 123));
for (uint8_t i = 0; i < 6; i++) // horizontal lines
{
m_paint->drawLine(0, height * i / 6, width, height * i / 6);
}
for (uint8_t i = 0; i < 10; i++) // vertical lines
{
m_paint->drawLine(width * i / 10, 0, width * i / 10, height);
}
m_paint->setPen(QColor(0, 0, 0, 255));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::openSerialPort()
{
m_serial->setPortName(m_ui_settings->m_currentSettings.name);
m_serial->setBaudRate(m_ui_settings->m_currentSettings.baudRate);
m_serial->setDataBits(m_ui_settings->m_currentSettings.dataBits);
m_serial->setParity(m_ui_settings->m_currentSettings.parity);
m_serial->setStopBits(m_ui_settings->m_currentSettings.stopBits);
m_serial->setFlowControl(m_ui_settings->m_currentSettings.flowControl);
if (m_serial->open(QIODevice::ReadOnly))
{
qInfo("Connected");
}
else
{
qInfo("Connection error");
}
}
void MainWindow::closeSerialPort()
{
if (m_serial->isOpen())
{
m_serial->close();
}
qInfo("Disconnected");
}
void MainWindow::readData()
{
static bool isTriggered = true;
static float oldxPos = 0;
static uint16_t oldyPos = m_pixmap->height();
static uint8_t oldValue = 0;
static uint8_t deltaRising = 0;
static uint8_t deltaFalling = 0;
uint16_t us = 100;
QByteArray data = m_serial->readAll();
float xDelta = m_pixmap->width() * us / 1000.0 / timeLenght; // float needed in case delta is less than one
for (uint16_t i = 0; i < data.size(); i++)
{
if ((uint8_t)data[i] > maxValue)
{
maxValue = data[i];
}
if ((uint8_t)data[i] < minValue)
{
minValue = data[i];
}
if (isTriggered == false && triggerType != none) // look for the trigger
{
if ((uint8_t)data[i] - oldValue > 0) // rising
{
deltaRising += (uint8_t)data[i] - oldValue;
deltaFalling = 0;
}
if ((uint8_t)data[i] - oldValue < 0) // falling
{
deltaFalling += oldValue - (uint8_t)data[i];
deltaRising = 0;
}
if (triggerType == rising && ((float)deltaRising) / 0xFF * 5 > trigger)
{
isTriggered = true;
}
if (triggerType == falling && ((float)deltaFalling) / 0xFF * 5 > trigger)
{
isTriggered = true;
}
oldValue = data[i];
}
if (isTriggered == true || triggerType == none) // draw new value
{
float newxPos = oldxPos + xDelta;
uint16_t newyPos = m_pixmap->height() - (uint8_t)data[i] * m_pixmap->height() / 0xFF;
newyPos = newyPos * 5 / volt + m_pixmap->height() * (6 - 5 / vDiv) / 6 / 2;
//newxPos += m_pixmap->width() * ui->slTime->value() / 100;
if (newyPos < 0)
{
newyPos = 0;
}
if (newxPos > m_pixmap->width())
{
if (triggerType != none)
{
isTriggered = false;
oldValue = data[i];
deltaRising = 0;
deltaFalling = 0;
}
ui->lbPic->setPixmap(*m_pixmap);
drawBackground();
newxPos -= m_pixmap->width();
maxValue = 0;
minValue = 0;
}
else
{
float timePos = (float)ui->slTime->value() / (ui->slTime->maximum() - ui->slTime->minimum()) * 0.25;
float voltPos = (float)ui->slVolt->value() / (ui->slVolt->maximum() - ui->slVolt->minimum()) * 0.50;
m_paint->drawLine(newxPos + m_pixmap->width() * timePos, newyPos + m_pixmap->height() * voltPos, oldxPos + m_pixmap->width() * timePos, oldyPos + m_pixmap->height() * voltPos);
}
oldxPos = newxPos;
oldyPos = newyPos;
}
}
}
void MainWindow::updateTrigger()
{
QString text = ui->sbTrigger->text();
trigger = text.toFloat();
}
void MainWindow::updateTriggerType()
{
if (ui->rbNone->isChecked())
{
triggerType = none;
}
else if (ui->rbRising->isChecked())
{
triggerType = rising;
}
else if (ui->rbFalling->isChecked())
{
triggerType = falling;
}
}
void MainWindow::updateVdiv()
{
if (ui->rbV20->isChecked())
{
vDiv = 2;
}
else if (ui->rbV10->isChecked())
{
vDiv = 1;
}
else if (ui->rbV5->isChecked())
{
vDiv = 0.5;
}
else if (ui->rbV1->isChecked())
{
vDiv = 0.1;
}
volt = vDiv * 6;
drawBackground();
ui->lbPic->setPixmap(*m_pixmap);
}
void MainWindow::updateHdiv()
{
if (ui->rbH100->isChecked())
{
timeLenght = 100;
}
else if (ui->rbH50->isChecked())
{
timeLenght = 50;
}
else if (ui->rbH10->isChecked())
{
timeLenght = 10;
}
else if (ui->rbH5->isChecked())
{
timeLenght = 5;
}
else if (ui->rbH1->isChecked())
{
timeLenght = 1;
}
drawBackground();
ui->lbPic->setPixmap(*m_pixmap);
}
void MainWindow::settings()
{
m_ui_settings->show();
}
void MainWindow::about()
{
m_ui_about->show();
}
void MainWindow::exitApp()
{
QApplication::quit();
}

Wyświetl plik

@ -1,60 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QDebug>
#include <QPainter>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class SettingsDialog;
class AboutDialog;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void resizeEvent(QResizeEvent* event);
private:
Ui::MainWindow *ui;
QSerialPort *m_serial = nullptr;
QPixmap *m_pixmap;
QPainter *m_paint;
SettingsDialog *m_ui_settings = nullptr;
AboutDialog *m_ui_about = nullptr;
float vDiv = 1;
float volt = 1 * 6;
uint16_t timeLenght = 100;
float trigger = 1;
enum Edge { min, max };
enum TriggerTypes { none, rising, falling };
uint8_t triggerType = none;
uint8_t maxValue = 0;
uint8_t minValue = 0;
void drawBackground();
private slots:
void openSerialPort();
void closeSerialPort();
void readData();
void updateTrigger();
void updateTriggerType();
void exitApp();
void updateVdiv();
void updateHdiv();
void settings();
void about();
};
#endif // MAINWINDOW_H

Wyświetl plik

@ -0,0 +1,294 @@
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
title: qsTr("Oscilloscope")
minimumWidth: 400
minimumHeight: 200
Settings {
id: settings
property string portname
property string baudrate
property string databits
property string parity
property string interval
property string backgroundColor
property string gridColor
property string signalColor
property string textColor
property string averagingElements
//property alias x: window.x
//property alias y: window.y
//property alias width: window.width
//property alias height: window.height
}
FileDialog {
id: fileDialogCapture
title: "Export image"
fileMode: FileDialog.SaveFile
nameFilters: ["Bitmap image (*.bmp)","All Files (*)"]
onAccepted: oscilloscope.exportImage(fileDialogCapture.currentFile)
}
FileDialog {
id: fileDialogExport
title: "Export data"
fileMode: FileDialog.SaveFile
nameFilters: ["Text CSV (*.csv)","All Files (*)"]
onAccepted: oscilloscope.exportCsv(fileDialogExport.currentFile)
}
ColorDialog {
id: colorDialog
property string setting: ""
onAccepted: {
console.log(color)
switch (setting) {
case "background":
settingsItem.backgroundColor = color
break
case "grid":
settingsItem.gridColor = color
break
case "signal":
settingsItem.signalColor = color
break
case "text":
settingsItem.textColor = color
break
}
}
}
Timer {
id: timer
onTriggered: mainItem.statusText = mainItem.statusTextPermanent
}
Connections {
target: oscilloscope
function onSendPixmap() {
mainItem.imageSource = ""
mainItem.imageSource = "image://imgProvider"
}
function onSendMessage(message, duration) {
if (duration === 0)
mainItem.statusTextPermanent = message
else {
timer.start()
timer.interval = duration
}
mainItem.statusText = message
}
function onSendStatusConn(status) {
if (status === 0) { // connected
connectButton.status = "connected"
connectMenu.status = "connected"
pauseButton.enabled = true
exportButton.enabled = true
pauseMenu.enabled = true
exportMenu.enabled = true
}
if (status === 1) { // disconnected
connectButton.status = "disconnected"
connectMenu.status = "disconnected"
pauseButton.enabled = false
exportButton.enabled = false
pauseMenu.enabled = false
exportMenu.enabled = false
}
}
function onIsPausedChanged(isPaused) {
if (isPaused) {
pauseButton.isPaused = true
pauseMenu.isPaused = true
}
else {
pauseButton.isPaused = false
pauseMenu.isPaused = false
}
}
}
header: ToolBar {
Layout.fillWidth: true
RowLayout {
anchors.fill: parent
ToolButton {
id: connectButton
property string status: "disconnected"
icon.height: 32
icon.width: 32
icon.source: (status === "disconnected") ? "qrc:res/disconnect.png" :"qrc:res/connect.png"
onClicked: (status === "disconnected")
? oscilloscope.openSerialPort(settings.portname, settings.baudrate, settings.databits, settings.parity, settings.interval)
: oscilloscope.closeSerialPort()
}
ToolButton {
id: pauseButton
property bool isPaused: false
enabled: false
icon.height: 32
icon.width: 32
icon.source: (isPaused === false) ? "qrc:res/pause.png" : "qrc:res/play.png"
onClicked: oscilloscope.setIsPaused(!oscilloscope.getIsPaused())
}
ToolButton {
id: captureButton
icon.height: 32
icon.width: 32
icon.source: "qrc:res/capture.png"
onClicked: fileDialogCapture.open()
}
ToolButton {
id: exportButton
enabled: false
icon.height: 32
icon.width: 32
icon.source: "qrc:res/export.png"
onClicked: fileDialogExport.open()
}
ToolButton {
icon.height: 32
icon.width: 32
icon.source: "qrc:res/settings.png"
onClicked: { settingsItem.fillPorts(); settingsWindow.show() }
}
ToolButton {
icon.height: 32
icon.width: 32
icon.source: "qrc:res/info.png"
onClicked: aboutWindow.show()
}
ToolButton {
icon.height: 32
icon.width: 32
icon.source: "qrc:res/application-exit.png"
onClicked: Qt.quit()
}
Label {
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
ToolButton {
icon.height: 32
icon.width: 32
icon.source: "qrc:res/menu.png"
onClicked: menu.open()
Menu {
id: menu
MenuItem {
id: connectMenu
property string status: "disconnected"
text: (status === "disconnected") ? "Connect" : "Disconnect"
onTriggered: (status === "disconnected") ?
oscilloscope.openSerialPort(settings.portname, settings.baudrate, settings.databits, settings.parity, settings.interval)
: oscilloscope.closeSerialPort()
}
MenuItem {
id: pauseMenu
enabled: false
property bool isPaused: false
text: (isPaused === false) ? "Pause" : "Play"
onTriggered: oscilloscope.setIsPaused(!oscilloscope.getIsPaused())
}
MenuItem {
text: "Capture image"
onTriggered: fileDialogCapture.open()
}
MenuItem {
id: exportMenu
enabled: false
text: "Export CSV"
onTriggered: fileDialogExport.open()
}
MenuItem {
text: "Settings"
onTriggered: { settingsItem.fillPorts(); settingsWindow.show() }
}
MenuItem {
text: "About"
onTriggered: aboutWindow.show()
}
MenuItem {
text: "Quit"
onTriggered: Qt.quit()
}
}
}
}
}
GridLayout {
anchors.margins: 5
anchors.fill: parent
MainItem {
id: mainItem
Layout.fillWidth: true
Layout.fillHeight: true
}
}
Window {
id: settingsWindow
width: 300
height: settingsItem.childrenRect.height
maximumHeight: height
maximumWidth: width
minimumHeight: height
minimumWidth: width
modality: Qt.ApplicationModal
flags: Qt.WindowTitleHint | Qt.WindowCloseButtonHint | Qt.Dialog
title: "Settings"
SettingsItem {
id: settingsItem
anchors.fill: parent
}
}
Window {
id: aboutWindow
width: aboutItem.childrenRect.width
height: aboutItem.childrenRect.height
maximumHeight: height
maximumWidth: width
minimumHeight: height
minimumWidth: width
modality: Qt.ApplicationModal
flags: Qt.WindowTitleHint | Qt.WindowCloseButtonHint | Qt.Dialog
title: "About"
AboutItem {
id: aboutItem
anchors.fill: parent
}
}
}
/*##^##
Designer {
D{i:0;formeditorZoom:0.9}
}
##^##*/

Wyświetl plik

@ -1,341 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>698</width>
<height>326</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Oscilloscope</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QSlider" name="slVolt">
<property name="styleSheet">
<string notr="true">selection-background-color: rgb(222, 221, 218);
selection-background-color: rgb(192, 191, 188);</string>
</property>
<property name="minimum">
<number>-6</number>
</property>
<property name="maximum">
<number>6</number>
</property>
<property name="pageStep">
<number>2</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="sliderPosition">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbPic">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QSlider" name="slTime">
<property name="styleSheet">
<string notr="true">selection-background-color: rgb(255, 190, 111);
selection-background-color: rgb(192, 191, 188);</string>
</property>
<property name="minimum">
<number>-10</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="sliderPosition">
<number>0</number>
</property>
<property name="tracking">
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>V/div</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QRadioButton" name="rbV20">
<property name="text">
<string>2V</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbV10">
<property name="text">
<string>1V</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbV5">
<property name="text">
<string>500mV</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbV1">
<property name="text">
<string>100mV</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>H/div</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QRadioButton" name="rbH100">
<property name="text">
<string>10ms</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbH50">
<property name="text">
<string>5ms</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbH10">
<property name="text">
<string>1ms</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbH5">
<property name="text">
<string>500us</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbH1">
<property name="text">
<string>100us</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Trigger</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QDoubleSpinBox" name="sbTrigger">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>6.000000000000000</double>
</property>
<property name="value">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbTriggerType">
<property name="title">
<string>Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="rbNone">
<property name="text">
<string>None</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbRising">
<property name="text">
<string>Rising</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbFalling">
<property name="text">
<string>Falling</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btOpen">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btClose">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>698</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFie">
<property name="title">
<string>File</string>
</property>
<addaction name="actionSettings"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>About</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuFie"/>
<addaction name="menuAbout"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionSettings">
<property name="text">
<string>Settings...</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About...</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

Wyświetl plik

@ -0,0 +1,255 @@
import QtQuick 2.9
import QtQuick.Window 2.2
import Qt.labs.platform 1.1
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.15
import Qt.labs.settings 1.0
ApplicationWindow {
id: window
visibility: "Maximized"
visible: true
title: qsTr("Oscilloscope")
Settings {
id: settings
property string portname
property string baudrate
property string databits
property string parity
property string interval
property string backgroundColor
property string gridColor
property string signalColor
property string textColor
}
FileDialog {
id: fileDialogCapture
fileMode: FileDialog.SaveFile
nameFilters: ["Bitmap image (*.bmp)","All Files (*)"]
onAccepted: oscilloscope.exportImage(fileDialogCapture.currentFile)
}
FileDialog {
id: fileDialogExport
fileMode: FileDialog.SaveFile
nameFilters: ["Text CSV (*.csv)","All Files (*)"]
onAccepted: oscilloscope.exportCsv(fileDialogExport.currentFile)
}
Timer {
id: timer
onTriggered: mainItem.statusText = mainItem.statusTextPermanent
}
Connections {
target: oscilloscope
function onSendPixmap() {
mainItem.imageSource = ""
mainItem.imageSource = "image://imgProvider"
}
function onSendMessage(message, duration) {
if (duration === 0)
mainItem.statusTextPermanent = message
else {
timer.start()
timer.interval = duration
}
mainItem.statusText = message
}
function onSendStatusConn(status) {
if (status === 0) { // connected
connectButton.status = "connected"
connectMenu.status = "connected"
pauseButton.enabled = true
exportButton.enabled = true
pauseMenu.enabled = true
exportMenu.enabled = true
}
if (status === 1) { // disconnected
connectButton.status = "disconnected"
connectMenu.status = "disconnected"
pauseButton.enabled = false
exportButton.enabled = false
pauseMenu.enabled = false
exportMenu.enabled = false
}
}
function onIsPausedChanged(isPaused) {
if (isPaused) {
pauseButton.isPaused = true
pauseMenu.isPaused = true
}
else {
pauseButton.isPaused = false
pauseMenu.isPaused = false
}
}
}
header: ToolBar {
RowLayout {
anchors.fill: parent
ToolButton {
id: backButton
text: "<"
font.pixelSize: 25
visible: false
onClicked: {
stack.pop()
connectButton.visible = true
pauseButton.visible = true
captureButton.visible = true
exportButton.visible = true
menuButton.visible = true
backButton.visible = false
toolBarLabel.text = ""
}
}
ToolButton {
id: connectButton
property string status: "disconnected"
icon.height: 32
icon.width: 32
icon.source: (status === "disconnected") ? "qrc:res/disconnect.png" :"qrc:res/connect.png"
onClicked: (status === "disconnected")
? oscilloscope.openSerialPort(settings.portname, settings.baudrate, settings.databits, settings.parity, settings.interval)
: oscilloscope.closeSerialPort()
}
ToolButton {
id: pauseButton
property bool isPaused: false
enabled: false
icon.height: 32
icon.width: 32
icon.source: (isPaused === false) ? "qrc:res/pause.png" : "qrc:res/play.png"
onClicked: oscilloscope.setIsPaused(!oscilloscope.getIsPaused())
}
ToolButton {
id: captureButton
icon.height: 32
icon.width: 32
icon.source: "qrc:res/capture.png"
onClicked: fileDialogCapture.open()
}
ToolButton {
id: exportButton
enabled: false
icon.height: 32
icon.width: 32
icon.source: "qrc:res/export.png"
onClicked: fileDialogExport.open()
}
Label {
id: toolBarLabel
Layout.fillWidth: true
rightPadding: 52
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
ToolButton {
id: menuButton
icon.height: 32
icon.width: 32
icon.source: "qrc:res/menu.png"
onClicked: {
menu.popup()
}
Menu {
id: menu
MenuItem {
id: connectMenu
property string status: "disconnected"
text: (status === "disconnected") ? "Connect" : "Disconnect"
onTriggered: (status === "disconnected") ?
oscilloscope.openSerialPort(settings.portname, settings.baudrate, settings.databits, settings.parity, settings.interval)
: oscilloscope.closeSerialPort()
}
MenuItem {
id: pauseMenu
enabled: false
property bool isPaused: false
text: (isPaused === false) ? "Pause" : "Play"
onTriggered: oscilloscope.setIsPaused(!oscilloscope.getIsPaused())
}
MenuItem {
text: "Capture image"
onTriggered: fileDialogCapture.open()
}
MenuItem {
id: exportMenu
enabled: false
text: "Export CSV"
onTriggered: fileDialogExport.open()
}
MenuItem {
text: "Settings"
onTriggered: {
settingsItem.fillPorts()
stack.push(settingsItem)
connectButton.visible = false
pauseButton.visible = false
captureButton.visible = false
exportButton.visible = false
backButton.visible = true
menuButton.visible = false
toolBarLabel.text = "Settings"
}
}
MenuItem {
text: "About"
onTriggered: {
stack.push(aboutItem)
connectButton.visible = false
pauseButton.visible = false
captureButton.visible = false
exportButton.visible = false
backButton.visible = true
menuButton.visible = false
toolBarLabel.text = "Oscilloscope"
}
}
MenuItem {
text: "Quit"
onTriggered: Qt.quit()
}
}
}
}
}
StackView {
id: stack
initialItem: mainItem
anchors.fill: parent
Page {
anchors.fill: parent
MainItem {
id: mainItem
}
}
Page {
anchors.fill: parent
SettingsItem {
id: settingsItem
colorsVisible: false
visible: false
}
}
Page {
anchors.fill: parent
AboutItem {
id: aboutItem
visible: false
}
}
}
}

Wyświetl plik

@ -0,0 +1,484 @@
#include "oscilloscope.h"
#ifdef Q_OS_ANDROID
Oscilloscope *Oscilloscope::m_instance = nullptr;
static void sendBuffer(JNIEnv *env, jobject /*thiz*/, jbyteArray array)
{
//jboolean isCopy = JNI_TRUE;
QByteArray buffer((char*)env->GetByteArrayElements(array,nullptr), env->GetArrayLength(array));
emit Oscilloscope::instance()->receiveBuffer(buffer);
}
static void sendStatus(JNIEnv *env, jobject /*thiz*/, int status, jstring str)
{
QString msg(env->GetStringUTFChars(str,nullptr));
emit Oscilloscope::instance()->receiveStatus(status, msg);
}
#endif
#ifndef Q_OS_ANDROID
Oscilloscope::Oscilloscope(qreal pixelRatio)
: QQuickImageProvider(QQuickImageProvider::Pixmap)
, pixelRatio(pixelRatio)
, pixmap(new QPixmap(pmWidth, pmHeight))
, paint(new QPainter(pixmap))
, serial(new QSerialPort())
, timer(new QTimer())
{
connect(timer, &QTimer::timeout, this, &Oscilloscope::timeOut);
}
#else
Oscilloscope::Oscilloscope(qreal pixelRatio)
: QQuickImageProvider(QQuickImageProvider::Pixmap)
, pixelRatio(pixelRatio)
, pixmap(new QPixmap(pmWidth, pmHeight))
, paint(new QPainter(pixmap))
{
m_instance = this;
connect(this, &Oscilloscope::receiveBuffer, this, &Oscilloscope::readData);
connect(this, &Oscilloscope::receiveStatus, this, &Oscilloscope::readStatus);
jclass classId = env->FindClass("org/qtproject/qt/UsbSerialInterface");
usbSerial = QAndroidJniObject(classId);
JNINativeMethod methods[] { {"sendBuffer", "([B)V", reinterpret_cast<void *>(sendBuffer)}
, {"sendStatus", "(ILjava/lang/String;)V", reinterpret_cast<void *>(sendStatus)}
};
env->RegisterNatives(classId, methods, 2);
}
#endif
Oscilloscope::~Oscilloscope()
{
}
QPixmap Oscilloscope::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(id)
*size = QSize(pmWidth, pmHeight);
if (*size != requestedSize && requestedSize.width() > 0 && requestedSize.height() > 0) {
paint->end();
*pixmap = pixmap->scaled(requestedSize, Qt::IgnoreAspectRatio);
pmHeight = requestedSize.height();
pmWidth = requestedSize.width();
paint->begin(pixmap);
yZeroV = getYZeroV();
drawBackground();
}
return *pixmap;
}
#ifndef Q_OS_ANDROID
void Oscilloscope::openSerialPort(QString portName, QString baudrate, QString dataBits, QString parity, QString intervalStr)
{
connect(serial, &QSerialPort::readyRead, this, &Oscilloscope::readData);
serial->setPortName(portName);
serial->setBaudRate(baudrate.toUInt());
serial->setDataBits((QSerialPort::DataBits)dataBits.toUInt());
serial->setParity((QSerialPort::Parity)parity.toUInt());
serial->setStopBits(QSerialPort::StopBits::OneStop);
serial->setFlowControl(QSerialPort::FlowControl::NoFlowControl);
interval = intervalStr.toUInt() / 100.0;
if (serial->open(QIODevice::ReadOnly)) {
status = connected;
emit sendStatusConn(status);
QString message("Connected (" + portName + " " + baudrate + "bps " + QString::number(interval) + "μs)");
emit sendMessage(message);
} else {
status = disconnected;
emit sendMessage("Connection error", 3000);
}
}
#else
void Oscilloscope::openSerialPort(QString portName, QString baudrate, QString dataBits, QString parity, QString interval)
{
this->interval = interval.toUInt();
quint8 parity_android;
if (parity.toUInt() == QSerialPort::OddParity)
parity_android = 1;
else
parity_android = parity.toUInt();
jstring name = env->NewStringUTF(portName.toStdString().c_str());
usbSerial.callMethod<void>
("openConnection"
, "(Landroid/content/Context;Ljava/lang/String;IIII)V"
, QtAndroid::androidContext().object(), name, baudrate.toUInt(), dataBits.toUInt(), 1, parity_android);
}
#endif
void Oscilloscope::closeSerialPort()
{
#ifndef Q_OS_ANDROID
if (serial->isOpen()) {
serial->close();
}
#else
usbSerial.callMethod<void>("closeConnection");
#endif
status = disconnected;
emit sendStatusConn(status);
emit sendMessage("Disconnected");
isPaused = false;
emit isPausedChanged(false);
}
void Oscilloscope::timeOut()
{
timedOut = true;
isPixmapSent = false;
isDataStart = true;
processData(data);
}
#ifndef Q_OS_ANDROID
void Oscilloscope::readData()
{
if (isRealTime) {
data = serial->readAll();
if (!isPaused) {
processData(data);
}
} else {
if (!isPaused) {
timer->setSingleShot(true);
timer->start(500);
if (timedOut) {
data.clear();
timedOut = false;
}
data.append(serial->readAll());
timedOut = false;
}
}
}
#else
void Oscilloscope::readData(const QByteArray &data)
{
if (!isPaused)
processData(data);
}
void Oscilloscope::readStatus(int status, const QString &message)
{
this->status = (Status)status;
switch(status) {
case connected:
this->status = connected;
emit sendStatusConn(this->status);
emit sendMessage(message);
break;
case disconnected:
this->status = disconnected;
emit sendStatusConn(this->status);
emit sendMessage("Disconnected");
break;
case connection_lost:
this->status = disconnected;
emit sendStatusConn(this->status);
emit sendMessage("Disconnected");
emit sendMessage("Connection lost", 3000);
break;
case error_connecting:
emit sendMessage("Connection error", 3000);
break;
case error_opening:
emit sendMessage("Opening error", 3000);
break;
case permission_not_granted:
emit sendMessage("Permission not granted", 3000);
break;
}
}
#endif
#ifndef Q_OS_ANDROID
QStringList Oscilloscope::fillPortsInfo()
{
const QList<QSerialPortInfo> infos = QSerialPortInfo::availablePorts();
QStringList list;
for (const QSerialPortInfo& info : infos) {
list.append(info.portName());
qDebug() << info.description();
qDebug() << info.manufacturer();
qDebug() << info.serialNumber();
}
return list;
}
#else
QStringList Oscilloscope::fillPortsInfo()
{
QAndroidJniObject drivers = usbSerial.callObjectMethod
("drivers"
, "(Landroid/content/Context;)Ljava/util/List;"
, QtAndroid::androidContext().object());
QStringList list;
int size = drivers.callMethod<jint>("size");
for (int i = 0; i < size; i++) {
QAndroidJniObject driver = drivers.callObjectMethod("get", "(I)Ljava/lang/Object;", i);
QString name = driver.toString();
if (name.contains("com.hoho.android.usbserial.driver."))
name = name.right(name.length() - QString("com.hoho.android.usbserial.driver.").length());
list.append(name);
}
return list;
}
#endif
void Oscilloscope::processData(const QByteArray &data)
{
static bool isTriggered = true;
static float oldxPos = 0;
static qint16 oldyPos = pixmap->height();
static quint8 prevValue = 0;
static quint16 deltaRising = 0;
static quint16 deltaFalling = 0;
static quint16 tsRising = 0;
static quint16 tsFalling = 0;
static quint16 triggerCont = 0;
quint16 height = pmHeight;
quint16 width = pmWidth;
paint->setPen(QPen(QColor(signalColor), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
float xDelta = width * interval / 1000.0 / timeRange;
static quint16 contX = 0;
if (isDataStart) {
oldxPos = 0;
maxValue = 0;
minValue = 0;
drawBackground();
paint->setPen(QPen(QColor(signalColor), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
isDataStart =false;
isTriggered = false;
}
for (quint16 contByte = 0; contByte < data.size(); contByte++) {
for (quint16 contSubByte = 8 / dataBits; contSubByte > 0; contSubByte--) {
quint8 value = (data[contByte] << (contSubByte - 1) * dataBits) & ~(0xFF >> dataBits);
//quint8 value = data[contByte];
// Find V limits
if (value > maxValue) {
maxValue = value;
}
if (value < minValue) {
minValue = value;
}
// Find triggers and signal properties
if (value - prevValue > 0) { // rising
deltaRising += value - prevValue;
deltaFalling = 0;
}
if (value - prevValue < 0) { // falling
deltaFalling += prevValue - value;
deltaRising = 0;
}
prevValue = value;
if (((float)deltaRising) / 0xFF * 5 > triggerValue / 1000.0) {
if ((triggerType == rising || triggerType == none) && triggerCont - tsRising > 2) {
isTriggered = true;
rawFreq = triggerCont - tsRising;
rawDuty = triggerCont - tsFalling;
rawFreqAvg = 0.1 * rawFreq + 0.9 * rawFreqAvg;
rawDutyAvg = 0.1 * rawDuty + 0.9 * rawDutyAvg;
}
deltaRising = 0;
deltaFalling = 0;
tsRising = triggerCont;
}
if (((float)deltaFalling) / 0xFF * 5 > triggerValue / 1000.0) {
if (triggerType == falling && triggerCont - tsFalling > 2) {
isTriggered = true;
rawFreq = triggerCont - tsFalling;
rawDuty = triggerCont - tsRising;
rawFreqAvg = 0.1 * rawFreq + 0.9 * rawFreqAvg;
rawDutyAvg = 0.1 * rawDuty + 0.9 * rawDutyAvg;
}
deltaRising = 0;
deltaFalling = 0;
tsFalling = triggerCont;
}
triggerCont++;
// Capture
if (isCapturing) {
captureBuffer->append(value);
}
// Draw new value
if (isTriggered == true || triggerType == none) {
float newxPos = contX * xDelta;
contX++;
qint16 newyPos = height + yZeroV - getYVal(value);
// End of pixmap
if (newxPos > width) {
if (triggerType != none) {
isTriggered = false;
deltaRising = 0;
deltaFalling = 0;
}
emit sendPixmap();
if (pendingExport) {
savePixmap(filename);
pendingExport = false;
}
if (isCapturing) {
isCapturing = false;
saveCsv(filename);
delete captureBuffer;
}
if (pendingCsv) {
isCapturing = true;
pendingCsv = false;
captureBuffer = new QByteArray(timeRange/interval+1, 0);
}
if (pendingPause) {
pendingPause = false;
isPaused = true;
emit isPausedChanged(true);
return;
}
if (!isRealTime) {
isPixmapSent = true;
newxPos = 0;
maxValue = 0;
minValue = 0;
contX = 0;
return;
}
drawBackground();
paint->setPen(QPen(QColor(signalColor), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
newxPos = 0;
maxValue = 0;
minValue = 0;
contX = 0;
}
// Draw new value
else {
paint->drawLine(newxPos + width * hAdjust, newyPos + height * vAdjust, oldxPos + width * hAdjust, oldyPos + height * vAdjust);
}
oldxPos = newxPos;
oldyPos = newyPos;
}
}
}
if (!isRealTime && !isPixmapSent)
emit sendPixmap();
}
qint16 Oscilloscope::getYZeroV()
{
return pmHeight * (5-voltRange)/voltRange/2;
}
quint16 Oscilloscope::getYVal(quint8 value)
{
return value * 5.0 / 0xFF * pmHeight / voltRange;
}
void Oscilloscope::drawBackground()
{
quint16 height = pmHeight;
quint16 width = pmWidth;
paint->fillRect(0, 0, width, height, QColor(backgroundColor));
// 0 volts line
paint->setPen(QPen(Qt::red, 1, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin));
quint16 yPos = height + yZeroV;
paint->drawLine(0, yPos + height * vAdjust, width, yPos + height * vAdjust);
paint->setPen(QColor(gridColor));
for (quint8 i = 0; i < 6; i++) { // horizontal lines
paint->drawLine(0, height * i / 6, width, height * i / 6);
}
for (quint8 i = 0; i < 11; i++) { // vertical lines
paint->drawLine(width * i / 11, 0, width * i / 11, height);
}
QFont font = paint->font();
font.setPixelSize(14 * pixelRatio);
paint->setFont(font);
paint->setPen(QColor(textColor));
paint->drawText(5, height - 5, QString::number(vDiv) + "mV/d " + QString::number(hDiv) + "μs/d Vmax=" + QString::number((float)maxValue / 0xFF * 5, 'f',
3) + " Vmin=" + QString::number((float)minValue / 0xFF * 5, 'f', 3));
QString freq, duty;
if (rawFreqAvg == 0) {
freq = "0";
duty = "0";
} else {
freq = QString::number((float)1000000 / (rawFreqAvg * interval), 'f', 0);
duty = QString::number(100 * (float)rawDutyAvg / rawFreqAvg, 'f', 0);
}
paint->drawText(5, font.pixelSize() + 5, freq + "Hz " + duty + "%");
}
void Oscilloscope::exportImage(QUrl url)
{
QString filename;
#ifndef Q_OS_ANDROID
filename = url.path();
#else
filename = url.toString();
#endif
if (filename.isEmpty()) {
return;
} else {
if (status == connected && !isPaused) {
pendingExport = true;
this->filename = filename;
} else
savePixmap(filename);
}
}
void Oscilloscope::savePixmap(QString filename)
{
if (!pixmap->toImage().save(filename, "BMP")) {
emit sendMessage("Export error", 3000);
} else {
emit sendMessage("Exported", 3000);
}
}
void Oscilloscope::exportCsv(QUrl url)
{
QString filename;
#ifndef Q_OS_ANDROID
filename = url.path();
#else
filename = url.toString();
#endif
if (filename.isEmpty()) {
return;
} else {
if (status == connected) {
if (isPaused) {
isPaused = false;
emit isPausedChanged(false);
}
pendingCsv = true;
this->filename = filename;
}
}
}
void Oscilloscope::saveCsv(QString filename)
{
QFile data(filename);
if(data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream output(&data);
output << "Interval\t" + QString::number(interval) + "\n";
for (quint16 i=0; i < captureBuffer->size(); i++) {
float volt = (quint8)captureBuffer->at(i) * 5.0/0xFF;
output << QString::number(volt, 'f', 3) + "\n";
}
}
data.close();
}
void Oscilloscope::setIsPaused(const bool value)
{
if (value == true)
pendingPause = true;
else {
isPaused = false;
pendingPause = false;
emit isPausedChanged(false);
}
}

Wyświetl plik

@ -0,0 +1,218 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef OSCILLOSCOPE_H
#define OSCILLOSCOPE_H
#include <QDebug>
#include <QFile>
#include <QPainter>
#include <QQuickImageProvider>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTime>
#include <QTimer>
#ifdef Q_OS_ANDROID
#include <QAndroidJniEnvironment>
#include <QAndroidJniObject>
#include <QtAndroid>
#endif
class Oscilloscope : public QObject, public QQuickImageProvider
{
Q_OBJECT
// Q_PROPERTY(bool isPaused READ getIsPaused WRITE setIsPaused NOTIFY
// isPausedChanged)
public:
enum TriggerType { none, rising, falling };
enum Status {
connected,
disconnected,
permission_not_granted,
error_connecting,
error_opening,
connection_lost,
driver_not_found,
permission_requested
};
Q_ENUM(Status)
Q_ENUM(TriggerType)
Oscilloscope(qreal pixelratio);
~Oscilloscope();
QPixmap requestPixmap(const QString &id, QSize *size,
const QSize &requestedSize) override;
Q_INVOKABLE void openSerialPort(QString portName, QString baudrate,
QString dataBits, QString parity,
QString interval);
Q_INVOKABLE void closeSerialPort();
Q_INVOKABLE QStringList fillPortsInfo();
Q_INVOKABLE void setBackgroundColor(const QString &color)
{
backgroundColor = color;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setGridColor(const QString &color)
{
gridColor = color;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setSignalColor(const QString &color)
{
signalColor = color;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setTextColor(const QString &color)
{
textColor = color;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setVDiv(const quint16 value)
{
vDiv = value;
voltRange = value * 6 / 1000.0;
yZeroV = getYZeroV();
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setHDiv(const quint16 value)
{
hDiv = value;
timeRange = value * 11 / 1000.0;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setTriggerType(const quint16 value)
{
triggerType = (TriggerType)value;
}
Q_INVOKABLE void setTriggerValue(const quint16 value)
{
triggerValue = value;
}
Q_INVOKABLE void setVAdjust(const qint16 value)
{
vAdjust = 6 / voltRange * value / 100.0;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void setHAdjust(const qint16 value)
{
hAdjust = 11 / timeRange * value / 100.0 * 0.25;
drawBackground();
emit sendPixmap();
}
Q_INVOKABLE void exportImage(QUrl filename);
Q_INVOKABLE void exportCsv(QUrl filename);
Q_INVOKABLE bool getIsPaused()
{
return isPaused;
}
Q_INVOKABLE void setIsPaused(const bool value);
Q_INVOKABLE QString getVersion()
{
return APP_VERSION;
}
#ifdef Q_OS_ANDROID
static Oscilloscope *instance()
{
return m_instance;
}
#endif
signals:
void isPausedChanged(bool isPaused);
void sendPixmap();
void sendStatusConn(Status status);
void sendMessage(QString message, quint16 duration = 0);
#ifdef Q_OS_ANDROID
void receiveBuffer(const QByteArray &buffer);
void receiveStatus(int status, const QString &msg);
#endif
private:
enum Edge { min, max };
quint16 pmHeight = 400;
quint16 pmWidth = 800;
quint8 maxValue = 0;
quint8 minValue = 0;
quint16 rawFreq = 0;
quint16 rawDuty = 0;
float rawFreqAvg = 0;
float rawDutyAvg = 0;
bool pendingExport = false;
bool pendingCsv = false;
bool pendingPause = false;
QString filename;
float interval = 26;
quint16 vDiv = 1000;
quint16 hDiv = 1000;
float voltRange = 1000 * 6 / 1000.0;
float timeRange = 1000 * 11 / 1000.0;
qint16 yZeroV;
quint16 triggerValue = 1000;
TriggerType triggerType = rising;
QString backgroundColor = "#000000";
QString gridColor = "#77767b";
QString signalColor = "#33d17a";
QString textColor = "#f9f06b";
float vAdjust = 0;
float hAdjust = 0;
Status status = disconnected;
qreal pixelRatio;
bool isPaused = false;
bool isCapturing = false;
QByteArray *captureBuffer;
QPixmap *pixmap;
QPainter *paint;
#ifdef Q_OS_ANDROID
static Oscilloscope *m_instance;
QAndroidJniEnvironment env;
QAndroidJniObject usbSerial;
jobject context;
void readStatus(int status, const QString &msg);
#else
QSerialPort *serial = nullptr;
#endif
void drawBackground();
void processData(const QByteArray &data);
qint16 getYZeroV();
quint16 getYVal(quint8 value);
void savePixmap(QString filename);
void saveCsv(QString filename);
quint8 dataBits = 8;
bool isRealTime = true;
bool isPixmapSent = false;
bool isDataStart = false;
QTimer *timer;
QByteArray data;
bool timedOut = false;
public slots:
#ifndef Q_OS_ANDROID
void readData();
void timeOut();
#else
void readData(const QByteArray &data);
#endif
};
#endif // OSCILLOSCOPE_H

Wyświetl plik

@ -1,36 +1,63 @@
QT += core gui serialport
QT += qml quick serialport widgets quickcontrols2
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
android {
QT += androidextras
}
CONFIG += c++11 console
CONFIG += c++11
#CONFIG += console
VERSION = 0.2
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
aboutdialog.cpp \
main.cpp \
mainwindow.cpp \
settingsdialog.cpp
oscilloscope.cpp
HEADERS += \
aboutdialog.h \
mainwindow.h \
settingsdialog.h
oscilloscope.h
FORMS += \
aboutdialog.ui \
mainwindow.ui \
settingsdialog.ui
FORMS +=
# mainwindow.ui \
win32 {
TARGET = oscilloscope_win
RC_ICONS = res/oscilloscope.ico
}
unix {
TARGET = oscilloscope_linux
}
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
RESOURCES += \
resources.qrc
DISTFILES += \
../../README.md
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/AndroidManifest.xml \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/build.gradle \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/gradle.properties \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/gradle/wrapper/gradle-wrapper.jar \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/gradle/wrapper/gradle-wrapper.properties \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/gradlew \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/gradlew.bat \
../../../../../../../../mnt/data/daniel/src/qt/oscilloscope/src/qt/android/res/values/libs.xml \
android/AndroidManifest.xml \
android/build.gradle \
android/gradle.properties \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew \
android/gradlew.bat \
android/res/values/libs.xml \
android/src/org/qtproject/qt/UsbSerialInterface.java \

Wyświetl plik

@ -1,258 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 5.0.1, 2021-10-29T18:38:44. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{1228bee3-dc7f-48ad-92d1-73e2d506f9f6}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.BuildSystem</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">4</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{ad3039d7-aac8-4d3f-a4e2-fbb234c9cc10}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/daniel/src/qt/oscilloscope/src/build-oscilloscope-Desktop-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/src/qt/oscilloscope/src/build-oscilloscope-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/daniel/src/qt/oscilloscope/src/build-oscilloscope-Desktop-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/src/qt/oscilloscope/src/build-oscilloscope-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/daniel/src/qt/oscilloscope/src/build-oscilloscope-Desktop-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/src/qt/oscilloscope/src/build-oscilloscope-Desktop-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 475 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 538 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 612 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 649 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 702 B

BIN
src/qt/res/info.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 879 B

BIN
src/qt/res/menu.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 353 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 5.8 MiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 374 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 9.0 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 23 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 150 B

BIN
src/qt/res/play.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 343 B

BIN
src/qt/res/save.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 350 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.0 KiB

Wyświetl plik

@ -1,5 +1,34 @@
<RCC>
<qresource prefix="/">
<file>oscilloscope.bmp</file>
<file>res/application-exit.png</file>
<file>res/connect.png</file>
<file>res/disconnect.png</file>
<file>res/info.png</file>
<file>res/oscilloscope.bmp</file>
<file>res/oscilloscope.ico</file>
<file>res/save.png</file>
<file>res/settings.png</file>
<file>res/oscilloscope_120x64.bmp</file>
<file>android/res/connect.png</file>
<file>android/res/disconnect.png</file>
<file>android/res/info.png</file>
<file>android/res/oscilloscope.bmp</file>
<file>android/res/save.png</file>
<file>res/play.png</file>
<file>res/export.png</file>
<file>res/capture.png</file>
<file>res/pause.png</file>
<file>android/res/play.png</file>
<file>android/res/export.png</file>
<file>android/res/capture.png</file>
<file>android/res/pause.png</file>
<file>AboutItem.qml</file>
<file>MainItem.qml</file>
<file>mainwindow.qml</file>
<file>mainwindow_device.qml</file>
<file>SettingsItem.qml</file>
<file>res/oscilloscope.png</file>
<file>res/menu.png</file>
<file>android/res/menu.png</file>
</qresource>
</RCC>

Wyświetl plik

@ -1,188 +0,0 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include <QIntValidator>
#include <QLineEdit>
#include <QSerialPortInfo>
static const char blankString[] = QT_TRANSLATE_NOOP("SettingsDialog", "N/A");
SettingsDialog::SettingsDialog(QWidget* parent) :
QDialog(parent),
m_settings(new QSettings("Oscilloscope", "DGeA Soft")),
m_ui(new Ui::SettingsDialog),
m_intValidator(new QIntValidator(0, 4000000, this))
{
m_ui->setupUi(this);
m_ui->baudRateBox->setInsertPolicy(QComboBox::NoInsert);
connect(m_ui->applyButton, &QPushButton::clicked,
this, &SettingsDialog::apply);
connect(m_ui->serialPortInfoListBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsDialog::showPortInfo);
connect(m_ui->baudRateBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsDialog::checkCustomBaudRatePolicy);
connect(m_ui->serialPortInfoListBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsDialog::checkCustomDevicePathPolicy);
fillPortsParameters();
fillPortsInfo();
m_ui->serialPortInfoListBox->setCurrentText(m_settings->value("serialport").toString());
m_ui->baudRateBox->setCurrentText(m_settings->value("baudrate").toString());
m_ui->dataBitsBox->setCurrentText(m_settings->value("databits").toString());
m_ui->parityBox->setCurrentText(m_settings->value("parity").toString());
m_ui->stopBitsBox->setCurrentText(m_settings->value("stopbits").toString());
m_ui->flowControlBox->setCurrentText(m_settings->value("flowcontrol").toString());
m_ui->sbInterval->setValue(m_settings->value("interval").toInt());
}
SettingsDialog::~SettingsDialog()
{
delete m_ui;
}
SettingsDialog::Settings SettingsDialog::settings() const
{
return m_currentSettings;
}
void SettingsDialog::showPortInfo(int idx)
{
if (idx == -1)
{
return;
}
const QStringList list = m_ui->serialPortInfoListBox->itemData(idx).toStringList();
m_ui->descriptionLabel->setText(tr("Description: %1").arg(list.count() > 1 ? list.at(1) : tr(blankString)));
m_ui->manufacturerLabel->setText(tr("Manufacturer: %1").arg(list.count() > 2 ? list.at(2) : tr(blankString)));
m_ui->serialNumberLabel->setText(tr("Serial number: %1").arg(list.count() > 3 ? list.at(3) : tr(blankString)));
m_ui->locationLabel->setText(tr("Location: %1").arg(list.count() > 4 ? list.at(4) : tr(blankString)));
m_ui->vidLabel->setText(tr("Vendor Identifier: %1").arg(list.count() > 5 ? list.at(5) : tr(blankString)));
m_ui->pidLabel->setText(tr("Product Identifier: %1").arg(list.count() > 6 ? list.at(6) : tr(blankString)));
}
void SettingsDialog::apply()
{
updateSettings();
hide();
}
void SettingsDialog::checkCustomBaudRatePolicy(int idx)
{
const bool isCustomBaudRate = !m_ui->baudRateBox->itemData(idx).isValid();
m_ui->baudRateBox->setEditable(isCustomBaudRate);
if (isCustomBaudRate)
{
m_ui->baudRateBox->clearEditText();
QLineEdit* edit = m_ui->baudRateBox->lineEdit();
edit->setValidator(m_intValidator);
}
}
void SettingsDialog::checkCustomDevicePathPolicy(int idx)
{
const bool isCustomPath = !m_ui->serialPortInfoListBox->itemData(idx).isValid();
m_ui->serialPortInfoListBox->setEditable(isCustomPath);
if (isCustomPath)
{
m_ui->serialPortInfoListBox->clearEditText();
}
}
void SettingsDialog::fillPortsParameters()
{
m_ui->baudRateBox->addItem(QStringLiteral("9600"), QSerialPort::Baud9600);
m_ui->baudRateBox->addItem(QStringLiteral("19200"), QSerialPort::Baud19200);
m_ui->baudRateBox->addItem(QStringLiteral("38400"), QSerialPort::Baud38400);
m_ui->baudRateBox->addItem(QStringLiteral("115200"), QSerialPort::Baud115200);
m_ui->baudRateBox->addItem(QStringLiteral("230400"), 230400);
m_ui->baudRateBox->addItem(QStringLiteral("500000"), 500000);
m_ui->baudRateBox->addItem(QStringLiteral("1000000"), 1000000);
m_ui->baudRateBox->addItem(tr("Custom"));
m_ui->dataBitsBox->addItem(QStringLiteral("5"), QSerialPort::Data5);
m_ui->dataBitsBox->addItem(QStringLiteral("6"), QSerialPort::Data6);
m_ui->dataBitsBox->addItem(QStringLiteral("7"), QSerialPort::Data7);
m_ui->dataBitsBox->addItem(QStringLiteral("8"), QSerialPort::Data8);
m_ui->dataBitsBox->setCurrentIndex(3);
m_ui->parityBox->addItem(tr("None"), QSerialPort::NoParity);
m_ui->parityBox->addItem(tr("Even"), QSerialPort::EvenParity);
m_ui->parityBox->addItem(tr("Odd"), QSerialPort::OddParity);
m_ui->parityBox->addItem(tr("Mark"), QSerialPort::MarkParity);
m_ui->parityBox->addItem(tr("Space"), QSerialPort::SpaceParity);
m_ui->stopBitsBox->addItem(QStringLiteral("1"), QSerialPort::OneStop);
#ifdef Q_OS_WIN
m_ui->stopBitsBox->addItem(tr("1.5"), QSerialPort::OneAndHalfStop);
#endif
m_ui->stopBitsBox->addItem(QStringLiteral("2"), QSerialPort::TwoStop);
m_ui->flowControlBox->addItem(tr("None"), QSerialPort::NoFlowControl);
m_ui->flowControlBox->addItem(tr("RTS/CTS"), QSerialPort::HardwareControl);
m_ui->flowControlBox->addItem(tr("XON/XOFF"), QSerialPort::SoftwareControl);
}
void SettingsDialog::fillPortsInfo()
{
m_ui->serialPortInfoListBox->clear();
QString description;
QString manufacturer;
QString serialNumber;
const auto infos = QSerialPortInfo::availablePorts();
for (const QSerialPortInfo& info : infos)
{
QStringList list;
description = info.description();
manufacturer = info.manufacturer();
serialNumber = info.serialNumber();
list << info.portName()
<< (!description.isEmpty() ? description : blankString)
<< (!manufacturer.isEmpty() ? manufacturer : blankString)
<< (!serialNumber.isEmpty() ? serialNumber : blankString)
<< info.systemLocation()
<< (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : blankString)
<< (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : blankString);
m_ui->serialPortInfoListBox->addItem(list.first(), list);
}
m_ui->serialPortInfoListBox->addItem(tr("Custom"));
}
void SettingsDialog::updateSettings()
{
QSettings settings;
m_currentSettings.name = m_ui->serialPortInfoListBox->currentText();
m_settings->setValue("serialport", m_ui->serialPortInfoListBox->currentText());
if (m_ui->baudRateBox->currentIndex() == 4)
{
m_currentSettings.baudRate = m_ui->baudRateBox->currentText().toInt();
}
else
{
m_currentSettings.baudRate = static_cast<QSerialPort::BaudRate>(
m_ui->baudRateBox->itemData(m_ui->baudRateBox->currentIndex()).toInt());
}
m_currentSettings.stringBaudRate = QString::number(m_currentSettings.baudRate);
m_settings->setValue("baudrate", m_ui->baudRateBox->currentText().toInt());
m_currentSettings.dataBits = static_cast<QSerialPort::DataBits>(
m_ui->dataBitsBox->itemData(m_ui->dataBitsBox->currentIndex()).toInt());
m_currentSettings.stringDataBits = m_ui->dataBitsBox->currentText();
m_settings->setValue("databits", m_ui->dataBitsBox->currentText().toInt());
m_currentSettings.parity = static_cast<QSerialPort::Parity>(
m_ui->parityBox->itemData(m_ui->parityBox->currentIndex()).toInt());
m_currentSettings.stringParity = m_ui->parityBox->currentText();
m_settings->setValue("parity", m_ui->parityBox->currentIndex());
m_currentSettings.stopBits = static_cast<QSerialPort::StopBits>(
m_ui->stopBitsBox->itemData(m_ui->stopBitsBox->currentIndex()).toInt());
m_currentSettings.stringStopBits = m_ui->stopBitsBox->currentText();
m_settings->setValue("stopbits", m_ui->stopBitsBox->currentText().toInt());
m_currentSettings.flowControl = static_cast<QSerialPort::FlowControl>(
m_ui->flowControlBox->itemData(m_ui->flowControlBox->currentIndex()).toInt());
m_currentSettings.stringFlowControl = m_ui->flowControlBox->currentText();
m_settings->setValue("flowcontrol", m_ui->flowControlBox->currentText().toInt());
m_currentSettings.interval = m_ui->sbInterval->value();
m_settings->setValue("interval", m_ui->sbInterval->value());
}

Wyświetl plik

@ -1,64 +0,0 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include <QSerialPort>
#include <QSettings>
QT_BEGIN_NAMESPACE
namespace Ui {
class SettingsDialog;
}
class QIntValidator;
QT_END_NAMESPACE
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
struct Settings {
QString name;
qint32 baudRate;
QString stringBaudRate;
QSerialPort::DataBits dataBits;
QString stringDataBits;
QSerialPort::Parity parity;
QString stringParity;
QSerialPort::StopBits stopBits;
QString stringStopBits;
QSerialPort::FlowControl flowControl;
QString stringFlowControl;
qint16 interval;
};
Settings m_currentSettings;
QSettings *m_settings;
explicit SettingsDialog(QWidget *parent = nullptr);
~SettingsDialog();
Settings settings() const;
private slots:
void showPortInfo(int idx);
void apply();
void checkCustomBaudRatePolicy(int idx);
void checkCustomDevicePathPolicy(int idx);
private:
void fillPortsParameters();
void fillPortsInfo();
void updateSettings();
private:
Ui::SettingsDialog *m_ui = nullptr;
QIntValidator *m_intValidator = nullptr;
};
#endif // SETTINGSDIALOG_H

Wyświetl plik

@ -1,184 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>363</width>
<height>353</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QGroupBox" name="parametersBox">
<property name="title">
<string>Select Parameters</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="baudRateLabel">
<property name="text">
<string>BaudRate:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="baudRateBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="dataBitsLabel">
<property name="text">
<string>Data bits:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="dataBitsBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="parityLabel">
<property name="text">
<string>Parity:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="parityBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="stopBitsLabel">
<property name="text">
<string>Stop bits:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="stopBitsBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="flowControlLabel">
<property name="text">
<string>Flow control:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="flowControlBox"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="selectBox">
<property name="title">
<string>Select Serial Port</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QComboBox" name="serialPortInfoListBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="manufacturerLabel">
<property name="text">
<string>Manufacturer:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="serialNumberLabel">
<property name="text">
<string>Serial number:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="locationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="vidLabel">
<property name="text">
<string>Vendor ID:</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="pidLabel">
<property name="text">
<string>Product ID:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>96</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="applyButton">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="additionalOptionsGroupBox">
<property name="title">
<string>Additional options</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Interval (us)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbInterval">
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>