mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-07-26 10:38:52 +00:00
Compare commits
205 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a07683b2a6 | |||
| e3de466743 | |||
| 3903aec071 | |||
| 2a11b59ab7 | |||
| 0d1d703ba9 | |||
| 84ea106f79 | |||
| dc06950a94 | |||
| cf82a3f439 | |||
| 16923717d9 | |||
| 23ec3ff11b | |||
| bbd9a865de | |||
| e985efd78b | |||
| 14484b550a | |||
| 4fcf2cd724 | |||
| 6aa88fb5f9 | |||
| 8f8af0732f | |||
| 4322670dbc | |||
| 602a8e6e7f | |||
| 535f671284 | |||
| 40654aba55 | |||
| aa9917be20 | |||
| 3bbad90949 | |||
| a0a1954138 | |||
| 94ec0c9087 | |||
| a571e40c59 | |||
| 79b24ebe13 | |||
| 8a4564f6f5 | |||
| 1a21e06bbe | |||
| da380261b2 | |||
| 790ebdff31 | |||
| cf906684cc | |||
| 0d51e3569f | |||
| 0d7bbac6a1 | |||
| b499380448 | |||
| ab8f93805d | |||
| f4db4e2b53 | |||
| 318720f364 | |||
| 6ef24ce71c | |||
| 62f063aef5 | |||
| 110b40ea49 | |||
| 2b045ffca6 | |||
| be01ca6da1 | |||
| 0fed64636a | |||
| ab364ca497 | |||
| a49c35088d | |||
| 848dba44d8 | |||
| 5a21c1c76a | |||
| b335886f42 | |||
| f12eb55f6b | |||
| 6871126100 | |||
| 5b4c3514fb | |||
| af7242f7d1 | |||
| 03eae70555 | |||
| 010f06c77c | |||
| 2f86fa7e99 | |||
| fe806b7bdc | |||
| 22e8add4dd | |||
| 93ce2b04c0 | |||
| b09439afb1 | |||
| 97349b06ef | |||
| 8329b66926 | |||
| 52376b12b2 | |||
| 95f72991c4 | |||
| 2ceb49e4f2 | |||
| 8afd83a4e1 | |||
| 8aff0bb4d8 | |||
| 7fe6a3b04e | |||
| c8a8a69832 | |||
| de994d5911 | |||
| 935db5b58b | |||
| 81f7875764 | |||
| 0f511508a3 | |||
| a80d91fb1e | |||
| 43e123bafe | |||
| fb0672925e | |||
| c2dc7d1cf5 | |||
| edcd780402 | |||
| c85e6a4d52 | |||
| 414ed9a0ec | |||
| f8f5963bcf | |||
| 9040e780bc | |||
| f1ba8c3dee | |||
| 3f1af56dfc | |||
| 226c0c2d80 | |||
| d74e1830f8 | |||
| 6bc2cbeda9 | |||
| e76609a74a | |||
| 97f3f773fb | |||
| bf0b9b9881 | |||
| 182059b3c6 | |||
| c307e9d5ae | |||
| a090f1fb0d | |||
| 62b789e432 | |||
| 42b33c4526 | |||
| a95c3a3e63 | |||
| a3ef7d069e | |||
| f5c3219035 | |||
| a2e4a15229 | |||
| 1a8319b86e | |||
| 2ab4ed591d | |||
| 4f74e262d2 | |||
| 88ca1234d9 | |||
| 433529b4cb | |||
| f161e85f96 | |||
| f1fd9a3db1 | |||
| 85e4a43cbd | |||
| 5f778c1734 | |||
| c19bcc17af | |||
| d60299af95 | |||
| 57ed3ebb43 | |||
| dfa1a98575 | |||
| e21fbbf234 | |||
| 136209dc8d | |||
| 838451f491 | |||
| 2da482f393 | |||
| 4cafce3286 | |||
| f9685517ea | |||
| d020016413 | |||
| 4c50401df2 | |||
| d57edd5e25 | |||
| 594890744b | |||
| a0eaa70ff4 | |||
| 9402634602 | |||
| 41864f06e7 | |||
| 133bfbf07b | |||
| f65852ff05 | |||
| 603b7fb1ab | |||
| 9d437aee6a | |||
| fe98a58a4f | |||
| ee2ebc8302 | |||
| f15cf78101 | |||
| f56e8930dc | |||
| f98c96e98a | |||
| de92faf67b | |||
| 27f354f841 | |||
| eca25898f2 | |||
| aea807e1f4 | |||
| 8807ab179b | |||
| 7049373d67 | |||
| 3c30c127e2 | |||
| b82b0f15d0 | |||
| 62c1e4e028 | |||
| cd8732c24f | |||
| 4f90c5efee | |||
| e0e57e5af2 | |||
| d59b0d44d3 | |||
| 5ca7398bd9 | |||
| dbb46edcb6 | |||
| 68e75cc98e | |||
| f0ca95ee7e | |||
| 1a48fb8c5a | |||
| 1a3a60f6ac | |||
| 77a7f48958 | |||
| 523877e0d1 | |||
| 282416169d | |||
| 8e8e156477 | |||
| b1135aab0a | |||
| 36f9e0cb7c | |||
| 9bd74f32d0 | |||
| dd0042b5f1 | |||
| fb61ad55c0 | |||
| ca7b5e110c | |||
| a6a41ca5a5 | |||
| 02d69e54eb | |||
| b75ef345a5 | |||
| 8c84719598 | |||
| 8bfeba0d89 | |||
| c3c680fc04 | |||
| f0457c106d | |||
| 5d73175a17 | |||
| 45b874694e | |||
| 42113434f0 | |||
| e9e4d20302 | |||
| ec520bf08c | |||
| 486c1d6bcd | |||
| b7eb095dd8 | |||
| 3c14d38286 | |||
| 3166a66756 | |||
| 961e115cc6 | |||
| 1483160df4 | |||
| c3fe053eb2 | |||
| 6c2950cfe8 | |||
| 89d46d59ee | |||
| 0d7aa1d32c | |||
| 266e398224 | |||
| e75677d366 | |||
| 1c1d3e9897 | |||
| 50bab791dd | |||
| 19ebf14e8c | |||
| 8b6442ee79 | |||
| 456b55d552 | |||
| 000b2d3e7d | |||
| 554db24b1f | |||
| 1207bac215 | |||
| 4306ba5d83 | |||
| 530789f963 | |||
| ebe6675a3a | |||
| 95be75a8af | |||
| 5cbbf62c5f | |||
| 80f074b82f | |||
| 7116ca3f91 | |||
| 8463cba4b6 | |||
| 78f2e417d6 | |||
| ac12bf5f50 | |||
| 8edaa1e51e |
+7
-1
@@ -63,4 +63,10 @@ CMakeFiles/
|
||||
|
||||
# Host OS leftovers
|
||||
.DS_Store
|
||||
/firmware/CMakeCache.txt
|
||||
/firmware/CMakeCache.txt
|
||||
|
||||
# Python env
|
||||
env/
|
||||
|
||||
# Other
|
||||
*.bak
|
||||
|
||||
@@ -1,281 +1,622 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
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
|
||||
this service 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.
|
||||
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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
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 give the recipients all the rights that
|
||||
you have. 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.
|
||||
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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
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.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
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.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
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.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
0. Definitions.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
"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.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
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) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
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.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
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.
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
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.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
1. Source Code.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
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.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
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.
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
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.
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
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.
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
2. Basic Permissions.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
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.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
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.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
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.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
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.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
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.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
14. Revised Versions of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
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.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
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.
|
||||
|
||||
NO WARRANTY
|
||||
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.
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
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
|
||||
|
||||
@@ -287,15 +628,15 @@ 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
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
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.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
<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
|
||||
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 2 of the License, or
|
||||
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,
|
||||
@@ -303,37 +644,31 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
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 your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
|
||||
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 2 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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
||||
@@ -0,0 +1,7 @@
|
||||
# License
|
||||
Portapack Mayhem is distributed under GPL v3.0, however some sub projects might have different (GPL v3.0 compatible) licenses.
|
||||
|
||||
## Other Licenses (compatible with GPL v3.0)
|
||||
- Most of Portapack Mayhem is distributed under GPL-2.0-or-later. [license](LICENSE.GPL-2.0-or-later)
|
||||
- ChibiOS is distributed under GPL v3.0. [license](/firmware/chibios/license.txt)
|
||||
- Portapack-ChibiOS is distributed under Apache-2.0 [license](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
@@ -1,8 +1,6 @@
|
||||
> ⚠ **BEFORE BUYING YOURS:** Beware of hardware mods that use a custom firmware, which are [NOT COMPATIBLE](https://github.com/eried/portapack-mayhem/issues/264) with older forks, and they do not follow the license. **ASK THE SELLER if the unit works with an specific firmware, for example, pointing to the [](https://github.com/eried/portapack-mayhem/releases/latest) on this repository**
|
||||
|
||||
# PortaPack Mayhem
|
||||
|
||||
[](https://travis-ci.com/eried/portapack-mayhem) [](https://app.buddy.works/eried/portapack/pipelines/pipeline/252276) [](https://codescene.io/projects/8381) [](https://github.com/eried/portapack-mayhem/releases) [](https://github.com/eried/portapack-mayhem/releases/latest) [](https://hub.docker.com/r/eried/portapack) [](https://discord.gg/tuwVMv3) [](https://www.bountysource.com/teams/portapack-mayhem/issues)
|
||||
[](https://travis-ci.com/eried/portapack-mayhem) [](https://codescene.io/projects/8381) [](https://github.com/eried/portapack-mayhem/releases) [](https://github.com/eried/portapack-mayhem/releases/latest) [](https://hub.docker.com/r/eried/portapack) [](https://discord.gg/tuwVMv3) [](https://www.bountysource.com/teams/portapack-mayhem/issues)
|
||||
|
||||
This is a fork of the [Havoc](https://github.com/furrtek/portapack-havoc/) firmware, which itself was a fork of the [PortaPack](https://github.com/sharebrained/portapack-hackrf) firmware, an add-on for the [HackRF](http://greatscottgadgets.com/hackrf/). A fork is a derivate, in this case one that has extra features and fixes when compared to the older versions.
|
||||
|
||||
@@ -28,7 +26,7 @@ To support the people behind the hardware, please buy a genuine [HackRF](https:/
|
||||
|
||||
## Where is the latest firmware?
|
||||
|
||||
The current stable release is on the [](https://github.com/eried/portapack-mayhem/releases/latest) page. Follow the instructions you can find in the release description. There is also [nightly builds](https://github.com/eried/portapack-mayhem/releases/tag/nightly) generated periodically, which include the latest commits, but they may contain incomplete or buggy functionality.
|
||||
The current stable release is on the [](https://github.com/eried/portapack-mayhem/releases/latest) page. Follow the instructions you can find in the release description.
|
||||
|
||||
## Is this the newest firmware for my PortaPack?
|
||||
Most probably: **YES**. *If you find new features somewhere else, please [suggest](https://github.com/eried/portapack-mayhem/issues/new/choose) them*.
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ RUN apt-get update && \
|
||||
apt-get -qy autoremove
|
||||
|
||||
#Install current pip from PyPa
|
||||
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
|
||||
RUN curl https://bootstrap.pypa.io/pip/3.4/get-pip.py -o get-pip.py && \
|
||||
python get-pip.py
|
||||
|
||||
#Fetch additional dependencies from Python 2.x pip
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ RUN apt-get update && \
|
||||
apt-get -qy autoremove
|
||||
|
||||
#Install current pip from PyPa
|
||||
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
|
||||
RUN curl https://bootstrap.pypa.io/pip/3.4/get-pip.py -o get-pip.py && \
|
||||
python3 get-pip.py
|
||||
|
||||
#Fetch additional dependencies from Python 3.x pip
|
||||
@@ -38,4 +38,4 @@ RUN mkdir ~/bin && cd ~/bin && \
|
||||
for tool in gcc g++ cpp c++;do ln -s $(which ccache) arm-none-eabi-$tool;done
|
||||
|
||||
CMD cd .. && cd build && \
|
||||
cmake .. && make firmware
|
||||
cmake .. && make firmware
|
||||
|
||||
@@ -140,6 +140,7 @@ set(CPPSRC
|
||||
${COMMON}/png_writer.cpp
|
||||
${COMMON}/pocsag.cpp
|
||||
${COMMON}/pocsag_packet.cpp
|
||||
${COMMON}/aprs_packet.cpp
|
||||
${COMMON}/portapack_io.cpp
|
||||
${COMMON}/portapack_persistent_memory.cpp
|
||||
${COMMON}/portapack_shared_memory.cpp
|
||||
@@ -218,6 +219,7 @@ set(CPPSRC
|
||||
apps/ui_adsb_rx.cpp
|
||||
apps/ui_adsb_tx.cpp
|
||||
apps/ui_afsk_rx.cpp
|
||||
apps/ui_aprs_rx.cpp
|
||||
apps/ui_btle_rx.cpp
|
||||
apps/ui_nrf_rx.cpp
|
||||
apps/ui_aprs_tx.cpp
|
||||
|
||||
@@ -199,7 +199,7 @@ void AnalogTvView::on_show_options_rf_gain() {
|
||||
void AnalogTvView::on_show_options_modulation() {
|
||||
std::unique_ptr<Widget> widget;
|
||||
|
||||
const auto modulation = static_cast<ReceiverModel::Mode>(receiver_model.modulation());
|
||||
static_cast<ReceiverModel::Mode>(receiver_model.modulation());
|
||||
tv.show_audio_spectrum_view(true);
|
||||
|
||||
set_options_widget(std::move(widget));
|
||||
@@ -216,6 +216,7 @@ void AnalogTvView::on_reference_ppm_correction_changed(int32_t v) {
|
||||
}
|
||||
|
||||
void AnalogTvView::on_headphone_volume_changed(int32_t v) {
|
||||
(void)v; //avoid warning
|
||||
//tv::TVView::set_headphone_volume(this,v);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
|
||||
std::unique_ptr<Widget> options_widget { };
|
||||
|
||||
tv::TVWidget tv { true };
|
||||
tv::TVWidget tv { };
|
||||
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
||||
|
||||
@@ -74,17 +74,58 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
|
||||
|
||||
option_bandwidth.on_change = [this](size_t, uint32_t base_rate) {
|
||||
sampling_rate = 8 * base_rate; // Decimation by 8 done on baseband side
|
||||
|
||||
/* base_rate is used for FFT calculation and display LCD, and also in recording writing SD Card rate. */
|
||||
/* ex. sampling_rate values, 4Mhz, when recording 500 khz (BW) and fs 8 Mhz , when selected 1 Mhz BW ...*/
|
||||
/* ex. recording 500khz BW to .C16 file, base_rate clock 500khz x2(I,Q) x 2 bytes (int signed) =2MB/sec rate SD Card */
|
||||
|
||||
waterfall.on_hide();
|
||||
record_view.set_sampling_rate(sampling_rate);
|
||||
receiver_model.set_sampling_rate(sampling_rate);
|
||||
/* Set up proper anti aliasing BPF bandwith in MAX2837 before ADC sampling according to the new added BW Options . */
|
||||
|
||||
switch(sampling_rate) { // we use the var fs (sampling_rate) , to set up BPF aprox < fs_max/2 by Nyquist theorem.
|
||||
|
||||
case 0 ... 2000000: // BW Captured range (0 <= 250Khz max ) fs = 8 x 250 Khz
|
||||
anti_alias_baseband_bandwidth_filter = 1750000; // Minimum BPF MAX2837 for all those lower BW options.
|
||||
break;
|
||||
|
||||
case 4000000 ... 6000000: // BW capture range (500k ... 750Khz max ) fs_max = 8 x 750Khz = 6Mhz
|
||||
// BW 500k ... 750khz , ex. 500khz (fs = 8*BW = 4Mhz) , BW 600Khz (fs = 4,8Mhz) , BW 750 Khz (fs = 6Mhz)
|
||||
anti_alias_baseband_bandwidth_filter = 2500000; // in some IC MAX2837 appear 2250000 , but both works similar.
|
||||
break;
|
||||
|
||||
case 8800000: // BW capture 1,1Mhz fs = 8 x 1,1Mhz = 8,8Mhz . (1Mhz showed slightly higher noise background).
|
||||
anti_alias_baseband_bandwidth_filter = 3500000;
|
||||
break;
|
||||
|
||||
case 14000000: // BW capture 1,75Mhz , fs = 8 x 1,75Mhz = 14Mhz
|
||||
// good BPF ,good matching, but LCD making flicker , refresh rate should be < 20 Hz , but reasonable picture
|
||||
anti_alias_baseband_bandwidth_filter = 5000000;
|
||||
break;
|
||||
|
||||
case 16000000: // BW capture 2Mhz , fs = 8 x 2Mhz = 16Mhz
|
||||
// good BPF ,good matching, but LCD making flicker , refresh rate should be < 20 Hz , but reasonable picture
|
||||
anti_alias_baseband_bandwidth_filter = 6000000;
|
||||
break;
|
||||
|
||||
case 20000000: // BW capture 2,5Mhz , fs= 8 x 2,5 Mhz = 20Mhz
|
||||
// good BPF ,good matching, but LCD making flicker , refresh rate should be < 20 Hz , but reasonable picture
|
||||
anti_alias_baseband_bandwidth_filter = 7000000;
|
||||
break;
|
||||
|
||||
default: // BW capture 2,75Mhz, fs = 8 x 2,75Mhz= 22Mhz max ADC sampling) and others.
|
||||
// We tested also 9Mhz FPB stightly too much noise floor , better 8Mhz
|
||||
anti_alias_baseband_bandwidth_filter = 8000000;
|
||||
}
|
||||
receiver_model.set_baseband_bandwidth(anti_alias_baseband_bandwidth_filter);
|
||||
|
||||
|
||||
waterfall.on_show();
|
||||
};
|
||||
|
||||
option_bandwidth.set_selected_index(7); // 500k
|
||||
option_bandwidth.set_selected_index(7); // 500k, Preselected starting default option 500khz
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::Capture);
|
||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||
receiver_model.enable();
|
||||
|
||||
record_view.on_error = [&nav](std::string message) {
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
static constexpr ui::Dim header_height = 3 * 16;
|
||||
|
||||
uint32_t sampling_rate = 0;
|
||||
static constexpr uint32_t baseband_bandwidth = 2500000;
|
||||
uint32_t anti_alias_baseband_bandwidth_filter = 2500000; // we rename the previous var , and change type static constexpr to normal var.
|
||||
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
|
||||
@@ -95,7 +95,14 @@ private:
|
||||
{ " 50k ", 50000 },
|
||||
{ "100k ", 100000 },
|
||||
{ "250k ", 250000 },
|
||||
{ "500k ", 500000 }
|
||||
{ "500k ", 500000 }, // Previous Limit bandwith Option with perfect micro SD write .C16 format operaton.
|
||||
{ "600k ", 600000 }, // That extended option is still possible to record with FW version Mayhem v1.41 (< 2,5MB/sec)
|
||||
{ "750k ", 750000 }, // From that BW onwards, the LCD is ok, but the recorded file is auto decimated,(not real file size)
|
||||
{ "1100k", 1100000 },
|
||||
{ "1750k", 1750000 },
|
||||
{ "2000k", 2000000 },
|
||||
{ "2500k", 2500000 },
|
||||
{ "2750k", 2750000 } // That is our max Capture option , to keep using later / 8 decimation (22Mhz sampling ADC)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,444 @@
|
||||
// Part of dump1090, a Mode S message decoder for RTLSDR devices.
|
||||
//
|
||||
// dump1090.h: main program header
|
||||
//
|
||||
// Copyright (c) 2014-2016 Oliver Jowett <oliver@mutability.co.uk>
|
||||
//
|
||||
// This file is free software: you may copy, redistribute and/or modify it
|
||||
// under the terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation, either version 2 of the License, or (at your
|
||||
// option) any later version.
|
||||
//
|
||||
// This file 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/>.
|
||||
|
||||
// This file incorporates work covered by the following copyright and
|
||||
// permission notice:
|
||||
//
|
||||
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef __DUMP1090_H
|
||||
#define __DUMP1090_H
|
||||
|
||||
// Default version number, if not overriden by the Makefile
|
||||
#ifndef MODES_DUMP1090_VERSION
|
||||
# define MODES_DUMP1090_VERSION "unknown"
|
||||
#endif
|
||||
|
||||
#ifndef MODES_DUMP1090_VARIANT
|
||||
# define MODES_DUMP1090_VARIANT "dump1090-unknown"
|
||||
#endif
|
||||
|
||||
|
||||
#define MODES_DEFAULT_FREQ 1090000000
|
||||
#define MODES_DEFAULT_WIDTH 1000
|
||||
#define MODES_DEFAULT_HEIGHT 700
|
||||
#define MODES_RTL_BUFFERS 15 // Number of RTL buffers
|
||||
#define MODES_RTL_BUF_SIZE (16*16384) // 256k
|
||||
#define MODES_MAG_BUF_SAMPLES (MODES_RTL_BUF_SIZE / 2) // Each sample is 2 bytes
|
||||
#define MODES_MAG_BUFFERS 12 // Number of magnitude buffers (should be smaller than RTL_BUFFERS for flowcontrol to work)
|
||||
#define MODES_AUTO_GAIN -100 // Use automatic gain
|
||||
#define MODES_MAX_GAIN 999999 // Use max available gain
|
||||
#define MODES_MSG_SQUELCH_DB 4.0 // Minimum SNR, in dB
|
||||
#define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors
|
||||
|
||||
#define MODEAC_MSG_SAMPLES (25 * 2) // include up to the SPI bit
|
||||
#define MODEAC_MSG_BYTES 2
|
||||
#define MODEAC_MSG_SQUELCH_LEVEL 0x07FF // Average signal strength limit
|
||||
|
||||
#define MODES_PREAMBLE_US 8 // microseconds = bits
|
||||
#define MODES_PREAMBLE_SAMPLES (MODES_PREAMBLE_US * 2)
|
||||
#define MODES_PREAMBLE_SIZE (MODES_PREAMBLE_SAMPLES * sizeof(uint16_t))
|
||||
#define MODES_LONG_MSG_BYTES 14
|
||||
#define MODES_SHORT_MSG_BYTES 7
|
||||
#define MODES_LONG_MSG_BITS (MODES_LONG_MSG_BYTES * 8)
|
||||
#define MODES_SHORT_MSG_BITS (MODES_SHORT_MSG_BYTES * 8)
|
||||
#define MODES_LONG_MSG_SAMPLES (MODES_LONG_MSG_BITS * 2)
|
||||
#define MODES_SHORT_MSG_SAMPLES (MODES_SHORT_MSG_BITS * 2)
|
||||
#define MODES_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
||||
#define MODES_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
||||
|
||||
#define MODES_OS_PREAMBLE_SAMPLES (20)
|
||||
#define MODES_OS_PREAMBLE_SIZE (MODES_OS_PREAMBLE_SAMPLES * sizeof(uint16_t))
|
||||
#define MODES_OS_LONG_MSG_SAMPLES (268)
|
||||
#define MODES_OS_SHORT_MSG_SAMPLES (135)
|
||||
#define MODES_OS_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
||||
#define MODES_OS_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
||||
|
||||
#define MODES_OUT_BUF_SIZE (1500)
|
||||
#define MODES_OUT_FLUSH_SIZE (MODES_OUT_BUF_SIZE - 256)
|
||||
#define MODES_OUT_FLUSH_INTERVAL (60000)
|
||||
|
||||
#define MODES_USER_LATLON_VALID (1<<0)
|
||||
|
||||
#define INVALID_ALTITUDE (-9999)
|
||||
|
||||
/* Where did a bit of data arrive from? In order of increasing priority */
|
||||
typedef enum {
|
||||
SOURCE_INVALID, /* data is not valid */
|
||||
SOURCE_MODE_AC, /* A/C message */
|
||||
SOURCE_MLAT, /* derived from mlat */
|
||||
SOURCE_MODE_S, /* data from a Mode S message, no full CRC */
|
||||
SOURCE_MODE_S_CHECKED, /* data from a Mode S message with full CRC */
|
||||
SOURCE_TISB, /* data from a TIS-B extended squitter message */
|
||||
SOURCE_ADSR, /* data from a ADS-R extended squitter message */
|
||||
SOURCE_ADSB, /* data from a ADS-B extended squitter message */
|
||||
} datasource_t;
|
||||
|
||||
/* What sort of address is this and who sent it?
|
||||
* (Earlier values are higher priority)
|
||||
*/
|
||||
typedef enum {
|
||||
ADDR_ADSB_ICAO, /* Mode S or ADS-B, ICAO address, transponder sourced */
|
||||
ADDR_ADSB_ICAO_NT, /* ADS-B, ICAO address, non-transponder */
|
||||
ADDR_ADSR_ICAO, /* ADS-R, ICAO address */
|
||||
ADDR_TISB_ICAO, /* TIS-B, ICAO address */
|
||||
|
||||
ADDR_ADSB_OTHER, /* ADS-B, other address format */
|
||||
ADDR_ADSR_OTHER, /* ADS-R, other address format */
|
||||
ADDR_TISB_TRACKFILE, /* TIS-B, Mode A code + track file number */
|
||||
ADDR_TISB_OTHER, /* TIS-B, other address format */
|
||||
|
||||
ADDR_MODE_A, /* Mode A */
|
||||
|
||||
ADDR_UNKNOWN /* unknown address format */
|
||||
} addrtype_t;
|
||||
|
||||
typedef enum {
|
||||
UNIT_FEET,
|
||||
UNIT_METERS
|
||||
} altitude_unit_t;
|
||||
|
||||
typedef enum {
|
||||
UNIT_NAUTICAL_MILES,
|
||||
UNIT_STATUTE_MILES,
|
||||
UNIT_KILOMETERS,
|
||||
} interactive_distance_unit_t;
|
||||
|
||||
typedef enum {
|
||||
ALTITUDE_BARO,
|
||||
ALTITUDE_GEOM
|
||||
} altitude_source_t;
|
||||
|
||||
typedef enum {
|
||||
AG_INVALID,
|
||||
AG_GROUND,
|
||||
AG_AIRBORNE,
|
||||
AG_UNCERTAIN
|
||||
} airground_t;
|
||||
|
||||
typedef enum {
|
||||
SIL_INVALID, SIL_UNKNOWN, SIL_PER_SAMPLE, SIL_PER_HOUR
|
||||
} sil_type_t;
|
||||
|
||||
typedef enum {
|
||||
CPR_SURFACE, CPR_AIRBORNE, CPR_COARSE
|
||||
} cpr_type_t;
|
||||
|
||||
typedef enum {
|
||||
HEADING_INVALID, // Not set
|
||||
HEADING_GROUND_TRACK, // Direction of track over ground, degrees clockwise from true north
|
||||
HEADING_TRUE, // Heading, degrees clockwise from true north
|
||||
HEADING_MAGNETIC, // Heading, degrees clockwise from magnetic north
|
||||
HEADING_MAGNETIC_OR_TRUE, // HEADING_MAGNETIC or HEADING_TRUE depending on the HRD bit in opstatus
|
||||
HEADING_TRACK_OR_HEADING // GROUND_TRACK / MAGNETIC / TRUE depending on the TAH bit in opstatus
|
||||
} heading_type_t;
|
||||
|
||||
typedef enum {
|
||||
COMMB_UNKNOWN,
|
||||
COMMB_AMBIGUOUS,
|
||||
COMMB_EMPTY_RESPONSE,
|
||||
COMMB_DATALINK_CAPS,
|
||||
COMMB_GICB_CAPS,
|
||||
COMMB_AIRCRAFT_IDENT,
|
||||
COMMB_ACAS_RA,
|
||||
COMMB_VERTICAL_INTENT,
|
||||
COMMB_TRACK_TURN,
|
||||
COMMB_HEADING_SPEED
|
||||
} commb_format_t;
|
||||
|
||||
typedef enum {
|
||||
NAV_MODE_AUTOPILOT = 1,
|
||||
NAV_MODE_VNAV = 2,
|
||||
NAV_MODE_ALT_HOLD = 4,
|
||||
NAV_MODE_APPROACH = 8,
|
||||
NAV_MODE_LNAV = 16,
|
||||
NAV_MODE_TCAS = 32
|
||||
} nav_modes_t;
|
||||
|
||||
// Matches encoding of the ES type 28/1 emergency/priority status subfield
|
||||
typedef enum {
|
||||
EMERGENCY_NONE = 0,
|
||||
EMERGENCY_GENERAL = 1,
|
||||
EMERGENCY_LIFEGUARD = 2,
|
||||
EMERGENCY_MINFUEL = 3,
|
||||
EMERGENCY_NORDO = 4,
|
||||
EMERGENCY_UNLAWFUL = 5,
|
||||
EMERGENCY_DOWNED = 6,
|
||||
EMERGENCY_RESERVED = 7
|
||||
} emergency_t;
|
||||
|
||||
typedef enum {
|
||||
NAV_ALT_INVALID, NAV_ALT_UNKNOWN, NAV_ALT_AIRCRAFT, NAV_ALT_MCP, NAV_ALT_FMS
|
||||
} nav_altitude_source_t;
|
||||
|
||||
#define MODES_NON_ICAO_ADDRESS (1<<24) // Set on addresses to indicate they are not ICAO addresses
|
||||
|
||||
#define MODES_INTERACTIVE_REFRESH_TIME 250 // Milliseconds
|
||||
#define MODES_INTERACTIVE_DISPLAY_TTL 60000 // Delete from display after 60 seconds
|
||||
|
||||
#define MODES_NET_HEARTBEAT_INTERVAL 60000 // milliseconds
|
||||
|
||||
#define MODES_CLIENT_BUF_SIZE 1024
|
||||
#define MODES_NET_SNDBUF_SIZE (1024*64)
|
||||
#define MODES_NET_SNDBUF_MAX (7)
|
||||
|
||||
#define HISTORY_SIZE 120
|
||||
#define HISTORY_INTERVAL 30000
|
||||
|
||||
#define MODES_NOTUSED(V) ((void) V)
|
||||
|
||||
#define MAX_AMPLITUDE 65535.0
|
||||
#define MAX_POWER (MAX_AMPLITUDE * MAX_AMPLITUDE)
|
||||
|
||||
#define FAUP_DEFAULT_RATE_MULTIPLIER 1.0 // FA Upload rate multiplier
|
||||
|
||||
|
||||
//======================== structure declarations =========================
|
||||
|
||||
typedef enum {
|
||||
SDR_NONE, SDR_IFILE, SDR_RTLSDR, SDR_BLADERF, SDR_HACKRF, SDR_LIMESDR
|
||||
} sdr_type_t;
|
||||
|
||||
|
||||
// The struct we use to store information about a decoded message.
|
||||
struct modesMessage {
|
||||
// Generic fields
|
||||
unsigned char msg[MODES_LONG_MSG_BYTES]; // Binary message.
|
||||
unsigned char verbatim[MODES_LONG_MSG_BYTES]; // Binary message, as originally received before correction
|
||||
int msgbits; // Number of bits in message
|
||||
int msgtype; // Downlink format #
|
||||
uint32_t crc; // Message CRC
|
||||
int correctedbits; // No. of bits corrected
|
||||
uint32_t addr; // Address Announced
|
||||
addrtype_t addrtype; // address format / source
|
||||
uint64_t timestampMsg; // Timestamp of the message (12MHz clock)
|
||||
uint64_t sysTimestampMsg; // Timestamp of the message (system time)
|
||||
int remote; // If set this message is from a remote station
|
||||
double signalLevel; // RSSI, in the range [0..1], as a fraction of full-scale power
|
||||
int score; // Scoring from scoreModesMessage, if used
|
||||
int reliable; // is this a "reliable" message (uncorrected DF11/DF17/DF18)?
|
||||
|
||||
datasource_t source; // Characterizes the overall message source
|
||||
|
||||
// Raw data, just extracted directly from the message
|
||||
// The names reflect the field names in Annex 4
|
||||
unsigned IID; // extracted from CRC of DF11s
|
||||
unsigned AA;
|
||||
unsigned AC;
|
||||
unsigned CA;
|
||||
unsigned CC;
|
||||
unsigned CF;
|
||||
unsigned DR;
|
||||
unsigned FS;
|
||||
unsigned ID;
|
||||
unsigned KE;
|
||||
unsigned ND;
|
||||
unsigned RI;
|
||||
unsigned SL;
|
||||
unsigned UM;
|
||||
unsigned VS;
|
||||
unsigned char MB[7];
|
||||
unsigned char MD[10];
|
||||
unsigned char ME[7];
|
||||
unsigned char MV[7];
|
||||
|
||||
// Decoded data
|
||||
unsigned altitude_baro_valid : 1;
|
||||
unsigned altitude_geom_valid : 1;
|
||||
unsigned track_valid : 1;
|
||||
unsigned track_rate_valid : 1;
|
||||
unsigned heading_valid : 1;
|
||||
unsigned roll_valid : 1;
|
||||
unsigned gs_valid : 1;
|
||||
unsigned ias_valid : 1;
|
||||
unsigned tas_valid : 1;
|
||||
unsigned mach_valid : 1;
|
||||
unsigned baro_rate_valid : 1;
|
||||
unsigned geom_rate_valid : 1;
|
||||
unsigned squawk_valid : 1;
|
||||
unsigned callsign_valid : 1;
|
||||
unsigned cpr_valid : 1;
|
||||
unsigned cpr_odd : 1;
|
||||
unsigned cpr_decoded : 1;
|
||||
unsigned cpr_relative : 1;
|
||||
unsigned category_valid : 1;
|
||||
unsigned geom_delta_valid : 1;
|
||||
unsigned from_mlat : 1;
|
||||
unsigned from_tisb : 1;
|
||||
unsigned spi_valid : 1;
|
||||
unsigned spi : 1;
|
||||
unsigned alert_valid : 1;
|
||||
unsigned alert : 1;
|
||||
unsigned emergency_valid : 1;
|
||||
|
||||
unsigned metype; // DF17/18 ME type
|
||||
unsigned mesub; // DF17/18 ME subtype
|
||||
|
||||
commb_format_t commb_format; // Inferred format of a comm-b message
|
||||
|
||||
// valid if altitude_baro_valid:
|
||||
int altitude_baro; // Altitude in either feet or meters
|
||||
altitude_unit_t altitude_baro_unit; // the unit used for altitude
|
||||
|
||||
// valid if altitude_geom_valid:
|
||||
int altitude_geom; // Altitude in either feet or meters
|
||||
altitude_unit_t altitude_geom_unit; // the unit used for altitude
|
||||
|
||||
// following fields are valid if the corresponding _valid field is set:
|
||||
int geom_delta; // Difference between geometric and baro alt
|
||||
float heading; // ground track or heading, degrees (0-359). Reported directly or computed from from EW and NS velocity
|
||||
heading_type_t heading_type;// how to interpret 'track_or_heading'
|
||||
float track_rate; // Rate of change of track, degrees/second
|
||||
float roll; // Roll, degrees, negative is left roll
|
||||
struct {
|
||||
// Groundspeed, kts, reported directly or computed from from EW and NS velocity
|
||||
// For surface movement, this has different interpretations for v0 and v2; both
|
||||
// fields are populated. The tracking layer will update "gs.selected".
|
||||
float v0;
|
||||
float v2;
|
||||
float selected;
|
||||
} gs;
|
||||
unsigned ias; // Indicated airspeed, kts
|
||||
unsigned tas; // True airspeed, kts
|
||||
double mach; // Mach number
|
||||
int baro_rate; // Rate of change of barometric altitude, feet/minute
|
||||
int geom_rate; // Rate of change of geometric (GNSS / INS) altitude, feet/minute
|
||||
unsigned squawk; // 13 bits identity (Squawk), encoded as 4 hex digits
|
||||
char callsign[9]; // 8 chars flight number, NUL-terminated
|
||||
unsigned category; // A0 - D7 encoded as a single hex byte
|
||||
emergency_t emergency; // emergency/priority status
|
||||
|
||||
// valid if cpr_valid
|
||||
cpr_type_t cpr_type; // The encoding type used (surface, airborne, coarse TIS-B)
|
||||
unsigned cpr_lat; // Non decoded latitude.
|
||||
unsigned cpr_lon; // Non decoded longitude.
|
||||
unsigned cpr_nucp; // NUCp/NIC value implied by message type
|
||||
|
||||
airground_t airground; // air/ground state
|
||||
|
||||
// valid if cpr_decoded:
|
||||
double decoded_lat;
|
||||
double decoded_lon;
|
||||
unsigned decoded_nic;
|
||||
unsigned decoded_rc;
|
||||
|
||||
// various integrity/accuracy things
|
||||
struct {
|
||||
unsigned nic_a_valid : 1;
|
||||
unsigned nic_b_valid : 1;
|
||||
unsigned nic_c_valid : 1;
|
||||
unsigned nic_baro_valid : 1;
|
||||
unsigned nac_p_valid : 1;
|
||||
unsigned nac_v_valid : 1;
|
||||
unsigned gva_valid : 1;
|
||||
unsigned sda_valid : 1;
|
||||
|
||||
unsigned nic_a : 1; // if nic_a_valid
|
||||
unsigned nic_b : 1; // if nic_b_valid
|
||||
unsigned nic_c : 1; // if nic_c_valid
|
||||
unsigned nic_baro : 1; // if nic_baro_valid
|
||||
|
||||
unsigned nac_p : 4; // if nac_p_valid
|
||||
unsigned nac_v : 3; // if nac_v_valid
|
||||
|
||||
unsigned sil : 2; // if sil_type != SIL_INVALID
|
||||
sil_type_t sil_type;
|
||||
|
||||
unsigned gva : 2; // if gva_valid
|
||||
|
||||
unsigned sda : 2; // if sda_valid
|
||||
} accuracy;
|
||||
|
||||
// Operational Status
|
||||
struct {
|
||||
unsigned valid : 1;
|
||||
unsigned version : 3;
|
||||
|
||||
unsigned om_acas_ra : 1;
|
||||
unsigned om_ident : 1;
|
||||
unsigned om_atc : 1;
|
||||
unsigned om_saf : 1;
|
||||
|
||||
unsigned cc_acas : 1;
|
||||
unsigned cc_cdti : 1;
|
||||
unsigned cc_1090_in : 1;
|
||||
unsigned cc_arv : 1;
|
||||
unsigned cc_ts : 1;
|
||||
unsigned cc_tc : 2;
|
||||
unsigned cc_uat_in : 1;
|
||||
unsigned cc_poa : 1;
|
||||
unsigned cc_b2_low : 1;
|
||||
unsigned cc_lw_valid : 1;
|
||||
|
||||
heading_type_t tah;
|
||||
heading_type_t hrd;
|
||||
|
||||
unsigned cc_lw;
|
||||
unsigned cc_antenna_offset;
|
||||
} opstatus;
|
||||
|
||||
// combined:
|
||||
// Target State & Status (ADS-B V2 only)
|
||||
// Comm-B BDS4,0 Vertical Intent
|
||||
struct {
|
||||
unsigned heading_valid : 1;
|
||||
unsigned fms_altitude_valid : 1;
|
||||
unsigned mcp_altitude_valid : 1;
|
||||
unsigned qnh_valid : 1;
|
||||
unsigned modes_valid : 1;
|
||||
|
||||
float heading; // heading, degrees (0-359) (could be magnetic or true heading; magnetic recommended)
|
||||
heading_type_t heading_type;
|
||||
unsigned fms_altitude; // FMS selected altitude
|
||||
unsigned mcp_altitude; // MCP/FCU selected altitude
|
||||
float qnh; // altimeter setting (QFE or QNH/QNE), millibars
|
||||
|
||||
nav_altitude_source_t altitude_source;
|
||||
|
||||
nav_modes_t modes;
|
||||
} nav;
|
||||
};
|
||||
|
||||
|
||||
#endif // __DUMP1090_H
|
||||
@@ -50,6 +50,8 @@ struct ERTKey {
|
||||
{
|
||||
}
|
||||
|
||||
ERTKey( const ERTKey& other ) = default;
|
||||
|
||||
ERTKey& operator=(const ERTKey& other) {
|
||||
id = other.id;
|
||||
commodity_type = other.commodity_type;
|
||||
|
||||
@@ -30,10 +30,11 @@ using namespace pocsag;
|
||||
|
||||
#include "string_format.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "audio.hpp"
|
||||
|
||||
void POCSAGLogger::log_raw_data(const pocsag::POCSAGPacket& packet, const uint32_t frequency) {
|
||||
std::string entry = "Raw: F:" + to_string_dec_uint(frequency) + "Hz " +
|
||||
pocsag::bitrate_str(packet.bitrate()) + " Codewords:";
|
||||
to_string_dec_uint(packet.bitrate()) + " Codewords:";
|
||||
|
||||
// Raw hex dump of all the codewords
|
||||
for (size_t c = 0; c < 16; c++)
|
||||
@@ -64,13 +65,13 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
|
||||
add_children({
|
||||
&rssi,
|
||||
&channel,
|
||||
&audio,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&field_frequency,
|
||||
&options_bitrate,
|
||||
&options_phase,
|
||||
&check_log,
|
||||
&field_volume,
|
||||
&check_ignore,
|
||||
&sym_ignore,
|
||||
&console
|
||||
@@ -99,14 +100,11 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
options_bitrate.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
on_config_changed(v, options_phase.selected_index_value());
|
||||
};
|
||||
options_bitrate.set_selected_index(1); // 1200bps
|
||||
|
||||
options_phase.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
on_config_changed(options_bitrate.selected_index_value(),v);
|
||||
field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99);
|
||||
field_volume.on_change = [this](int32_t v) {
|
||||
this->on_headphone_volume_changed(v);
|
||||
};
|
||||
|
||||
check_ignore.set_value(ignore);
|
||||
check_ignore.on_select = [this](Checkbox&, bool v) {
|
||||
ignore = v;
|
||||
@@ -121,9 +119,16 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
|
||||
logger = std::make_unique<POCSAGLogger>();
|
||||
if (logger)
|
||||
logger->append("pocsag.txt");
|
||||
|
||||
audio::output::start();
|
||||
audio::output::unmute();
|
||||
|
||||
baseband::set_pocsag();
|
||||
}
|
||||
|
||||
POCSAGAppView::~POCSAGAppView() {
|
||||
audio::output::stop();
|
||||
|
||||
// Save ignored address
|
||||
persistent_memory::set_pocsag_ignore_address(sym_ignore.value_dec_u32());
|
||||
|
||||
@@ -135,6 +140,12 @@ void POCSAGAppView::focus() {
|
||||
field_frequency.focus();
|
||||
}
|
||||
|
||||
void POCSAGAppView::on_headphone_volume_changed(int32_t v) {
|
||||
const auto new_volume = volume_t::decibel(v - 99) + audio::headphone::volume_range().max;
|
||||
receiver_model.set_headphone_volume(new_volume);
|
||||
}
|
||||
|
||||
|
||||
// Useless ?
|
||||
void POCSAGAppView::set_parent_rect(const Rect new_parent_rect) {
|
||||
View::set_parent_rect(new_parent_rect);
|
||||
@@ -154,11 +165,17 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||
// " Ignored address " + to_string_dec_uint(pocsag_state.address));
|
||||
return;
|
||||
}
|
||||
// Too many errors for reliable decode
|
||||
if ((ignore) && (pocsag_state.errors >= 3)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::string console_info;
|
||||
|
||||
const uint32_t roundVal = 50;
|
||||
const uint32_t bitrate = roundVal * ((message->packet.bitrate() + (roundVal/2))/roundVal);
|
||||
console_info = "\n" + to_string_datetime(message->packet.timestamp(), HM);
|
||||
console_info += " " + pocsag::bitrate_str(message->packet.bitrate());
|
||||
console_info += " " + to_string_dec_uint(bitrate);
|
||||
console_info += " ADDR:" + to_string_dec_uint(pocsag_state.address);
|
||||
console_info += " F" + to_string_dec_uint(pocsag_state.function);
|
||||
|
||||
@@ -201,10 +218,6 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||
logger->log_raw_data(message->packet, target_frequency());
|
||||
}
|
||||
|
||||
void POCSAGAppView::on_config_changed(const uint32_t new_bitrate, bool new_phase) {
|
||||
baseband::set_pocsag(pocsag_bitrates[new_bitrate], new_phase);
|
||||
}
|
||||
|
||||
void POCSAGAppView::set_target_frequency(const uint32_t new_value) {
|
||||
target_frequency_ = new_value;
|
||||
receiver_model.set_tuning_frequency(new_value);
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
static constexpr uint32_t initial_target_frequency = 466175000;
|
||||
|
||||
bool logging { true };
|
||||
bool ignore { false };
|
||||
bool ignore { true };
|
||||
uint32_t last_address = 0xFFFFFFFF;
|
||||
pocsag::POCSAGState pocsag_state { };
|
||||
|
||||
@@ -80,48 +80,41 @@ private:
|
||||
Channel channel {
|
||||
{ 21 * 8, 5, 6 * 8, 4 },
|
||||
};
|
||||
Audio audio{
|
||||
{ 21 * 8, 10, 6 * 8, 4 },
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
};
|
||||
OptionsField options_bitrate {
|
||||
{ 12 * 8, 21 },
|
||||
7,
|
||||
{
|
||||
{ "512bps ", 0 },
|
||||
{ "1200bps", 1 },
|
||||
{ "2400bps", 2 }
|
||||
}
|
||||
};
|
||||
OptionsField options_phase {
|
||||
{ 6 * 8, 21 },
|
||||
1,
|
||||
{
|
||||
{ "P", 0 },
|
||||
{ "N", 1 },
|
||||
}
|
||||
};
|
||||
Checkbox check_log {
|
||||
{ 22 * 8, 21 },
|
||||
{ 24 * 8, 21 },
|
||||
3,
|
||||
"LOG",
|
||||
true
|
||||
};
|
||||
NumberField field_volume{
|
||||
{ 28 * 8, 0 * 16 },
|
||||
2,
|
||||
{ 0, 99 },
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
Checkbox check_ignore {
|
||||
{ 1 * 8, 40 },
|
||||
15,
|
||||
"Ignore address:",
|
||||
{ 1 * 8, 21 },
|
||||
12,
|
||||
"Ignore addr:",
|
||||
true
|
||||
};
|
||||
SymField sym_ignore {
|
||||
{ 19 * 8, 40 },
|
||||
{ 16 * 8, 21 },
|
||||
7,
|
||||
SymField::SYMFIELD_DEC
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 4 * 16, 240, 240 }
|
||||
{ 0, 3 * 16, 240, 256 }
|
||||
};
|
||||
|
||||
std::unique_ptr<POCSAGLogger> logger { };
|
||||
@@ -132,7 +125,7 @@ private:
|
||||
|
||||
void on_packet(const POCSAGPacketMessage * message);
|
||||
|
||||
void on_config_changed(const uint32_t new_bitrate, const bool phase);
|
||||
void on_headphone_volume_changed(int32_t v);
|
||||
|
||||
uint32_t target_frequency() const;
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
|
||||
@@ -139,7 +139,12 @@ void ReplayAppView::start() {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
field_rfgain.on_change = [this](int32_t v) {
|
||||
tx_gain = v;
|
||||
};
|
||||
field_rfgain.set_value(tx_gain);
|
||||
receiver_model.set_tx_gain(tx_gain);
|
||||
|
||||
radio::enable({
|
||||
receiver_model.tuning_frequency(),
|
||||
sample_rate * 8 ,
|
||||
@@ -180,6 +185,8 @@ ReplayAppView::ReplayAppView(
|
||||
NavigationView& nav
|
||||
) : nav_ (nav)
|
||||
{
|
||||
|
||||
tx_gain = 35;field_rfgain.set_value(tx_gain);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_replay);
|
||||
|
||||
add_children({
|
||||
@@ -190,7 +197,7 @@ ReplayAppView::ReplayAppView(
|
||||
&text_duration,
|
||||
&progressbar,
|
||||
&field_frequency,
|
||||
&field_lna,
|
||||
&field_rfgain,
|
||||
&field_rf_amp,
|
||||
&check_loop,
|
||||
&button_play,
|
||||
|
||||
@@ -51,6 +51,7 @@ private:
|
||||
static constexpr ui::Dim header_height = 3 * 16;
|
||||
|
||||
uint32_t sample_rate = 0;
|
||||
int32_t tx_gain { 47 };
|
||||
static constexpr uint32_t baseband_bandwidth = 2500000;
|
||||
const size_t read_size { 16384 };
|
||||
const size_t buffer_count { 3 };
|
||||
@@ -75,7 +76,7 @@ private:
|
||||
bool ready_signal { false };
|
||||
|
||||
Labels labels {
|
||||
{ { 10 * 8, 2 * 16 }, "LNA: A:", Color::light_grey() }
|
||||
{ { 10 * 8, 2 * 16 }, "GAIN A:", Color::light_grey() }
|
||||
};
|
||||
|
||||
Button button_open {
|
||||
@@ -103,8 +104,13 @@ private:
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 2 * 16 },
|
||||
};
|
||||
LNAGainField field_lna {
|
||||
{ 14 * 8, 2 * 16 }
|
||||
|
||||
NumberField field_rfgain {
|
||||
{ 14 * 8, 2 * 16 },
|
||||
2,
|
||||
{ 0, 47 },
|
||||
1,
|
||||
' '
|
||||
};
|
||||
RFAmpField field_rf_amp {
|
||||
{ 19 * 8, 2 * 16 }
|
||||
|
||||
@@ -110,7 +110,11 @@ void SoundBoardView::start_tx(const uint32_t id) {
|
||||
1536000 / 20, // Update vu-meter at 20Hz
|
||||
transmitter_model.channel_bandwidth(),
|
||||
0, // Gain is unused
|
||||
TONES_F2D(tone_key_frequency(tone_key_index), 1536000)
|
||||
TONES_F2D(tone_key_frequency(tone_key_index), 1536000),
|
||||
0, //AM
|
||||
0, //DSB
|
||||
0, //USB
|
||||
0 //LSB
|
||||
);
|
||||
baseband::set_sample_rate(sample_rate);
|
||||
|
||||
@@ -130,6 +134,7 @@ void SoundBoardView::start_tx(const uint32_t id) {
|
||||
}*/
|
||||
|
||||
void SoundBoardView::on_tx_progress(const uint32_t progress) {
|
||||
(void)progress ; // avoid warning
|
||||
//progressbar.set_value(progress);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace ui
|
||||
{
|
||||
add_children({&console, &button_ok});
|
||||
|
||||
button_ok.on_select = [&nav](Button &) {
|
||||
button_ok.on_select = [&nav](Button &)
|
||||
{
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
@@ -28,9 +29,14 @@ namespace ui
|
||||
console.writeln("\x1B\x06Mayhem:\x1B\x10");
|
||||
console.writeln("eried,euquiq,gregoryfenton");
|
||||
console.writeln("johnelder,jwetzell,nnemanjan00");
|
||||
console.writeln("N0vaPixel,klockee,jamesshao8");
|
||||
console.writeln("ITAxReal,rascafr,mcules");
|
||||
console.writeln("dqs105,strijar");
|
||||
console.writeln("N0vaPixel,klockee,GullCode");
|
||||
console.writeln("jamesshao8,ITAxReal,rascafr");
|
||||
console.writeln("mcules,dqs105,strijar");
|
||||
console.writeln("zhang00963,RedFox-Fr,aldude999");
|
||||
console.writeln("East2West,fossum,ArjanOnwezen");
|
||||
console.writeln("vXxOinvizioNxX,teixeluis");
|
||||
console.writeln("Brumi-2021,texasyojimbo");
|
||||
console.writeln("heurist1,intoxsick");
|
||||
console.writeln("");
|
||||
break;
|
||||
|
||||
@@ -74,4 +80,4 @@ namespace ui
|
||||
button_ok.focus();
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#include "ui_adsb_rx.hpp"
|
||||
#include "ui_alphanum.hpp"
|
||||
|
||||
@@ -47,7 +49,7 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||
if (entry_age < ADSB_DECAY_A) {
|
||||
aged_color = 0x10;
|
||||
target_color = Color::green();
|
||||
} else if ((entry_age >= ADSB_DECAY_A) && (entry_age < ADSB_DECAY_B)) {
|
||||
} else if (entry_age < ADSB_DECAY_B) {
|
||||
aged_color = 0x07;
|
||||
target_color = Color::light_grey();
|
||||
} else {
|
||||
@@ -57,10 +59,21 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||
|
||||
std::string entry_string = "\x1B";
|
||||
entry_string += aged_color;
|
||||
#if false
|
||||
entry_string += to_string_hex(entry.ICAO_address, 6) + " " +
|
||||
entry.callsign + " " +
|
||||
(entry.hits <= 999 ? to_string_dec_uint(entry.hits, 4) : "999+") + " " +
|
||||
entry.time_string;
|
||||
#else
|
||||
// SBT
|
||||
entry_string +=
|
||||
(entry.callsign[0]!=' ' ? entry.callsign + " " : to_string_hex(entry.ICAO_address, 6) + " ") +
|
||||
to_string_dec_uint((unsigned int)((entry.pos.altitude+50)/100),4) +
|
||||
to_string_dec_uint((unsigned int)entry.velo.speed,4) +
|
||||
to_string_dec_uint((unsigned int)(entry.amp>>9),4) + " " +
|
||||
(entry.hits <= 999 ? to_string_dec_uint(entry.hits, 3) + " " : "1k+ ") +
|
||||
to_string_dec_uint(entry.age, 3);
|
||||
#endif
|
||||
|
||||
painter.draw_string(
|
||||
target_rect.location(),
|
||||
@@ -69,7 +82,7 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||
);
|
||||
|
||||
if (entry.pos.valid)
|
||||
painter.draw_bitmap(target_rect.location() + Point(15 * 8, 0), bitmap_target, target_color, style.background);
|
||||
painter.draw_bitmap(target_rect.location() + Point(8 * 8, 0), bitmap_target, target_color, style.background);
|
||||
}
|
||||
|
||||
void ADSBLogger::log_str(std::string& logline) {
|
||||
@@ -117,6 +130,7 @@ ADSBRxDetailsView::ADSBRxDetailsView(
|
||||
{
|
||||
char file_buffer[32] { 0 };
|
||||
bool found = false;
|
||||
int number_of_airlines = 0;
|
||||
std::string airline_code;
|
||||
size_t c;
|
||||
|
||||
@@ -140,7 +154,8 @@ ADSBRxDetailsView::ADSBRxDetailsView(
|
||||
// Try getting the airline's name from airlines.db
|
||||
auto result = db_file.open("ADSB/airlines.db");
|
||||
if (!result.is_valid()) {
|
||||
// Search for 3-letter code in 0x0000~0x2000
|
||||
// Search for 3-letter code
|
||||
number_of_airlines = (db_file.size() / 68); // determine number of airlines in file
|
||||
airline_code = entry_copy.callsign.substr(0, 3);
|
||||
c = 0;
|
||||
do {
|
||||
@@ -151,10 +166,10 @@ ADSBRxDetailsView::ADSBRxDetailsView(
|
||||
found = true;
|
||||
else
|
||||
c++;
|
||||
} while (!found);
|
||||
} while (!found && (c < number_of_airlines));
|
||||
|
||||
if (found) {
|
||||
db_file.seek(0x2000 + (c << 6));
|
||||
db_file.seek((number_of_airlines * 4) + (c << 6)); // seek starting after index
|
||||
db_file.read(file_buffer, 32);
|
||||
text_airline.set(file_buffer);
|
||||
db_file.read(file_buffer, 32);
|
||||
@@ -171,17 +186,19 @@ ADSBRxDetailsView::ADSBRxDetailsView(
|
||||
text_callsign.set(entry_copy.callsign);
|
||||
|
||||
button_see_map.on_select = [this, &nav](Button&) {
|
||||
geomap_view = nav.push<GeoMapView>(
|
||||
entry_copy.callsign,
|
||||
entry_copy.pos.altitude,
|
||||
GeoPos::alt_unit::FEET,
|
||||
entry_copy.pos.latitude,
|
||||
entry_copy.pos.longitude,
|
||||
entry_copy.velo.heading,
|
||||
[this]() {
|
||||
if (!send_updates) { // Prevent recursivley launching the map
|
||||
geomap_view = nav.push<GeoMapView>(
|
||||
entry_copy.callsign,
|
||||
entry_copy.pos.altitude,
|
||||
GeoPos::alt_unit::FEET,
|
||||
entry_copy.pos.latitude,
|
||||
entry_copy.pos.longitude,
|
||||
entry_copy.velo.heading,
|
||||
[this]() {
|
||||
send_updates = false;
|
||||
});
|
||||
send_updates = true;
|
||||
send_updates = true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -190,11 +207,41 @@ void ADSBRxView::focus() {
|
||||
}
|
||||
|
||||
ADSBRxView::~ADSBRxView() {
|
||||
receiver_model.set_tuning_frequency(prevFreq);
|
||||
|
||||
rtc_time::signal_tick_second -= signal_token_tick_second;
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
AircraftRecentEntry ADSBRxView::find_or_create_entry(uint32_t ICAO_address) {
|
||||
auto it = find(recent, ICAO_address);
|
||||
|
||||
// If not found
|
||||
if (it == std::end(recent)){
|
||||
recent.emplace_front(ICAO_address); // Add it
|
||||
truncate_entries(recent); // Truncate the list
|
||||
sort_entries_by_state();
|
||||
it = find(recent, ICAO_address); // Find it again
|
||||
}
|
||||
return *it;
|
||||
}
|
||||
|
||||
void ADSBRxView::replace_entry(AircraftRecentEntry & entry)
|
||||
{
|
||||
uint32_t ICAO_address = entry.ICAO_address;
|
||||
|
||||
std::replace_if( recent.begin(), recent.end(),
|
||||
[ICAO_address](const AircraftRecentEntry & compEntry) {return ICAO_address == compEntry.ICAO_address;},
|
||||
entry);
|
||||
}
|
||||
|
||||
void ADSBRxView::sort_entries_by_state()
|
||||
{
|
||||
// Sorting List pn age_state using lambda function as comparator
|
||||
recent.sort([](const AircraftRecentEntry & left, const AircraftRecentEntry & right){return (left.age_state < right.age_state); });
|
||||
}
|
||||
|
||||
void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||
rtc::RTC datetime;
|
||||
std::string str_timestamp;
|
||||
@@ -205,11 +252,17 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||
auto frame = message->frame;
|
||||
uint32_t ICAO_address = frame.get_ICAO_address();
|
||||
|
||||
if (frame.check_CRC() && frame.get_ICAO_address()) {
|
||||
if (frame.check_CRC() && ICAO_address) {
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
auto& entry = ::on_packet(recent, ICAO_address);
|
||||
auto entry = find_or_create_entry(ICAO_address);
|
||||
frame.set_rx_timestamp(datetime.minute() * 60 + datetime.second());
|
||||
entry.reset_age();
|
||||
if (entry.hits==0)
|
||||
{
|
||||
entry.amp = message->amp;
|
||||
} else {
|
||||
entry.amp = ((entry.amp*15)+message->amp)>>4;
|
||||
}
|
||||
str_timestamp = to_string_datetime(datetime, HMS);
|
||||
entry.set_time_string(str_timestamp);
|
||||
|
||||
@@ -222,36 +275,47 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||
uint8_t msg_sub = frame.get_msg_sub();
|
||||
uint8_t * raw_data = frame.get_raw_data();
|
||||
|
||||
if ((msg_type >= 1) && (msg_type <= 4)) {
|
||||
// 4: // surveillance, altitude reply
|
||||
if ((msg_type >= AIRCRAFT_ID_L) && (msg_type <= AIRCRAFT_ID_H)) {
|
||||
callsign = decode_frame_id(frame);
|
||||
entry.set_callsign(callsign);
|
||||
logentry+=callsign+" ";
|
||||
} else if (((msg_type >= 9) && (msg_type <= 18)) || ((msg_type >= 20) && (msg_type <= 22))) {
|
||||
}
|
||||
// 9:
|
||||
// 18: { // Extended squitter/non-transponder
|
||||
// 21: // Comm-B, identity reply
|
||||
// 20: // Comm-B, altitude reply
|
||||
else if (((msg_type >= AIRBORNE_POS_BARO_L) && (msg_type <= AIRBORNE_POS_BARO_H)) ||
|
||||
((msg_type >= AIRBORNE_POS_GPS_L) && (msg_type <= AIRBORNE_POS_GPS_H))) {
|
||||
entry.set_frame_pos(frame, raw_data[6] & 4);
|
||||
|
||||
if (entry.pos.valid) {
|
||||
str_info = "Alt:" + to_string_dec_int(entry.pos.altitude) +
|
||||
" Lat:" + to_string_dec_int(entry.pos.latitude) +
|
||||
"." + to_string_dec_int((int)abs(entry.pos.latitude * 1000) % 100, 2, '0') +
|
||||
" Lon:" + to_string_dec_int(entry.pos.longitude) +
|
||||
"." + to_string_dec_int((int)abs(entry.pos.longitude * 1000) % 100, 2, '0');
|
||||
|
||||
entry.set_info_string(str_info);
|
||||
logentry+=str_info+ " ";
|
||||
" Lat:" + to_string_decimal(entry.pos.latitude, 2) +
|
||||
" Lon:" + to_string_decimal(entry.pos.longitude, 2);
|
||||
|
||||
// printing the coordinates in the log file with more
|
||||
// resolution, as we are not constrained by screen
|
||||
// real estate there:
|
||||
|
||||
std::string log_info = "Alt:" + to_string_dec_int(entry.pos.altitude) +
|
||||
" Lat:" + to_string_decimal(entry.pos.latitude, 7) +
|
||||
" Lon:" + to_string_decimal(entry.pos.longitude, 7);
|
||||
|
||||
entry.set_info_string(str_info);
|
||||
logentry+=log_info + " ";
|
||||
|
||||
if (send_updates)
|
||||
details_view->update(entry);
|
||||
}
|
||||
} else if(msg_type == 19 && msg_sub >= 1 && msg_sub <= 4){
|
||||
} else if(msg_type == AIRBORNE_VEL && msg_sub >= VEL_GND_SUBSONIC && msg_sub <= VEL_AIR_SUPERSONIC){
|
||||
entry.set_frame_velo(frame);
|
||||
logentry += "Type:" + to_string_dec_uint(msg_sub) +
|
||||
" Hdg:" + to_string_dec_uint(entry.velo.heading) +
|
||||
" Spd: "+ to_string_dec_int(entry.velo.speed);
|
||||
if (send_updates)
|
||||
details_view->update(entry);
|
||||
|
||||
}
|
||||
}
|
||||
recent_entries_view.set_dirty();
|
||||
|
||||
replace_entry(entry);
|
||||
|
||||
logger = std::make_unique<ADSBLogger>();
|
||||
if (logger) {
|
||||
@@ -269,13 +333,16 @@ void ADSBRxView::on_tick_second() {
|
||||
entry.inc_age();
|
||||
|
||||
if (details_view) {
|
||||
if (send_updates && (entry.key() == detailed_entry_key))
|
||||
if (send_updates && (entry.key() == detailed_entry_key)) // Check if the ICAO address match
|
||||
details_view->update(entry);
|
||||
} else {
|
||||
if ((entry.age == ADSB_DECAY_A) || (entry.age == ADSB_DECAY_B))
|
||||
recent_entries_view.set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the list if it is being displayed
|
||||
if (!send_updates) {
|
||||
sort_entries_by_state();
|
||||
recent_entries_view.set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
ADSBRxView::ADSBRxView(NavigationView& nav) {
|
||||
@@ -304,6 +371,8 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
|
||||
on_tick_second();
|
||||
};
|
||||
|
||||
prevFreq = receiver_model.tuning_frequency();
|
||||
|
||||
baseband::set_adsb();
|
||||
|
||||
receiver_model.set_tuning_frequency(1090000000);
|
||||
|
||||
@@ -32,13 +32,39 @@
|
||||
#include "adsb.hpp"
|
||||
#include "message.hpp"
|
||||
|
||||
#include "crc.hpp"
|
||||
|
||||
using namespace adsb;
|
||||
|
||||
namespace ui {
|
||||
|
||||
#define ADSB_DECAY_A 10 // In seconds
|
||||
#define ADSB_DECAY_B 30
|
||||
#define ADSB_DECAY_C 60 // Can be used for removing old entries, RecentEntries already caps to 64
|
||||
#define ADSB_DECAY_A 10 // In seconds
|
||||
#define ADSB_DECAY_B 30
|
||||
#define ADSB_DECAY_C 60 // Can be used for removing old entries, RecentEntries already caps to 64
|
||||
|
||||
#define AIRCRAFT_ID_L 1 // aircraft ID message type (lowest type id)
|
||||
#define AIRCRAFT_ID_H 4 // aircraft ID message type (highest type id)
|
||||
|
||||
#define SURFACE_POS_L 5 // surface position (lowest type id)
|
||||
#define SURFACE_POS_H 8 // surface position (highest type id)
|
||||
|
||||
#define AIRBORNE_POS_BARO_L 9 // airborne position (lowest type id)
|
||||
#define AIRBORNE_POS_BARO_H 18 // airborne position (highest type id)
|
||||
|
||||
#define AIRBORNE_VEL 19 // airborne velocities
|
||||
|
||||
#define AIRBORNE_POS_GPS_L 20 // airborne position (lowest type id)
|
||||
#define AIRBORNE_POS_GPS_H 22 // airborne position (highest type id)
|
||||
|
||||
#define RESERVED_L 23 // reserved for other uses
|
||||
#define RESERVED_H 31 // reserved for other uses
|
||||
|
||||
#define VEL_GND_SUBSONIC 1
|
||||
#define VEL_GND_SUPERSONIC 2
|
||||
#define VEL_AIR_SUBSONIC 3
|
||||
#define VEL_AIR_SUPERSONIC 4
|
||||
|
||||
#define O_E_FRAME_TIMEOUT 20 // timeout between odd and even frames
|
||||
|
||||
struct AircraftRecentEntry {
|
||||
using Key = uint32_t;
|
||||
@@ -47,9 +73,12 @@ struct AircraftRecentEntry {
|
||||
|
||||
uint32_t ICAO_address { };
|
||||
uint16_t hits { 0 };
|
||||
|
||||
uint16_t age_state { 1 };
|
||||
uint32_t age { 0 };
|
||||
uint32_t amp { 0 };
|
||||
adsb_pos pos { false, 0, 0, 0 };
|
||||
adsb_vel velo { false, 0, 999 };
|
||||
adsb_vel velo { false, 0, 999, 0 };
|
||||
ADSBFrame frame_pos_even { };
|
||||
ADSBFrame frame_pos_odd { };
|
||||
|
||||
@@ -82,7 +111,7 @@ struct AircraftRecentEntry {
|
||||
frame_pos_odd = frame;
|
||||
|
||||
if (!frame_pos_even.empty() && !frame_pos_odd.empty()) {
|
||||
if (abs(frame_pos_even.get_rx_timestamp() - frame_pos_odd.get_rx_timestamp()) < 20)
|
||||
if (abs(frame_pos_even.get_rx_timestamp() - frame_pos_odd.get_rx_timestamp()) < O_E_FRAME_TIMEOUT)
|
||||
pos = decode_frame_pos(frame_pos_even, frame_pos_odd);
|
||||
}
|
||||
}
|
||||
@@ -98,13 +127,21 @@ struct AircraftRecentEntry {
|
||||
void set_time_string(std::string& new_time_string) {
|
||||
time_string = new_time_string;
|
||||
}
|
||||
|
||||
|
||||
void reset_age() {
|
||||
age = 0;
|
||||
}
|
||||
|
||||
void inc_age() {
|
||||
age++;
|
||||
if (age < ADSB_DECAY_A)
|
||||
{
|
||||
age_state = pos.valid ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
age_state = (age < ADSB_DECAY_B) ? 2 : 3;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -137,6 +174,8 @@ public:
|
||||
void update(const AircraftRecentEntry& entry);
|
||||
|
||||
std::string title() const override { return "Details"; };
|
||||
|
||||
AircraftRecentEntry get_current_entry() { return entry_copy; }
|
||||
|
||||
private:
|
||||
AircraftRecentEntry entry_copy { 0 };
|
||||
@@ -213,16 +252,30 @@ public:
|
||||
|
||||
std::string title() const override { return "ADS-B receive"; };
|
||||
|
||||
void replace_entry(AircraftRecentEntry & entry);
|
||||
AircraftRecentEntry find_or_create_entry(uint32_t ICAO_address);
|
||||
void sort_entries_by_state();
|
||||
|
||||
private:
|
||||
rf::Frequency prevFreq;
|
||||
std::unique_ptr<ADSBLogger> logger { };
|
||||
void on_frame(const ADSBFrameMessage * message);
|
||||
void on_tick_second();
|
||||
|
||||
const RecentEntriesColumns columns { {
|
||||
#if false
|
||||
{ "ICAO", 6 },
|
||||
{ "Callsign", 9 },
|
||||
{ "Hits", 4 },
|
||||
{ "Time", 8 }
|
||||
#else
|
||||
{ "ICAO/Call", 9 },
|
||||
{ "Lvl", 3 },
|
||||
{ "Spd", 3 },
|
||||
{ "Amp", 3 },
|
||||
{ "Hit", 3 },
|
||||
{ "Age", 3 }
|
||||
#endif
|
||||
} };
|
||||
AircraftRecentEntries recent { };
|
||||
RecentEntriesView<RecentEntries<AircraftRecentEntry>> recent_entries_view { columns, recent };
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_aprs_rx.hpp"
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "rtc_time.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
void APRSLogger::log_raw_data(const std::string& data) {
|
||||
rtc::RTC datetime;
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
|
||||
log_file.write_entry(datetime, data);
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
template<>
|
||||
void RecentEntriesTable<APRSRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
const Style& style
|
||||
) {
|
||||
char aged_color;
|
||||
Color target_color;
|
||||
// auto entry_age = entry.age;
|
||||
|
||||
target_color = Color::green();
|
||||
|
||||
aged_color = 0x10;
|
||||
std::string entry_string = "\x1B";
|
||||
entry_string += aged_color;
|
||||
|
||||
entry_string += entry.source_formatted;
|
||||
entry_string.append(10 - entry.source_formatted.size(),' ');
|
||||
entry_string += " ";
|
||||
entry_string += (entry.hits <= 999 ? to_string_dec_uint(entry.hits, 4) : "999+");
|
||||
entry_string += " ";
|
||||
entry_string += entry.time_string;
|
||||
|
||||
painter.draw_string(
|
||||
target_rect.location(),
|
||||
style,
|
||||
entry_string
|
||||
);
|
||||
|
||||
if (entry.has_position){
|
||||
painter.draw_bitmap(target_rect.location() + Point(12 * 8, 0), bitmap_target, target_color, style.background);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void APRSRxView::focus() {
|
||||
options_region.focus();
|
||||
}
|
||||
|
||||
void APRSRxView::update_freq(rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
}
|
||||
|
||||
APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect) : View(parent_rect) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_aprs_rx);
|
||||
|
||||
add_children({
|
||||
&rssi,
|
||||
&channel,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&options_region,
|
||||
&field_frequency,
|
||||
&record_view,
|
||||
&console
|
||||
});
|
||||
|
||||
// DEBUG
|
||||
record_view.on_error = [&nav](std::string message) {
|
||||
nav.display_modal("Error", message);
|
||||
};
|
||||
|
||||
record_view.set_sampling_rate(24000);
|
||||
|
||||
options_region.on_change = [this](size_t, int32_t i) {
|
||||
if (i == 0){
|
||||
field_frequency.set_value(144390000);
|
||||
}
|
||||
if(i == 1){
|
||||
field_frequency.set_value(144800000);
|
||||
}
|
||||
if(i == 2){
|
||||
field_frequency.set_value(145175000);
|
||||
}
|
||||
};
|
||||
|
||||
field_frequency.set_value(receiver_model.tuning_frequency());
|
||||
field_frequency.set_step(100);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
update_freq(f);
|
||||
};
|
||||
field_frequency.on_edit = [this, &nav]() {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
update_freq(f);
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
options_region.set_selected_index(0, true);
|
||||
|
||||
logger = std::make_unique<APRSLogger>();
|
||||
if (logger)
|
||||
logger->append("APRS_RX_LOG.TXT");
|
||||
|
||||
baseband::set_aprs(1200);
|
||||
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::output::start();
|
||||
|
||||
receiver_model.set_sampling_rate(3072000);
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
void APRSRxView::on_packet(const APRSPacketMessage* message){
|
||||
std::string str_console = "\x1B";
|
||||
|
||||
aprs::APRSPacket packet = message->packet;
|
||||
|
||||
std::string stream_text = packet.get_stream_text();
|
||||
str_console += (char)((console_color++ & 3) + 9);
|
||||
str_console += stream_text;
|
||||
|
||||
if(logger){
|
||||
logger->log_raw_data(stream_text);
|
||||
}
|
||||
|
||||
//if(reset_console){ //having more than one console causes issues when switching tabs where one is disabled, and the other enabled breaking the scoll setup.
|
||||
// console.on_hide();
|
||||
// console.on_show();
|
||||
// reset_console = false;
|
||||
//}
|
||||
|
||||
console.writeln(str_console);
|
||||
}
|
||||
|
||||
void APRSRxView::on_data(uint32_t value, bool is_data) {
|
||||
std::string str_console = "\x1B";
|
||||
std::string str_byte = "";
|
||||
|
||||
if (is_data) {
|
||||
// Colorize differently after message splits
|
||||
str_console += (char)((console_color & 3) + 9);
|
||||
|
||||
if (value == '\n') {
|
||||
// Message split
|
||||
console.writeln("");
|
||||
console_color++;
|
||||
|
||||
if (logger) {
|
||||
logger->log_raw_data(str_log);
|
||||
str_log = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((value >= 32) && (value < 127)) {
|
||||
str_console += (char)value; // Printable
|
||||
str_byte += (char)value;
|
||||
} else {
|
||||
str_console += "[" + to_string_hex(value, 2) + "]"; // Not printable
|
||||
str_byte += "[" + to_string_hex(value, 2) + "]";
|
||||
}
|
||||
|
||||
console.write(str_console);
|
||||
|
||||
if (logger) str_log += str_byte;
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void APRSRxView::on_show(){
|
||||
//some bug where the display scroll area is set to the entire screen when switching from the list tab with details showing back to the stream view.
|
||||
//reset_console = true;
|
||||
}
|
||||
|
||||
APRSRxView::~APRSRxView() {
|
||||
audio::output::stop();
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
void APRSTableView::on_show_list() {
|
||||
details_view.hidden(true);
|
||||
recent_entries_view.hidden(false);
|
||||
send_updates = false;
|
||||
focus();
|
||||
}
|
||||
|
||||
void APRSTableView::on_show_detail(const APRSRecentEntry& entry) {
|
||||
recent_entries_view.hidden(true);
|
||||
details_view.hidden(false);
|
||||
details_view.set_entry(entry);
|
||||
details_view.update();
|
||||
details_view.focus();
|
||||
detailed_entry_key = entry.key();
|
||||
send_updates = true;
|
||||
}
|
||||
|
||||
APRSTableView::APRSTableView(NavigationView& nav, Rect parent_rec) : View(parent_rec), nav_ {nav} {
|
||||
add_children({
|
||||
&recent_entries_view,
|
||||
&details_view
|
||||
});
|
||||
|
||||
hidden(true);
|
||||
|
||||
details_view.hidden(true);
|
||||
|
||||
recent_entries_view.set_parent_rect({0, 0, 240, 280});
|
||||
details_view.set_parent_rect({0, 0, 240, 280});
|
||||
|
||||
recent_entries_view.on_select = [this](const APRSRecentEntry& entry) {
|
||||
this->on_show_detail(entry);
|
||||
};
|
||||
|
||||
details_view.on_close = [this]() {
|
||||
this->on_show_list();
|
||||
};
|
||||
|
||||
|
||||
/* for(size_t i = 0; i <32 ; i++){
|
||||
std::string id = "test" + i;
|
||||
auto& entry = ::on_packet(recent, i);
|
||||
entry.set_source_formatted(id);
|
||||
}
|
||||
|
||||
recent_entries_view.set_dirty(); */
|
||||
|
||||
/*
|
||||
|
||||
std::string str1 = "test1";
|
||||
std::string str12 = "test2";
|
||||
std::string str13 = "test2";
|
||||
|
||||
auto& entry = ::on_packet(recent, 0x1);
|
||||
entry.set_source_formatted(str1);
|
||||
|
||||
auto& entry2 = ::on_packet(recent, 0x2);
|
||||
entry2.set_source_formatted(str12);
|
||||
|
||||
auto& entry3 = ::on_packet(recent, 0x2);
|
||||
entry2.set_source_formatted(str13);
|
||||
|
||||
recent_entries_view.set_dirty();
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void APRSTableView::on_pkt(const APRSPacketMessage* message){
|
||||
aprs::APRSPacket packet = message->packet;
|
||||
rtc::RTC datetime;
|
||||
std::string str_timestamp;
|
||||
std::string source_formatted = packet.get_source_formatted();
|
||||
std::string info_string = packet.get_stream_text();
|
||||
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
auto& entry = ::on_packet(recent, packet.get_source());
|
||||
entry.reset_age();
|
||||
entry.inc_hit();
|
||||
str_timestamp = to_string_datetime(datetime, HMS);
|
||||
entry.set_time_string(str_timestamp);
|
||||
entry.set_info_string(info_string);
|
||||
|
||||
entry.set_source_formatted(source_formatted);
|
||||
|
||||
if(entry.has_position && !packet.has_position()){
|
||||
//maintain position info
|
||||
}
|
||||
else {
|
||||
entry.set_has_position(packet.has_position());
|
||||
entry.set_pos(packet.get_position());
|
||||
}
|
||||
|
||||
if( entry.key() == details_view.entry().key() ) {
|
||||
details_view.set_entry(entry);
|
||||
details_view.update();
|
||||
}
|
||||
|
||||
recent_entries_view.set_dirty();
|
||||
}
|
||||
|
||||
void APRSTableView::on_show(){
|
||||
on_show_list();
|
||||
}
|
||||
|
||||
void APRSTableView::on_hide(){
|
||||
details_view.hidden(true);
|
||||
}
|
||||
|
||||
void APRSTableView::focus(){
|
||||
recent_entries_view.focus();
|
||||
}
|
||||
|
||||
APRSTableView::~APRSTableView(){
|
||||
|
||||
}
|
||||
|
||||
void APRSDetailsView::focus() {
|
||||
button_done.focus();
|
||||
}
|
||||
|
||||
void APRSDetailsView::set_entry(const APRSRecentEntry& entry){
|
||||
entry_copy = entry;
|
||||
}
|
||||
|
||||
void APRSDetailsView::update() {
|
||||
if(!hidden()){
|
||||
//uint32_t age = entry_copy.age;
|
||||
|
||||
console.clear(true);
|
||||
console.write(entry_copy.info_string);
|
||||
|
||||
button_see_map.hidden(!entry_copy.has_position);
|
||||
}
|
||||
|
||||
if (send_updates)
|
||||
geomap_view->update_position(entry_copy.pos.latitude, entry_copy.pos.longitude, 0);
|
||||
}
|
||||
|
||||
APRSDetailsView::~APRSDetailsView() {
|
||||
}
|
||||
|
||||
APRSDetailsView::APRSDetailsView(
|
||||
NavigationView& nav
|
||||
)
|
||||
{
|
||||
add_children({
|
||||
&console,
|
||||
&button_done,
|
||||
&button_see_map
|
||||
});
|
||||
|
||||
button_done.on_select = [this, &nav](Button&) {
|
||||
console.clear(true);
|
||||
this->on_close();
|
||||
};
|
||||
|
||||
button_see_map.on_select = [this, &nav](Button&) {
|
||||
geomap_view = nav.push<GeoMapView>(
|
||||
entry_copy.source_formatted,
|
||||
0, //entry_copy.pos.altitude,
|
||||
GeoPos::alt_unit::FEET,
|
||||
entry_copy.pos.latitude,
|
||||
entry_copy.pos.longitude,
|
||||
0, /*entry_copy.velo.heading,*/
|
||||
[this]() {
|
||||
send_updates = false;
|
||||
hidden(false);
|
||||
update();
|
||||
});
|
||||
send_updates = true;
|
||||
hidden(true);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
APRSRXView::APRSRXView(NavigationView& nav) : nav_ {nav} {
|
||||
add_children({
|
||||
&tab_view,
|
||||
&view_stream,
|
||||
&view_table
|
||||
});
|
||||
}
|
||||
|
||||
void APRSRXView::focus(){
|
||||
tab_view.focus();
|
||||
}
|
||||
|
||||
APRSRXView::~APRSRXView() {
|
||||
|
||||
}
|
||||
} /* namespace ui */
|
||||
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UI_APRS_RX_H__
|
||||
#define __UI_APRS_RX_H__
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_record_view.hpp" // DEBUG
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "recent_entries.hpp"
|
||||
#include "ui_tabview.hpp"
|
||||
|
||||
#include "log_file.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
class APRSLogger {
|
||||
public:
|
||||
Optional<File::Error> append(const std::string& filename) {
|
||||
return log_file.append(filename);
|
||||
}
|
||||
|
||||
void log_raw_data(const std::string& data);
|
||||
|
||||
private:
|
||||
LogFile log_file { };
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
|
||||
struct APRSRecentEntry {
|
||||
using Key = uint64_t;
|
||||
|
||||
static constexpr Key invalid_key = 0xffffffffffffffff;
|
||||
|
||||
uint16_t hits { 0 };
|
||||
uint32_t age { 0 };
|
||||
|
||||
uint64_t source;
|
||||
std::string source_formatted { " " };
|
||||
std::string time_string { "" };
|
||||
std::string info_string { "" };
|
||||
|
||||
aprs::aprs_pos pos;
|
||||
bool has_position = false;
|
||||
APRSRecentEntry(uint64_t src)
|
||||
{
|
||||
source = src;
|
||||
}
|
||||
|
||||
Key key() const {
|
||||
return source;
|
||||
}
|
||||
|
||||
void set_source_formatted(std::string& new_source) {
|
||||
source_formatted = new_source;
|
||||
}
|
||||
|
||||
void inc_hit() {
|
||||
hits++;
|
||||
}
|
||||
|
||||
void set_info_string(std::string& new_info_string) {
|
||||
info_string = new_info_string;
|
||||
}
|
||||
|
||||
void set_time_string(std::string& new_time_string) {
|
||||
time_string = new_time_string;
|
||||
}
|
||||
|
||||
void set_pos(aprs::aprs_pos pos_in){
|
||||
pos = pos_in;
|
||||
}
|
||||
|
||||
void set_has_position(bool has_pos){
|
||||
has_position = has_pos;
|
||||
}
|
||||
|
||||
void reset_age() {
|
||||
age = 0;
|
||||
}
|
||||
|
||||
void inc_age() {
|
||||
age++;
|
||||
}
|
||||
};
|
||||
|
||||
class APRSDetailsView : public View {
|
||||
public:
|
||||
APRSDetailsView(NavigationView&);
|
||||
~APRSDetailsView();
|
||||
|
||||
APRSDetailsView(const APRSDetailsView&) = delete;
|
||||
APRSDetailsView(APRSDetailsView&&) = delete;
|
||||
APRSDetailsView& operator=(const APRSDetailsView&) = delete;
|
||||
APRSDetailsView& operator=(APRSDetailsView&&) = delete;
|
||||
|
||||
void focus() override;
|
||||
|
||||
void update();
|
||||
void set_entry(const APRSRecentEntry& entry);
|
||||
|
||||
const APRSRecentEntry& entry() const { return entry_copy; };
|
||||
|
||||
std::string title() const override { return "Details"; };
|
||||
std::function<void(void)> on_close { };
|
||||
|
||||
private:
|
||||
APRSRecentEntry entry_copy { 0 };
|
||||
GeoMapView* geomap_view { nullptr };
|
||||
bool send_updates { false };
|
||||
|
||||
Console console {
|
||||
{ 0, 0 * 16, 240, 224 }
|
||||
};
|
||||
|
||||
Button button_done {
|
||||
{ 160, 14 * 16, 8 * 8, 3 * 16 },
|
||||
"Close"
|
||||
};
|
||||
|
||||
Button button_see_map {
|
||||
{ 80, 14 * 16, 8 * 8, 3 * 16 },
|
||||
"Map"
|
||||
};
|
||||
};
|
||||
|
||||
using APRSRecentEntries = RecentEntries<APRSRecentEntry>;
|
||||
|
||||
class APRSTableView: public View {
|
||||
public:
|
||||
APRSTableView(NavigationView& nav, Rect parent_rec);
|
||||
~APRSTableView();
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
void focus() override;
|
||||
void on_pkt(const APRSPacketMessage* message);
|
||||
|
||||
std::string title() const override { return "Stations"; };
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
const RecentEntriesColumns columns { {
|
||||
{ "Source", 9 },
|
||||
{ "Loc", 6 },
|
||||
{ "Hits", 4 },
|
||||
{ "Time", 8 }
|
||||
} };
|
||||
APRSRecentEntries recent { };
|
||||
RecentEntriesView<RecentEntries<APRSRecentEntry>> recent_entries_view { columns, recent };
|
||||
APRSDetailsView details_view { nav_ };
|
||||
uint32_t detailed_entry_key { 0 };
|
||||
bool send_updates { false };
|
||||
|
||||
void on_show_list();
|
||||
void on_show_detail(const APRSRecentEntry& entry);
|
||||
};
|
||||
|
||||
class APRSRxView : public View {
|
||||
public:
|
||||
APRSRxView(NavigationView& nav, Rect parent_rect);
|
||||
~APRSRxView();
|
||||
|
||||
void on_show() override;
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "APRS RX"; };
|
||||
void on_packet(const APRSPacketMessage* message);
|
||||
|
||||
private:
|
||||
void on_data(uint32_t value, bool is_data);
|
||||
bool reset_console = false;
|
||||
|
||||
uint8_t console_color { 0 };
|
||||
std::string str_log { "" };
|
||||
|
||||
RFAmpField field_rf_amp {
|
||||
{ 13 * 8, 0 * 16 }
|
||||
};
|
||||
LNAGainField field_lna {
|
||||
{ 15 * 8, 0 * 16 }
|
||||
};
|
||||
VGAGainField field_vga {
|
||||
{ 18 * 8, 0 * 16 }
|
||||
};
|
||||
RSSI rssi {
|
||||
{ 21 * 8, 0, 6 * 8, 4 },
|
||||
};
|
||||
Channel channel {
|
||||
{ 21 * 8, 5, 6 * 8, 4 },
|
||||
};
|
||||
|
||||
OptionsField options_region {
|
||||
{ 0 * 8, 0 * 8 },
|
||||
3,
|
||||
{
|
||||
{ "NA ", 0 },
|
||||
{ "EUR", 1 },
|
||||
{ "AUS", 2 }
|
||||
}
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 3 * 8, 0 * 16 },
|
||||
};
|
||||
|
||||
// DEBUG
|
||||
RecordView record_view {
|
||||
{ 0 * 8, 1 * 16, 30 * 8, 1 * 16 },
|
||||
u"AFS_????", RecordView::FileType::WAV, 4096, 4
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 2 * 16, 240, 240 }
|
||||
};
|
||||
|
||||
void update_freq(rf::Frequency f);
|
||||
|
||||
std::unique_ptr<APRSLogger> logger { };
|
||||
};
|
||||
|
||||
class APRSRXView : public View {
|
||||
public:
|
||||
APRSRXView(NavigationView& nav);
|
||||
~APRSRXView();
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "APRS RX"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
Rect view_rect = { 0, 3 * 8, 240, 280 };
|
||||
|
||||
APRSRxView view_stream { nav_, view_rect };
|
||||
APRSTableView view_table { nav_, view_rect };
|
||||
|
||||
TabView tab_view {
|
||||
{ "Stream", Color::cyan(), &view_stream },
|
||||
{ "List", Color::yellow(), &view_table }
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_packet {
|
||||
Message::ID::APRSPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const APRSPacketMessage*>(p);
|
||||
this->view_stream.on_packet(message);
|
||||
this->view_table.on_pkt(message);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif/*__UI_APRS_RX_H__*/
|
||||
@@ -121,7 +121,8 @@ void TemperatureWidget::paint(Painter& painter) {
|
||||
}
|
||||
|
||||
TemperatureWidget::temperature_t TemperatureWidget::temperature(const sample_t sensor_value) const {
|
||||
return -35 + sensor_value * 4; //max2837 datasheet temp 25ºC has sensor value: 15
|
||||
/*It seems to be a temperature difference of 25C*/
|
||||
return -40 +(sensor_value * 4.31)+25; //max2837 datasheet temp 25ºC has sensor value: 15
|
||||
}
|
||||
|
||||
std::string TemperatureWidget::temperature_str(const temperature_t temperature) const {
|
||||
|
||||
@@ -216,6 +216,7 @@ FileSaveView::FileSaveView(
|
||||
}*/
|
||||
|
||||
void FileLoadView::refresh_widgets(const bool v) {
|
||||
(void)v; //avoid unused warning
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ FreqManBaseView::FreqManBaseView(
|
||||
} else
|
||||
error_ = ERROR_NOFILES;
|
||||
|
||||
// initialize
|
||||
change_category(last_category_id);
|
||||
|
||||
// Default function
|
||||
on_change_category = [this](int32_t category_id) {
|
||||
change_category(category_id);
|
||||
|
||||
@@ -64,7 +64,7 @@ protected:
|
||||
|
||||
OptionsField options_category {
|
||||
{ 9 * 8, 4 },
|
||||
12,
|
||||
14,
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -103,19 +103,19 @@ private:
|
||||
};
|
||||
|
||||
Labels labels {
|
||||
{ { 2 * 8, 14 * 8 }, "Save as:", Color::white() }
|
||||
{ { 1 * 8, 12 * 8 }, "Save as:", Color::white() }
|
||||
};
|
||||
|
||||
Button button_save_name {
|
||||
{ 2 * 8, 17 * 8, 14 * 8, 48 },
|
||||
{ 1 * 8, 17 * 8, 12 * 8, 48 },
|
||||
"Name (set)"
|
||||
};
|
||||
Button button_save_timestamp {
|
||||
{ 2 * 8, 25 * 8, 14 * 8, 48 },
|
||||
{ 1 * 8, 25 * 8, 12 * 8, 48 },
|
||||
"Timestamp:"
|
||||
};
|
||||
LiveDateTime live_timestamp {
|
||||
{ 17 * 8, 27 * 8, 11 * 8, 16 }
|
||||
{ 14 * 8, 27 * 8, 16 * 8, 16 }
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ void GlassView::on_channel_spectrum(const ChannelSpectrum &spectrum)
|
||||
}
|
||||
|
||||
if (pixel_index)
|
||||
f_center += SEARCH_SLICE_WIDTH; //Move into the next bandwidth slice NOTE: spectrum.sampling_rate = SEARCH_SLICE_WIDTH
|
||||
f_center += LOOKING_GLASS_SLICE_WIDTH; //Move into the next bandwidth slice NOTE: spectrum.sampling_rate = LOOKING_GLASS_SLICE_WIDTH
|
||||
else
|
||||
f_center = f_center_ini; //Start a new sweep
|
||||
|
||||
@@ -143,8 +143,8 @@ void GlassView::on_range_changed()
|
||||
else
|
||||
field_marker.set_step(marker_step); //step needs to be a pixel wide.
|
||||
|
||||
f_center_ini = f_min + (SEARCH_SLICE_WIDTH / 2); //Initial center frequency for sweep
|
||||
f_center_ini += SEARCH_SLICE_WIDTH; //euquiq: Why do I need to move the center ???!!! (shift needed for marker accuracy)
|
||||
f_center_ini = f_min + (LOOKING_GLASS_SLICE_WIDTH / 2); //Initial center frequency for sweep
|
||||
f_center_ini += LOOKING_GLASS_SLICE_WIDTH; //euquiq: Why do I need to move the center ???!!! (shift needed for marker accuracy)
|
||||
|
||||
PlotMarker(field_marker.value()); //Refresh marker on screen
|
||||
|
||||
@@ -153,20 +153,20 @@ void GlassView::on_range_changed()
|
||||
max_power = 0;
|
||||
bins_Hz_size = 0; //reset amount of Hz filled up by pixels
|
||||
|
||||
baseband::set_spectrum(SEARCH_SLICE_WIDTH, field_trigger.value());
|
||||
baseband::set_spectrum(LOOKING_GLASS_SLICE_WIDTH, field_trigger.value());
|
||||
receiver_model.set_tuning_frequency(f_center_ini); //tune rx for this slice
|
||||
}
|
||||
|
||||
void GlassView::PlotMarker(rf::Frequency pos)
|
||||
void GlassView::PlotMarker(rf::Frequency fpos)
|
||||
{
|
||||
pos = pos * MHZ_DIV;
|
||||
int64_t pos = fpos * MHZ_DIV;
|
||||
pos -= f_min;
|
||||
pos = pos / marker_pixel_step; //Real pixel
|
||||
|
||||
portapack::display.fill_rectangle({0, 100, 240, 8}, Color::black()); //Clear old marker and whole marker rectangle btw
|
||||
portapack::display.fill_rectangle({pos - 2, 100, 5, 3}, Color::red()); //Red marker middle
|
||||
portapack::display.fill_rectangle({pos - 1, 103, 3, 3}, Color::red()); //Red marker middle
|
||||
portapack::display.fill_rectangle({pos, 106, 1, 2}, Color::red()); //Red marker middle
|
||||
portapack::display.fill_rectangle({(int16_t)pos - 2, 100, 5, 3}, Color::red()); //Red marker middle
|
||||
portapack::display.fill_rectangle({(int16_t)pos - 1, 103, 3, 3}, Color::red()); //Red marker middle
|
||||
portapack::display.fill_rectangle({(int16_t)pos, 106, 1, 2}, Color::red()); //Red marker middle
|
||||
}
|
||||
|
||||
GlassView::GlassView(
|
||||
@@ -216,10 +216,12 @@ GlassView::GlassView(
|
||||
|
||||
filter_config.set_selected_index(0);
|
||||
filter_config.on_change = [this](size_t n, OptionsField::value_t v) {
|
||||
(void)n;
|
||||
min_color_power = v;
|
||||
};
|
||||
|
||||
range_presets.on_change = [this](size_t n, OptionsField::value_t v) {
|
||||
(void)n;
|
||||
field_frequency_min.set_value(presets_db[v].min,false);
|
||||
field_frequency_max.set_value(presets_db[v].max,false);
|
||||
this->on_range_changed();
|
||||
@@ -240,11 +242,11 @@ GlassView::GlassView(
|
||||
|
||||
field_trigger.set_value(32); //Defaults to 32, as normal triggering resolution
|
||||
field_trigger.on_change = [this](int32_t v) {
|
||||
baseband::set_spectrum(SEARCH_SLICE_WIDTH, v);
|
||||
baseband::set_spectrum(LOOKING_GLASS_SLICE_WIDTH, v);
|
||||
};
|
||||
|
||||
display.scroll_set_area( 109, 319);
|
||||
baseband::set_spectrum(SEARCH_SLICE_WIDTH, field_trigger.value()); //trigger:
|
||||
baseband::set_spectrum(LOOKING_GLASS_SLICE_WIDTH, field_trigger.value()); //trigger:
|
||||
// Discord User jteich: WidebandSpectrum::on_message to set the trigger value. In WidebandSpectrum::execute ,
|
||||
// it keeps adding the output of the fft to the buffer until "trigger" number of calls are made,
|
||||
//at which time it pushes the buffer up with channel_spectrum.feed
|
||||
@@ -252,8 +254,8 @@ GlassView::GlassView(
|
||||
on_range_changed();
|
||||
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::SpectrumAnalysis);
|
||||
receiver_model.set_sampling_rate(SEARCH_SLICE_WIDTH); //20mhz
|
||||
receiver_model.set_baseband_bandwidth(SEARCH_SLICE_WIDTH); // possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz
|
||||
receiver_model.set_sampling_rate(LOOKING_GLASS_SLICE_WIDTH); //20mhz
|
||||
receiver_model.set_baseband_bandwidth(LOOKING_GLASS_SLICE_WIDTH); // possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz
|
||||
receiver_model.set_squelch_level(0);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
namespace ui
|
||||
{
|
||||
#define SEARCH_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz
|
||||
#define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz
|
||||
#define MHZ_DIV 1000000
|
||||
#define X2_MHZ_DIV 2000000
|
||||
|
||||
@@ -41,6 +41,10 @@
|
||||
{
|
||||
public:
|
||||
GlassView(NavigationView &nav);
|
||||
|
||||
GlassView( const GlassView &);
|
||||
GlassView& operator=(const GlassView &nav);
|
||||
|
||||
~GlassView();
|
||||
std::string title() const override { return "Looking Glass"; };
|
||||
|
||||
@@ -77,7 +81,7 @@
|
||||
rf::Frequency f_center { 0 };
|
||||
rf::Frequency f_center_ini { 0 };
|
||||
rf::Frequency marker_pixel_step { 0 };
|
||||
rf::Frequency each_bin_size { SEARCH_SLICE_WIDTH / 240 };
|
||||
rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 };
|
||||
rf::Frequency bins_Hz_size { 0 };
|
||||
uint8_t min_color_power { 0 };
|
||||
uint32_t pixel_index { 0 };
|
||||
@@ -180,4 +184,4 @@
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,8 +65,13 @@ void MicTXView::configure_baseband() {
|
||||
sampling_rate / 20, // Update vu-meter at 20Hz
|
||||
transmitting ? transmitter_model.channel_bandwidth() : 0,
|
||||
mic_gain,
|
||||
TONES_F2D(tone_key_frequency(tone_key_index), sampling_rate)
|
||||
TONES_F2D(tone_key_frequency(tone_key_index), sampling_rate),
|
||||
enable_am,
|
||||
enable_dsb,
|
||||
enable_usb,
|
||||
enable_lsb
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void MicTXView::set_tx(bool enable) {
|
||||
@@ -143,8 +148,20 @@ void MicTXView::rxaudio(bool is_on) {
|
||||
if (is_on) {
|
||||
audio::input::stop();
|
||||
baseband::shutdown();
|
||||
baseband::run_image(portapack::spi_flash::image_tag_nfm_audio);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
|
||||
if (enable_am || enable_usb || enable_lsb || enable_dsb) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::AMAudio);
|
||||
if (options_mode.selected_index() < 4)
|
||||
receiver_model.set_am_configuration(options_mode.selected_index() - 1);
|
||||
else
|
||||
receiver_model.set_am_configuration(0);
|
||||
}
|
||||
else {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_nfm_audio);
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio);
|
||||
|
||||
}
|
||||
receiver_model.set_sampling_rate(3072000);
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
// receiver_model.set_tuning_frequency(field_frequency.value()); //probably this too can be commented out.
|
||||
@@ -155,15 +172,15 @@ void MicTXView::rxaudio(bool is_on) {
|
||||
receiver_model.enable();
|
||||
audio::output::start();
|
||||
} else { //These incredibly convoluted steps are required for the vumeter to reappear when stopping RX.
|
||||
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio); //This fixes something with AM RX...
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
|
||||
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
|
||||
audio::input::start();
|
||||
// transmitter_model.enable();
|
||||
audio::output::stop();
|
||||
audio::input::start();
|
||||
portapack::pin_i2s0_rx_sda.mode(3);
|
||||
// transmitting = false;
|
||||
configure_baseband();
|
||||
// transmitter_model.disable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,11 +215,13 @@ MicTXView::MicTXView(
|
||||
&field_bw,
|
||||
&field_rfgain,
|
||||
&field_rfamp,
|
||||
&options_mode,
|
||||
&field_frequency,
|
||||
&options_tone_key,
|
||||
&check_rogerbeep,
|
||||
&check_rxactive,
|
||||
&field_volume,
|
||||
&field_rxbw,
|
||||
&field_squelch,
|
||||
&field_rxfrequency,
|
||||
&field_rxlna,
|
||||
@@ -262,6 +281,42 @@ MicTXView::MicTXView(
|
||||
};
|
||||
field_rfamp.set_value(rf_amp ? 14 : 0);
|
||||
|
||||
options_mode.on_change = [this](size_t, int32_t v) {
|
||||
enable_am = false;
|
||||
enable_usb = false;
|
||||
enable_lsb = false;
|
||||
enable_dsb = false;
|
||||
switch(v) {
|
||||
case 0:
|
||||
enable_am = false;
|
||||
enable_usb = false;
|
||||
enable_lsb = false;
|
||||
enable_dsb = false;
|
||||
field_bw.set_value(transmitter_model.channel_bandwidth() / 1000);
|
||||
//if (rx_enabled)
|
||||
rxaudio(rx_enabled); //Update now if we have RX audio on
|
||||
break;
|
||||
case 1:
|
||||
enable_am = true;
|
||||
rxaudio(rx_enabled); //Update now if we have RX audio on
|
||||
break;
|
||||
case 2:
|
||||
enable_usb = true;
|
||||
rxaudio(rx_enabled); //Update now if we have RX audio on
|
||||
break;
|
||||
case 3:
|
||||
enable_lsb = true;
|
||||
rxaudio(rx_enabled); //Update now if we have RX audio on
|
||||
break;
|
||||
case 4:
|
||||
enable_dsb = true;
|
||||
rxaudio(rx_enabled); //Update now if we have RX audio on
|
||||
break;
|
||||
}
|
||||
//configure_baseband();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
check_va.on_select = [this](Checkbox&, bool v) {
|
||||
va_enabled = v;
|
||||
@@ -331,6 +386,21 @@ MicTXView::MicTXView(
|
||||
field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99);
|
||||
field_volume.on_change = [this](int32_t v) { this->on_headphone_volume_changed(v); };
|
||||
|
||||
field_rxbw.on_change = [this](size_t, int32_t v) {
|
||||
switch(v) {
|
||||
case 0:
|
||||
receiver_model.set_nbfm_configuration(0);
|
||||
break;
|
||||
case 1:
|
||||
receiver_model.set_nbfm_configuration(1);
|
||||
break;
|
||||
case 2:
|
||||
receiver_model.set_nbfm_configuration(2);
|
||||
break;
|
||||
}
|
||||
};
|
||||
field_rxbw.set_selected_index(2);
|
||||
|
||||
field_squelch.on_change = [this](int32_t v) {
|
||||
receiver_model.set_squelch_level(100 - v);
|
||||
};
|
||||
|
||||
@@ -99,19 +99,27 @@ private:
|
||||
int32_t focused_ui { 2 };
|
||||
bool button_touch { false };
|
||||
|
||||
//AM TX Stuff
|
||||
bool enable_am { false };
|
||||
bool enable_dsb { false };
|
||||
bool enable_usb { false };
|
||||
bool enable_lsb { false };
|
||||
|
||||
|
||||
Labels labels {
|
||||
{ { 3 * 8, 1 * 8 }, "MIC. GAIN:", Color::light_grey() },
|
||||
{ { 3 * 8, 3 * 8 }, "F:", Color::light_grey() },
|
||||
{ { 15 * 8, 3 * 8 }, "BW: kHz", Color::light_grey() },
|
||||
{ { 15 * 8, 3 * 8 }, "BW: FM kHz", Color::light_grey() },
|
||||
{ { 3 * 8, 5 * 8 }, "GAIN:", Color::light_grey() },
|
||||
{ {11 * 8, 5 * 8 }, "Amp:", Color::light_grey() },
|
||||
{ { 18 * 8, (5 * 8) }, "Mode:", Color::light_grey() },
|
||||
{ { 3 * 8, 8 * 8 }, "TX Activation:", Color::light_grey() },
|
||||
{ { 4 * 8, 10 * 8 }, "LVL:", Color::light_grey() },
|
||||
{ {12 * 8, 10 * 8 }, "ATT:", Color::light_grey() },
|
||||
{ {20 * 8, 10 * 8 }, "DEC:", Color::light_grey() },
|
||||
{ { 4 * 8, ( 13 * 8 ) - 2 }, "TONE KEY:", Color::light_grey() },
|
||||
{ { 9 * 8, 23 * 8 }, "VOL:", Color::light_grey() },
|
||||
{ {17 * 8, 23 * 8 }, "FM RXBW:", Color::light_grey() },
|
||||
{ {17 * 8, 25 * 8 }, "SQ:", Color::light_grey() },
|
||||
{ { 5 * 8, 25 * 8 }, "F:", Color::light_grey() },
|
||||
{ { 5 * 8, 27 * 8 }, "LNA:", Color::light_grey()},
|
||||
@@ -162,6 +170,18 @@ private:
|
||||
14,
|
||||
' '
|
||||
};
|
||||
|
||||
OptionsField options_mode {
|
||||
{ 24 * 8, 5 * 8 },
|
||||
3,
|
||||
{
|
||||
{ "FM", 0 },
|
||||
{ "AM", 1 },
|
||||
{ "USB", 2 },
|
||||
{ "LSB", 3 },
|
||||
{ "DSB", 4 }
|
||||
}
|
||||
};
|
||||
/*
|
||||
Checkbox check_va {
|
||||
{ 3 * 8, (10 * 8) - 4 },
|
||||
@@ -231,6 +251,16 @@ private:
|
||||
' ',
|
||||
};
|
||||
|
||||
OptionsField field_rxbw {
|
||||
{ 25 * 8, 23 * 8},
|
||||
3,
|
||||
{
|
||||
{"8k5", 0},
|
||||
{"11k", 1},
|
||||
{"16k", 2}
|
||||
}
|
||||
};
|
||||
|
||||
NumberField field_squelch {
|
||||
{ 20 * 8, 25 * 8 },
|
||||
2,
|
||||
|
||||
@@ -226,6 +226,7 @@ MorseView::MorseView(
|
||||
};
|
||||
|
||||
options_loop.on_change = [this](size_t i, uint32_t n) {
|
||||
(void)i; //avoid unused warning
|
||||
loop = n;
|
||||
};
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ void ScannerView::show_max() { //show total number of freqs to scan
|
||||
|
||||
ScannerView::ScannerView(
|
||||
NavigationView& nav
|
||||
) : nav_ { nav }
|
||||
) : nav_ { nav } , loaded_file_name { "SCANNER" }
|
||||
{
|
||||
add_children({
|
||||
&labels,
|
||||
@@ -364,7 +364,7 @@ ScannerView::ScannerView(
|
||||
big_display.set(frequency_list[current_index]); //After showing an error
|
||||
}
|
||||
else {
|
||||
auto result = scanner_file.append(freq_file_path); //Second: append if it is not there
|
||||
scanner_file.append(freq_file_path); //Second: append if it is not there
|
||||
scanner_file.write_line(frequency_to_add + ",d=ADD FQ");
|
||||
}
|
||||
} else
|
||||
@@ -409,7 +409,12 @@ void ScannerView::frequency_file_load(std::string file_name, bool stop_all_befor
|
||||
case FM_2: def_step = 50000; break ;
|
||||
case N_1: def_step = 25000; break ;
|
||||
case N_2: def_step = 250000; break ;
|
||||
case AIRBAND:def_step= 8330; break ;
|
||||
case AIRBAND: def_step= 8330; break ;
|
||||
case ERROR_STEP:
|
||||
case STEP_DEF:
|
||||
default:
|
||||
def_step = step_mode.selected_index_value(); //Use def_step from manual selector
|
||||
break ;
|
||||
}
|
||||
frequency_list.push_back(entry.frequency_a); //Store starting freq and description
|
||||
description_list.push_back("R" + to_string_short_freq(entry.frequency_a)
|
||||
@@ -435,7 +440,7 @@ void ScannerView::frequency_file_load(std::string file_name, bool stop_all_befor
|
||||
}
|
||||
else
|
||||
{
|
||||
loaded_file_name = 'SCANNER'; // back to the default frequency file
|
||||
loaded_file_name = "SCANNER"; // back to the default frequency file
|
||||
desc_cycle.set(" NO " + file_name + ".TXT FILE ..." );
|
||||
}
|
||||
audio::output::stop();
|
||||
@@ -504,7 +509,9 @@ size_t ScannerView::change_mode(uint8_t new_mod) { //Before this, do a scan_thre
|
||||
using option_t = std::pair<std::string, int32_t>;
|
||||
using options_t = std::vector<option_t>;
|
||||
options_t bw;
|
||||
field_bw.on_change = [this](size_t n, OptionsField::value_t) { };
|
||||
field_bw.on_change = [this](size_t n, OptionsField::value_t) {
|
||||
(void)n; //avoid unused warning
|
||||
};
|
||||
|
||||
switch (new_mod) {
|
||||
case NFM: //bw 16k (2) default
|
||||
@@ -556,4 +563,4 @@ void ScannerView::start_scan_thread() {
|
||||
scan_thread = std::make_unique<ScannerThread>(frequency_list);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -212,12 +212,14 @@ private:
|
||||
true
|
||||
};
|
||||
OptionsField options_snap {
|
||||
{ 17 * 8, 15 * 8 },
|
||||
7,
|
||||
{
|
||||
{ 17 * 8, 15 * 8 }, // Position
|
||||
7, // Length
|
||||
{ // Options
|
||||
{ "25kHz ", 25000 },
|
||||
{ "12.5kHz", 12500 },
|
||||
{ "8.33kHz", 8333 }
|
||||
{ "8.33kHz", 8333 },
|
||||
{ "2.5kHz", 2500 },
|
||||
{ "500Hz", 500 }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ SetRadioView::SetRadioView(
|
||||
});
|
||||
|
||||
SetFrequencyCorrectionModel model {
|
||||
static_cast<int8_t>(portapack::persistent_memory::correction_ppb() / 1000)
|
||||
static_cast<int8_t>(portapack::persistent_memory::correction_ppb() / 1000) , 0
|
||||
};
|
||||
|
||||
form_init(model);
|
||||
@@ -285,15 +285,17 @@ SetUIView::SetUIView(NavigationView& nav) {
|
||||
&checkbox_bloff,
|
||||
&options_bloff,
|
||||
&checkbox_showsplash,
|
||||
&checkbox_showclock,
|
||||
&options_clockformat,
|
||||
&button_ok
|
||||
});
|
||||
|
||||
checkbox_speaker.set_value(persistent_memory::config_speaker());
|
||||
checkbox_showsplash.set_value(persistent_memory::config_splash());
|
||||
checkbox_showclock.set_value(!persistent_memory::hide_clock());
|
||||
//checkbox_login.set_value(persistent_memory::config_login());
|
||||
|
||||
uint32_t backlight_timer = persistent_memory::config_backlight_timer();
|
||||
|
||||
if (backlight_timer) {
|
||||
checkbox_bloff.set_value(true);
|
||||
options_bloff.set_by_value(backlight_timer);
|
||||
@@ -301,6 +303,12 @@ SetUIView::SetUIView(NavigationView& nav) {
|
||||
options_bloff.set_selected_index(0);
|
||||
}
|
||||
|
||||
if (persistent_memory::clock_with_date()) {
|
||||
options_clockformat.set_selected_index(1);
|
||||
} else {
|
||||
options_clockformat.set_selected_index(0);
|
||||
}
|
||||
|
||||
checkbox_speaker.on_select = [this](Checkbox&, bool v) {
|
||||
if (v) audio::output::speaker_mute(); //Just mute audio if speaker is disabled
|
||||
|
||||
@@ -316,7 +324,14 @@ SetUIView::SetUIView(NavigationView& nav) {
|
||||
else
|
||||
persistent_memory::set_config_backlight_timer(0);
|
||||
|
||||
if (checkbox_showclock.value()){
|
||||
if (options_clockformat.selected_index() == 1)
|
||||
persistent_memory::set_clock_with_date(true);
|
||||
else
|
||||
persistent_memory::set_clock_with_date(false);
|
||||
}
|
||||
persistent_memory::set_config_splash(checkbox_showsplash.value());
|
||||
persistent_memory::set_clock_hidden(!checkbox_showclock.value());
|
||||
//persistent_memory::set_config_login(checkbox_login.value());
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
|
||||
private:
|
||||
Labels labels {
|
||||
{ { 6 * 8, 7 * 16 }, "YYYY/MM/DD HH:MM:SS", Color::grey() },
|
||||
{ { 10 * 8, 9 * 16 }, "/ / : :", Color::light_grey() }
|
||||
{ { 6 * 8, 7 * 16 }, "YYYY-MM-DD HH:MM:SS", Color::grey() },
|
||||
{ { 10 * 8, 9 * 16 }, "- - : :", Color::light_grey() }
|
||||
};
|
||||
|
||||
NumberField field_year {
|
||||
@@ -226,19 +226,19 @@ private:
|
||||
};*/
|
||||
|
||||
Checkbox checkbox_speaker {
|
||||
{ 3 * 8, 2 * 16 },
|
||||
{ 3 * 8, 4 * 16 },
|
||||
20,
|
||||
"Hide H1 Speaker option"
|
||||
};
|
||||
|
||||
Checkbox checkbox_bloff {
|
||||
{ 3 * 8, 5 * 16 },
|
||||
{ 3 * 8, 6 * 16 },
|
||||
20,
|
||||
"Backlight off after:"
|
||||
};
|
||||
|
||||
OptionsField options_bloff {
|
||||
{ 52, 6 * 16 + 8 },
|
||||
10,
|
||||
{ 52, 7 * 16 + 8 },
|
||||
20,
|
||||
{
|
||||
{ "5 seconds", 5 },
|
||||
{ "15 seconds", 15 },
|
||||
@@ -252,10 +252,25 @@ private:
|
||||
|
||||
Checkbox checkbox_showsplash {
|
||||
{ 3 * 8, 9 * 16 },
|
||||
11,
|
||||
20,
|
||||
"Show splash"
|
||||
};
|
||||
|
||||
Checkbox checkbox_showclock {
|
||||
{ 3 * 8, 11 * 16 },
|
||||
20,
|
||||
"Show clock with:"
|
||||
};
|
||||
|
||||
OptionsField options_clockformat {
|
||||
{ 52, 12 * 16 + 8 },
|
||||
20,
|
||||
{
|
||||
{ "time only", 0 },
|
||||
{ "time and date", 1 }
|
||||
}
|
||||
};
|
||||
|
||||
Button button_ok {
|
||||
{ 2 * 8, 16 * 16, 12 * 8, 32 },
|
||||
"Save"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "ui_sonde.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "audio.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
#include <cstring>
|
||||
@@ -50,6 +51,8 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&rssi,
|
||||
&field_volume,
|
||||
&check_beep,
|
||||
&check_log,
|
||||
&check_crc,
|
||||
&text_signature,
|
||||
@@ -63,6 +66,9 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
&button_see_map
|
||||
});
|
||||
|
||||
// start from the frequency currently stored in the receiver_model:
|
||||
target_frequency_ = receiver_model.tuning_frequency();
|
||||
|
||||
field_frequency.set_value(target_frequency_);
|
||||
field_frequency.set_step(500); //euquiq: was 10000, but we are using this for fine-tunning
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
@@ -80,6 +86,10 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
|
||||
geopos.set_read_only(true);
|
||||
|
||||
check_beep.on_select = [this](Checkbox&, bool v) {
|
||||
beep = v;
|
||||
};
|
||||
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
@@ -107,16 +117,37 @@ SondeView::SondeView(NavigationView& nav) {
|
||||
gps_info.lon,
|
||||
999); //set a dummy heading out of range to draw a cross...probably not ideal?
|
||||
};
|
||||
|
||||
|
||||
logger = std::make_unique<SondeLogger>();
|
||||
if (logger)
|
||||
logger->append(u"sonde.txt");
|
||||
|
||||
// initialize audio:
|
||||
|
||||
field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99);
|
||||
|
||||
field_volume.on_change = [this](int32_t v) {
|
||||
this->on_headphone_volume_changed(v);
|
||||
};
|
||||
|
||||
audio::output::start();
|
||||
audio::output::speaker_unmute();
|
||||
|
||||
// inject a PitchRSSIConfigureMessage in order to arm
|
||||
// the pitch rssi events that will be used by the
|
||||
// processor:
|
||||
const PitchRSSIConfigureMessage message { true, 0 };
|
||||
|
||||
shared_memory.application_queue.push(message);
|
||||
|
||||
baseband::set_pitch_rssi(0, true);
|
||||
}
|
||||
|
||||
SondeView::~SondeView() {
|
||||
baseband::set_pitch_rssi(0, false);
|
||||
radio::disable();
|
||||
baseband::shutdown();
|
||||
audio::output::stop();
|
||||
}
|
||||
|
||||
void SondeView::focus() {
|
||||
@@ -156,18 +187,31 @@ void SondeView::on_packet(const sonde::Packet &packet)
|
||||
}
|
||||
|
||||
gps_info = packet.get_GPS_data();
|
||||
|
||||
geopos.set_altitude(gps_info.alt);
|
||||
geopos.set_lat(gps_info.lat);
|
||||
geopos.set_lon(gps_info.lon);
|
||||
|
||||
if (logger && logging)
|
||||
if (logger && logging) {
|
||||
logger->on_packet(packet);
|
||||
}
|
||||
|
||||
if(beep) {
|
||||
baseband::request_beep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SondeView::on_headphone_volume_changed(int32_t v) {
|
||||
const auto new_volume = volume_t::decibel(v - 99) + audio::headphone::volume_range().max;
|
||||
receiver_model.set_headphone_volume(new_volume);
|
||||
}
|
||||
|
||||
void SondeView::set_target_frequency(const uint32_t new_value) {
|
||||
target_frequency_ = new_value;
|
||||
radio::set_tuning_frequency(tuning_frequency());
|
||||
//radio::set_tuning_frequency(tuning_frequency());
|
||||
// we better remember the tuned frequency, by using this function instead:
|
||||
receiver_model.set_tuning_frequency(target_frequency_);
|
||||
}
|
||||
|
||||
uint32_t SondeView::tuning_frequency() const {
|
||||
|
||||
@@ -55,7 +55,7 @@ class SondeView : public View {
|
||||
public:
|
||||
static constexpr uint32_t sampling_rate = 2457600;
|
||||
static constexpr uint32_t baseband_bandwidth = 1750000;
|
||||
|
||||
|
||||
SondeView(NavigationView& nav);
|
||||
~SondeView();
|
||||
|
||||
@@ -68,10 +68,14 @@ private:
|
||||
uint32_t target_frequency_ { 402700000 };
|
||||
bool logging { false };
|
||||
bool use_crc { false };
|
||||
sonde::GPS_data gps_info;
|
||||
sonde::temp_humid temp_humid_info;
|
||||
std::string sonde_id;
|
||||
bool beep { false };
|
||||
|
||||
sonde::GPS_data gps_info { };
|
||||
sonde::temp_humid temp_humid_info { };
|
||||
std::string sonde_id { };
|
||||
|
||||
// AudioOutput audio_output { };
|
||||
|
||||
Labels labels {
|
||||
{ { 4 * 8, 2 * 16 }, "Type:", Color::light_grey() },
|
||||
{ { 6 * 8, 3 * 16 }, "ID:", Color::light_grey() },
|
||||
@@ -103,14 +107,29 @@ private:
|
||||
{ 21 * 8, 0, 6 * 8, 4 },
|
||||
};
|
||||
|
||||
NumberField field_volume {
|
||||
{ 28 * 8, 0 * 16 },
|
||||
2,
|
||||
{ 0, 99 },
|
||||
1,
|
||||
' ',
|
||||
};
|
||||
|
||||
|
||||
Checkbox check_beep {
|
||||
{ 22 * 8, 6 * 16 },
|
||||
3,
|
||||
"Beep"
|
||||
};
|
||||
|
||||
Checkbox check_log {
|
||||
{ 23 * 8, 6 * 16 },
|
||||
{ 22 * 8, 8 * 16 },
|
||||
3,
|
||||
"Log"
|
||||
};
|
||||
|
||||
Checkbox check_crc {
|
||||
{ 23 * 8, 8 * 16 },
|
||||
{ 22 * 8, 10 * 16 },
|
||||
3,
|
||||
"CRC"
|
||||
};
|
||||
@@ -170,7 +189,10 @@ private:
|
||||
};
|
||||
|
||||
void on_packet(const sonde::Packet& packet);
|
||||
void on_headphone_volume_changed(int32_t v);
|
||||
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
|
||||
uint32_t tuning_frequency() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -130,6 +130,13 @@ void set_afsk(const uint32_t baudrate, const uint32_t word_length, const uint32_
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_aprs(const uint32_t baudrate) {
|
||||
const APRSRxConfigureMessage message {
|
||||
baudrate
|
||||
};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_btle(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word) {
|
||||
const BTLERxConfigureMessage message {
|
||||
baudrate,
|
||||
@@ -176,13 +183,18 @@ void kill_afsk() {
|
||||
}
|
||||
|
||||
void set_audiotx_config(const uint32_t divider, const float deviation_hz, const float audio_gain,
|
||||
const uint32_t tone_key_delta) {
|
||||
const uint32_t tone_key_delta, const bool am_enabled, const bool dsb_enabled,
|
||||
const bool usb_enabled, const bool lsb_enabled) {
|
||||
const AudioTXConfigMessage message {
|
||||
divider,
|
||||
deviation_hz,
|
||||
audio_gain,
|
||||
tone_key_delta,
|
||||
(float)persistent_memory::tone_mix() / 100.0f
|
||||
(float)persistent_memory::tone_mix() / 100.0f,
|
||||
am_enabled,
|
||||
dsb_enabled,
|
||||
usb_enabled,
|
||||
lsb_enabled
|
||||
};
|
||||
send_message(&message);
|
||||
}
|
||||
@@ -224,11 +236,8 @@ void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit,
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
void set_pocsag(const pocsag::BitRate bitrate, bool phase) {
|
||||
const POCSAGConfigureMessage message {
|
||||
bitrate,
|
||||
phase
|
||||
};
|
||||
void set_pocsag() {
|
||||
const POCSAGConfigureMessage message {};
|
||||
send_message(&message);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,15 @@ void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint1
|
||||
void kill_tone();
|
||||
void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration);
|
||||
void set_audiotx_config(const uint32_t divider, const float deviation_hz, const float audio_gain,
|
||||
const uint32_t tone_key_delta);
|
||||
const uint32_t tone_key_delta, const bool am_enabled, const bool dsb_enabled,
|
||||
const bool usb_enabled, const bool lsb_enabled);
|
||||
void set_fifo_data(const int8_t * data);
|
||||
void set_pitch_rssi(int32_t avg, bool enabled);
|
||||
void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phase_inc_mark, const uint32_t afsk_phase_inc_space,
|
||||
const uint8_t afsk_repeat, const uint32_t afsk_bw, const uint8_t symbol_count);
|
||||
void kill_afsk();
|
||||
void set_afsk(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word);
|
||||
void set_aprs(const uint32_t baudrate);
|
||||
|
||||
void set_btle(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word);
|
||||
|
||||
@@ -77,7 +79,7 @@ void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit,
|
||||
const uint32_t pause_symbols);
|
||||
void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t shift,
|
||||
const uint32_t progress_notice);
|
||||
void set_pocsag(const pocsag::BitRate bitrate, bool phase);
|
||||
void set_pocsag();
|
||||
void set_adsb();
|
||||
void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed);
|
||||
void set_rds_data(const uint16_t message_length);
|
||||
|
||||
@@ -298,6 +298,12 @@ void EventDispatcher::handle_switches() {
|
||||
}
|
||||
|
||||
if( in_key_event ) {
|
||||
if (switches_state[(size_t)ui::KeyEvent::Left] && switches_state[(size_t)ui::KeyEvent::Up])
|
||||
{
|
||||
const auto event = static_cast<ui::KeyEvent>(ui::KeyEvent::Back);
|
||||
context.focus_manager().update(top_widget, event);
|
||||
}
|
||||
|
||||
// If we're in a key event, return. We will ignore all additional key
|
||||
// presses until the first key is released. We also want to ignore events
|
||||
// where the last key held generates a key event when other pressed keys
|
||||
|
||||
@@ -140,6 +140,9 @@ Continuous (Fox-oring)
|
||||
#include "sd_card.hpp"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "rffc507x.hpp" /* c/m, avoiding initial short ON Ant_DC_Bias pulse, from cold reset */
|
||||
rffc507x::RFFC507x first_if;
|
||||
|
||||
static void event_loop() {
|
||||
ui::Context context;
|
||||
@@ -160,6 +163,7 @@ static void event_loop() {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */
|
||||
if( portapack::init() ) {
|
||||
portapack::display.init();
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ TransmitterModel transmitter_model;
|
||||
TemperatureLogger temperature_logger;
|
||||
|
||||
bool antenna_bias { false };
|
||||
uint8_t bl_tick_counter { 0 };
|
||||
uint32_t bl_tick_counter { 0 };
|
||||
|
||||
void set_antenna_bias(const bool v) {
|
||||
antenna_bias = v;
|
||||
@@ -179,20 +179,23 @@ static PortaPackModel portapack_model() {
|
||||
static Optional<PortaPackModel> model;
|
||||
|
||||
if( !model.is_valid() ) {
|
||||
if( audio_codec_wm8731.detected() ) {
|
||||
model = PortaPackModel::R1_20150901;
|
||||
} else {
|
||||
/*For the time being, it is impossible to distinguish the hardware of R1 and R2 from the software level*/
|
||||
/*At this point, I2c is not ready.*/
|
||||
//if( audio_codec_wm8731.detected() ) {
|
||||
// model = PortaPackModel::R1_20150901;
|
||||
//} else {
|
||||
model = PortaPackModel::R2_20170522;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
return model.value();
|
||||
}
|
||||
|
||||
static audio::Codec* portapack_audio_codec() {
|
||||
return (portapack_model() == PortaPackModel::R2_20170522)
|
||||
? static_cast<audio::Codec*>(&audio_codec_ak4951)
|
||||
: static_cast<audio::Codec*>(&audio_codec_wm8731)
|
||||
/* I2C ready OK, Automatic recognition of audio chip */
|
||||
return (audio_codec_wm8731.detected())
|
||||
? static_cast<audio::Codec*>(&audio_codec_wm8731)
|
||||
: static_cast<audio::Codec*>(&audio_codec_ak4951)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ extern TransmitterModel transmitter_model;
|
||||
extern bool speaker_mode;
|
||||
void set_speaker_mode(const bool v);
|
||||
|
||||
extern uint8_t bl_tick_counter;
|
||||
extern uint32_t bl_tick_counter;
|
||||
extern bool antenna_bias;
|
||||
|
||||
extern TemperatureLogger temperature_logger;
|
||||
|
||||
@@ -111,14 +111,12 @@ void set_direction(const rf::Direction new_direction) {
|
||||
// Hack to fix the CPLD (clocking ?) bug: toggle CPLD SRAM overlay depending on new direction
|
||||
// Use CPLD's EEPROM config when transmitting
|
||||
// Use the SRAM overlay when receiving
|
||||
if (direction != new_direction) {
|
||||
if (new_direction == rf::Direction::Transmit) {
|
||||
hackrf::cpld::init_from_eeprom();
|
||||
} else {
|
||||
if( !hackrf::cpld::load_sram() ) {
|
||||
chSysHalt();
|
||||
}
|
||||
}
|
||||
|
||||
// teixeluis: undone "Hack to fix the CPLD (clocking ?) bug".
|
||||
// Apparently with current CPLD code from the hackrf repo,
|
||||
// toggling CPLD overlay should no longer be necessary:
|
||||
if (direction != new_direction && new_direction == rf::Direction::Transmit) {
|
||||
hackrf::cpld::init_from_eeprom();
|
||||
}
|
||||
|
||||
direction = new_direction;
|
||||
|
||||
@@ -171,7 +171,11 @@ void ReceiverModel::enable() {
|
||||
update_baseband_bandwidth();
|
||||
update_sampling_rate();
|
||||
update_modulation();
|
||||
|
||||
// TODO: would challenge if this should belong to the
|
||||
// receiver_model namespace:
|
||||
update_headphone_volume();
|
||||
|
||||
led_rx.on();
|
||||
}
|
||||
|
||||
@@ -182,6 +186,10 @@ void ReceiverModel::disable() {
|
||||
// TODO: Responsibility for enabling/disabling the radio is muddy.
|
||||
// Some happens in ReceiverModel, some inside radio namespace.
|
||||
radio::disable();
|
||||
|
||||
// TODO: we are doing this repeatedly in different levels of the
|
||||
// call stack. Keeping it for now, but there seem to be too many
|
||||
// redundant calls:
|
||||
led_rx.off();
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,24 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( event == ui::KeyEvent::Up ) {
|
||||
if(selected_key == recent.front().key()){
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
advance(-1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if( event == ui::KeyEvent::Down ) {
|
||||
if( selected_key == recent.back().key()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
advance(1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -264,7 +282,7 @@ public:
|
||||
// TODO: What happens here shouldn't matter if I do proper damage detection!
|
||||
}
|
||||
|
||||
void on_focus() override {
|
||||
void focus() override {
|
||||
_table.focus();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,23 @@ std::string to_string_dec_int(
|
||||
return q;
|
||||
}
|
||||
|
||||
std::string to_string_decimal(float decimal, int8_t precision) {
|
||||
double integer_part;
|
||||
double fractional_part;
|
||||
|
||||
std::string result;
|
||||
|
||||
fractional_part = modf(decimal, &integer_part) * pow(10, precision);
|
||||
|
||||
if (fractional_part < 0) {
|
||||
fractional_part = -fractional_part;
|
||||
}
|
||||
|
||||
result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision, '0');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_string_short_freq(const uint64_t f) {
|
||||
auto final_str = to_string_dec_int(f / 1000000,4) + "." + to_string_dec_int((f / 100) % 10000, 4, '0');
|
||||
return final_str;
|
||||
@@ -165,8 +182,8 @@ std::string to_string_datetime(const rtc::RTC& value, const TimeFormat format) {
|
||||
std::string string { "" };
|
||||
|
||||
if (format == YMDHMS) {
|
||||
string += to_string_dec_uint(value.year(), 4) + "/" +
|
||||
to_string_dec_uint(value.month(), 2, '0') + "/" +
|
||||
string += to_string_dec_uint(value.year(), 4) + "-" +
|
||||
to_string_dec_uint(value.month(), 2, '0') + "-" +
|
||||
to_string_dec_uint(value.day(), 2, '0') + " ";
|
||||
}
|
||||
|
||||
@@ -189,11 +206,11 @@ std::string to_string_timestamp(const rtc::RTC& value) {
|
||||
}
|
||||
|
||||
std::string to_string_FAT_timestamp(const FATTimestamp& timestamp) {
|
||||
return to_string_dec_uint((timestamp.FAT_date >> 9) + 1980) + "/" +
|
||||
to_string_dec_uint((timestamp.FAT_date >> 5) & 0xF, 2) + "/" +
|
||||
to_string_dec_uint((timestamp.FAT_date & 0x1F), 2) + " " +
|
||||
to_string_dec_uint((timestamp.FAT_time >> 11), 2) + ":" +
|
||||
to_string_dec_uint((timestamp.FAT_time >> 5) & 0x3F, 2);
|
||||
return to_string_dec_uint((timestamp.FAT_date >> 9) + 1980) + "-" +
|
||||
to_string_dec_uint((timestamp.FAT_date >> 5) & 0xF, 2, '0') + "-" +
|
||||
to_string_dec_uint((timestamp.FAT_date & 0x1F), 2, '0') + " " +
|
||||
to_string_dec_uint((timestamp.FAT_time >> 11), 2, '0') + ":" +
|
||||
to_string_dec_uint((timestamp.FAT_time >> 5) & 0x3F, 2, '0');
|
||||
}
|
||||
|
||||
std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision) {
|
||||
|
||||
@@ -43,6 +43,8 @@ const char unit_prefix[7] { 'n', 'u', 'm', 0, 'k', 'M', 'G' };
|
||||
std::string to_string_bin(const uint32_t n, const uint8_t l = 0);
|
||||
std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char fill = ' ');
|
||||
std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0);
|
||||
std::string to_string_decimal(float decimal, int8_t precision);
|
||||
|
||||
std::string to_string_hex(const uint64_t n, const int32_t l = 0);
|
||||
std::string to_string_hex_array(uint8_t * const array, const int32_t l = 0);
|
||||
|
||||
|
||||
@@ -63,17 +63,9 @@ GeoPos::GeoPos(
|
||||
const auto changed_fn = [this](int32_t) {
|
||||
float lat_value = lat();
|
||||
float lon_value = lon();
|
||||
double integer_part;
|
||||
double fractional_part;
|
||||
|
||||
fractional_part = modf(lat_value, &integer_part) * 100000;
|
||||
if (fractional_part < 0)
|
||||
fractional_part = -fractional_part;
|
||||
text_lat_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5));
|
||||
fractional_part = modf(lon_value, &integer_part) * 100000;
|
||||
if (fractional_part < 0)
|
||||
fractional_part = -fractional_part;
|
||||
text_lon_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5));
|
||||
|
||||
text_lat_decimal.set(to_string_decimal(lat_value, 5));
|
||||
text_lon_decimal.set(to_string_decimal(lon_value, 5));
|
||||
|
||||
if (on_change && report_change)
|
||||
on_change(altitude(), lat_value, lon_value);
|
||||
@@ -264,8 +256,13 @@ void GeoMapView::focus() {
|
||||
void GeoMapView::update_position(float lat, float lon, uint16_t angle) {
|
||||
lat_ = lat;
|
||||
lon_ = lon;
|
||||
|
||||
// Stupid hack to avoid an event loop
|
||||
geopos.set_report_change(false);
|
||||
geopos.set_lat(lat_);
|
||||
geopos.set_lon(lon_);
|
||||
geopos.set_report_change(true);
|
||||
|
||||
geomap.set_angle(angle);
|
||||
geomap.move(lon_, lat_);
|
||||
geomap.set_dirty();
|
||||
|
||||
@@ -75,8 +75,9 @@ void RSSI::paint(Painter& painter) {
|
||||
Color::black()
|
||||
);
|
||||
|
||||
if (pitch_rssi_enabled)
|
||||
if (pitch_rssi_enabled) {
|
||||
baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true);
|
||||
}
|
||||
}
|
||||
|
||||
void RSSI::set_pitch_rssi(bool enabled) {
|
||||
|
||||
@@ -103,6 +103,7 @@ void TransmitterView::set_transmitting(const bool transmitting) {
|
||||
|
||||
void TransmitterView::on_show() {
|
||||
field_frequency.set_value(transmitter_model.tuning_frequency());
|
||||
field_frequency_step.set_by_value(receiver_model.frequency_step());
|
||||
|
||||
field_gain.set_value(transmitter_model.tx_gain());
|
||||
field_amp.set_value(transmitter_model.rf_amp() ? 14 : 0);
|
||||
@@ -122,6 +123,7 @@ TransmitterView::TransmitterView(
|
||||
|
||||
add_children({
|
||||
&field_frequency,
|
||||
&field_frequency_step,
|
||||
&text_gain,
|
||||
&field_gain,
|
||||
&button_start,
|
||||
@@ -157,6 +159,10 @@ TransmitterView::TransmitterView(
|
||||
if (on_edit_frequency)
|
||||
on_edit_frequency();
|
||||
};
|
||||
|
||||
field_frequency_step.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
this->field_frequency.set_step(v);
|
||||
};
|
||||
|
||||
field_gain.on_change = [this](uint32_t tx_gain) {
|
||||
on_tx_gain_changed(tx_gain);
|
||||
|
||||
@@ -124,11 +124,11 @@ private:
|
||||
};
|
||||
|
||||
Text text_bw {
|
||||
{ 11 * 8, 1 * 8, 9 * 8, 1 * 16 },
|
||||
"BW: kHz"
|
||||
{ 18 * 8, 1 * 8, 3 * 8, 1 * 16 },
|
||||
"kHz"
|
||||
};
|
||||
NumberField field_bw {
|
||||
{ 14 * 8, 1 * 8 },
|
||||
{ 15 * 8, 1 * 8 },
|
||||
3,
|
||||
{ 1, 150 },
|
||||
1,
|
||||
@@ -152,6 +152,10 @@ private:
|
||||
{ 21 * 8, 1 * 8, 9 * 8, 32 },
|
||||
"START"
|
||||
};
|
||||
|
||||
FrequencyStepView field_frequency_step {
|
||||
{ 10 * 8 - 4, 1 * 8 },
|
||||
};
|
||||
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
void on_channel_bandwidth_changed(uint32_t channel_bandwidth);
|
||||
|
||||
@@ -182,7 +182,7 @@ void TVView::clear() {
|
||||
|
||||
/* TVWidget *******************************************************/
|
||||
|
||||
TVWidget::TVWidget(const bool cursor) {
|
||||
TVWidget::TVWidget() {
|
||||
add_children({
|
||||
&tv_view,
|
||||
&field_xcorr
|
||||
|
||||
@@ -92,7 +92,7 @@ class TVWidget : public View {
|
||||
public:
|
||||
std::function<void(int32_t offset)> on_select { };
|
||||
|
||||
TVWidget(const bool cursor = false);
|
||||
TVWidget();
|
||||
|
||||
TVWidget(const TVWidget&) = delete;
|
||||
TVWidget(TVWidget&&) = delete;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "ui_adsb_rx.hpp"
|
||||
#include "ui_adsb_tx.hpp"
|
||||
#include "ui_afsk_rx.hpp"
|
||||
#include "ui_aprs_rx.hpp"
|
||||
#include "ui_btle_rx.hpp"
|
||||
#include "ui_nrf_rx.hpp"
|
||||
#include "ui_aprs_tx.hpp"
|
||||
@@ -67,7 +68,7 @@
|
||||
#include "ui_view_wav.hpp"
|
||||
#include "ui_whipcalc.hpp"
|
||||
|
||||
#include "acars_app.hpp"
|
||||
//#include "acars_app.hpp"
|
||||
#include "ais_app.hpp"
|
||||
#include "analog_audio_app.hpp"
|
||||
#include "analog_tv_app.hpp"
|
||||
@@ -349,13 +350,21 @@ InformationView::InformationView(
|
||||
});
|
||||
|
||||
version.set_style(&style_infobar);
|
||||
|
||||
ltime.set_hide_clock(portapack::persistent_memory::hide_clock());
|
||||
ltime.set_style(&style_infobar);
|
||||
ltime.set_seconds_enabled(true);
|
||||
ltime.set_date_enabled(false);
|
||||
|
||||
ltime.set_date_enabled(portapack::persistent_memory::clock_with_date());
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void InformationView::refresh() {
|
||||
ltime.set_hide_clock(portapack::persistent_memory::hide_clock());
|
||||
ltime.set_seconds_enabled(true);
|
||||
ltime.set_date_enabled(portapack::persistent_memory::clock_with_date());
|
||||
|
||||
}
|
||||
|
||||
/* Navigation ************************************************************/
|
||||
|
||||
bool NavigationView::is_top() const {
|
||||
@@ -386,6 +395,7 @@ void NavigationView::pop() {
|
||||
|
||||
update_view();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NavigationView::pop_modal() {
|
||||
@@ -468,7 +478,8 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
|
||||
{ "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push<POCSAGAppView>(); } },
|
||||
{ "Radiosnde", ui::Color::green(), &bitmap_icon_sonde, [&nav](){ nav.push<SondeView>(); } },
|
||||
{ "TPMS Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.push<TPMSAppView>(); } },
|
||||
/*{ "APRS", ui::Color::dark_grey(), &bitmap_icon_aprs, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "APRS", ui::Color::green(), &bitmap_icon_aprs, [&nav](){ nav.push<APRSRXView>(); } }
|
||||
/*
|
||||
{ "DMR", ui::Color::dark_grey(), &bitmap_icon_dmr, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "SIGFOX", ui::Color::dark_grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
||||
{ "LoRa", ui::Color::dark_grey(), &bitmap_icon_lora, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
@@ -604,6 +615,7 @@ SystemView::SystemView(
|
||||
}
|
||||
else{
|
||||
add_child(&info_view);
|
||||
info_view.refresh();
|
||||
}
|
||||
|
||||
this->status_view.set_back_enabled(!this->navigation_view.is_top());
|
||||
@@ -625,7 +637,9 @@ SystemView::SystemView(
|
||||
navigation_view.push<SystemMenuView>();
|
||||
|
||||
if (portapack::persistent_memory::config_splash())
|
||||
{
|
||||
navigation_view.push<BMPView>();
|
||||
}
|
||||
status_view.set_back_enabled(false);
|
||||
status_view.set_title_image_enabled(true);
|
||||
status_view.set_dirty();
|
||||
@@ -656,7 +670,8 @@ BMPView::BMPView(NavigationView& nav) {
|
||||
}
|
||||
|
||||
void BMPView::paint(Painter&) {
|
||||
portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, false);
|
||||
if(!portapack::display.drawBMP2({ 0, 0 }, "splash.bmp"))
|
||||
portapack::display.drawBMP({(240 - 230) / 2, (320 - 50) / 2 - 10}, splash_bmp, false);
|
||||
}
|
||||
|
||||
/* NotImplementedView ****************************************************/
|
||||
|
||||
@@ -45,253 +45,252 @@
|
||||
|
||||
using namespace sd_card;
|
||||
|
||||
namespace ui {
|
||||
namespace ui
|
||||
{
|
||||
|
||||
enum modal_t {
|
||||
INFO = 0,
|
||||
YESNO,
|
||||
YESCANCEL,
|
||||
ABORT
|
||||
};
|
||||
|
||||
class NavigationView : public View {
|
||||
public:
|
||||
std::function<void(const View&)> on_view_changed { };
|
||||
|
||||
NavigationView() = default;
|
||||
|
||||
NavigationView(const NavigationView&) = delete;
|
||||
NavigationView(NavigationView&&) = delete;
|
||||
NavigationView& operator=(const NavigationView&) = delete;
|
||||
NavigationView& operator=(NavigationView&&) = delete;
|
||||
|
||||
bool is_top() const;
|
||||
|
||||
template<class T, class... Args>
|
||||
T* push(Args&&... args) {
|
||||
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
template<class T, class... Args>
|
||||
T* replace(Args&&... args) {
|
||||
pop();
|
||||
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
|
||||
void push(View* v);
|
||||
void replace(View* v);
|
||||
|
||||
void pop();
|
||||
void pop_modal();
|
||||
|
||||
void display_modal(const std::string& title, const std::string& message);
|
||||
void display_modal(const std::string& title, const std::string& message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
|
||||
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<View>> view_stack { };
|
||||
Widget* modal_view { nullptr };
|
||||
|
||||
Widget* view() const;
|
||||
|
||||
void free_view();
|
||||
void update_view();
|
||||
View* push_view(std::unique_ptr<View> new_view);
|
||||
};
|
||||
|
||||
class SystemStatusView : public View {
|
||||
public:
|
||||
std::function<void(void)> on_back { };
|
||||
|
||||
SystemStatusView(NavigationView& nav);
|
||||
|
||||
void set_back_enabled(bool new_value);
|
||||
void set_title_image_enabled(bool new_value);
|
||||
void set_title(const std::string new_value);
|
||||
|
||||
private:
|
||||
static constexpr auto default_title = "";
|
||||
|
||||
NavigationView& nav_;
|
||||
|
||||
Rectangle backdrop {
|
||||
{ 0 * 8, 0 * 16, 240, 16 },
|
||||
Color::dark_grey()
|
||||
enum modal_t
|
||||
{
|
||||
INFO = 0,
|
||||
YESNO,
|
||||
YESCANCEL,
|
||||
ABORT
|
||||
};
|
||||
|
||||
ImageButton button_back {
|
||||
{ 2, 0 * 16, 16, 16 },
|
||||
&bitmap_icon_previous,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
class NavigationView : public View
|
||||
{
|
||||
public:
|
||||
std::function<void(const View &)> on_view_changed{};
|
||||
|
||||
NavigationView() = default;
|
||||
|
||||
NavigationView(const NavigationView &) = delete;
|
||||
NavigationView(NavigationView &&) = delete;
|
||||
NavigationView &operator=(const NavigationView &) = delete;
|
||||
NavigationView &operator=(NavigationView &&) = delete;
|
||||
|
||||
bool is_top() const;
|
||||
|
||||
template <class T, class... Args>
|
||||
T *push(Args &&...args)
|
||||
{
|
||||
return reinterpret_cast<T *>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
template <class T, class... Args>
|
||||
T *replace(Args &&...args)
|
||||
{
|
||||
pop();
|
||||
return reinterpret_cast<T *>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
|
||||
void push(View *v);
|
||||
void replace(View *v);
|
||||
|
||||
void pop();
|
||||
void pop_modal();
|
||||
|
||||
void display_modal(const std::string &title, const std::string &message);
|
||||
void display_modal(const std::string &title, const std::string &message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
|
||||
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<View>> view_stack{};
|
||||
Widget *modal_view{nullptr};
|
||||
|
||||
Widget *view() const;
|
||||
|
||||
void free_view();
|
||||
void update_view();
|
||||
View *push_view(std::unique_ptr<View> new_view);
|
||||
};
|
||||
|
||||
Text title {
|
||||
{ 20, 0, 14 * 8, 1 * 16 },
|
||||
default_title,
|
||||
};
|
||||
class SystemStatusView : public View
|
||||
{
|
||||
public:
|
||||
std::function<void(void)> on_back{};
|
||||
|
||||
ImageButton button_title {
|
||||
{2, 0, 80, 16},
|
||||
&bitmap_titlebar_image,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
SystemStatusView(NavigationView &nav);
|
||||
|
||||
ImageButton button_speaker {
|
||||
{ 17 * 8, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_speaker_mute,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
|
||||
ImageButton button_stealth {
|
||||
{ 19 * 8, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_stealth,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
|
||||
/*ImageButton button_textentry {
|
||||
void set_back_enabled(bool new_value);
|
||||
void set_title_image_enabled(bool new_value);
|
||||
void set_title(const std::string new_value);
|
||||
|
||||
private:
|
||||
static constexpr auto default_title = "";
|
||||
|
||||
NavigationView &nav_;
|
||||
|
||||
Rectangle backdrop{
|
||||
{0 * 8, 0 * 16, 240, 16},
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_back{
|
||||
{2, 0 * 16, 16, 16},
|
||||
&bitmap_icon_previous,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
Text title{
|
||||
{20, 0, 14 * 8, 1 * 16},
|
||||
default_title,
|
||||
};
|
||||
|
||||
ImageButton button_title{
|
||||
{2, 0, 80, 16},
|
||||
&bitmap_titlebar_image,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_speaker{
|
||||
{17 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_speaker_mute,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_stealth{
|
||||
{19 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_stealth,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
/*ImageButton button_textentry {
|
||||
{ 170, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_unistroke,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};*/
|
||||
|
||||
ImageButton button_camera {
|
||||
{ 21 * 8, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_camera,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
ImageButton button_camera{
|
||||
{21 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_camera,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_sleep{
|
||||
{23 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_sleep,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_bias_tee{
|
||||
{25 * 8, 0, 12, 1 * 16},
|
||||
&bitmap_icon_biast_off,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_clock_status{
|
||||
{27 * 8, 0 * 16, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_clk_int,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
SDCardStatusView sd_card_status_view{
|
||||
{28 * 8, 0 * 16, 2 * 8, 1 * 16}};
|
||||
|
||||
void on_speaker();
|
||||
void on_stealth();
|
||||
void on_bias_tee();
|
||||
//void on_textentry();
|
||||
void on_camera();
|
||||
void on_title();
|
||||
void refresh();
|
||||
void on_clk();
|
||||
|
||||
MessageHandlerRegistration message_handler_refresh{
|
||||
Message::ID::StatusRefresh,
|
||||
[this](const Message *const p)
|
||||
{
|
||||
(void)p;
|
||||
this->refresh();
|
||||
}};
|
||||
};
|
||||
|
||||
ImageButton button_sleep {
|
||||
{ 23 * 8, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_sleep,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
|
||||
ImageButton button_bias_tee {
|
||||
{ 25 * 8, 0, 12, 1 * 16 },
|
||||
&bitmap_icon_biast_off,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
|
||||
ImageButton button_clock_status {
|
||||
{ 27 * 8, 0 * 16, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_clk_int,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
|
||||
SDCardStatusView sd_card_status_view {
|
||||
{ 28 * 8, 0 * 16, 2 * 8, 1 * 16 }
|
||||
class InformationView : public View
|
||||
{
|
||||
public:
|
||||
InformationView(NavigationView &nav);
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
static constexpr auto version_string = "v1.4.2";
|
||||
NavigationView &nav_;
|
||||
|
||||
Rectangle backdrop{
|
||||
{0, 0 * 16, 240, 16},
|
||||
{33, 33, 33}};
|
||||
|
||||
Text version{
|
||||
{2, 0, 11 * 8, 16},
|
||||
version_string};
|
||||
|
||||
LiveDateTime ltime{
|
||||
{86, 0, 19 * 8, 16}};
|
||||
};
|
||||
|
||||
void on_speaker();
|
||||
void on_stealth();
|
||||
void on_bias_tee();
|
||||
//void on_textentry();
|
||||
void on_camera();
|
||||
void on_title();
|
||||
void refresh();
|
||||
void on_clk();
|
||||
|
||||
MessageHandlerRegistration message_handler_refresh {
|
||||
Message::ID::StatusRefresh,
|
||||
[this](const Message* const p) {
|
||||
(void)p;
|
||||
this->refresh();
|
||||
}
|
||||
};
|
||||
};
|
||||
class BMPView : public View
|
||||
{
|
||||
public:
|
||||
BMPView(NavigationView &nav);
|
||||
void paint(Painter &) override;
|
||||
void focus() override;
|
||||
|
||||
class InformationView : public View {
|
||||
public:
|
||||
InformationView(NavigationView& nav);
|
||||
|
||||
private:
|
||||
static constexpr auto version_string = "v1.3.0";
|
||||
NavigationView& nav_;
|
||||
private:
|
||||
Text text_info{
|
||||
{4 * 8, 284, 20 * 8, 16},
|
||||
"Version " VERSION_STRING};
|
||||
|
||||
Rectangle backdrop {
|
||||
{ 0, 0 * 16, 240, 16 },
|
||||
{33, 33, 33}
|
||||
Button button_done{
|
||||
{240, 0, 1, 1},
|
||||
""};
|
||||
};
|
||||
|
||||
Text version {
|
||||
{2, 0, 11 * 8, 16},
|
||||
version_string
|
||||
class ReceiversMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
ReceiversMenuView(NavigationView &nav);
|
||||
std::string title() const override { return "Receivers"; };
|
||||
};
|
||||
|
||||
LiveDateTime ltime {
|
||||
{174, 0, 8 * 8, 16}
|
||||
|
||||
class TransmittersMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
TransmittersMenuView(NavigationView &nav);
|
||||
std::string title() const override { return "Transmitters"; };
|
||||
};
|
||||
};
|
||||
|
||||
class BMPView : public View {
|
||||
public:
|
||||
BMPView(NavigationView& nav);
|
||||
void paint(Painter&) override;
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
Text text_info {
|
||||
{ 4*8, 284, 20 * 8, 16 },
|
||||
"Version " VERSION_STRING
|
||||
class UtilitiesMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
UtilitiesMenuView(NavigationView &nav);
|
||||
std::string title() const override { return "Utilities"; };
|
||||
};
|
||||
|
||||
Button button_done {
|
||||
{ 240, 0, 1, 1 },
|
||||
""
|
||||
|
||||
class SystemMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
SystemMenuView(NavigationView &nav);
|
||||
|
||||
private:
|
||||
void hackrf_mode(NavigationView &nav);
|
||||
};
|
||||
};
|
||||
|
||||
class ReceiversMenuView : public BtnGridView {
|
||||
public:
|
||||
ReceiversMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Receivers"; };
|
||||
};
|
||||
class SystemView : public View
|
||||
{
|
||||
public:
|
||||
SystemView(
|
||||
Context &context,
|
||||
const Rect parent_rect);
|
||||
|
||||
class TransmittersMenuView : public BtnGridView {
|
||||
public:
|
||||
TransmittersMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Transmitters"; };
|
||||
};
|
||||
Context &context() const override;
|
||||
|
||||
class UtilitiesMenuView : public BtnGridView {
|
||||
public:
|
||||
UtilitiesMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Utilities"; };
|
||||
};
|
||||
private:
|
||||
SystemStatusView status_view{navigation_view};
|
||||
InformationView info_view{navigation_view};
|
||||
NavigationView navigation_view{};
|
||||
Context &context_;
|
||||
};
|
||||
|
||||
class SystemMenuView : public BtnGridView {
|
||||
public:
|
||||
SystemMenuView(NavigationView& nav);
|
||||
private:
|
||||
void hackrf_mode(NavigationView& nav);
|
||||
};
|
||||
|
||||
class SystemView : public View {
|
||||
public:
|
||||
SystemView(
|
||||
Context& context,
|
||||
const Rect parent_rect
|
||||
);
|
||||
|
||||
Context& context() const override;
|
||||
|
||||
private:
|
||||
SystemStatusView status_view { navigation_view };
|
||||
InformationView info_view { navigation_view };
|
||||
NavigationView navigation_view { };
|
||||
Context& context_;
|
||||
};
|
||||
|
||||
/*class NotImplementedView : public View {
|
||||
/*class NotImplementedView : public View {
|
||||
public:
|
||||
NotImplementedView(NavigationView& nav);
|
||||
|
||||
@@ -309,43 +308,43 @@ private:
|
||||
};
|
||||
};*/
|
||||
|
||||
class ModalMessageView : public View {
|
||||
public:
|
||||
ModalMessageView(
|
||||
NavigationView& nav,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const modal_t type,
|
||||
const std::function<void(bool)> on_choice
|
||||
);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
void focus() override;
|
||||
class ModalMessageView : public View
|
||||
{
|
||||
public:
|
||||
ModalMessageView(
|
||||
NavigationView &nav,
|
||||
const std::string &title,
|
||||
const std::string &message,
|
||||
const modal_t type,
|
||||
const std::function<void(bool)> on_choice);
|
||||
|
||||
std::string title() const override { return title_; };
|
||||
void paint(Painter &painter) override;
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
const std::string title_;
|
||||
const std::string message_;
|
||||
const modal_t type_;
|
||||
const std::function<void(bool)> on_choice_;
|
||||
std::string title() const override { return title_; };
|
||||
|
||||
Button button_ok {
|
||||
{ 10 * 8, 14 * 16, 10 * 8, 48 },
|
||||
"OK",
|
||||
private:
|
||||
const std::string title_;
|
||||
const std::string message_;
|
||||
const modal_t type_;
|
||||
const std::function<void(bool)> on_choice_;
|
||||
|
||||
Button button_ok{
|
||||
{10 * 8, 14 * 16, 10 * 8, 48},
|
||||
"OK",
|
||||
};
|
||||
|
||||
Button button_yes{
|
||||
{5 * 8, 14 * 16, 8 * 8, 48},
|
||||
"YES",
|
||||
};
|
||||
|
||||
Button button_no{
|
||||
{17 * 8, 14 * 16, 8 * 8, 48},
|
||||
"NO",
|
||||
};
|
||||
};
|
||||
|
||||
Button button_yes {
|
||||
{ 5 * 8, 14 * 16, 8 * 8, 48 },
|
||||
"YES",
|
||||
};
|
||||
|
||||
Button button_no {
|
||||
{ 17 * 8, 14 * 16, 8 * 8, 48 },
|
||||
"NO",
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif/*__UI_NAVIGATION_H__*/
|
||||
#endif /*__UI_NAVIGATION_H__*/
|
||||
|
||||
@@ -113,6 +113,8 @@ set(CPPSRC
|
||||
baseband_stats_collector.cpp
|
||||
dsp_decimate.cpp
|
||||
dsp_demodulate.cpp
|
||||
dsp_hilbert.cpp
|
||||
dsp_modulate.cpp
|
||||
dsp_goertzel.cpp
|
||||
matched_filter.cpp
|
||||
spectrum_collector.cpp
|
||||
@@ -125,6 +127,7 @@ set(CPPSRC
|
||||
${COMMON}/dsp_fft.cpp
|
||||
${COMMON}/dsp_fir_taps.cpp
|
||||
${COMMON}/dsp_iir.cpp
|
||||
${COMMON}/dsp_sos.cpp
|
||||
fxpt_atan2.cpp
|
||||
rssi.cpp
|
||||
rssi_dma.cpp
|
||||
@@ -312,6 +315,14 @@ set(MODE_CPPSRC
|
||||
proc_afskrx.cpp
|
||||
)
|
||||
DeclareTargets(PAFR afskrx)
|
||||
|
||||
### APRS RX
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_aprsrx.cpp
|
||||
)
|
||||
DeclareTargets(PAPR aprsrx)
|
||||
|
||||
### NRF RX
|
||||
|
||||
set(MODE_CPPSRC
|
||||
|
||||
@@ -35,7 +35,7 @@ class ChannelStatsCollector {
|
||||
public:
|
||||
template<typename Callback>
|
||||
void feed(const buffer_c16_t& src, Callback callback) {
|
||||
auto src_p = src.p;
|
||||
void *src_p = src.p;
|
||||
while(src_p < &src.p[src.count]) {
|
||||
const uint32_t sample = *__SIMD32(src_p)++;
|
||||
const uint32_t mag_sq = __SMUAD(sample, sample);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "dsp_hilbert.hpp"
|
||||
#include "dsp_sos_config.hpp"
|
||||
|
||||
namespace dsp {
|
||||
|
||||
HilbertTransform::HilbertTransform() {
|
||||
n = 0;
|
||||
|
||||
sos_i.configure(half_band_lpf_config);
|
||||
sos_q.configure(half_band_lpf_config);
|
||||
}
|
||||
|
||||
void HilbertTransform::execute(float in, float &out_i, float &out_q) {
|
||||
float a = 0, b = 0;
|
||||
|
||||
switch (n) {
|
||||
case 0: a = in; b = 0; break;
|
||||
case 1: a = 0; b = -in; break;
|
||||
case 2: a = -in; b = 0; break;
|
||||
case 3: a = 0; b = in; break;
|
||||
}
|
||||
|
||||
float i = sos_i.execute(a) * 2.0f;
|
||||
float q = sos_q.execute(b) * 2.0f;
|
||||
|
||||
switch (n) {
|
||||
case 0: out_i = i; out_q = q; break;
|
||||
case 1: out_i = -q; out_q = i; break;
|
||||
case 2: out_i = -i; out_q = -q; break;
|
||||
case 3: out_i = q; out_q = -i; break;
|
||||
}
|
||||
|
||||
n = (n + 1) % 4;
|
||||
}
|
||||
|
||||
} /* namespace dsp */
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __DSP_HILBERT_H__
|
||||
#define __DSP_HILBERT_H__
|
||||
|
||||
#include "dsp_sos.hpp"
|
||||
#include "dsp_types.hpp"
|
||||
|
||||
namespace dsp {
|
||||
|
||||
class HilbertTransform {
|
||||
public:
|
||||
|
||||
HilbertTransform();
|
||||
void execute(float in, float &out_i, float &out_q);
|
||||
|
||||
private:
|
||||
uint8_t n = 0;
|
||||
SOSFilter<5> sos_i;
|
||||
SOSFilter<5> sos_q;
|
||||
};
|
||||
|
||||
} /* namespace dsp */
|
||||
|
||||
#endif/*__DSP_HILBERT_H__*/
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "dsp_modulate.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
|
||||
namespace dsp {
|
||||
namespace modulate {
|
||||
|
||||
Modulator::~Modulator() {
|
||||
}
|
||||
|
||||
Mode Modulator::get_mode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
void Modulator::set_mode(Mode new_mode) {
|
||||
mode = new_mode;
|
||||
}
|
||||
|
||||
void Modulator::set_over(uint32_t new_over) {
|
||||
over = new_over;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
SSB::SSB() : hilbert() {
|
||||
mode = Mode::LSB;
|
||||
}
|
||||
|
||||
void SSB::execute(const buffer_s16_t& audio, const buffer_c8_t& buffer) {
|
||||
int32_t sample = 0;
|
||||
int8_t re = 0, im = 0;
|
||||
|
||||
for (size_t counter = 0; counter < buffer.count; counter++) {
|
||||
if (counter % 128 == 0) {
|
||||
float i = 0.0, q = 0.0;
|
||||
|
||||
sample = audio.p[counter / over] >> 2;
|
||||
//switch (mode) {
|
||||
//case Mode::LSB:
|
||||
hilbert.execute(sample / 32768.0f, i, q);
|
||||
//case Mode::USB: hilbert.execute(sample / 32768.0f, q, i);
|
||||
//default: break;
|
||||
//}
|
||||
|
||||
i *= 64.0f;
|
||||
q *= 64.0f;
|
||||
switch (mode) {
|
||||
case Mode::LSB: re = q; im = i; break;
|
||||
case Mode::USB: re = i; im = q; break;
|
||||
default: re = 0; im = 0; break;
|
||||
}
|
||||
//re = q;
|
||||
//im = i;
|
||||
//break;
|
||||
}
|
||||
|
||||
buffer.p[counter] = { re, im };
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
FM::FM() {
|
||||
mode = Mode::FM;
|
||||
}
|
||||
|
||||
void FM::set_fm_delta(uint32_t new_delta) {
|
||||
fm_delta = new_delta;
|
||||
}
|
||||
|
||||
void FM::execute(const buffer_s16_t& audio, const buffer_c8_t& buffer) {
|
||||
int32_t sample = 0;
|
||||
int8_t re, im;
|
||||
|
||||
for (size_t counter = 0; counter < buffer.count; counter++) {
|
||||
if (counter % over == 0) {
|
||||
sample = audio.p[counter / over] >> 8;
|
||||
delta = sample * fm_delta;
|
||||
}
|
||||
|
||||
phase += delta;
|
||||
sphase = phase >> 24;
|
||||
|
||||
re = (sine_table_i8[(sphase + 64) & 255]);
|
||||
im = (sine_table_i8[sphase]);
|
||||
|
||||
buffer.p[counter] = { re, im };
|
||||
}
|
||||
}
|
||||
|
||||
AM::AM() {
|
||||
mode = Mode::AM;
|
||||
}
|
||||
|
||||
void AM::execute(const buffer_s16_t& audio, const buffer_c8_t& buffer) {
|
||||
int32_t sample = 0;
|
||||
int8_t re = 0, im = 0;
|
||||
float q = 0.0;
|
||||
|
||||
for (size_t counter = 0; counter < buffer.count; counter++) {
|
||||
if (counter % 128 == 0) {
|
||||
sample = audio.p[counter / over] >> 2;
|
||||
}
|
||||
|
||||
q = sample / 32768.0f;
|
||||
q *= 64.0f;
|
||||
switch (mode) {
|
||||
case Mode::AM: re = q + 20; im = q + 20; break;
|
||||
case Mode::DSB: re = q; im = q; break;
|
||||
default: break;
|
||||
}
|
||||
buffer.p[counter] = { re, im };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __DSP_MODULATE_H__
|
||||
#define __DSP_MODULATE_H__
|
||||
|
||||
#include "dsp_types.hpp"
|
||||
#include "dsp_hilbert.hpp"
|
||||
|
||||
namespace dsp {
|
||||
namespace modulate {
|
||||
|
||||
enum class Mode {
|
||||
None,
|
||||
AM,
|
||||
DSB,
|
||||
LSB,
|
||||
USB,
|
||||
FM
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
class Modulator {
|
||||
public:
|
||||
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer) = 0;
|
||||
virtual ~Modulator();
|
||||
|
||||
Mode get_mode();
|
||||
void set_mode(Mode new_mode);
|
||||
|
||||
void set_over(uint32_t new_over);
|
||||
|
||||
protected:
|
||||
uint32_t over = 1;
|
||||
Mode mode = Mode::None;
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
class SSB : public Modulator {
|
||||
public:
|
||||
SSB();
|
||||
|
||||
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer);
|
||||
|
||||
private:
|
||||
dsp::HilbertTransform hilbert;
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
class FM : public Modulator {
|
||||
public:
|
||||
FM();
|
||||
|
||||
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer);
|
||||
void set_fm_delta(uint32_t new_delta);
|
||||
|
||||
///
|
||||
|
||||
private:
|
||||
uint32_t fm_delta { 0 };
|
||||
uint32_t phase { 0 }, sphase { 0 };
|
||||
int32_t sample { 0 }, delta { };
|
||||
};
|
||||
|
||||
class AM : public Modulator {
|
||||
public:
|
||||
AM();
|
||||
|
||||
virtual void execute(const buffer_s16_t& audio, const buffer_c8_t& buffer);
|
||||
};
|
||||
|
||||
} /* namespace modulate */
|
||||
} /* namespace dsp */
|
||||
|
||||
#endif/*__DSP_MODULATE_H__*/
|
||||
@@ -32,115 +32,125 @@ using namespace adsb;
|
||||
|
||||
void ADSBRXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
int8_t re, im;
|
||||
float mag;
|
||||
uint32_t mag;
|
||||
uint32_t c;
|
||||
uint8_t level, bit, byte { };
|
||||
//bool confidence;
|
||||
bool first_in_window, last_in_window;
|
||||
uint8_t bit, byte{};
|
||||
|
||||
// This is called at 2M/2048 = 977Hz
|
||||
// One pulse = 500ns = 2 samples
|
||||
// One bit = 2 pulses = 1us = 4 samples
|
||||
|
||||
|
||||
if (!configured) return;
|
||||
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
|
||||
// Compute sample's magnitude
|
||||
re = buffer.p[i].real();
|
||||
im = buffer.p[i].imag();
|
||||
mag = __builtin_sqrtf((re * re) + (im * im)) * k;
|
||||
|
||||
// Only used for preamble detection and visualisation
|
||||
level = (mag < 0.3) ? 0 : // Blank weak signals
|
||||
(mag > prev_mag) ? 1 : 0;
|
||||
|
||||
re = (int32_t)buffer.p[i].real(); // make re float and scale it
|
||||
im = (int32_t)buffer.p[i].imag(); // make re float and scale it
|
||||
mag = ((uint32_t)(re*re) + (uint32_t)(im*im));
|
||||
|
||||
if (decoding) {
|
||||
// Decode
|
||||
|
||||
// 1 bit lasts 2 samples
|
||||
if (sample_count & 1) {
|
||||
if ((prev_mag < threshold_low) && (mag < threshold_low)) {
|
||||
// Both under window, silence.
|
||||
if (null_count > 3) {
|
||||
const ADSBFrameMessage message(frame);
|
||||
shared_memory.application_queue.push(message);
|
||||
|
||||
decoding = false;
|
||||
} else
|
||||
null_count++;
|
||||
|
||||
//confidence = false;
|
||||
if (prev_mag > mag)
|
||||
bit = 1;
|
||||
else
|
||||
bit = 0;
|
||||
|
||||
} else {
|
||||
|
||||
null_count = 0;
|
||||
|
||||
first_in_window = ((prev_mag >= threshold_low) && (prev_mag <= threshold_high));
|
||||
last_in_window = ((mag >= threshold_low) && (mag <= threshold_high));
|
||||
|
||||
if ((first_in_window && !last_in_window) || (!first_in_window && last_in_window)) {
|
||||
//confidence = true;
|
||||
if (prev_mag > mag)
|
||||
bit = 1;
|
||||
else
|
||||
bit = 0;
|
||||
} else {
|
||||
//confidence = false;
|
||||
if (prev_mag > mag)
|
||||
bit = 1;
|
||||
else
|
||||
bit = 0;
|
||||
}
|
||||
if (bit_count >= msgLen)
|
||||
{
|
||||
const ADSBFrameMessage message(frame, amp);
|
||||
shared_memory.application_queue.push(message);
|
||||
decoding = false;
|
||||
bit = (prev_mag > mag) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//confidence = true;
|
||||
bit = (prev_mag > mag) ? 1 : 0;
|
||||
}
|
||||
|
||||
byte = bit | (byte << 1);
|
||||
bit_count++;
|
||||
|
||||
// Perform checks at the end of the first byte
|
||||
if (!(bit_count & 7)) {
|
||||
// Got one byte
|
||||
|
||||
// Store the byte
|
||||
frame.push_byte(byte);
|
||||
}
|
||||
}
|
||||
|
||||
// Check at the end of the first byte of the message
|
||||
uint8_t df = (byte >> 3);
|
||||
if ( (bit_count == 8) && !(df & 0x10) ) {
|
||||
msgLen = 56; // DFs 16 or greater are long 112. DFs 15 or less are short 56.
|
||||
}
|
||||
|
||||
// Abondon all frames that arent DF17 or DF18 extended squitters
|
||||
if ( (bit_count == 8) && !((df == 17)||(df == 18)) ) {
|
||||
decoding = false;
|
||||
bit = (prev_mag > mag) ? 1 : 0;
|
||||
frame.clear();
|
||||
}
|
||||
} // last bit of a byte
|
||||
} // Second sample of each bit
|
||||
sample_count++;
|
||||
} else {
|
||||
// Look for preamble
|
||||
|
||||
// Shift
|
||||
for (c = 0; c < (ADSB_PREAMBLE_LENGTH - 1); c++)
|
||||
shifter[c] = shifter[c + 1];
|
||||
shifter[15] = std::make_pair(mag, level);
|
||||
|
||||
// Compare
|
||||
for (c = 0; c < ADSB_PREAMBLE_LENGTH; c++) {
|
||||
if (shifter[c].second != adsb_preamble[c])
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == ADSB_PREAMBLE_LENGTH) {
|
||||
decoding = true;
|
||||
sample_count = 0;
|
||||
null_count = 0;
|
||||
bit_count = 0;
|
||||
frame.clear();
|
||||
|
||||
// Compute preamble pulses power to set thresholds
|
||||
threshold = (shifter[0].first + shifter[2].first + shifter[7].first + shifter[9].first) / 4;
|
||||
threshold_high = threshold * 1.414; // +3dB
|
||||
threshold_low = threshold * 0.707; // -3dB
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Continue looking for preamble even if in a packet
|
||||
// switch is new preamble id higher magnitude
|
||||
|
||||
// Shift the preamble
|
||||
for (c = 0; c < (ADSB_PREAMBLE_LENGTH ); c++) { shifter[c] = shifter[c + 1]; }
|
||||
shifter[ADSB_PREAMBLE_LENGTH] = mag;
|
||||
|
||||
// First check of relations between the first 10 samples
|
||||
// representing a valid preamble. We don't even investigate further
|
||||
// if this simple test is not passed
|
||||
if (shifter[0] < shifter[1] &&
|
||||
shifter[1] > shifter[2] &&
|
||||
shifter[2] < shifter[3] &&
|
||||
shifter[3] > shifter[4] &&
|
||||
shifter[4] < shifter[1] &&
|
||||
shifter[5] < shifter[1] &&
|
||||
shifter[6] < shifter[1] &&
|
||||
shifter[7] < shifter[1] &&
|
||||
shifter[8] > shifter[9] &&
|
||||
shifter[9] < shifter[10] &&
|
||||
shifter[10]> shifter[11] )
|
||||
{
|
||||
// The samples between the two spikes must be < than the average
|
||||
// of the high spikes level. We don't test bits too near to
|
||||
// the high levels as signals can be out of phase so part of the
|
||||
// energy can be in the near samples
|
||||
int32_t thisAmp = (shifter[1] + shifter[3] + shifter[8] + shifter[10]);
|
||||
int32_t high = thisAmp / 9;
|
||||
if (
|
||||
shifter[5] < high &&
|
||||
shifter[6] < high &&
|
||||
// Similarly samples in the range 11-13 must be low, as it is the
|
||||
// space between the preamble and real data. Again we don't test
|
||||
// bits too near to high levels, see above
|
||||
shifter[12] < high &&
|
||||
shifter[13] < high &&
|
||||
shifter[14] < high )
|
||||
{
|
||||
if ((decoding == false) || // New preamble
|
||||
((decoding == true) && (thisAmp > amp))) // Higher power than existing packet
|
||||
{
|
||||
decoding = true;
|
||||
msgLen = 112;
|
||||
amp = thisAmp;
|
||||
sample_count = 0;
|
||||
bit_count = 0;
|
||||
frame.clear();
|
||||
}
|
||||
} // 4 & 5 low and 11-14 low
|
||||
} // Check for preamble pattern
|
||||
|
||||
// Store mag for next time
|
||||
prev_mag = mag;
|
||||
}
|
||||
}
|
||||
|
||||
void ADSBRXProcessor::on_message(const Message* const message) {
|
||||
if (message->id == Message::ID::ADSBConfigure) {
|
||||
null_count = 0;
|
||||
bit_count = 0;
|
||||
sample_count = 0;
|
||||
decoding = false;
|
||||
@@ -148,8 +158,10 @@ void ADSBRXProcessor::on_message(const Message* const message) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<ADSBRXProcessor>() };
|
||||
event_dispatcher.run();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -40,8 +40,6 @@ public:
|
||||
void on_message(const Message* const message) override;
|
||||
|
||||
private:
|
||||
static constexpr float k = 1.0f / 128.0f;
|
||||
|
||||
static constexpr size_t baseband_fs = 2000000;
|
||||
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
|
||||
@@ -49,16 +47,17 @@ private:
|
||||
|
||||
ADSBFrame frame { };
|
||||
bool configured { false };
|
||||
float prev_mag { 0 };
|
||||
float threshold { }, threshold_low { }, threshold_high { };
|
||||
size_t null_count { 0 }, bit_count { 0 }, sample_count { 0 };
|
||||
std::pair<float, uint8_t> shifter[ADSB_PREAMBLE_LENGTH];
|
||||
uint32_t prev_mag { 0 };
|
||||
size_t bit_count { 0 }, sample_count { 0 };
|
||||
size_t msgLen{ 112 };
|
||||
uint32_t shifter[ADSB_PREAMBLE_LENGTH+1];
|
||||
bool decoding { };
|
||||
bool preamble { }, active { };
|
||||
uint16_t bit_pos { 0 };
|
||||
uint8_t cur_bit { 0 };
|
||||
uint32_t sample { 0 };
|
||||
int8_t re { }, im { };
|
||||
int32_t re { }, im { };
|
||||
int32_t amp {0};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -87,7 +87,7 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& message) {
|
||||
constexpr size_t decim_2_output_fs = decim_2_input_fs / decim_2_decimation_factor;
|
||||
|
||||
constexpr size_t channel_filter_input_fs = decim_2_output_fs;
|
||||
const size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor;
|
||||
//const size_t channel_filter_output_fs = channel_filter_input_fs / channel_filter_decimation_factor;
|
||||
|
||||
decim_0.configure(message.decim_0_filter.taps, 33554432);
|
||||
decim_1.configure(message.decim_1_filter.taps, 131072);
|
||||
|
||||
@@ -43,14 +43,15 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
|
||||
const buffer_c16_t buffer_c16 {spectrum.data(),spectrum.size(),buffer.sampling_rate};
|
||||
channel_spectrum.feed(buffer_c16);
|
||||
|
||||
int8_t re, im;
|
||||
int8_t mag;
|
||||
int8_t re ;
|
||||
//int8_t im;
|
||||
//int8_t mag;
|
||||
|
||||
for (size_t i = 0; i < 128; i++)
|
||||
{
|
||||
re = buffer.p[i].real();
|
||||
im = buffer.p[i].imag();
|
||||
mag = __builtin_sqrtf((re * re) + (im * im)) ;
|
||||
//im = buffer.p[i].imag();
|
||||
//mag = __builtin_sqrtf((re * re) + (im * im)) ;
|
||||
const unsigned int v = re + 127.0f; //timescope
|
||||
audio_spectrum.db[i] = std::max(0U, std::min(255U, v));
|
||||
}
|
||||
@@ -75,6 +76,7 @@ void WidebandFMAudio::on_message(const Message* const message) {
|
||||
}
|
||||
|
||||
void WidebandFMAudio::configure(const WFMConfigureMessage& message) {
|
||||
(void)message; // avoid warning
|
||||
configured = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "proc_aprsrx.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
void APRSRxProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// This is called at 3072000 / 2048 = 1500Hz
|
||||
|
||||
if (!configured) return;
|
||||
|
||||
// FM demodulation
|
||||
const auto decim_0_out = decim_0.execute(buffer, dst_buffer); // 2048 / 8 = 256 (512 I/Q samples)
|
||||
const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer); // 256 / 8 = 32 (64 I/Q samples)
|
||||
const auto channel_out = channel_filter.execute(decim_1_out, dst_buffer); // 32 / 2 = 16 (32 I/Q samples)
|
||||
|
||||
feed_channel_stats(channel_out);
|
||||
|
||||
auto audio = demod.execute(channel_out, audio_buffer);
|
||||
|
||||
audio_output.write(audio);
|
||||
|
||||
// Audio signal processing
|
||||
for (size_t c = 0; c < audio.count; c++) {
|
||||
|
||||
const int32_t sample_int = audio.p[c] * 32768.0f;
|
||||
int32_t current_sample = __SSAT(sample_int, 16);
|
||||
|
||||
current_sample /= 128;
|
||||
|
||||
// Delay line put
|
||||
delay_line[delay_line_index & 0x3F] = current_sample;
|
||||
|
||||
// Delay line get, and LPF
|
||||
sample_mixed = (delay_line[(delay_line_index - (samples_per_bit/2)) & 0x3F] * current_sample) / 4;
|
||||
sample_filtered = prev_mixed + sample_mixed + (prev_filtered / 2);
|
||||
|
||||
delay_line_index++;
|
||||
|
||||
prev_filtered = sample_filtered;
|
||||
prev_mixed = sample_mixed;
|
||||
|
||||
// Slice
|
||||
sample_bits <<= 1;
|
||||
|
||||
uint8_t bit = (sample_filtered < -20) ? 1 : 0;
|
||||
sample_bits |= bit;
|
||||
|
||||
/*
|
||||
int16_t scaled = bit == 1 ? 32767 : -32767;
|
||||
|
||||
if( stream ) {
|
||||
const size_t bytes_to_write = sizeof(scaled) * 1;
|
||||
const auto result = stream->write(&scaled, bytes_to_write);
|
||||
}
|
||||
*/
|
||||
|
||||
// Check for "clean" transition: either 0011 or 1100
|
||||
if ((((sample_bits >> 2) ^ sample_bits) & 3) == 3) {
|
||||
// Adjust phase
|
||||
if (phase < 0x8000)
|
||||
phase += 0x800; // Is this a proper value ?
|
||||
else
|
||||
phase -= 0x800;
|
||||
}
|
||||
|
||||
phase += phase_inc;
|
||||
|
||||
if (phase >= 0x10000) {
|
||||
phase &= 0xFFFF;
|
||||
|
||||
if (true) {
|
||||
uint8_t bit;
|
||||
if(__builtin_popcount(sample_bits & 0xFF) >= 0x05){
|
||||
bit = 0x1;
|
||||
}
|
||||
else {
|
||||
bit = 0x0;
|
||||
}
|
||||
|
||||
if(parse_bit(bit)){
|
||||
parse_packet();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void APRSRxProcessor::parse_packet(){
|
||||
//validate crc
|
||||
if(packet_buffer_size >= aprs::APRS_MIN_LENGTH){
|
||||
uint16_t crc = 0xFFFF;
|
||||
|
||||
for(size_t i = 0; i < packet_buffer_size; i++){
|
||||
uint8_t byte = packet_buffer[i];
|
||||
crc = ((crc >> 8) ^ crc_ccitt_tab[(crc ^ byte) & 0xFF]) & 0xFFFF;
|
||||
}
|
||||
|
||||
if(crc == 0xF0B8){
|
||||
parse_ax25();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void APRSRxProcessor::parse_ax25(){
|
||||
aprs_packet.clear();
|
||||
aprs_packet.set_valid_checksum(true);
|
||||
|
||||
for(size_t i = 0; i < packet_buffer_size; i++){
|
||||
aprs_packet.set(i, packet_buffer[i]);
|
||||
}
|
||||
|
||||
APRSPacketMessage packet_message { aprs_packet };
|
||||
shared_memory.application_queue.push(packet_message);
|
||||
}
|
||||
|
||||
bool APRSRxProcessor::parse_bit(const uint8_t current_bit){
|
||||
uint8_t decoded_bit = ~(current_bit ^ last_bit) & 0x1;
|
||||
last_bit = current_bit;
|
||||
|
||||
//int16_t log = decoded_bit == 0 ? -32768 : 32767;
|
||||
//if(stream){
|
||||
// const size_t bytes_to_write = sizeof(log) * 1;
|
||||
// const auto result = stream->write(&log, bytes_to_write);
|
||||
//}
|
||||
|
||||
if(decoded_bit & 0x1){
|
||||
if(ones_count < 8){
|
||||
ones_count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(ones_count > 6){ //not valid
|
||||
state = WAIT_FLAG;
|
||||
current_byte = 0;
|
||||
ones_count = 0;
|
||||
byte_index = 0;
|
||||
packet_buffer_size = 0;
|
||||
return false;
|
||||
}
|
||||
else if(ones_count == 6){ //flag
|
||||
bool done = false;
|
||||
if(state == IN_FRAME){
|
||||
done = true;
|
||||
}
|
||||
else {
|
||||
packet_buffer_size = 0;
|
||||
}
|
||||
state = WAIT_FRAME;
|
||||
current_byte = 0;
|
||||
ones_count = 0;
|
||||
byte_index = 0;
|
||||
|
||||
return done;
|
||||
}
|
||||
else if(ones_count == 5){ //bit stuff
|
||||
ones_count = 0;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
ones_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//store
|
||||
current_byte = current_byte >> 1;
|
||||
current_byte |= (decoded_bit == 0x1 ? 0x80 : 0x0);
|
||||
byte_index++;
|
||||
|
||||
if(byte_index >= 8){
|
||||
byte_index = 0;
|
||||
if(state == WAIT_FRAME){
|
||||
state = IN_FRAME;
|
||||
}
|
||||
|
||||
if(state == IN_FRAME){
|
||||
if(packet_buffer_size + 1 >= 256){
|
||||
state = WAIT_FLAG;
|
||||
current_byte = 0;
|
||||
ones_count = 0;
|
||||
byte_index = 0;
|
||||
packet_buffer_size = 0;
|
||||
return false;
|
||||
}
|
||||
packet_buffer[packet_buffer_size++] = current_byte;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void APRSRxProcessor::on_message(const Message* const message) {
|
||||
if (message->id == Message::ID::APRSRxConfigure)
|
||||
configure(*reinterpret_cast<const APRSRxConfigureMessage*>(message));
|
||||
if(message->id == Message::ID::CaptureConfig)
|
||||
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
|
||||
}
|
||||
|
||||
void APRSRxProcessor::capture_config(const CaptureConfigMessage& message) {
|
||||
if( message.config ) {
|
||||
//stream = std::make_unique<StreamInput>(message.config);
|
||||
audio_output.set_stream(std::make_unique<StreamInput>(message.config));
|
||||
} else {
|
||||
//stream.reset();
|
||||
audio_output.set_stream(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void APRSRxProcessor::configure(const APRSRxConfigureMessage& message) {
|
||||
decim_0.configure(taps_11k0_decim_0.taps, 33554432);
|
||||
decim_1.configure(taps_11k0_decim_1.taps, 131072);
|
||||
channel_filter.configure(taps_11k0_channel.taps, 2);
|
||||
demod.configure(audio_fs, 5000);
|
||||
|
||||
audio_output.configure(audio_24k_hpf_300hz_config, audio_24k_deemph_300_6_config, 0);
|
||||
|
||||
samples_per_bit = audio_fs / message.baudrate;
|
||||
|
||||
phase_inc = (0x10000 * message.baudrate) / audio_fs;
|
||||
phase = 0;
|
||||
|
||||
// Delay line
|
||||
delay_line_index = 0;
|
||||
|
||||
state = WAIT_FLAG;
|
||||
|
||||
configured = true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<APRSRxProcessor>() };
|
||||
event_dispatcher.run();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROC_APRSRX_H__
|
||||
#define __PROC_APRSRX_H__
|
||||
|
||||
#include "baseband_processor.hpp"
|
||||
#include "baseband_thread.hpp"
|
||||
#include "rssi_thread.hpp"
|
||||
|
||||
#include "dsp_decimate.hpp"
|
||||
#include "dsp_demodulate.hpp"
|
||||
#include "stream_input.hpp"
|
||||
|
||||
#include "audio_output.hpp"
|
||||
|
||||
#include "fifo.hpp"
|
||||
#include "message.hpp"
|
||||
|
||||
#include "aprs_packet.hpp"
|
||||
|
||||
static uint16_t crc_ccitt_tab[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
|
||||
class APRSRxProcessor : public BasebandProcessor {
|
||||
public:
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const message) override;
|
||||
|
||||
private:
|
||||
static constexpr size_t baseband_fs = 3072000;
|
||||
static constexpr size_t audio_fs = baseband_fs / 8 / 8 / 2;
|
||||
|
||||
size_t samples_per_bit { };
|
||||
|
||||
enum State {
|
||||
WAIT_FLAG,
|
||||
WAIT_FRAME,
|
||||
IN_FRAME
|
||||
};
|
||||
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
|
||||
RSSIThread rssi_thread { NORMALPRIO + 10 };
|
||||
|
||||
std::array<complex16_t, 512> dst { };
|
||||
const buffer_c16_t dst_buffer {
|
||||
dst.data(),
|
||||
dst.size()
|
||||
};
|
||||
std::array<float, 32> audio { };
|
||||
const buffer_f32_t audio_buffer {
|
||||
audio.data(),
|
||||
audio.size()
|
||||
};
|
||||
|
||||
// Array size ok down to 375 bauds (24000 / 375)
|
||||
std::array<int32_t, 64> delay_line { 0 };
|
||||
|
||||
dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0 { };
|
||||
dsp::decimate::FIRC16xR16x32Decim8 decim_1 { };
|
||||
dsp::decimate::FIRAndDecimateComplex channel_filter { };
|
||||
|
||||
std::unique_ptr<StreamInput> stream { };
|
||||
|
||||
dsp::demodulate::FM demod { };
|
||||
|
||||
AudioOutput audio_output { };
|
||||
|
||||
State state { };
|
||||
size_t delay_line_index { };
|
||||
uint32_t bit_counter { 0 };
|
||||
uint32_t word_bits { 0 };
|
||||
uint32_t sample_bits { 0 };
|
||||
uint32_t phase { }, phase_inc { };
|
||||
int32_t sample_mixed { }, prev_mixed { }, sample_filtered { }, prev_filtered { };
|
||||
uint8_t last_bit;
|
||||
uint8_t ones_count = 0;
|
||||
uint8_t current_byte = 0;
|
||||
uint8_t byte_index = 0;
|
||||
uint8_t packet_buffer[256];
|
||||
size_t packet_buffer_size = 0;
|
||||
|
||||
bool configured { false };
|
||||
bool wait_start { };
|
||||
bool bit_value { };
|
||||
|
||||
aprs::APRSPacket aprs_packet;
|
||||
|
||||
void configure(const APRSRxConfigureMessage& message);
|
||||
void capture_config(const CaptureConfigMessage& message);
|
||||
void parse_packet();
|
||||
bool parse_bit(const uint8_t bit);
|
||||
void parse_ax25();
|
||||
};
|
||||
|
||||
#endif/*__PROC_TPMS_H__*/
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
int32_t sample { 0 }, delta { };
|
||||
int8_t re { 0 }, im { 0 };
|
||||
|
||||
size_t progress_interval_samples, progress_samples = 0;
|
||||
size_t progress_interval_samples = 0 , progress_samples = 0;
|
||||
|
||||
bool configured { false };
|
||||
uint32_t bytes_read { 0 };
|
||||
|
||||
@@ -53,7 +53,6 @@ void BTLERxProcessor::execute(const buffer_c8_t& buffer) {
|
||||
auto audio_oversampled = demod.execute(buffer_c16, work_audio_buffer);*/
|
||||
// Audio signal processing
|
||||
for (size_t c = 0; c < audio_oversampled.count; c++) {
|
||||
int result;
|
||||
|
||||
/*const int32_t sample_int = audio_oversampled.p[c] * 32768.0f;
|
||||
int32_t current_sample = __SSAT(sample_int, 16);
|
||||
@@ -107,9 +106,9 @@ void BTLERxProcessor::execute(const buffer_c8_t& buffer) {
|
||||
uint8_t packet_data[500];
|
||||
int packet_length;
|
||||
uint32_t packet_crc;
|
||||
uint32_t calced_crc;
|
||||
//uint32_t calced_crc; // NOTE: restore when CRC is passing
|
||||
uint64_t packet_addr_l;
|
||||
uint32_t result;
|
||||
//uint32_t result; // NOTE: restore when CRC is passing
|
||||
uint8_t crc[3];
|
||||
uint8_t packet_header_arr[2];
|
||||
|
||||
@@ -255,21 +254,21 @@ void BTLERxProcessor::execute(const buffer_c8_t& buffer) {
|
||||
counter = counter + 1;
|
||||
}
|
||||
for (v=0;v<3;v++) crc_result=(crc_result<<8)|crc[v];
|
||||
calced_crc = crc_result;
|
||||
//calced_crc = crc_result; // NOTE: restore when CRC is passing
|
||||
|
||||
packet_crc=0;
|
||||
for (int c=0;c<3;c++) packet_crc=(packet_crc<<8)|packet_data[packet_length+2+c];
|
||||
|
||||
if (packet_addr_l==0x8E89BED6)
|
||||
//if (packet_crc==calced_crc)
|
||||
//if (packet_crc==calced_crc) // NOTE: restore when CRC is passing
|
||||
{
|
||||
uint8_t mac_data[6];
|
||||
int counter = 0;
|
||||
for (int i = 7; i >= 2; i--)
|
||||
{
|
||||
uint8_t byte_temp6 = (uint8_t) (((packet_data[i] * 0x0802LU & 0x22110LU) | (packet_data[i] * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16);
|
||||
//result = byte_temp6;
|
||||
mac_data[counter] = byte_temp6;
|
||||
//result = byte_temp6; // NOTE: restore when CRC is passing
|
||||
mac_data[counter] = byte_temp6;
|
||||
counter = counter + 1;
|
||||
}
|
||||
|
||||
@@ -325,6 +324,7 @@ void BTLERxProcessor::on_message(const Message* const message) {
|
||||
}
|
||||
|
||||
void BTLERxProcessor::configure(const BTLERxConfigureMessage& message) {
|
||||
(void)message; //avoid warning
|
||||
decim_0.configure(taps_200k_wfm_decim_0.taps, 33554432);
|
||||
decim_1.configure(taps_200k_wfm_decim_1.taps, 131072);
|
||||
demod.configure(audio_fs, 5000);
|
||||
|
||||
@@ -44,7 +44,11 @@ void CaptureProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
if( stream ) {
|
||||
const size_t bytes_to_write = sizeof(*decimator_out.p) * decimator_out.count;
|
||||
const auto result = stream->write(decimator_out.p, bytes_to_write);
|
||||
const size_t written = stream->write(decimator_out.p, bytes_to_write);
|
||||
if( written != bytes_to_write )
|
||||
{
|
||||
//TODO eventually report error somewhere
|
||||
}
|
||||
}
|
||||
|
||||
feed_channel_stats(channel);
|
||||
|
||||
@@ -35,6 +35,7 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
|
||||
if (!configured) return;
|
||||
|
||||
audio_input.read_audio_buffer(audio_buffer);
|
||||
modulator->execute(audio_buffer, buffer);
|
||||
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
|
||||
@@ -70,6 +71,7 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
|
||||
sample = beep_gen.process(0);
|
||||
}
|
||||
|
||||
/*
|
||||
sample = tone_gen.process(sample);
|
||||
|
||||
// FM
|
||||
@@ -87,6 +89,7 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
|
||||
}
|
||||
|
||||
buffer.p[i] = { re, im };
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +99,40 @@ void MicTXProcessor::on_message(const Message* const msg) {
|
||||
|
||||
switch(msg->id) {
|
||||
case Message::ID::AudioTXConfig:
|
||||
fm_delta = config_message.deviation_hz * (0xFFFFFFUL / baseband_fs);
|
||||
if (fm_enabled) {
|
||||
dsp::modulate::FM *fm = new dsp::modulate::FM();
|
||||
|
||||
fm->set_fm_delta(config_message.deviation_hz * (0xFFFFFFUL / baseband_fs));
|
||||
modulator = fm;
|
||||
}
|
||||
|
||||
if (usb_enabled) {
|
||||
modulator = new dsp::modulate::SSB();
|
||||
modulator->set_mode(dsp::modulate::Mode::USB);
|
||||
}
|
||||
|
||||
if (lsb_enabled) {
|
||||
modulator = new dsp::modulate::SSB();
|
||||
modulator->set_mode(dsp::modulate::Mode::LSB);
|
||||
}
|
||||
if (am_enabled) {
|
||||
modulator = new dsp::modulate::AM();
|
||||
modulator->set_mode(dsp::modulate::Mode::AM);
|
||||
}
|
||||
if (dsb_enabled) {
|
||||
modulator = new dsp::modulate::AM();
|
||||
modulator->set_mode(dsp::modulate::Mode::DSB);
|
||||
}
|
||||
|
||||
modulator->set_over(baseband_fs / 24000);
|
||||
|
||||
am_enabled = config_message.am_enabled;
|
||||
usb_enabled = config_message.usb_enabled;
|
||||
lsb_enabled = config_message.lsb_enabled;
|
||||
dsb_enabled = config_message.dsb_enabled;
|
||||
if (!am_enabled || !usb_enabled || !lsb_enabled || !dsb_enabled) {
|
||||
fm_enabled = true;
|
||||
}
|
||||
|
||||
audio_gain = config_message.audio_gain;
|
||||
divider = config_message.divider;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "baseband_thread.hpp"
|
||||
#include "audio_input.hpp"
|
||||
#include "tone_gen.hpp"
|
||||
#include "dsp_modulate.hpp"
|
||||
|
||||
class MicTXProcessor : public BasebandProcessor {
|
||||
public:
|
||||
@@ -50,7 +51,14 @@ private:
|
||||
AudioInput audio_input { };
|
||||
ToneGen tone_gen { };
|
||||
ToneGen beep_gen { };
|
||||
|
||||
dsp::modulate::Modulator *modulator;
|
||||
|
||||
bool am_enabled { false };
|
||||
bool fm_enabled { true };
|
||||
bool usb_enabled { false };
|
||||
bool lsb_enabled { false };
|
||||
bool dsb_enabled { false };
|
||||
|
||||
uint32_t divider { };
|
||||
float audio_gain { };
|
||||
uint64_t power_acc { 0 };
|
||||
|
||||
@@ -37,7 +37,6 @@ void NRFRxProcessor::execute(const buffer_c8_t& buffer) {
|
||||
auto audio_oversampled = demod.execute(decim_0_out, work_audio_buffer);
|
||||
// Audio signal processing
|
||||
for (size_t c = 0; c < audio_oversampled.count; c++) {
|
||||
int result;
|
||||
int g_srate = 4; //4 for 250KPS
|
||||
//int g_srate = 1; //1 for 1MPS, not working yet
|
||||
int32_t current_sample = audio_oversampled.p[c]; //if I directly use this, some results can pass crc but not correct.
|
||||
@@ -48,11 +47,8 @@ void NRFRxProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
skipSamples = skipSamples - 1;
|
||||
|
||||
|
||||
if (skipSamples<1)
|
||||
{
|
||||
|
||||
|
||||
int32_t threshold_tmp=0;
|
||||
for (int c=0;c<8*g_srate;c++)
|
||||
{
|
||||
@@ -272,6 +268,7 @@ void NRFRxProcessor::on_message(const Message* const message) {
|
||||
}
|
||||
|
||||
void NRFRxProcessor::configure(const NRFRxConfigureMessage& message) {
|
||||
(void)message; //avoir unused warning
|
||||
decim_0.configure(taps_200k_wfm_decim_0.taps, 33554432);
|
||||
decim_1.configure(taps_200k_wfm_decim_1.taps, 131072);
|
||||
demod.configure(audio_fs, 5000);
|
||||
|
||||
+464
-106
@@ -28,6 +28,9 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <algorithm> // std::max
|
||||
#include <cmath>
|
||||
|
||||
|
||||
void POCSAGProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// This is called at 1500Hz
|
||||
@@ -39,114 +42,45 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) {
|
||||
const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer);
|
||||
const auto channel_out = channel_filter.execute(decim_1_out, dst_buffer);
|
||||
auto audio = demod.execute(channel_out, audio_buffer);
|
||||
//audio_output.write(audio);
|
||||
smooth.Process(audio.p, audio.count); // Smooth the data to make decoding more accurate
|
||||
audio_output.write(audio);
|
||||
|
||||
for (uint32_t c = 0; c < 16; c++) {
|
||||
|
||||
const int32_t sample_int = audio.p[c] * 32768.0f;
|
||||
const int32_t audio_sample = __SSAT(sample_int, 16);
|
||||
|
||||
slicer_sr <<= 1;
|
||||
if (phase == 0)
|
||||
slicer_sr |= (audio_sample < 0); // Do we need hysteresis ?
|
||||
else
|
||||
slicer_sr |= !(audio_sample < 0);
|
||||
|
||||
// Detect transitions to adjust clock
|
||||
if ((slicer_sr ^ (slicer_sr >> 1)) & 1) {
|
||||
if (sphase < (0x8000u - sphase_delta_half))
|
||||
sphase += sphase_delta_eighth;
|
||||
else
|
||||
sphase -= sphase_delta_eighth;
|
||||
}
|
||||
|
||||
sphase += sphase_delta;
|
||||
|
||||
// Symbol time elapsed
|
||||
if (sphase >= 0x10000u) {
|
||||
sphase &= 0xFFFFu;
|
||||
|
||||
rx_data <<= 1;
|
||||
rx_data |= (slicer_sr & 1);
|
||||
|
||||
switch (rx_state) {
|
||||
|
||||
case WAITING:
|
||||
if (rx_data == 0xAAAAAAAA) {
|
||||
rx_state = PREAMBLE;
|
||||
sync_timeout = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case PREAMBLE:
|
||||
if (sync_timeout < POCSAG_TIMEOUT) {
|
||||
sync_timeout++;
|
||||
processDemodulatedSamples(audio.p, 16);
|
||||
extractFrames();
|
||||
|
||||
if (rx_data == POCSAG_SYNCWORD) {
|
||||
packet.clear();
|
||||
codeword_count = 0;
|
||||
rx_bit = 0;
|
||||
msg_timeout = 0;
|
||||
rx_state = SYNC;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Timeout here is normal (end of message)
|
||||
rx_state = WAITING;
|
||||
//push_packet(pocsag::PacketFlag::TIMED_OUT);
|
||||
}
|
||||
break;
|
||||
|
||||
case SYNC:
|
||||
if (msg_timeout < POCSAG_BATCH_LENGTH) {
|
||||
msg_timeout++;
|
||||
rx_bit++;
|
||||
|
||||
if (rx_bit >= 32) {
|
||||
rx_bit = 0;
|
||||
|
||||
// Got a complete codeword
|
||||
|
||||
//pocsag_brute_repair(&s->l2.pocsag, &rx_data);
|
||||
|
||||
packet.set(codeword_count, rx_data);
|
||||
|
||||
if (codeword_count < 15) {
|
||||
codeword_count++;
|
||||
} else {
|
||||
push_packet(pocsag::PacketFlag::NORMAL);
|
||||
rx_state = PREAMBLE;
|
||||
sync_timeout = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
packet.set(0, codeword_count); // Replace first codeword with count, for debug
|
||||
push_packet(pocsag::PacketFlag::TIMED_OUT);
|
||||
rx_state = WAITING;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void POCSAGProcessor::push_packet(pocsag::PacketFlag flag) {
|
||||
packet.set_bitrate(bitrate);
|
||||
packet.set_flag(flag);
|
||||
packet.set_timestamp(Timestamp::now());
|
||||
const POCSAGPacketMessage message(packet);
|
||||
shared_memory.application_queue.push(message);
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
int POCSAGProcessor::OnDataWord(uint32_t word, int pos)
|
||||
{
|
||||
packet.set(pos, word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
int POCSAGProcessor::OnDataFrame(int len, int baud)
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
packet.set_bitrate(baud);
|
||||
packet.set_flag(pocsag::PacketFlag::NORMAL);
|
||||
packet.set_timestamp(Timestamp::now());
|
||||
const POCSAGPacketMessage message(packet);
|
||||
shared_memory.application_queue.push(message);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void POCSAGProcessor::on_message(const Message* const message) {
|
||||
if (message->id == Message::ID::POCSAGConfigure)
|
||||
configure(*reinterpret_cast<const POCSAGConfigureMessage*>(message));
|
||||
configure();
|
||||
}
|
||||
|
||||
void POCSAGProcessor::configure(const POCSAGConfigureMessage& message) {
|
||||
void POCSAGProcessor::configure() {
|
||||
constexpr size_t decim_0_input_fs = baseband_fs;
|
||||
constexpr size_t decim_0_output_fs = decim_0_input_fs / decim_0.decimation_factor;
|
||||
|
||||
@@ -162,18 +96,442 @@ void POCSAGProcessor::configure(const POCSAGConfigureMessage& message) {
|
||||
decim_1.configure(taps_11k0_decim_1.taps, 131072);
|
||||
channel_filter.configure(taps_11k0_channel.taps, 2);
|
||||
demod.configure(demod_input_fs, 4500);
|
||||
//audio_output.configure(false);
|
||||
// Smoothing should be roughly sample rate over max baud
|
||||
// 24k / 3.2k is 7.5
|
||||
smooth.SetSize(8);
|
||||
audio_output.configure(false);
|
||||
|
||||
bitrate = message.bitrate;
|
||||
phase = message.phase;
|
||||
sphase_delta = 0x10000u * bitrate / POCSAG_AUDIO_RATE;
|
||||
sphase_delta_half = sphase_delta / 2; // Just for speed
|
||||
sphase_delta_eighth = sphase_delta / 8;
|
||||
|
||||
rx_state = WAITING;
|
||||
// Set up the frame extraction, limits of baud
|
||||
setFrameExtractParams(demod_input_fs, 4000, 300, 32);
|
||||
|
||||
// Mark the class as ready to accept data
|
||||
configured = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------
|
||||
// Frame extractraction methods
|
||||
// -----------------------------
|
||||
#define BAUD_STABLE (104)
|
||||
#define MAX_CONSEC_SAME (32)
|
||||
#define MAX_WITHOUT_SINGLE (64)
|
||||
#define MAX_BAD_TRANS (10)
|
||||
|
||||
#define M_SYNC (0x7cd215d8)
|
||||
#define M_NOTSYNC (0x832dea27)
|
||||
|
||||
#define M_IDLE (0x7a89c197)
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
inline int bitsDiff(unsigned long left, unsigned long right)
|
||||
{
|
||||
unsigned long xord = left ^ right;
|
||||
int count = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if ((xord & 0x01) != 0) ++count;
|
||||
xord = xord >> 1;
|
||||
}
|
||||
return(count);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
void POCSAGProcessor::initFrameExtraction()
|
||||
{
|
||||
m_averageSymbolLen_1024 = m_maxSymSamples_1024;
|
||||
m_lastStableSymbolLen_1024 = m_minSymSamples_1024;
|
||||
|
||||
m_badTransitions = 0;
|
||||
m_bitsStart = 0;
|
||||
m_bitsEnd = 0;
|
||||
m_inverted = false;
|
||||
|
||||
resetVals();
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
void POCSAGProcessor::resetVals()
|
||||
{
|
||||
// Reset the parameters
|
||||
// --------------------
|
||||
m_goodTransitions = 0;
|
||||
m_badTransitions = 0;
|
||||
m_averageSymbolLen_1024 = m_maxSymSamples_1024;
|
||||
m_shortestGoodTrans_1024 = m_maxSymSamples_1024;
|
||||
m_valMid = 0;
|
||||
|
||||
// And reset the counts
|
||||
// --------------------
|
||||
m_lastTransPos_1024 = 0;
|
||||
m_lastBitPos_1024 = 0;
|
||||
m_lastSample = 0;
|
||||
m_sampleNo = 0;
|
||||
m_nextBitPos_1024 = m_maxSymSamples_1024;
|
||||
m_nextBitPosInt = (long)m_nextBitPos_1024;
|
||||
|
||||
// Extraction
|
||||
m_fifo.numBits = 0;
|
||||
m_gotSync = false;
|
||||
m_numCode = 0;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
void POCSAGProcessor::setFrameExtractParams(long a_samplesPerSec, long a_maxBaud, long a_minBaud, long maxRunOfSameValue)
|
||||
{
|
||||
m_samplesPerSec = a_samplesPerSec;
|
||||
m_minSymSamples_1024 = (uint32_t)(1024.0f * (float)a_samplesPerSec / (float)a_maxBaud);
|
||||
m_maxSymSamples_1024 = (uint32_t)(1024.0f*(float)a_samplesPerSec / (float)a_minBaud);
|
||||
m_maxRunOfSameValue = maxRunOfSameValue;
|
||||
|
||||
m_shortestGoodTrans_1024 = m_maxSymSamples_1024;
|
||||
m_averageSymbolLen_1024 = m_maxSymSamples_1024;
|
||||
m_lastStableSymbolLen_1024 = m_minSymSamples_1024;
|
||||
|
||||
m_nextBitPos_1024 = m_averageSymbolLen_1024 / 2;
|
||||
m_nextBitPosInt = m_nextBitPos_1024 >> 10;
|
||||
|
||||
initFrameExtraction();
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
int POCSAGProcessor::processDemodulatedSamples(float * sampleBuff, int noOfSamples)
|
||||
{
|
||||
bool transition = false;
|
||||
uint32_t samplePos_1024 = 0;
|
||||
uint32_t len_1024 = 0;
|
||||
|
||||
// Loop through the block of data
|
||||
// ------------------------------
|
||||
for (int pos = 0; pos < noOfSamples; ++pos)
|
||||
{
|
||||
m_sample = sampleBuff[pos];
|
||||
m_valMid += (m_sample - m_valMid) / 1024.0f;
|
||||
|
||||
++m_sampleNo;
|
||||
|
||||
// Detect Transition
|
||||
// -----------------
|
||||
transition = ! ((m_lastSample < m_valMid) ^ (m_sample >= m_valMid)); // use XOR for speed
|
||||
|
||||
// If this is a transition
|
||||
// -----------------------
|
||||
if (transition)
|
||||
{
|
||||
// Calculate samples since last trans
|
||||
// ----------------------------------
|
||||
int32_t fractional_1024 = (int32_t)(((m_sample - m_valMid)*1024) / (m_sample - m_lastSample));
|
||||
if (fractional_1024 < 0) { fractional_1024 = -fractional_1024; }
|
||||
|
||||
samplePos_1024 = (m_sampleNo<<10)-fractional_1024;
|
||||
len_1024 = samplePos_1024 - m_lastTransPos_1024;
|
||||
m_lastTransPos_1024 = samplePos_1024;
|
||||
|
||||
// If symbol is large enough to be valid
|
||||
// -------------------------------------
|
||||
if (len_1024 > m_minSymSamples_1024)
|
||||
{
|
||||
// Check for shortest good transition
|
||||
// ----------------------------------
|
||||
if ((len_1024 < m_shortestGoodTrans_1024) &&
|
||||
(m_goodTransitions < BAUD_STABLE)) // detect change of symbol size
|
||||
{
|
||||
int32_t fractionOfShortest_1024 = (len_1024<<10) / m_shortestGoodTrans_1024;
|
||||
|
||||
// If currently at half the baud rate
|
||||
// ----------------------------------
|
||||
if ((fractionOfShortest_1024 > 410) && (fractionOfShortest_1024 < 614)) // 0.4 and 0.6
|
||||
{
|
||||
m_averageSymbolLen_1024 /= 2;
|
||||
m_shortestGoodTrans_1024 = len_1024;
|
||||
}
|
||||
// If currently at the wrong baud rate
|
||||
// -----------------------------------
|
||||
else if (fractionOfShortest_1024 < 768) // 0.75
|
||||
{
|
||||
m_averageSymbolLen_1024 = len_1024;
|
||||
m_shortestGoodTrans_1024 = len_1024;
|
||||
m_goodTransitions = 0;
|
||||
m_lastSingleBitPos_1024 = samplePos_1024 - len_1024;
|
||||
}
|
||||
}
|
||||
|
||||
// Calc the number of bits since events
|
||||
// ------------------------------------
|
||||
int32_t halfSymbol_1024 = m_averageSymbolLen_1024 / 2;
|
||||
int bitsSinceLastTrans = max((uint32_t)1, (len_1024+halfSymbol_1024) / m_averageSymbolLen_1024 );
|
||||
int bitsSinceLastSingle = (((m_sampleNo<<10)-m_lastSingleBitPos_1024) + halfSymbol_1024) / m_averageSymbolLen_1024;
|
||||
|
||||
// Check for single bit
|
||||
// --------------------
|
||||
if (bitsSinceLastTrans == 1)
|
||||
{
|
||||
m_lastSingleBitPos_1024 = samplePos_1024;
|
||||
}
|
||||
|
||||
// If too long since last transition
|
||||
// ---------------------------------
|
||||
if (bitsSinceLastTrans > MAX_CONSEC_SAME)
|
||||
{
|
||||
resetVals();
|
||||
}
|
||||
// If too long sice last single bit
|
||||
// --------------------------------
|
||||
else if (bitsSinceLastSingle > MAX_WITHOUT_SINGLE)
|
||||
{
|
||||
resetVals();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If this is a good transition
|
||||
// ----------------------------
|
||||
int32_t offsetFromExtectedTransition_1024 = len_1024 - (bitsSinceLastTrans*m_averageSymbolLen_1024);
|
||||
if (offsetFromExtectedTransition_1024 < 0) { offsetFromExtectedTransition_1024 = -offsetFromExtectedTransition_1024; }
|
||||
if (offsetFromExtectedTransition_1024 < ((int32_t)m_averageSymbolLen_1024 / 4)) // Has to be within 1/4 of symbol to be good
|
||||
{
|
||||
++m_goodTransitions;
|
||||
uint32_t bitsCount = min((uint32_t)BAUD_STABLE, m_goodTransitions);
|
||||
|
||||
uint32_t propFromPrevious = m_averageSymbolLen_1024*bitsCount;
|
||||
uint32_t propFromCurrent = (len_1024 / bitsSinceLastTrans);
|
||||
m_averageSymbolLen_1024 = (propFromPrevious + propFromCurrent) / (bitsCount + 1);
|
||||
m_badTransitions = 0;
|
||||
//if ( len < m_shortestGoodTrans ){m_shortestGoodTrans = len;}
|
||||
// Store the old symbol size
|
||||
if (m_goodTransitions >= BAUD_STABLE)
|
||||
{
|
||||
m_lastStableSymbolLen_1024 = m_averageSymbolLen_1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the point of the last bit if not yet stable
|
||||
// -----------------------------------------------
|
||||
if ((m_goodTransitions < BAUD_STABLE) || (m_badTransitions > 0))
|
||||
{
|
||||
m_lastBitPos_1024 = samplePos_1024 - (m_averageSymbolLen_1024 / 2);
|
||||
}
|
||||
|
||||
// Calculate the exact positiom of the next bit
|
||||
// --------------------------------------------
|
||||
int32_t thisPlusHalfsymbol_1024 = samplePos_1024 + (m_averageSymbolLen_1024/2);
|
||||
int32_t lastPlusSymbol = m_lastBitPos_1024 + m_averageSymbolLen_1024;
|
||||
m_nextBitPos_1024 = lastPlusSymbol + ((thisPlusHalfsymbol_1024 - lastPlusSymbol) / 16);
|
||||
|
||||
// Check for bad pos error
|
||||
// -----------------------
|
||||
if (m_nextBitPos_1024 < samplePos_1024) m_nextBitPos_1024 += m_averageSymbolLen_1024;
|
||||
|
||||
// Calculate integer sample after next bit
|
||||
// ---------------------------------------
|
||||
m_nextBitPosInt = (m_nextBitPos_1024>>10) + 1;
|
||||
|
||||
} // symbol is large enough to be valid
|
||||
else
|
||||
{
|
||||
// Bad transition, so reset the counts
|
||||
// -----------------------------------
|
||||
++m_badTransitions;
|
||||
if (m_badTransitions > MAX_BAD_TRANS)
|
||||
{
|
||||
resetVals();
|
||||
}
|
||||
}
|
||||
} // end of if transition
|
||||
|
||||
// Reached the point of the next bit
|
||||
// ---------------------------------
|
||||
if (m_sampleNo >= m_nextBitPosInt)
|
||||
{
|
||||
// Everything is good so extract a bit
|
||||
// -----------------------------------
|
||||
if (m_goodTransitions > 20)
|
||||
{
|
||||
// Store value at the center of bit
|
||||
// --------------------------------
|
||||
storeBit();
|
||||
}
|
||||
// Check for long 1 or zero
|
||||
// ------------------------
|
||||
uint32_t bitsSinceLastTrans = ((m_sampleNo<<10) - m_lastTransPos_1024) / m_averageSymbolLen_1024;
|
||||
if (bitsSinceLastTrans > m_maxRunOfSameValue)
|
||||
{
|
||||
resetVals();
|
||||
}
|
||||
|
||||
// Store the point of the last bit
|
||||
// -------------------------------
|
||||
m_lastBitPos_1024 = m_nextBitPos_1024;
|
||||
|
||||
// Calculate the exact point of the next bit
|
||||
// -----------------------------------------
|
||||
m_nextBitPos_1024 += m_averageSymbolLen_1024;
|
||||
|
||||
// Look for the bit after the next bit pos
|
||||
// ---------------------------------------
|
||||
m_nextBitPosInt = (m_nextBitPos_1024>>10) + 1;
|
||||
|
||||
} // Reached the point of the next bit
|
||||
|
||||
m_lastSample = m_sample;
|
||||
|
||||
} // Loop through the block of data
|
||||
|
||||
return getNoOfBits();
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
void POCSAGProcessor::storeBit()
|
||||
{
|
||||
if (++m_bitsStart >= BIT_BUF_SIZE) { m_bitsStart = 0; }
|
||||
|
||||
// Calculate the bit value
|
||||
float sample = (m_sample + m_lastSample) / 2;
|
||||
//int32_t sample_1024 = m_sample_1024;
|
||||
bool bit = sample > m_valMid;
|
||||
|
||||
// If buffer not full
|
||||
if (m_bitsStart != m_bitsEnd)
|
||||
{
|
||||
// Decide on output val
|
||||
if (bit)
|
||||
{
|
||||
m_bits[m_bitsStart] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bits[m_bitsStart] = 1;
|
||||
}
|
||||
}
|
||||
// Throw away bits if the buffer is full
|
||||
else
|
||||
{
|
||||
if (--m_bitsStart <= -1)
|
||||
{
|
||||
m_bitsStart = BIT_BUF_SIZE - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
int POCSAGProcessor::extractFrames()
|
||||
{
|
||||
int msgCnt = 0;
|
||||
// While there is unread data in the bits buffer
|
||||
//----------------------------------------------
|
||||
while (getNoOfBits() > 0)
|
||||
{
|
||||
m_fifo.codeword = (m_fifo.codeword << 1) + getBit();
|
||||
m_fifo.numBits++;
|
||||
|
||||
// If number of bits in fifo equals 32
|
||||
//------------------------------------
|
||||
if (m_fifo.numBits >= 32)
|
||||
{
|
||||
// Not got sync
|
||||
// ------------
|
||||
if (!m_gotSync)
|
||||
{
|
||||
if (bitsDiff(m_fifo.codeword, M_SYNC) <= 2)
|
||||
{
|
||||
m_inverted = false;
|
||||
m_gotSync = true;
|
||||
m_numCode = -1;
|
||||
m_fifo.numBits = 0;
|
||||
}
|
||||
else if (bitsDiff(m_fifo.codeword, M_NOTSYNC) <= 2)
|
||||
{
|
||||
m_inverted = true;
|
||||
m_gotSync = true;
|
||||
m_numCode = -1;
|
||||
m_fifo.numBits = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cause it to load one more bit
|
||||
m_fifo.numBits = 31;
|
||||
}
|
||||
} // Not got sync
|
||||
else
|
||||
{
|
||||
// Increment the word count
|
||||
// ------------------------
|
||||
++m_numCode; // It got set to -1 when a sync was found, now count the 16 words
|
||||
uint32_t val = m_inverted ? ~m_fifo.codeword : m_fifo.codeword;
|
||||
OnDataWord(val, m_numCode);
|
||||
|
||||
// If at the end of a 16 word block
|
||||
// --------------------------------
|
||||
if (m_numCode >= 15)
|
||||
{
|
||||
msgCnt += OnDataFrame(m_numCode+1, (m_samplesPerSec<<10) / m_lastStableSymbolLen_1024);
|
||||
m_gotSync = false;
|
||||
m_numCode = -1;
|
||||
}
|
||||
m_fifo.numBits = 0;
|
||||
}
|
||||
} // If number of bits in fifo equals 32
|
||||
} // While there is unread data in the bits buffer
|
||||
return msgCnt;
|
||||
} // extractFrames
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
short POCSAGProcessor::getBit()
|
||||
{
|
||||
if (m_bitsEnd != m_bitsStart)
|
||||
{
|
||||
if (++m_bitsEnd >= BIT_BUF_SIZE)
|
||||
{
|
||||
m_bitsEnd = 0;
|
||||
}
|
||||
return m_bits[m_bitsEnd];
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
int POCSAGProcessor::getNoOfBits()
|
||||
{
|
||||
int bits = m_bitsEnd - m_bitsStart;
|
||||
if (bits < 0) { bits += BIT_BUF_SIZE; }
|
||||
return bits;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
uint32_t POCSAGProcessor::getRate()
|
||||
{
|
||||
return ((m_samplesPerSec<<10)+512) / m_lastStableSymbolLen_1024;
|
||||
}
|
||||
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// ====================================================================
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<POCSAGProcessor>() };
|
||||
event_dispatcher.run();
|
||||
|
||||
@@ -40,25 +40,100 @@
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <bitset>
|
||||
using namespace std;
|
||||
|
||||
// Class used to smooth demodulated waveform prior to decoding
|
||||
// -----------------------------------------------------------
|
||||
template <class ValType, class CalcType>
|
||||
class SmoothVals
|
||||
{
|
||||
protected:
|
||||
ValType * m_lastVals; // Previoius N values
|
||||
int m_size; // The size N
|
||||
CalcType m_sumVal; // Running sum of lastVals
|
||||
int m_pos; // Current position in last vals ring buffer
|
||||
int m_count; //
|
||||
|
||||
class POCSAGProcessor : public BasebandProcessor {
|
||||
public:
|
||||
SmoothVals() : m_lastVals(NULL), m_size(1), m_sumVal(0), m_pos(0), m_count(0)
|
||||
{
|
||||
m_lastVals = new ValType[m_size];
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// --------------------------------------------------
|
||||
virtual ~SmoothVals()
|
||||
{
|
||||
delete[] m_lastVals;
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// Set size of smoothing
|
||||
// --------------------------------------------------
|
||||
void SetSize(int size)
|
||||
{
|
||||
m_size = std::max(size, 1);
|
||||
m_pos = 0;
|
||||
delete[] m_lastVals;
|
||||
m_lastVals = new ValType[m_size];
|
||||
m_sumVal = 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// Get size of smoothing
|
||||
// --------------------------------------------------
|
||||
int Size() { return m_size; }
|
||||
|
||||
// --------------------------------------------------
|
||||
// In place processing
|
||||
// --------------------------------------------------
|
||||
void Process(ValType * valBuff, int numVals)
|
||||
{
|
||||
ValType tmpVal;
|
||||
|
||||
if (m_count > (1024*10))
|
||||
{
|
||||
// Recalculate the sum value occasionaly, stops accumulated errors when using float
|
||||
m_count = 0;
|
||||
m_sumVal = 0;
|
||||
for (int i = 0; i < m_size; ++i) { m_sumVal += (CalcType)m_lastVals[i]; }
|
||||
}
|
||||
|
||||
// Use a rolling smoothed value while processing the buffer
|
||||
for (int buffPos = 0; buffPos < numVals; ++buffPos)
|
||||
{
|
||||
m_pos = (m_pos + 1); // Increment the position in the stored values
|
||||
if (m_pos >= m_size) { m_pos = 0; } // loop if reached the end of the stored values
|
||||
|
||||
m_sumVal -= (CalcType)m_lastVals[m_pos]; // Subtract the oldest value
|
||||
m_lastVals[m_pos] = valBuff[buffPos]; // Store the new value
|
||||
m_sumVal += (CalcType)m_lastVals[m_pos]; // Add on the new value
|
||||
|
||||
tmpVal = (ValType)(m_sumVal / m_size); // Scale by number of values smoothed
|
||||
valBuff[buffPos] = tmpVal;
|
||||
}
|
||||
|
||||
m_count += numVals;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// Class to process base band data to pocsag frames
|
||||
// --------------------------------------------------
|
||||
class POCSAGProcessor : public BasebandProcessor{
|
||||
public:
|
||||
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const message) override;
|
||||
|
||||
private:
|
||||
enum rx_states {
|
||||
WAITING = 0,
|
||||
PREAMBLE = 32,
|
||||
SYNC = 64,
|
||||
//LOSING_SYNC = 65,
|
||||
//LOST_SYNC = 66,
|
||||
//ADDRESS = 67,
|
||||
//MESSAGE = 68,
|
||||
//END_OF_MESSAGE = 69
|
||||
};
|
||||
int OnDataFrame(int len, int baud);
|
||||
int OnDataWord(uint32_t word, int pos);
|
||||
|
||||
private:
|
||||
static constexpr size_t baseband_fs = 3072000;
|
||||
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
|
||||
@@ -79,28 +154,71 @@ private:
|
||||
dsp::decimate::FIRC16xR16x32Decim8 decim_1 { };
|
||||
dsp::decimate::FIRAndDecimateComplex channel_filter { };
|
||||
dsp::demodulate::FM demod { };
|
||||
SmoothVals<float, float> smooth;
|
||||
|
||||
//AudioOutput audio_output { };
|
||||
AudioOutput audio_output { };
|
||||
|
||||
uint32_t sync_timeout { 0 };
|
||||
uint32_t msg_timeout { 0 };
|
||||
|
||||
uint32_t slicer_sr { 0 };
|
||||
uint32_t sphase { 0 };
|
||||
uint32_t sphase_delta { 0 };
|
||||
uint32_t sphase_delta_half { 0 };
|
||||
uint32_t sphase_delta_eighth { 0 };
|
||||
uint32_t rx_data { 0 };
|
||||
uint32_t rx_bit { 0 };
|
||||
bool configured = false;
|
||||
rx_states rx_state { WAITING };
|
||||
pocsag::BitRate bitrate { pocsag::BitRate::FSK1200 };
|
||||
bool phase;
|
||||
uint32_t codeword_count { 0 };
|
||||
pocsag::POCSAGPacket packet { };
|
||||
|
||||
void push_packet(pocsag::PacketFlag flag);
|
||||
void configure(const POCSAGConfigureMessage& message);
|
||||
|
||||
void configure();
|
||||
|
||||
// ----------------------------------------
|
||||
// Frame extractraction methods and members
|
||||
// ----------------------------------------
|
||||
private:
|
||||
void initFrameExtraction();
|
||||
struct FIFOStruct {
|
||||
unsigned long codeword;
|
||||
int numBits;
|
||||
};
|
||||
|
||||
#define BIT_BUF_SIZE (64)
|
||||
|
||||
void resetVals();
|
||||
void setFrameExtractParams(long a_samplesPerSec, long a_maxBaud = 8000, long a_minBaud = 200, long maxRunOfSameValue = 32);
|
||||
|
||||
int processDemodulatedSamples(float * sampleBuff, int noOfSamples);
|
||||
int extractFrames();
|
||||
|
||||
void storeBit();
|
||||
short getBit();
|
||||
|
||||
int getNoOfBits();
|
||||
uint32_t getRate();
|
||||
|
||||
uint32_t m_averageSymbolLen_1024{0};
|
||||
uint32_t m_lastStableSymbolLen_1024{0};
|
||||
|
||||
uint32_t m_samplesPerSec{0};
|
||||
uint32_t m_goodTransitions{0};
|
||||
uint32_t m_badTransitions{0};
|
||||
|
||||
uint32_t m_sampleNo{0};
|
||||
float m_sample{0};
|
||||
float m_valMid{0.0f};
|
||||
float m_lastSample{0.0f};
|
||||
|
||||
uint32_t m_lastTransPos_1024{0};
|
||||
uint32_t m_lastSingleBitPos_1024{0};
|
||||
|
||||
uint32_t m_nextBitPosInt{0}; // Integer rounded up version to save on ops
|
||||
uint32_t m_nextBitPos_1024{0};
|
||||
uint32_t m_lastBitPos_1024{0};
|
||||
|
||||
uint32_t m_shortestGoodTrans_1024{0};
|
||||
uint32_t m_minSymSamples_1024{0};
|
||||
uint32_t m_maxSymSamples_1024{0};
|
||||
uint32_t m_maxRunOfSameValue{0};
|
||||
|
||||
bitset<(size_t)BIT_BUF_SIZE> m_bits{0};
|
||||
long m_bitsStart{0};
|
||||
long m_bitsEnd{0};
|
||||
|
||||
FIFOStruct m_fifo{0,0};
|
||||
bool m_gotSync{false};
|
||||
int m_numCode{0};
|
||||
bool m_inverted{false};
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,9 +26,16 @@
|
||||
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include "audio_output.hpp"
|
||||
|
||||
SondeProcessor::SondeProcessor() {
|
||||
|
||||
decim_0.configure(taps_11k0_decim_0.taps, 33554432);
|
||||
decim_1.configure(taps_11k0_decim_1.taps, 131072);
|
||||
|
||||
audio_output.configure(false);
|
||||
|
||||
tone_gen.configure(BEEP_BASE_FREQ, 1.0, ToneGen::tone_type::sine, AUDIO_SAMPLE_RATE);
|
||||
}
|
||||
|
||||
void SondeProcessor::execute(const buffer_c8_t& buffer) {
|
||||
@@ -47,10 +54,97 @@ void SondeProcessor::execute(const buffer_c8_t& buffer) {
|
||||
clock_recovery_fsk_4800(mf.get_output());
|
||||
}
|
||||
}
|
||||
|
||||
if(pitch_rssi_enabled) {
|
||||
if(beep_play) {
|
||||
// if we let the buffer underrun, for some reason
|
||||
// once it starts looping it ignores zero (silence)
|
||||
// samples, so we need to keep feeding the buffer
|
||||
// and not be able to take advantage of the circular
|
||||
// buffer loop:
|
||||
//beep_play = false;
|
||||
generate_beep();
|
||||
}
|
||||
|
||||
if(silence_play) {
|
||||
//silence_play = false;
|
||||
generate_silence();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SondeProcessor::on_message(const Message* const msg) {
|
||||
switch(msg->id) {
|
||||
case Message::ID::RequestSignal:
|
||||
if ((*reinterpret_cast<const RequestSignalMessage*>(msg)).signal == RequestSignalMessage::Signal::BeepRequest) {
|
||||
float rssi_ratio = (float) last_rssi / (float) RSSI_CEILING;
|
||||
int beep_duration = 0;
|
||||
|
||||
if(rssi_ratio <= PROPORTIONAL_BEEP_THRES) {
|
||||
beep_duration = BEEP_MIN_DURATION;
|
||||
}
|
||||
else if(rssi_ratio < 1) {
|
||||
beep_duration = (int) rssi_ratio * BEEP_DURATION_RANGE + BEEP_MIN_DURATION;
|
||||
}
|
||||
else {
|
||||
beep_duration = BEEP_DURATION_RANGE + BEEP_MIN_DURATION;
|
||||
}
|
||||
|
||||
play_beep();
|
||||
chThdSleepMilliseconds(beep_duration);
|
||||
stop_beep();
|
||||
}
|
||||
break;
|
||||
|
||||
case Message::ID::PitchRSSIConfigure:
|
||||
pitch_rssi_config(*reinterpret_cast<const PitchRSSIConfigureMessage*>(msg));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SondeProcessor::play_beep() {
|
||||
beep_play = true;
|
||||
silence_play = false;
|
||||
}
|
||||
|
||||
void SondeProcessor::stop_beep() {
|
||||
beep_play = false;
|
||||
silence_play = true;
|
||||
}
|
||||
|
||||
void SondeProcessor::generate_beep() {
|
||||
// here we let the samples be created using the ToneGen class:
|
||||
|
||||
for(uint8_t i = 0; i < sizeof(audio_buffer.p); i++) {
|
||||
audio_buffer.p[i] = (int16_t) ((tone_gen.process(0) >> 16) & 0x0000FFFF);
|
||||
}
|
||||
|
||||
audio_output.write(audio_buffer);
|
||||
}
|
||||
|
||||
void SondeProcessor::generate_silence() {
|
||||
for(uint8_t i = 0; i < sizeof(audio_buffer.p); i++) {
|
||||
audio_buffer.p[i] = 0;
|
||||
}
|
||||
|
||||
audio_output.write(audio_buffer);
|
||||
}
|
||||
|
||||
void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) {
|
||||
pitch_rssi_enabled = message.enabled;
|
||||
|
||||
uint32_t freq = (int) ((float) message.rssi * (float) RSSI_PITCH_WEIGHT + (float) BEEP_BASE_FREQ);
|
||||
|
||||
last_rssi = message.rssi;
|
||||
tone_gen.configure(freq, 1.0, ToneGen::tone_type::sine, AUDIO_SAMPLE_RATE);
|
||||
}
|
||||
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<SondeProcessor>() };
|
||||
event_dispatcher.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -88,19 +88,51 @@
|
||||
#include "message.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "audio_output.hpp"
|
||||
#include "tone_gen.hpp"
|
||||
|
||||
#include "buffer.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <bitset>
|
||||
|
||||
|
||||
#define BEEP_MIN_DURATION 60
|
||||
#define BEEP_DURATION_RANGE 100
|
||||
#define BEEP_BASE_FREQ 200
|
||||
#define RSSI_CEILING 1000
|
||||
#define PROPORTIONAL_BEEP_THRES 0.8
|
||||
#define RSSI_PITCH_WEIGHT 0.5
|
||||
#define AUDIO_SAMPLE_RATE 24000
|
||||
|
||||
class SondeProcessor : public BasebandProcessor {
|
||||
public:
|
||||
SondeProcessor();
|
||||
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const msg);
|
||||
private:
|
||||
|
||||
static constexpr size_t baseband_fs = 2457600;
|
||||
|
||||
|
||||
std::array<int16_t, 32> audio { };
|
||||
|
||||
const buffer_s16_t audio_buffer {
|
||||
(int16_t*) audio.data(),
|
||||
sizeof(audio) / sizeof(int16_t)
|
||||
};
|
||||
|
||||
AudioOutput audio_output { };
|
||||
|
||||
bool beep_play { false };
|
||||
bool silence_play { false };
|
||||
bool pitch_rssi_enabled { false };
|
||||
|
||||
uint32_t last_rssi { 0 };
|
||||
|
||||
ToneGen tone_gen { };
|
||||
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
|
||||
RSSIThread rssi_thread { NORMALPRIO + 10 };
|
||||
|
||||
@@ -149,6 +181,23 @@ private:
|
||||
shared_memory.application_queue.push(message);
|
||||
}
|
||||
};
|
||||
|
||||
void play_beep();
|
||||
void stop_beep();
|
||||
|
||||
/**
|
||||
* Used for filling the audio buffer with the waveform
|
||||
* generated by the ToneGen class:
|
||||
*
|
||||
*/
|
||||
void generate_beep();
|
||||
|
||||
/**
|
||||
* Used for filling the audio buffer with silence:
|
||||
*/
|
||||
void generate_silence();
|
||||
|
||||
void pitch_rssi_config(const PitchRSSIConfigureMessage& message);
|
||||
};
|
||||
|
||||
#endif/*__PROC_ERT_H__*/
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "event_m4.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void SpectrumCollector::on_message(const Message* const message) {
|
||||
@@ -105,24 +103,38 @@ void SpectrumCollector::post_message(const buffer_c16_t& data) {
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
/* 3 types of Windowing time domain shapes declaration , but only used Hamming , shapes for FFT
|
||||
GCC10 compile sintax error c/m (1/2),
|
||||
The primary diff. between const and constexpr variables is that
|
||||
the initialization of a const var can be deferred until run time.
|
||||
A constexpr var. must be initialized at compile time. ...
|
||||
A var. can be declared with constexpr , when it has a literal type and is initialized.
|
||||
GCC compile sintax error c/m (2/2)
|
||||
Static assert --> Tests a software assertion at compile time for debugging.
|
||||
we keep the same safety compile protection , just changing slightly the sintax checking that the size of the called array is power of 2.
|
||||
if the bool "constant expression" is TRUE (normal case) , the declaration has no effect.
|
||||
if the bool "constant expression" is FALSE (abnormal array size) , it is aborted the compile with a msg error.
|
||||
*/
|
||||
|
||||
|
||||
template<typename T> // Although currently we are not using that Windowing shape, we apply the same GCC10 compile error c/m
|
||||
static typename T::value_type spectrum_window_none(const T& s, const size_t i) {
|
||||
static_assert(power_of_two(s.size()), "Array size must be power of 2");
|
||||
static_assert(power_of_two(ARRAY_ELEMENTS(s)), "Array number of elements must be power of 2"); // c/m compile error GCC10 , OK for all GCC versions.
|
||||
return s[i];
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<typename T> // Currently we are calling and using that Window shape.
|
||||
static typename T::value_type spectrum_window_hamming_3(const T& s, const size_t i) {
|
||||
static_assert(power_of_two(s.size()), "Array size must be power of 2");
|
||||
constexpr size_t mask = s.size() - 1;
|
||||
static_assert(power_of_two(ARRAY_ELEMENTS(s)), "Array number of elements must be power of 2"); // c/m compile error GCC10 , OK for all GCC versions.
|
||||
const size_t mask = s.size() - 1; // c/m compile error GCC10 , constexpr->const
|
||||
// Three point Hamming window.
|
||||
return s[i] * 0.54f + (s[(i-1) & mask] + s[(i+1) & mask]) * -0.23f;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<typename T> // Although currently we are not using that Windowing shape, we apply the same GCC10 compile error c/m
|
||||
static typename T::value_type spectrum_window_blackman_3(const T& s, const size_t i) {
|
||||
static_assert(power_of_two(s.size()), "Array size must be power of 2");
|
||||
constexpr size_t mask = s.size() - 1;
|
||||
static_assert(power_of_two(ARRAY_ELEMENTS(s)), "Array number of elements must be power of 2"); // c/m compile error GCC10 , OK for all GCC versions.
|
||||
const size_t mask = s.size() - 1; // c/m compile error GCC10 , constexpr->const
|
||||
// Three term Blackman window.
|
||||
constexpr float alpha = 0.42f;
|
||||
constexpr float beta = 0.5f * 0.5f;
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#ifndef __SPECTRUM_COLLECTOR_H__
|
||||
#define __SPECTRUM_COLLECTOR_H__
|
||||
|
||||
#define ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
|
||||
/* sizeof() compile-time operator that returns #bytes of (data type). We used it to get #elements_array */
|
||||
|
||||
#include "dsp_types.hpp"
|
||||
#include "complex.hpp"
|
||||
|
||||
|
||||
@@ -23,18 +23,56 @@
|
||||
#include "tone_gen.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
|
||||
|
||||
int32_t ToneGen::tone_sine() {
|
||||
int32_t tone_sample = sine_table_i8[tone_phase_] * 0x1000000;
|
||||
tone_phase_ += delta_;
|
||||
|
||||
return tone_sample;
|
||||
}
|
||||
|
||||
int32_t ToneGen::tone_square() {
|
||||
int32_t tone_sample = 0;
|
||||
|
||||
if(tone_phase_ < (UINT32_MAX / 2)) {
|
||||
tone_sample = INT32_MAX;
|
||||
}
|
||||
else {
|
||||
tone_sample = INT32_MIN;
|
||||
}
|
||||
|
||||
tone_phase_ += delta_;
|
||||
|
||||
return tone_sample;
|
||||
}
|
||||
|
||||
void ToneGen::configure(const uint32_t delta, const float tone_mix_weight) {
|
||||
delta_ = delta;
|
||||
delta_ = (uint8_t) ((delta & 0xFF000000U) >> 24);
|
||||
tone_mix_weight_ = tone_mix_weight;
|
||||
input_mix_weight_ = 1.0 - tone_mix_weight;
|
||||
|
||||
current_tone_type_ = sine;
|
||||
}
|
||||
|
||||
void ToneGen::configure(const uint32_t freq, const float tone_mix_weight, const tone_type tone_type, const uint32_t sample_rate) {
|
||||
delta_ = (uint8_t) ((freq * sizeof(sine_table_i8)) / sample_rate);
|
||||
tone_mix_weight_ = tone_mix_weight;
|
||||
input_mix_weight_ = 1.0 - tone_mix_weight;
|
||||
current_tone_type_ = tone_type;
|
||||
}
|
||||
|
||||
int32_t ToneGen::process(const int32_t sample_in) {
|
||||
if (!delta_)
|
||||
return sample_in;
|
||||
|
||||
int32_t tone_sample = sine_table_i8[(tone_phase_ & 0xFF000000U) >> 24];
|
||||
tone_phase_ += delta_;
|
||||
int32_t tone_sample = 0;
|
||||
|
||||
if(current_tone_type_ == sine) {
|
||||
tone_sample = tone_sine();
|
||||
}
|
||||
else if(current_tone_type_ == square) {
|
||||
tone_sample = tone_square();
|
||||
}
|
||||
|
||||
return (sample_in * input_mix_weight_) + (tone_sample * tone_mix_weight_);
|
||||
}
|
||||
|
||||
@@ -28,19 +28,36 @@
|
||||
|
||||
class ToneGen {
|
||||
public:
|
||||
enum tone_type { sine, square };
|
||||
|
||||
/*ToneGen(const size_t sample_rate
|
||||
) : sample_rate_ { sample_rate }
|
||||
{};*/
|
||||
|
||||
void configure(const uint32_t delta, const float tone_mix_weight);
|
||||
void configure(const uint32_t freq, const float tone_mix_weight, const tone_type tone_type, const uint32_t sample_rate);
|
||||
|
||||
int32_t process(const int32_t sample_in);
|
||||
|
||||
private:
|
||||
//size_t sample_rate_;
|
||||
tone_type current_tone_type_ { sine };
|
||||
|
||||
float input_mix_weight_ { 1 };
|
||||
float tone_mix_weight_ { 0 };
|
||||
uint32_t delta_ { 0 };
|
||||
uint32_t tone_phase_ { 0 };
|
||||
|
||||
uint8_t delta_ { 0 };
|
||||
uint8_t tone_phase_ { 0 };
|
||||
|
||||
/**
|
||||
* Generator function which selects every other sample from the reference sine waveform to the output sample:
|
||||
*/
|
||||
int32_t tone_sine();
|
||||
|
||||
|
||||
/**
|
||||
* Generator function for square waves:
|
||||
*/
|
||||
int32_t tone_square();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* __TONE_GEN_H__ */
|
||||
|
||||
@@ -88,11 +88,9 @@ void TvCollector::post_message(const buffer_c16_t& data) {
|
||||
// Called from baseband processing thread.
|
||||
float re, im;
|
||||
float mag;
|
||||
float max;
|
||||
if( streaming && !channel_spectrum_request_update ) {
|
||||
for(size_t i=0; i<256; i++)
|
||||
{
|
||||
const auto s = data.p[i];
|
||||
re = (float)(data.p[i].real());
|
||||
im = (float)(data.p[i].imag());
|
||||
mag = __builtin_sqrtf((re * re) + (im * im)) ;
|
||||
|
||||
@@ -119,7 +119,7 @@ void chSysInit(void) {
|
||||
serve interrupts in its context while keeping the lowest energy saving
|
||||
mode compatible with the system status.*/
|
||||
chThdCreateStatic(_idle_thread_wa, sizeof(_idle_thread_wa), IDLEPRIO,
|
||||
(tfunc_t)_idle_thread, NULL);
|
||||
(void *)_idle_thread, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+28
-12
@@ -141,7 +141,11 @@ float cpr_mod(float a, float b) {
|
||||
return a - (b * floor(a / b));
|
||||
}
|
||||
|
||||
int cpr_NL(float lat) {
|
||||
int cpr_NL_precise(float lat) {
|
||||
return (int) floor(2 * PI / acos(1 - ((1 - cos(PI / (2 * NZ))) / pow(cos(PI * lat / 180), 2))));
|
||||
}
|
||||
|
||||
int cpr_NL_approx(float lat) {
|
||||
if (lat < 0)
|
||||
lat = -lat; // Symmetry
|
||||
|
||||
@@ -150,7 +154,19 @@ int cpr_NL(float lat) {
|
||||
return 59 - c;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cpr_NL(float lat) {
|
||||
// TODO prove that the approximate function is good
|
||||
// enough for the precision we need. Uncomment if
|
||||
// that is true. No performance penalty was noticed
|
||||
// from testing, but if you find it might be an issue,
|
||||
// switch to cpr_NL_approx() instead:
|
||||
|
||||
//return cpr_NL_approx(lat);
|
||||
|
||||
return cpr_NL_precise(lat);
|
||||
}
|
||||
|
||||
int cpr_N(float lat, int is_odd) {
|
||||
@@ -185,18 +201,18 @@ void encode_frame_pos(ADSBFrame& frame, const uint32_t ICAO_address, const int32
|
||||
// CPR encoding
|
||||
// Info from: http://antena.fe.uni-lj.si/literatura/Razno/Avionika/modes/CPRencoding.pdf
|
||||
|
||||
delta_lat = 360.0 / ((4.0 * 15.0) - time_parity); // NZ = 15
|
||||
yz = floor(131072.0 * (cpr_mod(latitude, delta_lat) / delta_lat) + 0.5);
|
||||
rlat = delta_lat * ((yz / 131072.0) + floor(latitude / delta_lat));
|
||||
delta_lat = 360.0 / ((4.0 * NZ) - time_parity); // NZ = 15
|
||||
yz = floor(CPR_MAX_VALUE * (cpr_mod(latitude, delta_lat) / delta_lat) + 0.5);
|
||||
rlat = delta_lat * ((yz / CPR_MAX_VALUE) + floor(latitude / delta_lat));
|
||||
|
||||
if ((cpr_NL(rlat) - time_parity) > 0)
|
||||
delta_lon = 360.0 / cpr_N(rlat, time_parity);
|
||||
else
|
||||
delta_lon = 360.0;
|
||||
xz = floor(131072.0 * (cpr_mod(longitude, delta_lon) / delta_lon) + 0.5);
|
||||
xz = floor(CPR_MAX_VALUE * (cpr_mod(longitude, delta_lon) / delta_lon) + 0.5);
|
||||
|
||||
lat = cpr_mod(yz, 131072.0);
|
||||
lon = cpr_mod(xz, 131072.0);
|
||||
lat = cpr_mod(yz, CPR_MAX_VALUE);
|
||||
lon = cpr_mod(xz, CPR_MAX_VALUE);
|
||||
|
||||
frame.push_byte((altitude_coded << 4) | ((uint32_t)time_parity << 2) | (lat >> 15)); // T = 0
|
||||
frame.push_byte(lat >> 7);
|
||||
@@ -258,7 +274,7 @@ adsb_pos decode_frame_pos(ADSBFrame& frame_even, ADSBFrame& frame_odd) {
|
||||
|
||||
// Compute longitude
|
||||
if (time_even > time_odd) {
|
||||
// Use even frame
|
||||
// Use even frame2
|
||||
ni = cpr_N(latE, 0);
|
||||
Dlon = 360.0 / ni;
|
||||
|
||||
@@ -279,7 +295,7 @@ adsb_pos decode_frame_pos(ADSBFrame& frame_even, ADSBFrame& frame_odd) {
|
||||
position.latitude = latO;
|
||||
}
|
||||
|
||||
if (position.longitude > 180) position.longitude -= 360;
|
||||
if (position.longitude >= 180) position.longitude -= 360;
|
||||
|
||||
position.valid = true;
|
||||
|
||||
@@ -319,14 +335,14 @@ void encode_frame_velo(ADSBFrame& frame, const uint32_t ICAO_address, const uint
|
||||
|
||||
// Decoding method from dump1090
|
||||
adsb_vel decode_frame_velo(ADSBFrame& frame){
|
||||
adsb_vel velo {false, 0, 0};
|
||||
adsb_vel velo {false, 0, 0, 0};
|
||||
|
||||
uint8_t * frame_data = frame.get_raw_data();
|
||||
uint8_t velo_type = frame.get_msg_sub();
|
||||
|
||||
if(velo_type >= 1 && velo_type <= 4){ //vertical rate is always present
|
||||
|
||||
velo.v_rate = (((frame_data[8] & 0x07 ) << 6) | ((frame_data[9]) >> 2) - 1) * 64;
|
||||
velo.v_rate = (((frame_data[8] & 0x07 ) << 6) | ((frame_data[9] >> 2) - 1)) * 64;
|
||||
|
||||
if((frame_data[8] & 0x8) >> 3) velo.v_rate *= -1; //check v_rate sign
|
||||
}
|
||||
|
||||
@@ -83,6 +83,10 @@ const float adsb_lat_lut[58] = {
|
||||
86.53536998, 87.00000000
|
||||
};
|
||||
|
||||
const float PI = 3.14159265358979323846;
|
||||
|
||||
const float NZ = 15.0;
|
||||
|
||||
void make_frame_adsb(ADSBFrame& frame, const uint32_t ICAO_address);
|
||||
|
||||
void encode_frame_id(ADSBFrame& frame, const uint32_t ICAO_address, const std::string& callsign);
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
}
|
||||
|
||||
uint8_t * get_raw_data() const {
|
||||
return (uint8_t* const)raw_data;
|
||||
return (uint8_t* )raw_data;
|
||||
}
|
||||
|
||||
void make_CRC() {
|
||||
|
||||
@@ -42,6 +42,7 @@ struct DateTime {
|
||||
|
||||
template<size_t FieldSize, int32_t DegMax, uint32_t NAValue>
|
||||
struct LatLonBase {
|
||||
|
||||
constexpr LatLonBase(
|
||||
) : LatLonBase { raw_not_available }
|
||||
{
|
||||
@@ -58,6 +59,8 @@ struct LatLonBase {
|
||||
) : raw_ { other.raw_ }
|
||||
{
|
||||
}
|
||||
|
||||
LatLonBase& operator=( const LatLonBase &)=default;
|
||||
|
||||
int32_t normalized() const {
|
||||
return static_cast<int32_t>(raw() << sign_extend_shift) / (1 << sign_extend_shift);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "aprs_packet.hpp"
|
||||
|
||||
namespace aprs {
|
||||
|
||||
} /* namespace zwave */
|
||||
@@ -0,0 +1,495 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __APRS_PACKET_H__
|
||||
#define __APRS_PACKET_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cctype>
|
||||
|
||||
#include "baseband.hpp"
|
||||
|
||||
namespace aprs {
|
||||
|
||||
const int APRS_MIN_LENGTH = 18; //14 bytes address, control byte and pid. 2 CRC.
|
||||
|
||||
struct aprs_pos{
|
||||
float latitude;
|
||||
float longitude;
|
||||
uint8_t symbol_code;
|
||||
uint8_t sym_table_id;
|
||||
};
|
||||
|
||||
enum ADDRESS_TYPE {
|
||||
SOURCE,
|
||||
DESTINATION,
|
||||
REPEATER
|
||||
};
|
||||
|
||||
class APRSPacket {
|
||||
public:
|
||||
void set_timestamp(const Timestamp& value) {
|
||||
timestamp_ = value;
|
||||
}
|
||||
|
||||
Timestamp timestamp() const {
|
||||
return timestamp_;
|
||||
}
|
||||
|
||||
void set(const size_t index, const uint8_t data) {
|
||||
payload[index] = data;
|
||||
|
||||
if(index + 1 > payload_size){
|
||||
payload_size = index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t operator[](const size_t index) const {
|
||||
return payload[index];
|
||||
}
|
||||
|
||||
|
||||
uint8_t size() const {
|
||||
return payload_size;
|
||||
}
|
||||
|
||||
void set_valid_checksum(const bool valid) {
|
||||
valid_checksum = valid;
|
||||
}
|
||||
|
||||
bool is_valid_checksum() const {
|
||||
return valid_checksum;
|
||||
}
|
||||
|
||||
uint64_t get_source(){
|
||||
uint64_t source = 0x0;
|
||||
|
||||
for(uint8_t i = SOURCE_START; i < SOURCE_START + ADDRESS_SIZE; i++){
|
||||
source |= ( ((uint64_t)payload[i]) << ((i - SOURCE_START) * 8));
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
std::string get_source_formatted(){
|
||||
parse_address(SOURCE_START, SOURCE);
|
||||
return std::string(address_buffer);
|
||||
}
|
||||
|
||||
std::string get_destination_formatted(){
|
||||
parse_address(DESTINATION_START, DESTINATION);
|
||||
return std::string(address_buffer);
|
||||
}
|
||||
|
||||
std::string get_digipeaters_formatted(){
|
||||
uint8_t position = DIGIPEATER_START;
|
||||
bool has_more = parse_address(SOURCE_START, REPEATER);
|
||||
|
||||
std::string repeaters = "";
|
||||
while(has_more){
|
||||
has_more = parse_address(position, REPEATER);
|
||||
repeaters += std::string(address_buffer);
|
||||
|
||||
position += ADDRESS_SIZE;
|
||||
|
||||
if(has_more){
|
||||
repeaters += ">";
|
||||
}
|
||||
}
|
||||
|
||||
return repeaters;
|
||||
}
|
||||
|
||||
uint8_t get_number_of_digipeaters(){
|
||||
uint8_t position = DIGIPEATER_START;
|
||||
bool has_more = parse_address(SOURCE_START, REPEATER);
|
||||
uint8_t repeaters = 0;
|
||||
while(has_more){
|
||||
has_more = parse_address(position, REPEATER);
|
||||
position += ADDRESS_SIZE;
|
||||
repeaters++;
|
||||
}
|
||||
|
||||
return repeaters;
|
||||
}
|
||||
|
||||
uint8_t get_information_start_index(){
|
||||
return DIGIPEATER_START + (get_number_of_digipeaters() * ADDRESS_SIZE) + 2;
|
||||
}
|
||||
|
||||
std::string get_information_text_formatted(){
|
||||
std::string information_text = "";
|
||||
for(uint8_t i = get_information_start_index(); i < payload_size - 2; i++){
|
||||
information_text += payload[i];
|
||||
}
|
||||
|
||||
return information_text;
|
||||
}
|
||||
|
||||
std::string get_stream_text(){
|
||||
std::string stream = get_source_formatted() + ">" + get_destination_formatted() + ";" + get_digipeaters_formatted() + ";" + get_information_text_formatted();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
char get_data_type_identifier(){
|
||||
char ident = '\0';
|
||||
for(uint8_t i = get_information_start_index(); i < payload_size - 2; i++){
|
||||
ident = payload[i];
|
||||
break;
|
||||
}
|
||||
return ident;
|
||||
}
|
||||
|
||||
bool has_position(){
|
||||
char ident = get_data_type_identifier();
|
||||
|
||||
return
|
||||
ident == '!' ||
|
||||
ident == '=' ||
|
||||
ident == '/' ||
|
||||
ident == '@' ||
|
||||
ident == ';' ||
|
||||
ident == '`' ||
|
||||
ident == '\''||
|
||||
ident == 0x1d||
|
||||
ident == 0x1c;
|
||||
}
|
||||
|
||||
aprs_pos get_position(){
|
||||
aprs::aprs_pos pos;
|
||||
|
||||
char ident = get_data_type_identifier();
|
||||
std::string info_text = get_information_text_formatted();
|
||||
|
||||
std::string lat_str, lng_str;
|
||||
char first;
|
||||
//bool supports_compression = true;
|
||||
bool is_mic_e_format = false;
|
||||
std::string::size_type start;
|
||||
|
||||
switch(ident){
|
||||
case '/':
|
||||
case '@':
|
||||
start = 8;
|
||||
break;
|
||||
case '=':
|
||||
case '!':
|
||||
start = 1;
|
||||
break;
|
||||
case ';':
|
||||
start = 18;
|
||||
//supports_compression = false;
|
||||
break;
|
||||
case '`':
|
||||
case '\'':
|
||||
case 0x1c:
|
||||
case 0x1d:
|
||||
is_mic_e_format = true;
|
||||
break;
|
||||
default:
|
||||
return pos;
|
||||
}
|
||||
if(is_mic_e_format){
|
||||
parse_mic_e_format(pos);
|
||||
}
|
||||
else {
|
||||
if(start < info_text.size()){
|
||||
first = info_text.at(start);
|
||||
|
||||
if(std::isdigit(first)){
|
||||
if(start + 18 < info_text.size()){
|
||||
lat_str = info_text.substr(start, 8);
|
||||
pos.sym_table_id = info_text.at(start + 8);
|
||||
lng_str = info_text.substr(start + 9, 9);
|
||||
pos.symbol_code = info_text.at(start + 18);
|
||||
|
||||
pos.latitude = parse_lat_str(lat_str);
|
||||
pos.longitude = parse_lng_str(lng_str);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if(start + 9 < info_text.size()){
|
||||
pos.sym_table_id = info_text.at(start);
|
||||
lat_str = info_text.substr(start + 1, 4);
|
||||
lng_str = info_text.substr(start + 5, 4);
|
||||
pos.symbol_code = info_text.at(start + 9);
|
||||
|
||||
pos.latitude = parse_lat_str_cmp(lat_str);
|
||||
pos.longitude = parse_lng_str_cmp(lng_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
payload_size = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const uint8_t DIGIPEATER_START = 14;
|
||||
const uint8_t SOURCE_START = 7;
|
||||
const uint8_t DESTINATION_START = 0;
|
||||
const uint8_t ADDRESS_SIZE = 7;
|
||||
|
||||
bool valid_checksum = false;
|
||||
uint8_t payload[256];
|
||||
char address_buffer[15];
|
||||
uint8_t payload_size;
|
||||
Timestamp timestamp_ { };
|
||||
|
||||
float parse_lat_str_cmp(const std::string& lat_str){
|
||||
return 90.0 - ( (lat_str.at(0) - 33) * (91*91*91) + (lat_str.at(1) - 33) * (91*91) + (lat_str.at(2) - 33) * 91 + (lat_str.at(3)) ) / 380926.0;
|
||||
}
|
||||
|
||||
float parse_lng_str_cmp(const std::string& lng_str){
|
||||
return -180.0 + ( (lng_str.at(0) - 33) * (91*91*91) + (lng_str.at(1) - 33) * (91*91) + (lng_str.at(2) - 33) * 91 + (lng_str.at(3)) ) / 190463.0;
|
||||
}
|
||||
|
||||
uint8_t parse_digits(const std::string& str){
|
||||
if(str.at(0) == ' '){
|
||||
return 0;
|
||||
}
|
||||
uint8_t end = str.find_last_not_of(' ') + 1;
|
||||
std::string sub = str.substr(0, end);
|
||||
|
||||
if(!is_digits(sub)){
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return std::stoi(sub);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_digits(const std::string& str){
|
||||
return str.find_last_not_of("0123456789") == std::string::npos;
|
||||
}
|
||||
|
||||
float parse_lat_str(const std::string& lat_str){
|
||||
float lat = 0.0;
|
||||
|
||||
std::string str_lat_deg = lat_str.substr(0, 2);
|
||||
std::string str_lat_min = lat_str.substr(2, 2);
|
||||
std::string str_lat_hund = lat_str.substr(5, 2);
|
||||
std::string dir = lat_str.substr(7, 1);
|
||||
|
||||
uint8_t lat_deg = parse_digits(str_lat_deg);
|
||||
uint8_t lat_min = parse_digits(str_lat_min);
|
||||
uint8_t lat_hund = parse_digits(str_lat_hund);
|
||||
|
||||
lat += lat_deg;
|
||||
lat += (lat_min + (lat_hund/ 100.0))/60.0;
|
||||
|
||||
if(dir.c_str()[0] == 'S'){
|
||||
lat = -lat;
|
||||
}
|
||||
|
||||
return lat;
|
||||
|
||||
}
|
||||
|
||||
float parse_lng_str(std::string& lng_str){
|
||||
float lng = 0.0;
|
||||
|
||||
std::string str_lng_deg = lng_str.substr(0, 3);
|
||||
std::string str_lng_min = lng_str.substr(3, 2);
|
||||
std::string str_lng_hund = lng_str.substr(6, 2);
|
||||
std::string dir = lng_str.substr(8, 1);
|
||||
|
||||
uint8_t lng_deg = parse_digits(str_lng_deg);
|
||||
uint8_t lng_min = parse_digits(str_lng_min);
|
||||
uint8_t lng_hund = parse_digits(str_lng_hund);
|
||||
|
||||
lng += lng_deg;
|
||||
lng += (lng_min + (lng_hund/ 100.0))/60.0;
|
||||
|
||||
if(dir.c_str()[0] == 'W'){
|
||||
lng = -lng;
|
||||
}
|
||||
|
||||
return lng;
|
||||
|
||||
}
|
||||
|
||||
void parse_mic_e_format(aprs::aprs_pos& pos){
|
||||
std::string lat_str = "";
|
||||
std::string lng_str = "";
|
||||
|
||||
bool is_north = false;
|
||||
bool is_west = false;
|
||||
uint8_t lng_offset = 0;
|
||||
for(uint8_t i = DESTINATION_START; i < DESTINATION_START + ADDRESS_SIZE - 1; i++){
|
||||
uint8_t ascii = payload[i] >> 1;
|
||||
|
||||
lat_str += get_mic_e_lat_digit(ascii);
|
||||
|
||||
if(i - DESTINATION_START == 3){
|
||||
lat_str += ".";
|
||||
}
|
||||
if(i - DESTINATION_START == 3){
|
||||
is_north = is_mic_e_lat_N(ascii);
|
||||
}
|
||||
if(i - DESTINATION_START == 4){
|
||||
lng_offset = get_mic_e_lng_offset(ascii);
|
||||
}
|
||||
if(i - DESTINATION_START == 5){
|
||||
is_west = is_mic_e_lng_W(ascii);
|
||||
}
|
||||
}
|
||||
if(is_north){
|
||||
lat_str += "N";
|
||||
}
|
||||
else {
|
||||
lat_str += "S";
|
||||
}
|
||||
|
||||
pos.latitude = parse_lat_str(lat_str);
|
||||
|
||||
float lng = 0.0;
|
||||
uint8_t information_start = get_information_start_index() + 1;
|
||||
for(uint8_t i = information_start; i < information_start + 3 && i < payload_size - 2; i++){
|
||||
uint8_t ascii = payload[i];
|
||||
|
||||
if(i - information_start == 0){ //deg
|
||||
ascii -=28;
|
||||
ascii += lng_offset;
|
||||
|
||||
if(ascii >= 180 && ascii <= 189){
|
||||
ascii -= 80;
|
||||
}
|
||||
else if (ascii >= 190 && ascii <= 199){
|
||||
ascii -= 190;
|
||||
}
|
||||
|
||||
lng += ascii;
|
||||
}
|
||||
else if(i - information_start == 1){ //min
|
||||
ascii -= 28;
|
||||
if(ascii >= 60){
|
||||
ascii -= 60;
|
||||
}
|
||||
lng += ascii/60.0;
|
||||
}
|
||||
else if(i - information_start == 2){ //hundredth minutes
|
||||
ascii -= 28;
|
||||
|
||||
lng += (ascii/100.0)/60.0;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_west){
|
||||
lng = -lng;
|
||||
}
|
||||
|
||||
pos.longitude = lng;
|
||||
|
||||
}
|
||||
|
||||
uint8_t get_mic_e_lat_digit(uint8_t ascii){
|
||||
if(ascii >= '0' && ascii <= '9'){
|
||||
return ascii;
|
||||
}
|
||||
if(ascii >= 'A' && ascii <= 'J'){
|
||||
return ascii - 17;
|
||||
}
|
||||
if(ascii >= 'P' && ascii <='Y'){
|
||||
return ascii - 32;
|
||||
}
|
||||
if(ascii == 'K' || ascii == 'L' || ascii == 'Z'){
|
||||
return ' ';
|
||||
}
|
||||
|
||||
return '\0';
|
||||
}
|
||||
|
||||
bool is_mic_e_lat_N(uint8_t ascii){
|
||||
if(ascii >= 'P' && ascii <='Z'){
|
||||
return true;
|
||||
}
|
||||
return false; //not technical definition, but the other case is invalid
|
||||
}
|
||||
|
||||
bool is_mic_e_lng_W(uint8_t ascii){
|
||||
if(ascii >= 'P' && ascii <='Z'){
|
||||
return true;
|
||||
}
|
||||
return false; //not technical definition, but the other case is invalid
|
||||
}
|
||||
|
||||
uint8_t get_mic_e_lng_offset(uint8_t ascii){
|
||||
if(ascii >= 'P' && ascii <='Z'){
|
||||
return 100;
|
||||
}
|
||||
return 0; //not technical definition, but the other case is invalid
|
||||
}
|
||||
|
||||
bool parse_address(uint8_t start, ADDRESS_TYPE address_type){
|
||||
uint8_t byte = 0;
|
||||
uint8_t has_more = false;
|
||||
uint8_t ssid = 0;
|
||||
uint8_t buffer_index = 0;
|
||||
|
||||
for(uint8_t i = start; i < start + ADDRESS_SIZE && i < payload_size - 2; i++){
|
||||
byte = payload[i];
|
||||
|
||||
if(i - start == 6){
|
||||
has_more = (byte & 0x1) == 0;
|
||||
ssid = (byte >> 1) & 0x0F;
|
||||
|
||||
if(ssid != 0 || address_type == REPEATER){
|
||||
address_buffer[buffer_index++] = '-';
|
||||
|
||||
if(ssid < 10){
|
||||
address_buffer[buffer_index++] = '0' + ssid;
|
||||
address_buffer[buffer_index++] = '\0';
|
||||
}
|
||||
else {
|
||||
address_buffer[buffer_index++] = '1';
|
||||
address_buffer[buffer_index++] = '0' + ssid - 10;
|
||||
address_buffer[buffer_index++] = '\0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
address_buffer[buffer_index++] = '\0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
byte >>= 1;
|
||||
|
||||
if(byte != ' '){
|
||||
address_buffer[buffer_index++] = byte;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return has_more;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace aprs */
|
||||
|
||||
#endif/*__APRS_PACKET_H__*/
|
||||
@@ -55,3 +55,29 @@ void IIRBiquadFilter::execute(const buffer_f32_t& buffer_in, const buffer_f32_t&
|
||||
void IIRBiquadFilter::execute_in_place(const buffer_f32_t& buffer) {
|
||||
execute(buffer, buffer);
|
||||
}
|
||||
|
||||
void IIRBiquadDF2Filter::configure(const iir_biquad_df2_config_t& config) {
|
||||
b0 = config[0] / config[3];
|
||||
b1 = config[1] / config[3];
|
||||
b2 = config[2] / config[3];
|
||||
a1 = config[4] / config[3];
|
||||
a2 = config[5] / config[3];
|
||||
}
|
||||
|
||||
// scipy.signal.sosfilt
|
||||
//
|
||||
// x_n = x[i, n] # make a temporary copy
|
||||
// # Use direct II transposed structure:
|
||||
// x[i, n] = b[s, 0] * x_n + zi[i, s, 0]
|
||||
// zi[i, s, 0] = (b[s, 1] * x_n - a[s, 0] * x[i, n] + zi[i, s, 1])
|
||||
// zi[i, s, 1] = (b[s, 2] * x_n - a[s, 1] * x[i, n])
|
||||
|
||||
float IIRBiquadDF2Filter::execute(float x) {
|
||||
float y;
|
||||
|
||||
y = b0 * x + z0;
|
||||
z0 = b1 * x - a1 * y + z1;
|
||||
z1 = b2 * x - a2 * y;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ struct iir_biquad_config_t {
|
||||
std::array<float, 3> a;
|
||||
};
|
||||
|
||||
// 0..2 - b, 3..5 - a
|
||||
typedef std::array<float, 6> iir_biquad_df2_config_t;
|
||||
|
||||
constexpr iir_biquad_config_t iir_config_passthrough {
|
||||
{ { 1.0f, 0.0f, 0.0f } },
|
||||
{ { 0.0f, 0.0f, 0.0f } },
|
||||
@@ -67,4 +70,21 @@ private:
|
||||
std::array<float, 3> y { { 0.0f, 0.0f, 0.0f } };
|
||||
};
|
||||
|
||||
class IIRBiquadDF2Filter {
|
||||
public:
|
||||
|
||||
void configure(const iir_biquad_df2_config_t& config);
|
||||
float execute(float z);
|
||||
|
||||
private:
|
||||
float b0 = 0;
|
||||
float b1 = 0;
|
||||
float b2 = 0;
|
||||
float a1 = 0;
|
||||
float a2 = 0;
|
||||
|
||||
float z0 = 0;
|
||||
float z1 = 0;
|
||||
};
|
||||
|
||||
#endif/*__DSP_IIR_H__*/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "dsp_sos.hpp"
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __DSP_SOS_H__
|
||||
#define __DSP_SOS_H__
|
||||
|
||||
#include "dsp_iir.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
template <size_t N>
|
||||
class SOSFilter {
|
||||
|
||||
public:
|
||||
|
||||
void configure(const iir_biquad_df2_config_t config[N]) {
|
||||
for (size_t i = 0; i < N; i++)
|
||||
filters[i].configure(config[i]);
|
||||
}
|
||||
|
||||
float execute(float value) {
|
||||
for (auto &filter : filters)
|
||||
value = filter.execute(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
IIRBiquadDF2Filter filters[N];
|
||||
};
|
||||
|
||||
#endif/*__DSP_SOS_H__*/
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Belousov Oleg
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* 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 2, 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __DSP_SOS_CONFIG_H__
|
||||
#define __DSP_SOS_CONFIG_H__
|
||||
|
||||
#include "dsp_iir.hpp"
|
||||
|
||||
// scipy.signal.iirfilter(ftype="ellip", N = 10, rp = 0.5, rs = 60.0, Wn = 0.5, btype = 'lowpass', output="sos")
|
||||
|
||||
constexpr iir_biquad_df2_config_t half_band_lpf_config[5] = {
|
||||
{ 0.02339042f, 0.0411599f, 0.02339042f, 1.0f, -0.95317621f, 0.33446485f },
|
||||
{ 1.0f, 0.82196114f, 1.0f, 1.0f, -0.50327735f, 0.63611027f },
|
||||
{ 1.0f, 0.32515305f, 1.0f, 1.0f, -0.18144446f, 0.85269598f },
|
||||
{ 1.0f, 0.14394122f, 1.0f, 1.0f, -0.04368236f, 0.94798064f },
|
||||
{ 1.0f, 0.08720754, 1.0f, 1.0f, 0.00220944f, 0.98743139f }
|
||||
};
|
||||
|
||||
#endif/*__DSP_SOS_CONFIG_H__*/
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
/* The "start_bit" winds up being the MSB of the returned field value. */
|
||||
/* The BitRemap functor determines which bits are read from the source
|
||||
* packet. */
|
||||
uint32_t read(const size_t start_bit, const size_t length) const {
|
||||
int32_t read(const size_t start_bit, const size_t length) const { //Euquiq: was uint32_t, used for calculating lat / lon in radiosondes, can be negative too
|
||||
uint32_t value = 0;
|
||||
for(size_t i=start_bit; i<(start_bit + length); i++) {
|
||||
value = (value << 1) | data[bit_remap(i)];
|
||||
|
||||
@@ -30,8 +30,13 @@ using namespace portapack;
|
||||
|
||||
#include "ch.h"
|
||||
|
||||
#include "file.hpp"
|
||||
|
||||
#include <complex>
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
namespace lcd {
|
||||
|
||||
namespace {
|
||||
@@ -416,6 +421,113 @@ void ILI9341::drawBMP(const ui::Point p, const uint8_t * bitmap, const bool tran
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Draw BMP from SD card.
|
||||
Currently supported formats:
|
||||
16bpp ARGB, RGB565
|
||||
24bpp RGB
|
||||
32bpp ARGB
|
||||
*/
|
||||
bool ILI9341::drawBMP2(const ui::Point p, const std::string file) {
|
||||
File bmpimage;
|
||||
size_t file_pos = 0;
|
||||
uint16_t pointer = 0;
|
||||
int16_t px = 0, py, width, height;
|
||||
bmp_header_t bmp_header;
|
||||
uint8_t type = 0;
|
||||
char buffer[257];
|
||||
ui::Color line_buffer[240];
|
||||
|
||||
auto result = bmpimage.open(file);
|
||||
if(result.is_valid())
|
||||
return false;
|
||||
|
||||
bmpimage.seek(file_pos);
|
||||
auto read_size = bmpimage.read(&bmp_header, sizeof(bmp_header));
|
||||
if (!((bmp_header.signature == 0x4D42) && // "BM" Signature
|
||||
(bmp_header.planes == 1) && // Seems always to be 1
|
||||
(bmp_header.compression == 0 || bmp_header.compression == 3 ))) { // No compression
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(bmp_header.bpp) {
|
||||
case 16:
|
||||
file_pos = 0x36;
|
||||
memset(buffer, 0, 16);
|
||||
bmpimage.read(buffer, 16);
|
||||
if(buffer[1] == 0x7C)
|
||||
type = 3; // A1R5G5B5
|
||||
else
|
||||
type = 0; // R5G6B5
|
||||
break;
|
||||
case 24:
|
||||
type = 1;
|
||||
break;
|
||||
case 32:
|
||||
default:
|
||||
type = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
width = bmp_header.width;
|
||||
height = bmp_header.height;
|
||||
|
||||
file_pos = bmp_header.image_data;
|
||||
|
||||
py = height + 16;
|
||||
|
||||
while(1) {
|
||||
while(px < width) {
|
||||
bmpimage.seek(file_pos);
|
||||
memset(buffer, 0, 257);
|
||||
read_size = bmpimage.read(buffer, 256);
|
||||
if (read_size.is_error())
|
||||
return false; // Read error
|
||||
|
||||
pointer = 0;
|
||||
while(pointer < 256) {
|
||||
if(pointer + 4 > 256)
|
||||
break;
|
||||
switch(type) {
|
||||
case 0:
|
||||
case 3:
|
||||
if(!type)
|
||||
line_buffer[px] = ui::Color((uint16_t)buffer[pointer] | ((uint16_t)buffer[pointer + 1] << 8));
|
||||
else
|
||||
line_buffer[px] = ui::Color(((uint16_t)buffer[pointer] & 0x1F) | ((uint16_t)buffer[pointer] & 0xE0) << 1 | ((uint16_t)buffer[pointer + 1] & 0x7F) << 9);
|
||||
pointer += 2;
|
||||
file_pos += 2;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
line_buffer[px] = ui::Color(buffer[pointer + 2], buffer[pointer + 1], buffer[pointer]);
|
||||
pointer += 3;
|
||||
file_pos += 3;
|
||||
break;
|
||||
case 2:
|
||||
line_buffer[px] = ui::Color(buffer[pointer + 2], buffer[pointer + 1], buffer[pointer]);
|
||||
pointer += 4;
|
||||
file_pos += 4;
|
||||
break;
|
||||
}
|
||||
px++;
|
||||
if(px >= width) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(read_size.value() != 256)
|
||||
break;
|
||||
}
|
||||
render_line({ p.x(), p.y() + py }, px, line_buffer);
|
||||
px = 0;
|
||||
py--;
|
||||
|
||||
if(read_size.value() < 256 || py < 0)
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ILI9341::draw_line(const ui::Point start, const ui::Point end, const ui::Color color) {
|
||||
int x0 = start.x();
|
||||
int y0 = start.y();
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
void draw_pixel(const ui::Point p, const ui::Color color);
|
||||
void drawBMP(const ui::Point p, const uint8_t * bitmap, const bool transparency);
|
||||
bool drawBMP2(const ui::Point p, const std::string file);
|
||||
void render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer);
|
||||
void render_box(const ui::Point p, const ui::Size s, const ui::Color* line_buffer);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user