1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-12 19:10:19 +03:00

Companion build on Linux

This commit is contained in:
Bertrand Songis 2013-12-02 18:47:43 +01:00
parent 942e658c8e
commit 2f8f2df3c7
530 changed files with 230710 additions and 0 deletions

235
CREDITS.txt Normal file
View file

@ -0,0 +1,235 @@
Mario Sette
Felice Baratto
Alessandro Mari
Gianpiero Spontina
Ingo Kuzniak
Hans-Åke Rahm
Tamas Varga
Thomas Gregg
Didier Christien
Alain Pinard
Sergio Melas
Paul Montenot
Chris Guy
Adrien Gravouille
Thomas Black
Marc Lucht
Michel Baily
Zdenek Trojanek
Martin Hotar
[Devo] Stefan Grundevik
[Devo] Fabio Eboli
Federico Zotti
Albin Esbjörnsson
Kilian Hüttenhofer
Stephen Stough
Adilson Oliveira
Robert Saint Marie
Tad Leake
Andreas Weitl
Chan Lofland
Dirk Kasten
Denisov Alexander
Timo Varppee
Ondrej Hatapka
Valérie Billon
R. Scott Page
Johan Cronje
Renato Aranghelovici
Jeffrey Irvin
Aloft Hobbies
John Rodgers
Kenneth Crump
Damjan Adamic
Martin Wilson
Joe Street
John Holdsworth
Daniel Schwartz
Dean Church
Michael Halse
David Mark
Ted Moss
Jim Wagner
Nicola Porzi
Michael Halse
Chewytm
Espen Solbu
Mike Frizell
Bruce Jones
Kenneth Crump
Stefano Airaghi
Dan Eeckhout
Alex Calderhead
Leonard MacKey
Heung Jin Choi
Mike Retterer
Keith Wood
Viljo Liukku
Eric Beier
Burt Pickard-Richardson
Helmut Renz
Rick Harms
Vincenzo Vavala
Patricia Martin
Harald Klein
Carl Petersen
Douglas Burkett
Clifford Evans
Teodor Yantchev
Jarad Berkman
Christian Schulz
Gregory J Shepherd
Michael Shellim
Ming Wang
R. Scott Page
Bernard Lukaschek
Nigel Chippindale
Mike Perkins
Ted Hammond
Kenneth Crump
David Beanland
Bernd Koehler
Frédéric Duflos
Dave Fasken
Heinrich Illig
Michael Collins
Michael Manning
Craig Lorentz
Jonathan Modellismo - http://jonathan.it
Aviomotive - http://www.aviomotive.com
André Lasseret
Felipe Alexandre de Oliveira
Brian Harris
Philippe Herbots
Rainer Nelte
Franck Bernhard
Erhard Werner
Stig Jøran Moen
Keith Hertzog
Christophe Dauvergne
Michel Baily
Tauno Rautakorpi
Sven Assmus
Paul Dittman
Mike Matheny
Cheryl Wynne
Emay Toha
Don Nolder
André Lasseret
Filip Lowette
Arnaldo Gabella
Fiorenzo Agnelli
Michele Villa
Christophe Rodriguez
Harald Klein
Larisa Filocamo
Alex Calderhead
Hartmut Sahm
Åke Brodin
Aloft Hobbies - http://www.alofthobbies.com
Ted Moss
Filippos Tigarakis
Chewytm
Eric Burdis
Nigel Chippindale
Michael Deasy
Stephen Stough
Kenneth Lilja
Robert Jero
Gary Bancroft
Robert Cotsford
Rafael Eric Suarez Nordlow
Gordon Stahl
NorthSide
George Constandinides
Robert Schonk Jr
Kevin Berkefeld
Peter Webster
Mike Matheny
Martin Sniedze
Fernando Rimoldi
Sidney Fisher
Bruce Anderson
John Rodgers
Ed Pare
Thomas Kilduff
Robert Ferguson
Bryan Green
Kevin Berkefeld
Julien Michel
Krittikun Chiraphanda
Douglas Law
Alberto Scotti
Oliver Kunkel
D. Joseph Frazier
Heiko Polig
Andrew Fernie
Marco Lange
Nick McMillan
Michel Baily (mensual)
Patrick Mullen
Scott Campbell
Erich Roeder
Wayne Davy
Michael Fontenot
Willie Swanepoel
Satoru Sasaki
Tyler Darby
Nicholas Crego
Keith Hertzog
Johan Moelich
Timo Esser
Dean Church (mensual)
Brian Paddock (mensual)
Jean Pierre Parisy
Norbert Martsch
Jean-Marie Guitard
Eric Beier
Mike Perkins
Tilman Baumann (mensual)
Fred Larssen
Ari Aalto
Robert Sams
Kirk Robertson
John Koontz
Jeffery Golias
Paul Robinson
Kenneth Crump
Dave Matison
Mike Matheny
Pino Agostino
Graham Boucher (mensual)
Nelson Noura
Joel Allamy
Philip David Martin
Sean Stephen
Bruce Mackay
Blake Spilman
Timothy Pelletier
Glen Roe (ShowMaster)
Jan Van Ooteghem
David Ankers - Special thanks here to the OpenPilot project!
Lawrence Christensen (mensual)
Leo Duflou
Bruce Wood
Arnd Feige
Tauno Rautakorpi
Steve Coley
Stefan Kiendl
Gregory Nuspel
Mitchell Brenner
Ronnnie DePrez
Ferenc Koller
Robert Sessler
Didier Lanot
Rodney Hunt
Steve Bernard
Paul Nazaroff
Gordon Ernenputsch
Ksamak
Marc Gittelman
David Poole
Ralph Sauer
Karl-Heinz Gansel
Michels Bernhard
Thomas Demmelbauer

11
DONATIONS.txt Normal file
View file

@ -0,0 +1,11 @@
Bertrand Songis
Romolo Manfredini
Bryan Rentoul (aka Gruvin)
Cameron Weeks
Andrè Bernet (mac)
Michael Byrne (logos and official splashes)
Severino Anedda (splash screens)
Grootwitbaas - 9xforums.com (mac)
Adrian Amberg (splash screens)
Wallaguest1 - 9xforums.com (splash screens)
HC1969 - 9xforums.com (splash screens)

339
GPLv2.txt Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 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.

1
README.txt Normal file
View file

@ -0,0 +1 @@
[to be written]

143
companion/releasenotes.txt Normal file
View file

@ -0,0 +1,143 @@
<h2>Version 1.51</h2>
<ul>
<li>Wrong DFU-Util default path (MAC)</li>
<li>new voices download server (ip address changed to new fiber connection)</li>
<li>Fixed contributor list</li>
</ul>
<h2>Version 1.50</h2>
<ul>
<li>solved issue with taranis radio with some linux distributions</li>
<li>blank eeprom created using a radio profile that holds calibration data, will contain calibration data from the profile</li>
<li>new opentx compilation server (ip address changed to new fiber connection)</li>
</ul>
<h2>Version 1.49</h2>
<ul>
<li>Stack usage optimizations</li>
<li>Playsound order is misaligned between companion9x and the TX</li>
<li>Model image could not be reset.</li>
</ul>
<h2>Version 1.48</h2>
<ul>
<li>Interface fixes</li>
<li>Hide include dr/expo when not applicable</li>
<li>Fix extraction of grayscale images from taranis firmwares</li>
<li>No TX and RX in Taranis telemetry fields</li>
<li>Issue 255 fixed - "No GVAR selection possible for PLAY VALUE"</li>
<li>Issue 254 fixed - "SE Language for building opentx"</li>
<li>Issue 253 fixed - "OpenTX doesn't accept this protocol (DSM2 on Sky9x)"</li>
<li>Prevent segfault while parsing wrong log files or files with broken lines</li>
<li>Small bug in model printout</li>
<li>Fixed wrong display of values in custom functions</li>
<li>Image in preferences was saved only black & white</li>
<li>Issue 247 fixed - "Labelled items on radio should not be translated."</li>
<li>Added support of tstick (taranis like stick) compile option for sky9x opentx firmware</li>
</ul>
<h2>Version 1.47</h2>
<ul>
<li>Interface fixes (issues 232,233,238,241)</li>
<li>Fix for print/compare models</li>
<li>Function switch parameter on screen different than printout.</li>
<li>Translations fixes</li>
<li>Command line print mode</li>
<li>Better mavlink support</li>
<li>SE tts language added for taranis</li>
<li>Alternate font option for opentx added</li>
</ul>
<h2>Version 1.46</h2>
<ul>
<li>Interface fixes (issues 224,225)</li>
<li>Show persistent timers value in modeledit</li>
<li>Consistent naming of Custom Switches in c9x</li>
</ul>
<h2>Version 1.45</h2>
<ul>
<li>Various fixes</li>
</ul>
<h2>Version 1.44</h2>
<ul>
<li>Fix regression on AND parameter in custom functions</li>
<li>Add mavlink support for stock and m128 boards</li>
</ul>
<h2>Version 1.43</h2>
<ul>
<li>Copy Malfunctions in Custom Functions (Issue 205)</li>
<li>Enable repeat parameter in functions for all boards</li>
<li>Remove sink tones from vario for stock/m128 board</li>
<li>Fix for wrongly named channels in mixerlist (Issue 210)</li>
<li>Fix badly exported gvars in mixers</li>
<li>Fix while editing custom switches</li>
<li>Add access to the release notes of currently selected firmware</li>
</ul>
<h2>Version 1.42</h2>
<ul>
<li>Add Companion9X changelog</li>
<li>Add Fw release notes browser</li>
<li>Simplify burn menu for sky9x and Taranis.</li>
<li>Fix in telemetry conversion (rssi alarm) for stock board</li>
<li>Drop support of sky9x boards on MacOS due to missing SAM-BA tool.</li>
</ul>
<h2>Version 1.41</h2>
<ul>
<li>Fix unneeded rescaling of splash images</li>
<li>Fix for telemetry screens for Taranis</li>
</ul>
<h2>Version 1.40</h2>
<ul>
<li>Log dialog - Split of logging sessions.</li>
<li>Telemetry screen 1 as default (issue 206)</li>
<li>Rename all channels in mixer tab accordingly to limits names</li>
<li>Fix a segfault in phases tabs (Issue 203 regression introduced in release 2140)</li>
</ul>
<h2>Version 1.39</h2>
<ul>
<li>Custom functions cut&paste </li>
<li>Custom switches cut&paste </li>
<li>Color button text in curve editor for MACOSX</li>
<li>Adjust name lengths for Taranis</li>
</ul>
<h2>Version 1.38</h2>
<ul>
<li>Core when model names were > 10 chars</li>
</ul>
<h2>Version 1.37</h2>
<ul>
<li>Fix OpenTX segfault in Taranis simulator</li>
<li>Implement brightness control for Taranis</li>
<li>Reduce modeledit windows size</li>
<li>Taranis splash screen in grayscale</li>
</ul>
<h2>Version 1.36</h2>
<ul>
<li>Burning windows (with progress bar) now in foreground (Issue 197)</li>
<li>Allow a selection of tracks for Background Music (Issue 199)</li>
</ul>
<h2>Version 1.35</h2>
<ul>
<li>Country names mismatch between Taranis and Companion 9X (Issue 198)</li>
<li>TIM function in custom switches</li>
<li>Fix timer switches.</li>
<li>Taranis LCD adjustment in general settings.</li>
<li>New tool in curve editor</li>
<li>Minor fixes</li>
<li>Expo move bug + invalid chars in channels, expo and mixer names</li>
<li>Try to reduce modeledit window form MAC</li>
<li>Wrong init of RF-Module data</li>
<li>Read flash from TX didn't worked for Taranis</li>
</ul>

View file

@ -0,0 +1,418 @@
PROJECT( companion9x )
SET( C9X_VERSION_MAJOR "1" )
SET( C9X_VERSION_MINOR "51" )
SET( C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR} )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
MESSAGE( STATUS "Looking for XercesC " )
FIND_PACKAGE(XercesC)
IF ( XERCESC_FOUND )
INCLUDE_DIRECTORIES( ${XERCESC_INCLUDE_DIR} )
SET(LidarFormat_LIBRAIRIES ${LidarFormat_LIBRAIRIES} ${XERCESC_LIBRARIES})
ELSE()
MESSAGE( FATAL_ERROR "XercesC not found! Please set XercesC path ..." )
ENDIF()
MESSAGE( STATUS "Looking for Xsd " )
FIND_PACKAGE(Xsd)
IF ( XSD_FOUND )
INCLUDE_DIRECTORIES( ${XSD_INCLUDE_DIR} )
MESSAGE("XSD Include Path: " ${XSD_INCLUDE_DIR} )
ELSE()
MESSAGE( FATAL_ERROR "XSD not found! Please set XSD path ..." )
ENDIF()
MESSAGE( STATUS "Looking for SDL " )
FIND_PACKAGE(Sdl)
IF ( SDL_FOUND )
INCLUDE_DIRECTORIES( ${SDL_INCLUDE_DIR} )
MESSAGE("SDL Include Path: " ${SDL_INCLUDE_DIR} )
ADD_DEFINITIONS( -DJOYSTICKS )
ELSE()
MESSAGE( "SDL not found! Joysticks support will be disabled" )
ENDIF()
FIND_PACKAGE( Qt4 REQUIRED )
SET( QT_USE_QTNETWORK True )
SET( QT_USE_QTXML True )
INCLUDE( ${QT_USE_FILE} )
IF ( APPLE )
MESSAGE( STATUS "Phonon still not supported on APPLE " )
ELSE()
MESSAGE( STATUS "Looking for PHONON " )
FIND_PACKAGE(Phonon)
IF ( PHONON_FOUND )
INCLUDE_DIRECTORIES( ${PHONO_INCLUDE_DIR} )
MESSAGE("PHONON Include Path: " ${PHONON_INCLUDE_DIR} )
ADD_DEFINITIONS( -DPHONON )
ELSE()
MESSAGE( "PHONON not found!" )
ENDIF()
ENDIF()
ADD_CUSTOM_COMMAND(
COMMAND ${XSDCXX_EXECUTABLE} cxx-tree --root-element-all --generate-serialization --output-dir ${PROJECT_BINARY_DIR}/ ${PROJECT_SOURCE_DIR}/radio.xsd
OUTPUT ${PROJECT_BINARY_DIR}/radio.hxx ${PROJECT_BINARY_DIR}/radio.cxx
DEPENDS ${PROJECT_SOURCE_DIR}/radio.xsd
)
IF( MSVC )
SET(CMAKE_CXX_FLAGS "/EHsc /LD")
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/winbuild C:/Programs/pthreads/Pre-built.2/include C:/Programs/msinttypes)
LINK_DIRECTORIES( C:/Programs/pthreads/Pre-built.2/lib/ )
SET( PTHREAD_LIBRARY pthreadVC2.lib )
ELSE( )
SET( PTHREAD_LIBRARY pthread )
ADD_DEFINITIONS( -Wall )
LINK_DIRECTORIES( /usr/local/lib )
ENDIF( )
INCLUDE_DIRECTORIES( ${XSD_INCLUDE_DIR} )
FIND_PACKAGE( Subversion )
SET( C9X_WC_REVISION 0 )
IF( Subversion_FOUND )
# Subversion_WC_INFO( ${PROJECT_SOURCE_DIR} C9X )
ENDIF( )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/../.. ${PROJECT_SOURCE_DIR}/../../radio/src/fonts/std )
set(TH9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/th9x)
add_custom_command(
OUTPUT ${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp
COMMAND ${CMAKE_COMMAND} -E make_directory ${TH9X_CHECKOUT_DIRECTORY}
COMMAND cd ${TH9X_CHECKOUT_DIRECTORY} && svn checkout http://th9x.googlecode.com/svn/trunk/src@285 .
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/th9x/th9xsimulator.cpp ${TH9X_CHECKOUT_DIRECTORY}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/th9x/th9xsimulator.cpp
)
set(ER9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/er9x)
add_custom_command(
OUTPUT ${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp
COMMAND ${CMAKE_COMMAND} -E make_directory ${ER9X_CHECKOUT_DIRECTORY}
COMMAND cd ${ER9X_CHECKOUT_DIRECTORY} && svn checkout http://er9x.googlecode.com/svn/trunk/src@790 .
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/er9x/er9xsimulator.cpp ${ER9X_CHECKOUT_DIRECTORY}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/er9x/er9xsimulator.cpp
)
set(ERSKY9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/ersky9x)
add_custom_command(
OUTPUT ${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp
COMMAND ${CMAKE_COMMAND} -E make_directory ${ERSKY9X_CHECKOUT_DIRECTORY}
COMMAND cd ${ERSKY9X_CHECKOUT_DIRECTORY} && svn checkout http://ersky9x.googlecode.com/svn/trunk/src@170 .
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp ${ERSKY9X_CHECKOUT_DIRECTORY}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp
)
SET( companion9x_SRCS
eeprominterface.cpp
hexinterface.cpp
flashinterface.cpp
file.cpp
xmlinterface.cpp
${PROJECT_BINARY_DIR}/radio.cxx
firmwares/th9x/th9xeeprom.cpp
firmwares/th9x/th9xinterface.cpp
${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp
firmwares/er9x/er9xeeprom.cpp
firmwares/er9x/er9xinterface.cpp
${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp
firmwares/gruvin9x/gruvin9xeeprom.cpp
firmwares/gruvin9x/gruvin9xinterface.cpp
firmwares/opentx/open9xeeprom.cpp
firmwares/opentx/open9xStockeeprom.cpp
firmwares/opentx/open9xinterface.cpp
firmwares/opentx/open9xGruvin9xeeprom.cpp
firmwares/opentx/open9xSky9xeeprom.cpp
firmwares/opentx/opentxTaranisSimulator.cpp
firmwares/opentx/open9xSky9xsimulator.cpp
firmwares/opentx/open9xGruvin9xsimulator.cpp
firmwares/opentx/open9xM128simulator.cpp
firmwares/opentx/open9xsimulator.cpp
firmwares/ersky9x/ersky9xeeprom.cpp
firmwares/ersky9x/ersky9xinterface.cpp
${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp
node.cpp
edge.cpp
helpers.cpp
mdichild.cpp
generaledit.cpp
modeledit.cpp
modelslist.cpp
mountlist.cpp
mixerslist.cpp
avroutputdialog.cpp
preferencesdialog.cpp
burnconfigdialog.cpp
comparedialog.cpp
contributorsdialog.cpp
customizesplashdialog.cpp
burndialog.cpp
printdialog.cpp
fusesdialog.cpp
expodialog.cpp
mixerdialog.cpp
logsdialog.cpp
downloaddialog.cpp
simulatordialog.cpp
xsimulatordialog.cpp
splashlibrary.cpp
mainwindow.cpp
main.cpp
modelconfigdialog.cpp
qcustomplot.cpp
)
SET( companion9x_MOC_HDRS
avroutputdialog.h
preferencesdialog.h
burnconfigdialog.h
comparedialog.h
printdialog.h
fusesdialog.h
mixerdialog.h
logsdialog.h
expodialog.h
contributorsdialog.h
customizesplashdialog.h
splashlibrary.h
splashlabel.h
burndialog.h
downloaddialog.h
cursorwidget.h
menuwidget.h
simulatordialog.h
xcursorwidget.h
xmenuwidget.h
xsimulatordialog.h
generaledit.h
modeledit.h
modelslist.h
mixerslist.h
mdichild.h
mainwindow.h
myslider.h
modelconfigdialog.h
qcustomplot.h
)
SET( companion9x_UIS
mdichild.ui
avroutputdialog.ui
comparedialog.ui
fusesdialog.ui
expodialog.ui
logsdialog.ui
mixerdialog.ui
preferencesdialog.ui
simulatordialog.ui
xsimulatordialog.ui
burnconfigdialog.ui
downloaddialog.ui
generaledit.ui
modeledit.ui
printdialog.ui
contributorsdialog.ui
customizesplashdialog.ui
splashlibrary.ui
burndialog.ui
modelconfigdialog.ui
)
IF ( SDL_FOUND )
SET( companion9x_SRCS
${companion9x_SRCS}
joystick.cpp
joystickdialog.cpp
)
SET( companion9x_MOC_HDRS
${companion9x_MOC_HDRS}
joystick.h
joystickdialog.h
)
SET( companion9x_UIS
${companion9x_UIS}
joystickdialog.ui
)
ENDIF( )
SET( companion9x_RCS
companion9x.qrc
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
)
MACRO (TODAY RESULT)
IF (WIN32)
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}})
ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}})
ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} 00.00.0000)
ENDIF (WIN32)
ENDMACRO (TODAY)
MACRO (NOW RESULT)
IF (WIN32)
EXECUTE_PROCESS(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}})
ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}})
ELSE (WIN32)
MESSAGE(SEND_ERROR "time not implemented")
SET(${RESULT} 00:00:00)
ENDIF (WIN32)
ENDMACRO (NOW)
TODAY(DATE)
NOW(TIME)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc @ONLY)
# Subversion_WC_INFO( ${PROJECT_SOURCE_DIR}/../${FIRMWARE} G9X )
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/firmwares/opentx/stamp-opentx.h.in ${CMAKE_CURRENT_BINARY_DIR}/stamp-opentx.h @ONLY)
SET( PATCH_FLAGS "--binary" )
IF( WIN32 )
SET( companion9x_SRCS ${companion9x_SRCS} icon.rc )
IF ( NOT MSVC )
SET(CMAKE_EXE_LINKER_FLAGS -mwindows)
ENDIF( )
ENDIF( )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} )
SET( LANGUAGES he pt ru de fr it sv cs )
FOREACH( language ${LANGUAGES} )
SET( companion9x_TS ${companion9x_TS} translations/companion9x_${language}.ts )
ENDFOREACH( language )
QT4_WRAP_UI( companion9x_SRCS ${companion9x_UIS} )
QT4_WRAP_CPP( companion9x_SRCS ${companion9x_MOC_HDRS} )
QT4_ADD_TRANSLATION( companion9x_QM ${companion9x_TS} )
QT4_ADD_RESOURCES( companion9x_SRCS ${companion9x_RCS} )
ADD_DEFINITIONS( -DQT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}" )
IF( APPLE )
ADD_EXECUTABLE( ${PROJECT_NAME} MACOSX_BUNDLE ${companion9x_SRCS} ${companion9x_QM} )
ELSE( )
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion9x_SRCS} ${companion9x_QM} )
ENDIF( )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} )
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
INSTALL( FILES companion9x.desktop DESTINATION share/applications )
INSTALL( FILES companion9x.png DESTINATION share/icons )
INSTALL( FILES ../linuxtools/45-taranis.rules DESTINATION /etc/udev/rules.d/ )
# Linux specific code
SET(OperatingSystem "Linux")
ELSE (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${QT_BINARY_DIR} )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF( WIN32 )
IF( MSVC )
SET( NSI_IN_FILE companion9x-vs.nsi.in )
ELSE( )
SET( NSI_IN_FILE companion9x-msys.nsi.in )
ENDIF( )
SET( SYSDIR "$ENV{windir}/system32" )
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../winbuild/${NSI_IN_FILE} ${CMAKE_CURRENT_BINARY_DIR}/companion9x.nsi @ONLY)
FIND_PROGRAM(NSIS_EXE makensis.exe PATHS
"C:/Program Files/NSIS"
"C:/Program Files (x86)/NSIS"
"C:/Programs/NSIS"
)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/companion9xInstall.exe
COMMAND "${NSIS_EXE}" ARGS companion9x.nsi
DEPENDS ${PROJECT_NAME} ${PROJECT_BINARY_DIR}/companion9x.nsi
COMMENT "Windows NSIS Installer")
ADD_CUSTOM_TARGET( installer
DEPENDS ${PROJECT_BINARY_DIR}/companion9xInstall.exe
SOURCES ${PROJECT_BINARY_DIR}/companion9x.nsi)
ENDIF( )
IF( APPLE )
SET(MACOSX_BUNDLE_ICON_FILE iconmac.icns)
IF( CMAKE_GENERATOR STREQUAL Xcode )
SET( WORK_DIR ${CMAKE_BINARY_DIR}/Debug )
ELSE( )
SET( WORK_DIR ${PROJECT_BINARY_DIR} )
ENDIF()
ADD_CUSTOM_TARGET( addframeworks ALL
COMMAND mkdir -p companion9x.app/Contents/Frameworks
COMMAND mkdir -p companion9x.app/Contents/Resources
COMMAND mkdir -p companion9x.app/Contents/translations
COMMAND rsync ${PROJECT_SOURCE_DIR}/images/${MACOSX_BUNDLE_ICON_FILE} companion9x.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE} # Copy the icon files
COMMAND rsync ${PROJECT_SOURCE_DIR}/../macbuild/lib* companion9x.app/Contents/Frameworks
#COMMAND rsync ${PROJECT_SOURCE_DIR}/../macbuild/libcrypto.1.0.0.dylib companion9x.app/Contents/Frameworks
COMMAND rsync -r --exclude=.svn ${PROJECT_SOURCE_DIR}/../macbuild/qt_menu.nib companion9x.app/Contents/Resources/
COMMAND rsync ${PROJECT_BINARY_DIR}/*.qm companion9x.app/Contents/translations
COMMAND ${QT_BINARY_DIR}/macdeployqt companion9x.app
WORKING_DIRECTORY ${WORK_DIR}
DEPENDS ${PROJECT_NAME} )
ADD_CUSTOM_TARGET( makedmg
COMMAND ${QT_BINARY_DIR}/macdeployqt companion9x.app -dmg -no-plugins
WORKING_DIRECTORY ${WORK_DIR}
DEPENDS addframeworks )
ENDIF( )
ADD_CUSTOM_TARGET( stamp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/version.h ${CMAKE_SOURCE_DIR}/../companion9x.stamp
DEPENDS ${CMAKE_BINARY_DIR}/version.h )
ADD_CUSTOM_TARGET( translations
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND lupdate-qt4 ${CMAKE_SOURCE_DIR} -ts ${companion9x_TS} )
SET(CPACK_PACKAGE_NAME "COMPANION9X")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "EEPROM Editor for the openTx open source firmware")
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
if(DPKG_PROGRAM)
SET(CPACK_GENERATOR "DEB")
execute_process(
COMMAND ${DPKG_PROGRAM} --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${C9X_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Romolo Manfredini <romolo.manfredini-nosp@m-gmail.com>")
SET(CPACK_DEBIAN_PACKAGE_VERSION ${C9X_VERSION})
SET(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${C9X_VERSION_MAJOR})
SET(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${C9X_VERSION_MINOR})
SET(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR))
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
else(DPKG_PROGRAM)
SET(CPACK_GENERATOR "RPM")
SET(CPACK_RPM_PACKAGE_VERSION ${C9X_VERSION})
SET(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${C9X_VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
endif(DPKG_PROGRAM)
INCLUDE(CPack)

View file

@ -0,0 +1,481 @@
#include "avroutputdialog.h"
#include "ui_avroutputdialog.h"
#include <QtGui>
#include "eeprominterface.h"
#include "flashinterface.h"
#if defined WIN32 || !defined __GNUC__
#include <Windows.h>
#include <WinBase.h>
#include <tlhelp32.h>
#define sleep(x) Sleep(x*1000)
#else
#include <unistd.h>
#include "mountlist.h"
#endif
avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg, QString wTitle, int closeBehaviour, bool displayDetails) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::avrOutputDialog),
kill_timer(NULL),
hasErrors(false)
{
ui->setupUi(this);
#ifdef __APPLE__
QFont newFont("Courier", 13);
ui->plainTextEdit->setFont(newFont);
ui->plainTextEdit->setAttribute(Qt::WA_MacNormalSize);
#endif
#if defined WIN32 || !defined __GNUC__
QFont newFont("Courier", 9);
ui->plainTextEdit->setFont(newFont);
#endif
cmdLine = prog;
closeOpt = closeBehaviour;
if (cmdLine.isEmpty()) {
if (arg.count()<2) {
closeOpt = AVR_DIALOG_FORCE_CLOSE;
QTimer::singleShot(0, this, SLOT(forceClose()));
} else {
sourceFile=arg.at(0);
destFile=arg.at(1);
if (!displayDetails) {
ui->plainTextEdit->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
} else {
ui->checkBox->setChecked(true);
}
ui->progressBar->setMaximum(127);
QTimer::singleShot(500, this, SLOT(doCopy()));
}
} else {
if(wTitle.isEmpty())
setWindowTitle(getProgrammer() + " " + tr("result"));
else
setWindowTitle(getProgrammer() + " - " + wTitle);
QFile exec;
winTitle=wTitle;
if (!(exec.exists(prog))) {
QMessageBox::critical(this, "companion9x", getProgrammer() + " " + tr("executable not found"));
closeOpt = AVR_DIALOG_FORCE_CLOSE;
QTimer::singleShot(0, this, SLOT(forceClose()));
} else {
foreach(QString str, arg) cmdLine.append(" " + str);
lfuse = 0;
hfuse = 0;
efuse = 0;
phase=0;
currLine.clear();
prevLine.clear();
if (!displayDetails) {
ui->plainTextEdit->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
} else {
ui->checkBox->setChecked(true);
}
process = new QProcess(this);
connect(process,SIGNAL(readyReadStandardError()), this, SLOT(doAddTextStdErr()));
connect(process,SIGNAL(started()),this,SLOT(doProcessStarted()));
connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(doAddTextStdOut()));
connect(process,SIGNAL(finished(int)),this,SLOT(doFinished(int)));
#if !__GNUC__
kill_timer = new QTimer(this);
connect(kill_timer, SIGNAL(timeout()), this, SLOT(killTimerElapsed()));
kill_timer->start(2000);
#endif
process->start(prog,arg);
}
}
}
# if !__GNUC__
BOOL KillProcessByName(char *szProcessToKill){
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); // Takes a snapshot of all the processes
if(hProcessSnap == INVALID_HANDLE_VALUE){
return( FALSE );
}
pe32.dwSize = sizeof(PROCESSENTRY32);
if(!Process32First(hProcessSnap, &pe32)){
CloseHandle(hProcessSnap);
return( FALSE );
}
do{
if(!strcmp(pe32.szExeFile,szProcessToKill)){ // checks if process at current position has the name of to be killed app
hProcess = OpenProcess(PROCESS_TERMINATE,0, pe32.th32ProcessID); // gets handle to process
TerminateProcess(hProcess,0); // Terminate process by handle
CloseHandle(hProcess); // close the handle
}
}while(Process32Next(hProcessSnap,&pe32)); // gets next member of snapshot
CloseHandle(hProcessSnap); // closes the snapshot handle
return( TRUE );
}
#endif
void avrOutputDialog::doCopy()
{
hasErrors=false;
char buf[READBUF];
char * pointer=buf;
QFile source(sourceFile);
int blocks=(source.size()/BLKSIZE);
ui->progressBar->setMaximum(blocks-1);
if (!source.open(QIODevice::ReadOnly)) {
QMessageBox::warning(this, tr("Error"),tr("Cannot open source file"));
hasErrors=true;
} else {
source.read(buf,READBUF);
source.close();
QFile dest(destFile);
if (!dest.open(QIODevice::WriteOnly)) {
QMessageBox::warning(this, tr("Error"),tr("Cannot write destination"));
hasErrors=true;
} else {
addText(tr("Writing file: "));
for (int i=0;i<blocks;i++) {
if (dest.write(pointer,BLKSIZE)!=BLKSIZE) {
hasErrors=true;
break;
};
dest.flush();
pointer+=BLKSIZE;
ui->progressBar->setValue(i);
if ((i%2)!=0)
addText("#");
}
dest.close();
}
}
doFinished(0);
}
void avrOutputDialog::killTimerElapsed()
{
delete kill_timer;
kill_timer = NULL;
# if !__GNUC__
KillProcessByName("tasklist.exe");
#endif
}
avrOutputDialog::~avrOutputDialog()
{
delete ui;
delete kill_timer;
}
void avrOutputDialog::runAgain(QString prog, QStringList arg, int closeBehaviour)
{
cmdLine = prog;
foreach(QString str, arg) cmdLine.append(" " + str);
closeOpt = closeBehaviour;
currLine.clear();
prevLine.clear();
process->start(prog,arg);
}
void avrOutputDialog::waitForFinish()
{
process->waitForFinished();
}
void avrOutputDialog::addText(const QString &text)
{
int val = ui->plainTextEdit->verticalScrollBar()->maximum();
ui->plainTextEdit->insertPlainText(text);
if(val!=ui->plainTextEdit->verticalScrollBar()->maximum())
ui->plainTextEdit->verticalScrollBar()->setValue(ui->plainTextEdit->verticalScrollBar()->maximum());
}
void avrOutputDialog::doAddTextStdOut()
{
QByteArray data = process->readAllStandardOutput();
QString text = QString(data);
QString temp;
int nlPos, pos, size;
addText(text);
currStdLine.append(text);
if (currStdLine.contains("size = ")) {
pos=currStdLine.lastIndexOf("size = ");
temp=currStdLine.mid(pos+7);
pos=temp.lastIndexOf("\n");
size=temp.left(pos).toInt();
ui->progressBar->setMaximum(size/2048);
}
if (currStdLine.contains("\n")) {
nlPos=currStdLine.lastIndexOf("\n");
prevStdLine=currStdLine.left(nlPos).trimmed();
currStdLine=currStdLine.mid(nlPos+1);
}
if (!currStdLine.isEmpty()) {
if (currStdLine.at(0)==QChar('.')) {
pos=currStdLine.lastIndexOf(".");
ui->progressBar->setValue(pos);
}
}
if (!currStdLine.isEmpty()) {
if (currStdLine.startsWith("Starting upload: [")) {
pos=(currStdLine.lastIndexOf("#")-19)/(MAX_FSIZE/204800.0);
ui->progressBar->setValue(pos);
}
}
if (text.contains("Complete ")) {
#if !__GNUC__
if (kill_timer) {
delete kill_timer;
kill_timer = NULL;
}
#endif
int start = text.indexOf("Complete ");
int end = text.indexOf("%");
if (start > 0) {
start += 9;
int value = text.mid(start, end-start).toInt();
ui->progressBar->setValue(value);
}
}
//addText("\n=====\n" + text + "\n=====\n");
if(text.contains(":010000")) //contains fuse info
{
QStringList stl = text.split(":01000000");
foreach (QString t, stl)
{
bool ok = false;
if(!lfuse) lfuse = t.left(2).toInt(&ok,16);
if(!hfuse && !ok) hfuse = t.left(2).toInt(&ok,16);
if(!efuse && !ok) efuse = t.left(2).toInt(&ok,16);
}
}
if (text.contains("-E-")) {
hasErrors = true;
}
}
QString avrOutputDialog::getProgrammer()
{
EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_TARANIS(eepromInterface->getBoard())) {
return "DFU Util";
} else if (eepromInterface->getBoard()==BOARD_SKY9X) {
return "SAM-BA";
} else {
return "AVRDUDE";
}
}
void avrOutputDialog::errorWizard()
{
QString output=ui->plainTextEdit->toPlainText();
if (output.contains("avrdude: Expected signature for")) { // wrong signature
int pos=output.indexOf("avrdude: Device signature = ");
bool fwexist=false;
QString DeviceStr="Unknown";
QString FwStr="";
if (pos>0) {
QString DeviceId=output.mid(pos+28,8);
if (DeviceId=="0x1e9602") {
DeviceStr="Atmega 64";
FwStr="\n"+tr("ie: OpenTX for 9X board or OpenTX for 9XR board");
fwexist=true;
} else if (DeviceId=="0x1e9702") {
DeviceStr="Atmega 128";
FwStr="\n"+tr("ie: OpenTX for M128 / 9X board or OpenTX for 9XR board with M128 chip");
fwexist=true;
} else if (DeviceId=="0x1e9703") {
DeviceStr="Atmega 1280";
} else if (DeviceId=="0x1e9704") {
DeviceStr="Atmega 1281";
} else if (DeviceId=="0x1e9801") {
DeviceStr="Atmega 2560";
FwStr="\n"+tr("ie: OpenTX for Gruvin9X board");
fwexist=true;
} else if (DeviceId=="0x1e9802") {
DeviceStr="Atmega 2561";
}
}
if (fwexist==false) {
QMessageBox::warning(this, "companion9x - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease check advanced burn options to set the correct cpu type.").arg(DeviceStr));
} else {
FirmwareInfo *firmware = GetCurrentFirmware();
QMessageBox::warning(this, "companion9x - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease select an appropriate firmware type to program it.").arg(DeviceStr)+FwStr+tr("\nYou are currently using:\n %1").arg(firmware->name));
}
}
}
void avrOutputDialog::doAddTextStdErr()
{
int nlPos;
int pbvalue;
QString avrphase;
QByteArray data = process->readAllStandardError();
QString text = QString(data);
currLine.append(text);
if (currLine.contains("#")) {
avrphase=currLine.left(1).toLower();
if (avrphase=="w") {
ui->progressBar->setStyleSheet("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: #ff0000; text-align:center;}:");
phase=1;
if(winTitle.isEmpty())
setWindowTitle(getProgrammer() + " - " + tr("Writing"));
else
setWindowTitle(getProgrammer() + " - " + winTitle + " - " + tr("Writing"));
pbvalue=currLine.count("#")*2;
ui->progressBar->setValue(pbvalue);
}
if (avrphase=="r") {
if (phase==0) {
ui->progressBar->setStyleSheet("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: #00ff00; text-align:center;}:");
if(winTitle.isEmpty())
setWindowTitle(getProgrammer() + " - " + tr("Reading"));
else
setWindowTitle(getProgrammer() + " - " + winTitle + " - " + tr("Reading"));
} else {
ui->progressBar->setStyleSheet("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: #0000ff; text-align:center;}:");
phase=2;
if(winTitle.isEmpty())
setWindowTitle(getProgrammer() + " - " + tr("Verifying"));
else
setWindowTitle(getProgrammer() + " - " + winTitle + " - " + tr("Verifying"));
}
pbvalue=currLine.count("#")*2;
ui->progressBar->setValue(pbvalue);
}
}
if (currLine.contains("\n")) {
nlPos=currLine.lastIndexOf("\n");
prevLine=currLine.left(nlPos).trimmed();
currLine=currLine.mid(nlPos+1);
}
if (text.contains("-E-") && !text.contains("-E- No receive file name")) {
hasErrors = true;
}
addText(text);
}
#define HLINE_SEPARATOR "================================================================================="
void avrOutputDialog::doFinished(int code=0)
{
addText("\n" HLINE_SEPARATOR);
if (code==1 && getProgrammer()=="SAM-BA")
code=0;
if (code) {
ui->checkBox->setChecked(true);
addText("\n" + getProgrammer() + " " + tr("done - exit code %1").arg(code));
} else if (hasErrors) {
ui->checkBox->setChecked(true);
addText("\n" + getProgrammer() + " " + tr("done with errors"));
} else if (!cmdLine.isEmpty()) {
addText("\n" + getProgrammer() + " " + tr("done - SUCCESSFUL"));
} else {
addText(tr("done - SUCCESSFUL"));
}
addText("\n" HLINE_SEPARATOR "\n");
if(lfuse || hfuse || efuse) addReadFuses();
switch(closeOpt)
{
case AVR_DIALOG_CLOSE_IF_SUCCESSFUL:
if (!hasErrors && !code) accept();
if (code) {
errorWizard();
}
break;
case AVR_DIALOG_FORCE_CLOSE:
if (hasErrors || code)
reject();
else
accept();
break;
case AVR_DIALOG_SHOW_DONE:
if (hasErrors || code) {
if (!cmdLine.isEmpty()) {
if (getProgrammer()!="AVRDUDE") {
QMessageBox::critical(this, "companion9x", getProgrammer() + " " + tr("did not finish correctly"));
} else {
int res = QMessageBox::question(this, "companion9x",getProgrammer() + " " + tr("did not finish correctly!\nDo you want some help ?"),QMessageBox::Yes | QMessageBox::No);
if (res != QMessageBox::No) {
errorWizard();
}
}
} else {
QMessageBox::critical(this, "companion9x", tr("Copy did not finish correctly"));
}
// reject();
} else {
if (!cmdLine.isEmpty()) {
ui->progressBar->setValue(100);
QMessageBox::information(this, "companion9x", getProgrammer() + " " + tr("finished correctly"));
accept();
} else {
QMessageBox::information(this, "companion9x", tr("Copy finished correctly"));
accept();
}
}
break;
default: //AVR_DIALOG_KEEP_OPEN
break;
}
}
void avrOutputDialog::doProcessStarted()
{
addText(HLINE_SEPARATOR "\n");
addText(tr("Started") + " " + getProgrammer() + "\n");
addText(cmdLine);
addText("\n" HLINE_SEPARATOR "\n");
}
void avrOutputDialog::addReadFuses()
{
addText(HLINE_SEPARATOR "\n");
addText(tr("FUSES: Low=%1 High=%2 Ext=%3").arg(lfuse,2,16,QChar('0')).arg(hfuse,2,16,QChar('0')).arg(efuse,2,16,QChar('0')));
addText("\n" HLINE_SEPARATOR "\n");
}
void avrOutputDialog::on_checkBox_toggled(bool checked) {
if (checked) {
ui->plainTextEdit->show();
} else {
ui->plainTextEdit->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
}
}
void avrOutputDialog::shrink() {
resize(0,0);
}
void avrOutputDialog::forceClose() {
accept();;
}

View file

@ -0,0 +1,67 @@
#ifndef AVROUTPUTDIALOG_H
#define AVROUTPUTDIALOG_H
#include <QDialog>
#include <QtGui>
#define AVR_DIALOG_CLOSE_IF_SUCCESSFUL 0x00
#define AVR_DIALOG_KEEP_OPEN 0x01
#define AVR_DIALOG_FORCE_CLOSE 0x02
#define AVR_DIALOG_SHOW_DONE 0x04
#define READBUF 65536
#define BLKSIZE 512
namespace Ui {
class avrOutputDialog;
}
class avrOutputDialog : public QDialog
{
Q_OBJECT
public:
explicit avrOutputDialog(QWidget *parent, QString prog, QStringList arg, QString wTitle, int closeBehaviour=AVR_DIALOG_CLOSE_IF_SUCCESSFUL, bool displayDetails=false);
~avrOutputDialog();
void addText(const QString &text);
void runAgain(QString prog, QStringList arg, int closeBehaviour=AVR_DIALOG_CLOSE_IF_SUCCESSFUL);
void waitForFinish();
void addReadFuses();
protected slots:
void doAddTextStdOut();
void doAddTextStdErr();
void doProcessStarted();
void doCopy();
void doFinished(int code);
void on_checkBox_toggled(bool checked);
void shrink();
void forceClose();
void killTimerElapsed();
void errorWizard();
private:
QString getProgrammer();
Ui::avrOutputDialog *ui;
QProcess *process;
QTimer *kill_timer;
QString cmdLine;
int closeOpt;
quint8 lfuse;
quint8 hfuse;
quint8 efuse;
QString prevLine;
QString currLine;
QString prevStdLine;
QString currStdLine;
int phase;
QString winTitle;
bool hasErrors;
QString sourceFile;
QString destFile;
};
#endif // AVROUTPUTDIALOG_H

View file

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>avrOutputDialog</class>
<widget class="QDialog" name="avrOutputDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>348</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>0</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Show Details</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>312</height>
</size>
</property>
<property name="font">
<font>
<family>Courier</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::WidgetWidth</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,423 @@
#include "burnconfigdialog.h"
#include "ui_burnconfigdialog.h"
#include "avroutputdialog.h"
#include "eeprominterface.h"
#include <QtGui>
#if !defined WIN32 && defined __GNUC__
#include <unistd.h>
#endif
burnConfigDialog::burnConfigDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::burnConfigDialog)
{
ui->setupUi(this);
ui->avrdude_programmer->model()->sort(0);
getSettings();
populateProgrammers();
EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_TARANIS(eepromInterface->getBoard())) {
setWindowTitle(tr("DFU-UTIL Configuration"));
ui->avrArgs->hide();
ui->avrdude_location->hide();
ui->avrdude_port->hide();
ui->avrdude_programmer->hide();
ui->label_av1->hide();
ui->label_av2->hide();
ui->label_av4->hide();
ui->label_av5->hide();
ui->pushButton->hide();
ui->pushButton_3->hide();
ui->pushButton_4->hide();
ui->label_sb1->hide();
ui->label_sb3->hide();
ui->samba_location->hide();
ui->samba_port->hide();
ui->sb_browse->hide();
} else if (eepromInterface->getBoard()==BOARD_SKY9X) {
setWindowTitle(tr("SAM-BA Configuration"));
ui->avrArgs->hide();
ui->avrdude_location->hide();
ui->avrdude_port->hide();
ui->avrdude_programmer->hide();
ui->label_av1->hide();
ui->label_av2->hide();
ui->label_av4->hide();
ui->label_av5->hide();
ui->pushButton->hide();
ui->pushButton_3->hide();
ui->pushButton_4->hide();
ui->label_dfu1->hide();
ui->dfu_location->hide();
ui->dfu_browse->hide();
} else {
setWindowTitle(tr("AVRDUDE Configuration"));
ui->label_sb1->hide();
ui->label_sb3->hide();
ui->samba_location->hide();
ui->samba_port->hide();
ui->sb_browse->hide();
ui->label_dfu1->hide();
ui->label_dfu2->hide();
ui->dfu_location->hide();
ui->dfu_browse->hide();
}
ui->label_av3->hide();
ui->avrdude_mcu->hide();
ui->label_sb2->hide();
ui->arm_mcu->hide();
ui->label_dfu2->hide();
ui->dfuArgs->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
connect(this,SIGNAL(accepted()),this,SLOT(putSettings()));
}
burnConfigDialog::~burnConfigDialog()
{
delete ui;
}
void burnConfigDialog::getSettings()
{
QSettings settings("companion9x", "companion9x");
#if defined WIN32 || !defined __GNUC__
avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString();
sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString();
dfuLoc = settings.value("dfu_location", QFileInfo("dfu-util.exe").absoluteFilePath()).toString();
#elif defined __APPLE__
avrLoc = settings.value("avrdude_location", "/usr/local/bin/avrdude").toString();
sambaLoc = settings.value("samba_location", "/usr/local/bin/sam-ba").toString();
dfuLoc = settings.value("dfu_location", QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath()).toString();
#else
avrLoc = settings.value("avrdude_location", "/usr/bin/avrdude").toString();
sambaLoc = settings.value("samba_location", "/usr/bin/sam-ba").toString();
dfuLoc = settings.value("dfu_location", QFileInfo("/usr/bin/dfu-util").absoluteFilePath()).toString();
#endif
QString str = settings.value("avr_arguments").toString();
avrArgs = str.split(" ", QString::SkipEmptyParts);
avrProgrammer = settings.value("programmer", QString("usbasp")).toString();
avrMCU = settings.value("mcu", QString("m64")).toString();
armMCU = settings.value("arm_mcu", QString("at91sam3s4-9x")).toString();
avrPort = settings.value("avr_port", "").toString();
sambaPort = settings.value("samba_port", "\\USBserial\\COM23").toString();
str = settings.value("dfu_arguments", "-a 0").toString();
dfuArgs = str.split(" ", QString::SkipEmptyParts);
ui->avrdude_location->setText(getAVRDUDE());
ui->avrArgs->setText(getAVRArgs().join(" "));
ui->samba_location->setText(getSAMBA());
ui->samba_port->setText(getSambaPort());
ui->dfu_location->setText(getDFU());
ui->dfuArgs->setText(getDFUArgs().join(" "));
int idx1 = ui->avrdude_programmer->findText(getProgrammer());
int idx2 = ui->avrdude_port->findText(getPort());
int idx3 = ui->avrdude_mcu->findText(getMCU());
int idx4 = ui->arm_mcu->findText(getArmMCU());
if(idx1>=0) ui->avrdude_programmer->setCurrentIndex(idx1);
if(idx2>=0) ui->avrdude_port->setCurrentIndex(idx2);
if(idx3>=0) ui->avrdude_mcu->setCurrentIndex(idx3);
if(idx4>=0) ui->arm_mcu->setCurrentIndex(idx4);
QFile file;
if (file.exists(avrLoc)) {
ui->pushButton_3->setEnabled(true);
} else {
ui->pushButton_3->setDisabled(true);
}
}
void burnConfigDialog::putSettings()
{
QSettings settings("companion9x", "companion9x");
settings.setValue("avrdude_location", avrLoc);
settings.setValue("programmer", avrProgrammer);
settings.setValue("mcu", avrMCU);
settings.setValue("avr_port", avrPort);
settings.setValue("avr_arguments", avrArgs.join(" "));
settings.setValue("samba_location", sambaLoc);
settings.setValue("samba_port", sambaPort);
settings.setValue("arm_mcu", armMCU);
settings.setValue("dfu_location", dfuLoc);
settings.setValue("dfu_arguments", dfuArgs.join(" "));
}
void burnConfigDialog::populateProgrammers()
{
QString fileName = QFileInfo(avrLoc).canonicalPath() + "/avrdude.conf"; //for windows
if(!QFileInfo(fileName).exists()) fileName = "/etc/avrdude.conf"; //for linux
if(!QFileInfo(fileName).exists()) fileName = "/etc/avrdude/avrdude.conf"; //for linux
if(!QFileInfo(fileName).exists()) return; // not found avrdude.conf - returning
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
QStringList items;
QString line = "";
QString prevline = "";
QTextStream in(&file);
while (!in.atEnd())
{
prevline = line;
line = in.readLine();
if(prevline.left(10).toLower()=="programmer")
items << line.section('"',1,1);
}
file.close();
items.sort();
QString avrProgrammer_temp = avrProgrammer;
ui->avrdude_programmer->clear();
ui->avrdude_programmer->addItems(items);
int idx1 = ui->avrdude_programmer->findText(avrProgrammer_temp);
if(idx1>=0) ui->avrdude_programmer->setCurrentIndex(idx1);
}
void burnConfigDialog::on_avrdude_programmer_currentIndexChanged(QString )
{
avrProgrammer = ui->avrdude_programmer->currentText();
}
void burnConfigDialog::on_avrdude_mcu_currentIndexChanged(QString )
{
avrMCU = ui->avrdude_mcu->currentText();
}
void burnConfigDialog::on_avrdude_location_editingFinished()
{
avrLoc = ui->avrdude_location->text();
if (avrLoc.isEmpty()) {
ui->pushButton_3->setDisabled(true);
} else {
QFile file;
if (file.exists(avrLoc)) {
ui->pushButton_3->setEnabled(true);
}
}
}
void burnConfigDialog::on_avrArgs_editingFinished()
{
avrArgs = ui->avrArgs->text().split(" ", QString::SkipEmptyParts);
}
void burnConfigDialog::on_avrdude_port_currentIndexChanged(QString )
{
avrPort = ui->avrdude_port->currentText();
}
void burnConfigDialog::on_samba_location_editingFinished()
{
sambaLoc = ui->samba_location->text();
}
void burnConfigDialog::on_samba_port_editingFinished()
{
sambaPort = ui->samba_port->text();
}
void burnConfigDialog::on_arm_mcu_currentIndexChanged(QString )
{
armMCU = ui->arm_mcu->currentText();
}
void burnConfigDialog::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Location"),ui->avrdude_location->text());
if(!fileName.isEmpty())
{
ui->avrdude_location->setText(fileName);
avrLoc = fileName;
}
}
void burnConfigDialog::on_sb_browse_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Location"),ui->samba_location->text());
if(!fileName.isEmpty())
{
ui->samba_location->setText(fileName);
sambaLoc = fileName;
}
}
void burnConfigDialog::on_dfu_browse_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Location"),ui->dfu_location->text());
if(!fileName.isEmpty())
{
ui->dfu_location->setText(fileName);
dfuLoc = fileName;
}
}
void burnConfigDialog::on_dfu_location_editingFinished()
{
dfuLoc = ui->dfu_location->text();
}
void burnConfigDialog::on_dfuArgs_editingFinished()
{
dfuArgs = ui->dfuArgs->text().split(" ", QString::SkipEmptyParts);
}
void burnConfigDialog::listProgrammers()
{
QStringList arguments;
arguments << "-c?";
avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "List available programmers", AVR_DIALOG_KEEP_OPEN, TRUE);
ad->setWindowIcon(QIcon(":/images/list.png"));
ad->show();
}
void burnConfigDialog::on_pushButton_3_clicked()
{
listProgrammers();
}
void burnConfigDialog::on_pushButton_4_clicked()
{
QStringList arguments;
arguments << "-?";
avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "Show help", AVR_DIALOG_KEEP_OPEN,TRUE);
ad->setWindowIcon(QIcon(":/images/configure.png"));
ad->show();
}
void burnConfigDialog::readFuses()
{
QStringList args = avrArgs;
if(!avrPort.isEmpty()) args << "-P" << avrPort;
QStringList str;
str << "-U" << "lfuse:r:-:i" << "-U" << "hfuse:r:-:i" << "-U" << "efuse:r:-:i";
QStringList arguments;
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << str;
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Read Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
ad->setWindowIcon(QIcon(":/images/fuses.png"));
ad->show();
}
void burnConfigDialog::restFuses(bool eeProtect)
{
//fuses
//avrdude -c usbasp -p m64 -U lfuse:w:<0x0E>:m
//avrdude -c usbasp -p m64 -U hfuse:w:<0x89>:m 0x81 for eeprom protection
//avrdude -c usbasp -p m64 -U efuse:w:<0xFF>:m
QMessageBox::StandardButton ret = QMessageBox::No;
ret = QMessageBox::warning(this, tr("companion9x"),
tr("<b><u>WARNING!</u></b><br>This will reset the fuses of %1 to the factory settings.<br>Writing fuses can mess up your radio.<br>Do this only if you are sure they are wrong!<br>Are you sure you want to continue?").arg(avrMCU),
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes)
{
QStringList args = avrArgs;
if(!avrPort.isEmpty()) args << "-P" << avrPort;
QStringList str;
if (avrMCU=="m2560") {
args << "-B8";
QString erStr = eeProtect ? "hfuse:w:0x11:m" : "hfuse:w:0x19:m";
str << "-U" << "lfuse:w:0xD7:m" << "-U" << erStr << "-U" << "efuse:w:0xFC:m";
//use hfuse = 0x81 to prevent eeprom being erased with every flashing
} else {
QString tempDir = QDir::tempPath();
QString tempFile;
QString lfuses;
tempFile = tempDir + "/ftemp.bin";
QStringList argread;
argread << "-c" << avrProgrammer << "-p" << avrMCU << args <<"-U" << "lfuse:r:"+tempFile+":r" ;
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, argread, "Reset Fuses",AVR_DIALOG_CLOSE_IF_SUCCESSFUL,FALSE);
ad->setWindowIcon(QIcon(":/images/fuses.png"));
ad->exec();
QFile file(tempFile);
if (file.exists() && file.size()==1) {
file.open(QIODevice::ReadOnly);
char bin_flash[1];
file.read(bin_flash, 1);
if (bin_flash[0]==0x0E) {
lfuses="lfuse:w:0x0E:m";
} else {
lfuses="lfuse:w:0x3F:m";
}
file.close();
unlink(tempFile.toAscii());
} else {
lfuses="lfuse:w:0x3F:m";
}
QString erStr = eeProtect ? "hfuse:w:0x81:m" : "hfuse:w:0x89:m";
str << "-U" << lfuses << "-U" << erStr << "-U" << "efuse:w:0xFF:m";
//use hfuse = 0x81 to prevent eeprom being erased with every flashing
}
QStringList arguments;
if (avrMCU=="m2560") {
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-u" << str;
} else {
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-B" << "100" << "-u" << str;
}
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Reset Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
ad->setWindowIcon(QIcon(":/images/fuses.png"));
ad->show();
}
}
void burnConfigDialog::on_advCtrChkB_toggled(bool checked)
{
EEPROMInterface *eepromInterface = GetEepromInterface();
if (checked) {
if (IS_TARANIS(eepromInterface->getBoard())) {
ui->label_dfu2->show();
ui->dfuArgs->show();
} else if (eepromInterface->getBoard()==BOARD_SKY9X) {
ui->label_sb2->show();
ui->arm_mcu->show();
} else {
ui->label_av3->show();
ui->avrdude_mcu->show();
QMessageBox::warning(this, tr("companion9x"),
tr("<b><u>WARNING!</u></b><br>Normally CPU type is automatically selected according to the chosen firmware.<br>If you change the CPU type the resulting eeprom could be inconsistent."),
QMessageBox::Ok);
}
} else {
if (IS_TARANIS(eepromInterface->getBoard())) {
ui->label_dfu2->hide();
ui->dfuArgs->hide();
} else if (eepromInterface->getBoard()==BOARD_SKY9X) {
ui->label_sb2->hide();
ui->arm_mcu->hide();
} else {
ui->label_av3->hide();
ui->avrdude_mcu->hide();
}
}
QTimer::singleShot(0, this, SLOT(shrink()));
}
void burnConfigDialog::shrink()
{
resize(0,0);
}

View file

@ -0,0 +1,76 @@
#ifndef BURNCONFIGDIALOG_H
#define BURNCONFIGDIALOG_H
#include <QDialog>
#include <QtGui>
#define MEM_TYPE_EEPROM 1
#define MEM_TYPE_FLASH 2
#define OPR_TYPE_READ 1
#define OPR_TYPE_WRITE 2
namespace Ui {
class burnConfigDialog;
}
class burnConfigDialog : public QDialog {
Q_OBJECT
public:
burnConfigDialog(QWidget *parent = 0);
~burnConfigDialog();
QString getAVRDUDE() {return avrLoc;}
QString getSAMBA() {return sambaLoc;}
QString getDFU() {return dfuLoc;}
QStringList getAVRArgs() {return avrArgs;}
QStringList getDFUArgs() {return dfuArgs;}
QString getProgrammer() {return avrProgrammer;}
QString getMCU() {return avrMCU;}
QString getArmMCU() {return armMCU;}
QString getPort() {return avrPort;}
QString getSambaPort() {return sambaPort;}
void listProgrammers();
void restFuses(bool eeProtect);
void readFuses();
private:
Ui::burnConfigDialog *ui;
void populateProgrammers();
QString avrLoc;
QString sambaLoc;
QString dfuLoc;
QStringList avrArgs;
QString avrProgrammer;
QString avrMCU;
QString armMCU;
QString avrPort;
QString sambaPort;
QStringList dfuArgs;
private slots:
void shrink();
void on_avrArgs_editingFinished();
void on_pushButton_4_clicked();
void on_pushButton_3_clicked();
void on_pushButton_clicked();
void on_avrdude_location_editingFinished();
void on_avrdude_programmer_currentIndexChanged(QString );
void on_avrdude_mcu_currentIndexChanged(QString );
void on_avrdude_port_currentIndexChanged(QString );
void on_samba_location_editingFinished();
void on_samba_port_editingFinished();
void on_arm_mcu_currentIndexChanged(QString );
void on_sb_browse_clicked();
void on_dfu_browse_clicked();
void on_dfu_location_editingFinished();
void on_dfuArgs_editingFinished();
void on_advCtrChkB_toggled(bool checked);
void getSettings();
void putSettings();
};
#endif // BURNCONFIGDIALOG_H

View file

@ -0,0 +1,799 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>burnConfigDialog</class>
<widget class="QDialog" name="burnConfigDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>335</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>531</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Programmer Configuration</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/images/configure.png</normaloff>:/images/configure.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="9" column="2">
<widget class="QLineEdit" name="dfu_location">
<property name="toolTip">
<string>Location of sam-ba executable</string>
</property>
<property name="whatsThis">
<string>The location of the AVRDUDE executable.</string>
</property>
<property name="text">
<string notr="true">dfu-util</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_dfu1">
<property name="text">
<string>DFU-Util Location</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="avrdude_location">
<property name="toolTip">
<string>Location of AVRDUDE executable</string>
</property>
<property name="whatsThis">
<string>The location of the AVRDUDE executable.</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="4" rowspan="2">
<widget class="QPushButton" name="pushButton">
<property name="whatsThis">
<string>Use this button to browse and look for the AVRDUDE executable file.</string>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_av2">
<property name="text">
<string>Programmer</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="avrdude_programmer">
<property name="whatsThis">
<string>Programmer used for communicating with the controller.
Please consult the programmer's documentation and the AVRDUDE documentation to select the appropriate programmer.</string>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAlphabetically</enum>
</property>
<item>
<property name="text">
<string notr="true">c2n232i</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dasa3</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dasa</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">siprog</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">ponyser</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">89isp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">frank-stk200</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">blaster</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">ere-isp-avr</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">atisp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dapa</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">xil</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">futurlec</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">abcmini</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">picoweb</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">sp12</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">alf</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bascom</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dt006</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">pony-stk200</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk200</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bsd</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">pavr</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dragon_pdi</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dragon_dw</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dragon_hvsp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dragon_pp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dragon_isp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dragon_jtag</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2pdi</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2avr32</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtagmkII_avr32</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2dw</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2isp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2fast</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag2slow</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtagmkII</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag1slow</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtag1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">jtagmkI</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avr911</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avr109</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">butterfly</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">usbtiny</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">usbasp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avr910</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk600hvsp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk600pp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk600</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk500hvsp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk500pp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk500v2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mib510</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk500v1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stk500</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">buspirate</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avrisp2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avrispmkII</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avrispv2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avrisp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">arduino</string>
</property>
</item>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="pushButton_3">
<property name="whatsThis">
<string>List all available programmers.</string>
</property>
<property name="text">
<string>List Available</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="avrArgs">
<property name="toolTip">
<string>Extra arguments that will be passed to AVRDUDE on every call</string>
</property>
<property name="whatsThis">
<string>Extra arguments used in AVRDUDE.
This can be used for providing extra information to AVRDUDE.
Please only use this if you know what you are doing. There are no error checks and you could cripple your controller.</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_av5">
<property name="text">
<string>Extra Arguments</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QPushButton" name="pushButton_4">
<property name="whatsThis">
<string>Show AVRDUDE help</string>
</property>
<property name="text">
<string>Show Help</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="avrdude_port">
<property name="whatsThis">
<string>Communication port to the programmer.
</string>
</property>
<item>
<property name="text">
<string notr="true"/>
</property>
</item>
<item>
<property name="text">
<string notr="true">usb</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com3</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">lpt1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">lpt2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">lpt3</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">lpt4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">avrdoper</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">/dev/ttyUSB0</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">/dev/ttyUSB1</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_av4">
<property name="text">
<string>Port</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_av1">
<property name="text">
<string>AVRDUDE Location</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_av3">
<property name="text">
<string>MCU</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="avrdude_mcu">
<property name="toolTip">
<string>CPU of your TX</string>
</property>
<property name="whatsThis">
<string>CPU present on your 9x radio
Should be m64 for stock radios
m2560 for v4.1 boards</string>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAlphabetically</enum>
</property>
<item>
<property name="text">
<string notr="true">m64</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">m128</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">m2560</string>
</property>
</item>
</widget>
</item>
<item row="7" column="2">
<widget class="QComboBox" name="arm_mcu">
<property name="toolTip">
<string>CPU of your TX</string>
</property>
<property name="whatsThis">
<string>CPU present on your 9x radio
Should be m64 for stock radios
m2560 for v4.1 boards</string>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAlphabetically</enum>
</property>
<item>
<property name="text">
<string notr="true">at91sam3s4-9x</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_sb1">
<property name="text">
<string>SAM-BA Location</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="samba_location">
<property name="toolTip">
<string>Location of sam-ba executable</string>
</property>
<property name="whatsThis">
<string>The location of the AVRDUDE executable.</string>
</property>
<property name="text">
<string notr="true">sam-ba.exe</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_sb2">
<property name="text">
<string>ARM MCU</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_sb3">
<property name="text">
<string>Port</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLineEdit" name="samba_port">
<property name="toolTip">
<string>sam-ba serial port</string>
</property>
<property name="whatsThis">
<string>The location of the AVRDUDE executable.</string>
</property>
<property name="text">
<string notr="true">\USBserial\COM23</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_dfu2">
<property name="text">
<string>Alternate device</string>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QLineEdit" name="dfuArgs">
<property name="toolTip">
<string>Extra arguments that will be passed to AVRDUDE on every call</string>
</property>
<property name="whatsThis">
<string>Extra arguments used in AVRDUDE.
This can be used for providing extra information to AVRDUDE.
Please only use this if you know what you are doing. There are no error checks and you could cripple your controller.</string>
</property>
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QPushButton" name="sb_browse">
<property name="whatsThis">
<string>Use this button to browse and look for the AVRDUDE executable file.</string>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QPushButton" name="dfu_browse">
<property name="whatsThis">
<string>Use this button to browse and look for the AVRDUDE executable file.</string>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="QCheckBox" name="advCtrChkB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Use advanced controls</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>avrdude_location</tabstop>
<tabstop>pushButton</tabstop>
<tabstop>avrdude_programmer</tabstop>
<tabstop>pushButton_3</tabstop>
<tabstop>avrdude_mcu</tabstop>
<tabstop>avrdude_port</tabstop>
<tabstop>avrArgs</tabstop>
<tabstop>pushButton_4</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>burnConfigDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>burnConfigDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -0,0 +1,728 @@
#include "burndialog.h"
#include "ui_burndialog.h"
#include <QtGui>
#include "eeprominterface.h"
#include "helpers.h"
#include "splashlibrary.h"
#include "flashinterface.h"
#include "hexinterface.h"
burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * backupEE, QString DocName):
QDialog(parent),
ui(new Ui::burnDialog),
hexfileName(fileName),
backup(backupEE),
hexType(Type)
{
ui->setupUi(this);
ui->SplashFrame->hide();
ui->FramFWInfo->hide();
ui->EEbackupCB->hide();
ui->EEbackupCB->setCheckState(*backup ? Qt::Checked : Qt::Unchecked);
if (Type == 2) {
ui->EEpromCB->hide();
ui->profile_label->hide();
ui->patchcalib_CB->hide();
ui->patchhw_CB->hide();
ui->InvertColorButton->setDisabled(true);
this->setWindowTitle(tr("Write firmware to TX"));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->hide();
}
} else {
ui->FlashLoadButton->setText(tr("Load eEprom"));
ui->profile_label->hide();
ui->patchcalib_CB->hide();
ui->patchhw_CB->hide();
ui->EEpromCB->hide();
ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true);
ui->InvertColorButton->setDisabled(true);
ui->BurnFlashButton->setDisabled(true);
ui->ImageFileName->clear();
ui->FwImage->clear();
ui->FWFileName->clear();
ui->DateField->clear();
ui->SVNField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
ui->BurnFlashButton->setDisabled(true);
ui->EEbackupCB->hide();
if (DocName.isEmpty()) {
this->setWindowTitle(tr("Write models to TX"));
} else {
this->setWindowTitle(tr("Write %1 to TX").arg(DocName));
}
QSettings settings("companion9x", "companion9x");
int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
settings.beginGroup(profile);
QString Name=settings.value("Name","").toString();
settings.endGroup();
settings.endGroup();
ui->profile_label->setText(tr("Current profile")+QString(": ")+Name);
}
if (!hexfileName->isEmpty()) {
ui->FWFileName->setText(*hexfileName);
if (Type==2) {
checkFw(*hexfileName);
} else {
burnraw=false;
if (checkeEprom(*hexfileName)) {
QSettings settings("companion9x", "companion9x");
int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
settings.beginGroup(profile);
QString Name=settings.value("Name","").toString();
QString calib=settings.value("StickPotCalib","").toString();
QString trainercalib=settings.value("TrainerCalib","").toString();
QString DisplaySet=settings.value("Display","").toString();
QString BeeperSet=settings.value("Beeper","").toString();
QString HapticSet=settings.value("Haptic","").toString();
QString SpeakerSet=settings.value("Speaker","").toString();
settings.endGroup();
settings.endGroup();
if (!Name.isEmpty()) {
ui->profile_label->show();
ui->patchcalib_CB->show();
ui->patchhw_CB->show();
// TODO I hardcode the number of pots here, should be dependant on the board?
if (!((calib.length()==(NUM_STICKS+3)*12) && (trainercalib.length()==16))) {
ui->patchcalib_CB->setDisabled(true);
}
if (!((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6))) {
ui->patchhw_CB->setDisabled(true);
}
} else {
ui->profile_label->hide();
}
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show();
} else {
ui->EEpromCB->setChecked(false);
}
ui->BurnFlashButton->setEnabled(true);
}
}
ui->FWFileName->hide();
ui->FlashLoadButton->hide();
hexfileName->clear();
}
else if (Type==2) {
QSettings settings("companion9x", "companion9x");
QString FileName;
FileName = settings.value("lastFw").toString();
QFile file(FileName);
if (file.exists()) {
checkFw(FileName);
}
}
resize(0, 0);
}
burnDialog::~burnDialog() {
delete ui;
}
void burnDialog::on_FlashLoadButton_clicked()
{
QString fileName;
QSettings settings("companion9x", "companion9x");
ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true);
ui->InvertColorButton->setDisabled(true);
ui->BurnFlashButton->setDisabled(true);
ui->ImageFileName->clear();
ui->FwImage->clear();
ui->FWFileName->clear();
ui->DateField->clear();
ui->SVNField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
ui->BurnFlashButton->setDisabled(true);
ui->EEbackupCB->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
if (hexType==2) {
fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
checkFw(fileName);
} else {
QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to write to EEPROM memory"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER));
if (checkeEprom(fileName)) {
if (burnraw==false) {
ui->BurnFlashButton->setEnabled(true);
ui->profile_label->show();
ui->patchcalib_CB->show();
ui->patchhw_CB->show();
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show();
} else {
ui->EEpromCB->setChecked(false);
}
} else {
ui->BurnFlashButton->setEnabled(true);
ui->profile_label->hide();
ui->patchcalib_CB->setChecked(false);
ui->patchhw_CB->setChecked(false);
ui->patchhw_CB->hide();
ui->patchcalib_CB->hide();
}
QTimer::singleShot(0, this, SLOT(shrink()));
}
}
}
void burnDialog::checkFw(QString fileName)
{
if (fileName.isEmpty()) {
return;
}
QSettings settings("companion9x", "companion9x");
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->show();
} else {
ui->EEbackupCB->setChecked(false);
*backup=false;
}
ui->FWFileName->setText(fileName);
FlashInterface flash(fileName);
if (flash.isValid()) {
ui->FramFWInfo->show();
ui->DateField->setText(flash.getDate() + " " + flash.getTime());
ui->SVNField->setText(flash.getSvn());
ui->ModField->setText(flash.getBuild());
ui->BurnFlashButton->setEnabled(true);
ui->BurnFlashButton->setText(tr("Burn to TX"));
if (flash.hasSplash()) {
ui->SplashFrame->show();
ui->ImageLoadButton->setEnabled(true);
ui->libraryButton->setEnabled(true);
ui->FwImage->setFixedSize(flash.getSplashWidth(),flash.getSplashHeight());
ui->imageLabel->setFixedSize(flash.getSplashWidth(),flash.getSplashHeight());
ui->FwImage->show();
ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash()));
QString ImageStr = settings.value("SplashImage", "").toString();
bool PatchFwCB = settings.value("patchImage", false).toBool();
if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr);
ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat())));
ui->InvertColorButton->setEnabled(true);
ui->PreferredImageCB->setChecked(true);
ui->PatchFWCB->setChecked(PatchFwCB);
}
else {
QString fileName=ui->ImageFileName->text();
if (!fileName.isEmpty()) {
QImage image(fileName);
if (!image.isNull()) {
ui->InvertColorButton->setEnabled(true);
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(flash.getSplashFormat())));
ui->PatchFWCB->setEnabled(true);
ui->PatchFWCB->setChecked(PatchFwCB);
} else {
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
ui->PreferredImageCB->setDisabled(true);
}
} else {
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
ui->PreferredImageCB->setDisabled(true);
}
}
} else {
ui->FwImage->hide();
ui->ImageFileName->setText("");
ui->SplashFrame->hide();
}
} else {
QMessageBox::warning(this, tr("Warning"), tr("%1 is not a known firmware").arg(fileName));
ui->BurnFlashButton->setText(tr("Burn anyway !"));
ui->BurnFlashButton->setEnabled(true);
}
QTimer::singleShot(0, this, SLOT(shrink()));
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
}
bool burnDialog::checkeEprom(QString fileName)
{
if (fileName.isEmpty()) {
return false;
}
QFile file(fileName);
if (!file.exists()) {
QMessageBox::critical(this, tr("Error"), tr("Unable to find file %1!").arg(fileName));
return false;
}
burnraw=false;
int fileType = getFileType(fileName);
if (fileType==FILE_TYPE_XML) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QMessageBox::critical(this, tr("Error"),tr("Error opening file %1:\n%2.").arg(fileName).arg(file.errorString()));
return false;
}
QTextStream inputStream(&file);
XmlInterface(inputStream).load(radioData);
} else if (fileType==FILE_TYPE_HEX || fileType==FILE_TYPE_EEPE) { //read HEX file
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QMessageBox::critical(this, tr("Error"),tr("Error opening file %1:\n%2.").arg(fileName).arg(file.errorString()));
return false;
}
QDomDocument doc(ER9X_EEPROM_FILE_TYPE);
bool xmlOK = doc.setContent(&file);
if(xmlOK) {
if (!LoadEepromXml(radioData, doc)){
return false;
}
}
file.reset();
QTextStream inputStream(&file);
if (fileType==FILE_TYPE_EEPE) { // read EEPE file header
QString hline = inputStream.readLine();
if (hline!=EEPE_EEPROM_FILE_HEADER) {
file.close();
return false;
}
}
uint8_t eeprom[EESIZE_RLC_MAX];
int eeprom_size = HexInterface(inputStream).load(eeprom, EESIZE_RLC_MAX);
if (!eeprom_size) {
int res = QMessageBox::question(this, "companion9x",tr("Invalid binary EEPROM File %1, Proceed anyway ?").arg(fileName),QMessageBox::Yes | QMessageBox::No);
if (res == QMessageBox::No) {
return false;
}
burnraw=true;
ui->FWFileName->setText(fileName);
return true;
}
file.close();
if (!LoadEeprom(radioData, eeprom, eeprom_size)) {
int res = QMessageBox::question(this, "companion9x",tr("Invalid binary EEPROM File %1, Proceed anyway ?").arg(fileName),QMessageBox::Yes | QMessageBox::No);
if (res == QMessageBox::No) {
return false;
}
burnraw=true;
ui->FWFileName->setText(fileName);
return true;
}
} else if (fileType==FILE_TYPE_BIN) { //read binary
int eeprom_size = file.size();
if (!file.open(QFile::ReadOnly)) { //reading binary file - TODO HEX support
QMessageBox::critical(this, tr("Error"),tr("Error opening file %1:\n%2.").arg(fileName).arg(file.errorString()));
return false;
}
uint8_t *eeprom = (uint8_t *)malloc(eeprom_size);
memset(eeprom, 0, eeprom_size);
long result = file.read((char*)eeprom, eeprom_size);
file.close();
if (result != eeprom_size) {
QMessageBox::critical(this, tr("Error"),tr("Error reading file %1:\n%2.").arg(fileName).arg(file.errorString()));
return false;
}
if (!LoadEeprom(radioData, eeprom, eeprom_size)) {
int res = QMessageBox::question(this, "companion9x",tr("Invalid binary EEPROM File %1, Proceed anyway ?").arg(fileName),QMessageBox::Yes | QMessageBox::No);
if (res == QMessageBox::No) {
return false;
}
burnraw=true;
}
}
ui->FWFileName->setText(fileName);
return true;
}
void burnDialog::on_ImageLoadButton_clicked()
{
QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
QSettings settings("companion9x", "companion9x");
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
ui->InvertColorButton->setDisabled(true);
return;
}
ui->ImageFileName->setText(fileName);
ui->InvertColorButton->setEnabled(true);
if (ui->imageLabel->width()!=128) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
} else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
}
ui->PatchFWCB->setEnabled(true);
}
}
void burnDialog::on_libraryButton_clicked()
{
QString fileName;
splashLibrary *ld = new splashLibrary(this,&fileName);
ld->exec();
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
ui->InvertColorButton->setDisabled(true);
return;
}
ui->ImageFileName->setText(fileName);
ui->InvertColorButton->setEnabled(true);
if (ui->imageLabel->width()!=128) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
} else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
}
ui->PatchFWCB->setEnabled(true);
}
}
void burnDialog::on_BurnFlashButton_clicked()
{
if (hexType==2) {
QString fileName=ui->FWFileName->text();
if (!fileName.isEmpty()) {
QSettings settings("companion9x", "companion9x");
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
settings.setValue("lastFw", fileName);
if (ui->PatchFWCB->isChecked()) {
settings.setValue("patchImage", true);
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height());
if (!image.isNull()) {
QString tempDir = QDir::tempPath();
QString tempFile;
if (getFileType(fileName) == FILE_TYPE_HEX)
tempFile = tempDir + "/flash.hex";
else
tempFile = tempDir + "/flash.bin";
FlashInterface flash(fileName);
flash.setSplash(image);
if (flash.saveFlash(tempFile) > 0) {
hexfileName->clear();
hexfileName->append(tempFile);
} else {
hexfileName->clear();
QMessageBox::critical(this, tr("Warning"), tr("Cannot save customized firmware"));
}
} else {
hexfileName->clear();
QMessageBox::critical(this, tr("Warning"), tr("Custom image not found"));
}
} else {
settings.setValue("patchImage", false);
hexfileName->clear();
hexfileName->append(fileName);
}
} else {
QMessageBox::critical(this, tr("Warning"), tr("No firmware selected"));
hexfileName->clear();
}
}
if (hexType==1) {
QSettings settings("companion9x", "companion9x");
int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
settings.beginGroup(profile);
QString calib=settings.value("StickPotCalib","").toString();
QString trainercalib=settings.value("TrainerCalib","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots);
int8_t vBatCalib=(int8_t)settings.value("VbatCalib", radioData.generalSettings.vBatCalib).toInt();
int8_t currentCalib=(int8_t)settings.value("currentCalib", radioData.generalSettings.currentCalib).toInt();
int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", radioData.generalSettings.PPM_Multiplier).toInt();
uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", radioData.generalSettings.stickMode).toUInt();
uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",radioData.generalSettings.vBatWarn).toUInt();
QString DisplaySet=settings.value("Display","").toString();
QString BeeperSet=settings.value("Beeper","").toString();
QString HapticSet=settings.value("Haptic","").toString();
QString SpeakerSet=settings.value("Speaker","").toString();
settings.endGroup();
settings.endGroup();
bool patch=false;
if (ui->patchcalib_CB->isChecked()) {
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
radioData.generalSettings.calibMid[i]=byte16;
Byte=calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
radioData.generalSettings.calibSpanNeg[i]=byte16;
Byte=calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
radioData.generalSettings.calibSpanPos[i]=byte16;
}
for (int i=0; i<4; i++) {
Byte=trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
radioData.generalSettings.trainer.calib[i]=byte16;
}
radioData.generalSettings.currentCalib=currentCalib;
radioData.generalSettings.vBatCalib=vBatCalib;
radioData.generalSettings.PPM_Multiplier=PPM_Multiplier;
patch=true;
} else {
QMessageBox::critical(this, tr("Warning"), tr("Wrong radio calibration data in profile, eeprom not patched"));
}
}
if (ui->patchhw_CB->isChecked()) {
if ((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6)) {
radioData.generalSettings.vBatWarn=vBatWarn;
radioData.generalSettings.stickMode=GSStickMode;
uint8_t byte8u;
int8_t byte8;
bool ok;
byte8=(int8_t)DisplaySet.mid(0,2).toInt(&ok,16);
if (ok)
radioData.generalSettings.optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)DisplaySet.mid(2,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.contrast=byte8u;
byte8u=(uint8_t)DisplaySet.mid(4,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.backlightBright=byte8u;
byte8u=(uint8_t)BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.beeperMode=(BeeperMode)byte8u;
byte8=(int8_t)BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
radioData.generalSettings.beeperLength=byte8;
byte8u=(uint8_t)HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.hapticMode=(BeeperMode)byte8u;
byte8u=(uint8_t)HapticSet.mid(2,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.hapticStrength=byte8u;
byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
radioData.generalSettings.hapticLength=byte8;
byte8u=(uint8_t)SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.speakerMode=byte8u;
byte8u=(uint8_t)SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.speakerPitch=byte8u;
byte8u=(uint8_t)SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
radioData.generalSettings.speakerVolume=byte8u;
patch=true;
} else {
QMessageBox::critical(this, tr("Warning"), tr("Wrong radio setting data in profile, eeprom not patched"));
}
QString fileName;
if (patch) {
QString tempDir = QDir::tempPath();
fileName = tempDir + "/temp.bin";
QFile file(fileName);
uint8_t *eeprom = (uint8_t*)malloc(GetEepromInterface()->getEEpromSize());
int eeprom_size = 0;
eeprom_size = GetEepromInterface()->save(eeprom, radioData, GetCurrentFirmwareVariant());
if (!eeprom_size) {
QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString()));
hexfileName->clear();
}
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString()));
hexfileName->clear();
}
QTextStream outputStream(&file);
long result = file.write((char*)eeprom, eeprom_size);
if(result!=eeprom_size) {
QMessageBox::warning(this, tr("Error"),tr("Error writing file %1:\n%2.").arg(fileName).arg(file.errorString()));
hexfileName->clear();
}
hexfileName->clear();
hexfileName->append(fileName);
} else {
hexfileName->clear();
hexfileName->append(ui->FWFileName->text());
}
} else {
hexfileName->clear();
hexfileName->append(ui->FWFileName->text());
}
}
this->close();
}
void burnDialog::on_cancelButton_clicked()
{
hexfileName->clear();
this->close();
}
void burnDialog::on_InvertColorButton_clicked()
{
if (ui->imageLabel->pixmap()) {
QImage image = ui->imageLabel->pixmap()->toImage();
image.invertPixels();
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
}
}
void burnDialog::on_EEpromCB_toggled(bool checked)
{
if (ui->EEpromCB->isChecked()) {
*backup=true;
} else {
*backup=false;
}
}
void burnDialog::on_PreferredImageCB_toggled(bool checked)
{
QString tmpFileName;
if (checked) {
QSettings settings("companion9x", "companion9x");
QString ImageStr = settings.value("SplashImage", "").toString();
if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr);
if (ui->imageLabel->width()!=128) {
Image=Image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = Image.width();
int height = Image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = Image.pixel(i, j);
gray = qGray(col);
Image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
} else {
Image=Image.convertToFormat(QImage::Format_Mono);
}
ui->imageLabel->setPixmap(QPixmap::fromImage(Image));
ui->InvertColorButton->setEnabled(true);
ui->PreferredImageCB->setChecked(true);
ui->ImageFileName->setDisabled(true);
ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true);
ui->PatchFWCB->setEnabled(true);
}
} else {
ui->imageLabel->clear();
ui->ImageLoadButton->setEnabled(true);
ui->libraryButton->setEnabled(true);
tmpFileName = ui->ImageFileName->text();
if (!tmpFileName.isEmpty()) {
QImage image(tmpFileName);
if (!image.isNull()) {
if (ui->imageLabel->width()!=128) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
} else {
image=image.convertToFormat(QImage::Format_Mono);
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
ui->InvertColorButton->setEnabled(true);
ui->ImageFileName->setEnabled(true);
ui->PatchFWCB->setDisabled(false);
} else {
ui->InvertColorButton->setDisabled(true);
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
}
} else {
ui->InvertColorButton->setDisabled(true);
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
}
}
}
void burnDialog::shrink()
{
resize(0,0);
}
void burnDialog::on_EEbackupCB_clicked()
{
if (ui->EEbackupCB->isChecked()) {
*backup=true;
} else {
*backup=false;
}
}

View file

@ -0,0 +1,60 @@
#ifndef BURNDIALOG_H
#define BURNDIALOG_H
#include <QtGui>
#include <QDialog>
#include "eeprominterface.h"
#include "flashinterface.h"
#include "xmlinterface.h"
#define XML_FILES_FILTER "XML files (*.xml);;"
#define HEX_FILES_FILTER "HEX files (*.hex);;"
#define BIN_FILES_FILTER "BIN files (*.bin);;"
#define EEPE_FILES_FILTER "EEPE EEPROM files (*.eepe);;"
#define EEPM_FILES_FILTER "EEPE MODEL files (*.eepm);;"
// #define EEPROM_FILES_FILTER "EEPE files (*.xml *.eepe *.eepm *.bin *.hex);;" XML_FILES_FILTER EEPE_FILES_FILTER EEPM_FILES_FILTER BIN_FILES_FILTER HEX_FILES_FILTER
#define EEPROM_FILES_FILTER "EEPE files (*.eepe *.bin *.hex);;" EEPE_FILES_FILTER BIN_FILES_FILTER HEX_FILES_FILTER
#define FLASH_FILES_FILTER "FLASH files (*.bin *.hex);;" BIN_FILES_FILTER HEX_FILES_FILTER
#define EXTERNAL_EEPROM_FILES_FILTER "EEPROM files (*.bin *.hex);;" BIN_FILES_FILTER HEX_FILES_FILTER
#define ER9X_EEPROM_FILE_TYPE "ER9X_EEPROM_FILE"
#define EEPE_EEPROM_FILE_HEADER "EEPE EEPROM FILE"
#define EEPE_MODEL_FILE_HEADER "EEPE MODEL FILE"
namespace Ui
{
class burnDialog;
}
class burnDialog : public QDialog
{
Q_OBJECT
public:
explicit burnDialog(QWidget *parent = 0, int Type = 2, QString * fileName = NULL, bool * backupEE=NULL, QString docname="");
~burnDialog();
private slots:
void on_FlashLoadButton_clicked();
void on_ImageLoadButton_clicked();
void on_libraryButton_clicked();
void on_BurnFlashButton_clicked();
void on_cancelButton_clicked();
void on_InvertColorButton_clicked();
void on_EEbackupCB_clicked();
void on_PreferredImageCB_toggled(bool checked);
void on_EEpromCB_toggled(bool checked);
void checkFw(QString fileName);
bool checkeEprom(QString fileName);
void shrink();
private:
Ui::burnDialog *ui;
QString * hexfileName;
bool * backup;
int hexType;
RadioData radioData;
bool burnraw;
};
#endif // BURNDIALOG_H

494
companion/src/burndialog.ui Normal file
View file

@ -0,0 +1,494 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>burnDialog</class>
<widget class="QDialog" name="burnDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>418</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>440</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Customize Splash</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/images/c_home.png</normaloff>:/images/c_home.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="hs2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="BurnFlashButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Burn to TX</string>
</property>
</widget>
</item>
<item>
<spacer name="hs2_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="5" column="0">
<widget class="QCheckBox" name="patchcalib_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Modify calibration parameters using settings from current profile&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Patch calibration setting from profile</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="patchhw_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Modify HW parameters using settings from current profile&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Patch HW setting from profile</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="FramFWInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="2" rowspan="3">
<widget class="QLabel" name="FwImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>212</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="DateField">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="dateLabel">
<property name="text">
<string>Date &amp; Time</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="SVNField">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="svnLabel">
<property name="text">
<string>SVN</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="ModField">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="buildLabel">
<property name="text">
<string>Variant</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="FWFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="FlashLoadButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load Firmware</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="EEpromCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Allows companion9x to write to older version of the firmware</string>
</property>
<property name="text">
<string>Check Firmware compatibility</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="EEbackupCB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Backup and restore existing eeprom</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="profile_label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Current Profile</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="SplashFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout" name="SplashLayout" rowstretch="0,0,0,1">
<item row="0" column="1" rowspan="4">
<layout class="QGridLayout" name="gridLayout_2" rowstretch="1,0">
<item row="1" column="0">
<widget class="QPushButton" name="InvertColorButton">
<property name="text">
<string>Invert Color</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>212</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="PreferredImageCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use image in settings</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="PatchFWCB">
<property name="text">
<string>Substitute image in firmware</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="ImageFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ImageLoadButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Image</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="libraryButton">
<property name="toolTip">
<string>Open Splash Library</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="companion9x.qrc">
<normaloff>:/images/library.png</normaloff>:/images/library.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>FWFileName</tabstop>
<tabstop>FlashLoadButton</tabstop>
<tabstop>ImageFileName</tabstop>
<tabstop>ImageLoadButton</tabstop>
<tabstop>libraryButton</tabstop>
<tabstop>EEbackupCB</tabstop>
<tabstop>EEpromCB</tabstop>
<tabstop>cancelButton</tabstop>
<tabstop>BurnFlashButton</tabstop>
</tabstops>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,67 @@
# Find libphonon
# Once done this will define
#
# PHONON_FOUND - system has Phonon Library
# PHONON_INCLUDES - the Phonon include directory
# PHONON_LIBS - link these to use Phonon
# PHONON_VERSION - the version of the Phonon Library
# Copyright (c) 2008, Matthias Kretz <kretz@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro(_phonon_find_version)
file(READ "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h" _phonon_header LIMIT 5000 OFFSET 1000)
string(REGEX MATCH "define PHONON_VERSION_STR \"(4\\.[0-9]+\\.[0-9a-z]+)\"" _phonon_version_match "${_phonon_header}")
set(PHONON_VERSION "${CMAKE_MATCH_1}")
message(STATUS "Phonon Version: ${PHONON_VERSION}")
endmacro(_phonon_find_version)
if(PHONON_FOUND)
# Already found, nothing more to do except figuring out the version
_phonon_find_version()
else(PHONON_FOUND)
if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
set(PHONON_FIND_QUIETLY TRUE)
endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
# As discussed on kde-buildsystem: first look at CMAKE_PREFIX_PATH, then at the suggested PATHS (kde4 install dir)
find_library(PHONON_LIBRARY NAMES phonon phonon4 PATHS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
# then at the default system locations (CMAKE_SYSTEM_PREFIX_PATH, i.e. /usr etc.)
find_library(PHONON_LIBRARY NAMES phonon)
find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h PATHS ${KDE4_INCLUDE_INSTALL_DIR} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h)
if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY})
set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR})
set(PHONON_FOUND TRUE)
_phonon_find_version()
else(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
set(PHONON_FOUND FALSE)
endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
if(PHONON_FOUND)
if(NOT PHONON_FIND_QUIETLY)
message(STATUS "Found Phonon: ${PHONON_LIBRARY}")
message(STATUS "Found Phonon Includes: ${PHONON_INCLUDES}")
endif(NOT PHONON_FIND_QUIETLY)
else(PHONON_FOUND)
if(Phonon_FIND_REQUIRED)
if(NOT PHONON_INCLUDE_DIR)
message(STATUS "Phonon includes NOT found!")
endif(NOT PHONON_INCLUDE_DIR)
if(NOT PHONON_LIBRARY)
message(STATUS "Phonon library NOT found!")
endif(NOT PHONON_LIBRARY)
message(FATAL_ERROR "Phonon library or includes NOT found!")
else(Phonon_FIND_REQUIRED)
message(STATUS "Unable to find Phonon")
endif(Phonon_FIND_REQUIRED)
endif(PHONON_FOUND)
mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY PHONON_INCLUDES)
endif(PHONON_FOUND)

View file

@ -0,0 +1,165 @@
# - Locate the SDL library
# This module defines
# SDL_LIBRARY, the library to link against
# SDL_FOUND, if false, do not try to link to SDL
# SDL_INCLUDE_DIR, where to find SDL.h
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDLmain which
# this module will try to find on your behalf.) Also for OS X, this
# module will automatically add the -framework Cocoa on your behalf.
# $SDLDIR is an environment variable that would
# correspond to the ./configure --prefix=$SDLDIR
# used in building SDL.
# l.e.galup 9-20-02
#
# Modified by Eric Wing.
# Added new modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
# Also corrected the header search path to follow "proper" SDL guidelines.
# Added a search for SDLmain which is needed by some platforms.
# Added a search for threads which is needed by some platforms.
# Added needed compile switches for MinGW.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# SDL_LIBRARY to override this selection.
#
# Note that the header path has changed from SDL/SDL.h to just SDL.h
# This needed to change because "proper" SDL convention
# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
# reasons because not all systems place things in SDL/ (see FreeBSD).
FIND_PATH(SDL_INCLUDE_DIR SDL.h
$ENV{SDLDIR}/include
~/Library/Frameworks/SDL.framework/Headers
/Library/Frameworks/SDL.framework/Headers
/usr/local/include/SDL
/usr/include/SDL
/usr/local/include/SDL12
/usr/local/include/SDL11 # FreeBSD ports
/usr/include/SDL12
/usr/include/SDL11
/usr/local/include
/usr/include
/sw/include/SDL # Fink
/sw/include
/opt/local/include/SDL # DarwinPorts
/opt/local/include
/opt/csw/include/SDL # Blastwave
/opt/csw/include
/opt/include/SDL
/opt/include
C:/Programs/SDL/include
)
# I'm not sure if I should do a special casing for Apple. It is
# unlikely that other Unix systems will find the framework path.
# But if they do ([Next|Open|GNU]Step?),
# do they want the -framework option also?
IF(${SDL_INCLUDE_DIR} MATCHES ".framework")
# The Cocoa framework must be linked into SDL because SDL is Cocoa based.
# Remember that the OS X framework version expects you to drop in
# SDLmain.h and SDLmain.m directly into your project.
# (Cocoa link moved to bottom of this script.)
# SET (SDL_LIBRARY "-framework SDL -framework Cocoa" CACHE STRING "SDL framework for OSX")
# SET(SDL_LIBRARY "-framework SDL" CACHE STRING "SDL framework for OSX")
# Extract the path the framework resides in so we can use it for the -F flag
STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" SDL_FRAMEWORK_PATH_TEMP ${SDL_INCLUDE_DIR})
IF("${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
OR "${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
)
# String is in default search path, don't need to use -F
SET(SDL_LIBRARY_TEMP "-framework SDL")
ELSE("${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
OR "${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
)
# String is not /Library/Frameworks, need to use -F
SET(SDL_LIBRARY_TEMP "-F${SDL_FRAMEWORK_PATH_TEMP} -framework SDL")
ENDIF("${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
OR "${SDL_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
)
# Clear the temp variable so nobody can see it
SET(SDL_FRAMEWORK_PATH_TEMP "" CACHE INTERNAL "")
ELSE(${SDL_INCLUDE_DIR} MATCHES ".framework")
# SDL-1.1 is the name used by FreeBSD ports...
# don't confuse it for the version number.
FIND_LIBRARY(SDL_LIBRARY_TEMP
NAMES SDL SDL-1.1
PATHS
$ENV{SDLDIR}/lib
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
C:/Programs/SDL/lib
)
# Non-OS X framework versions expect you to also dynamically link to
# SDLmain. This is mainly for Windows and OS X. Other platforms
# seem to provide SDLmain for compatibility even though they don't
# necessarily need it.
FIND_LIBRARY(SDLMAIN_LIBRARY
NAMES SDLmain SDLmain-1.1
PATHS
$ENV{SDLDIR}/lib
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
C:/Programs/SDL/lib
)
ENDIF(${SDL_INCLUDE_DIR} MATCHES ".framework")
# SDL may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
IF(NOT APPLE)
FIND_PACKAGE(Threads)
ENDIF(NOT APPLE)
# MinGW needs an additional library, mwindows
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
# (Actually on second look, I think it only needs one of the m* libraries.)
IF(MINGW)
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
ENDIF(MINGW)
SET(SDL_FOUND "NO")
IF(SDL_LIBRARY_TEMP)
# For SDLmain
IF(SDLMAIN_LIBRARY)
SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP})
ENDIF(SDLMAIN_LIBRARY)
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there. I think it has something to do
# with the CACHE STRING. Maybe somebody else knows how to fix this.
# The problem is mainly cosmetic, and not a functional issue.
IF(APPLE)
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if Find the threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For MinGW library
IF(MINGW)
SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP})
ENDIF(MINGW)
# Set the final string here so the GUI reflects the final state.
SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
SET(SDL_FOUND "YES")
ENDIF(SDL_LIBRARY_TEMP)
MARK_AS_ADVANCED(SDL_LIBRARY_TEMP)

View file

@ -0,0 +1,68 @@
# Find Xerces-C
# The following setings are defined
# XERCESC_ROOT_DIR, the root of the include and lib directory
# XERCESC_INCLUDE_DIR, the full path of the include dir (ADVANCED)
# XERCESC_LIBRARIES, the name of the xerces-c library (ADVANCED)
# Look for a root installation
IF( MSVC )
SET( XERCES_WINDIR C:/Programs/xerces-vc )
ELSE( )
SET( XERCES_WINDIR C:/Programs/xerces )
ENDIF( )
FIND_PATH(XERCESC_ROOT_DIR include/xercesc/parsers/SAXParser.hpp
${XERCES_WINDIR}
"C:/mingw/msys/1.0/local"
"C:/Program Files/CodeSynthesis XSD 3.2"
/usr
/usr/local
"C:/MinGW"
$ENV{CODESYNTH}
DOC "The root of an installed xerces-c installation"
)
# try to find the header
FIND_PATH(XERCESC_INCLUDE_DIR xercesc/parsers/SAXParser.hpp
${XERCESC_ROOT_DIR}/include
/usr/include
/usr/local/include
)
# Find the library
FIND_LIBRARY(XERCESC_LIBRARY
NAMES xerces-c xerces-c_3
PATHS
${XERCESC_ROOT_DIR}/lib
${XERCESC_ROOT_DIR}/lib/vc-9.0
${XERCESC_ROOT_DIR}/lib64/vc-9.0
/usr/lib
/usr/local/lib
DOC "The name of the xerces-c library"
)
IF (XERCESC_ROOT_DIR)
IF (XERCESC_INCLUDE_DIR AND XERCESC_LIBRARY)
SET (XERCESC_FOUND TRUE)
SET (XERCESC_LIBRARIES "${XERCESC_LIBRARY}")
# FIXME: There should be a better way of handling this?
# FIXME: How can we test to see if the lib dir isn't
# FIXME: one of the default dirs?
LINK_DIRECTORIES(${XERCESC_ROOT_DIR}/lib)
ENDIF (XERCESC_INCLUDE_DIR AND XERCESC_LIBRARY)
ENDIF (XERCESC_ROOT_DIR)
IF (XERCESC_FOUND)
IF (NOT XERCESC_FIND_QUIETLY)
MESSAGE (STATUS " found xerces-c: ${XERCESC_LIBRARY}")
ENDIF (NOT XERCESC_FIND_QUIETLY)
ELSE (XERCESC_FOUND)
IF (XERCESC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Xerces-C")
ENDIF (XERCESC_FIND_REQUIRED)
ENDIF (XERCESC_FOUND)
MARK_AS_ADVANCED(
XERCESC_INCLUDE_DIR
XERCESC_LIBRARY
)

View file

@ -0,0 +1,52 @@
# Locate Xsd from code synthesis include paths and binary
# Xsd can be found at http://codesynthesis.com/products/xsd/
# Written by Frederic Heem, frederic.heem _at_ telsey.it
# This module defines
# XSD_INCLUDE_DIR, where to find elements.hxx, etc.
# XSD_EXECUTABLE, where is the xsd compiler
# XSD_FOUND, If false, don't try to use xsd
FIND_PATH( XSD_INCLUDE_DIR xsd/cxx/parser/elements.hxx
"/opt/local/xsd-3.3.0-i686-macosx/libxsd"
"C:/Programs/xsd-3.3.0/libxsd"
"C:/Program Files/CodeSynthesis XSD 3.2/include"
"C:/mingw/xsd-3.3.0-i686-windows/libxsd"
$ENV{XSDDIR}/include
$ENV{CODESYNTH}/include
/usr/local/include /usr/include
)
IF( WIN32 )
SET( XSDCXX_FILENAME1 xsd-cxx.exe )
ELSE( )
SET( XSDCXX_FILENAME1 xsdcxx )
SET( XSDCXX_FILENAME2 xsd )
ENDIF( )
FIND_PROGRAM( XSDCXX_EXECUTABLE
NAMES
${XSDCXX_FILENAME1} ${XSDCXX_FILENAME2}
PATHS
"/opt/local/xsd-3.3.0-i686-macosx/bin"
"C:/Programs/xsd-3.3.0/bin"
"C:/mingw/xsd-3.3.0-i686-windows/bin"
"C:/Program Files/CodeSynthesis XSD 3.2/bin"
$ENV{XSDDIR}/bin
/usr/local/bin
/usr/bin
)
MESSAGE(STATUS ${XSDCXX_EXECUTABLE})
# if the include and the program are found then we have it
IF( XSD_INCLUDE_DIR )
IF( XSDCXX_EXECUTABLE )
SET( XSD_FOUND "YES" )
ENDIF( XSDCXX_EXECUTABLE )
ENDIF( XSD_INCLUDE_DIR )
MARK_AS_ADVANCED(
XSD_INCLUDE_DIR
XSDCXX_EXECUTABLE
)

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=companion9x
GenericName=COMPANION9X
Comment=9x EeProm Editor
Icon=/usr/share/icons/companion9x.png
Exec='companion9x'
Terminal=false
StartupNotify=false
Categories=Application

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

@ -0,0 +1,335 @@
<RCC>
<qresource prefix="/">
<file>icon.png</file>
<file>../../CREDITS.txt</file>
<file>../../DONATIONS.txt</file>
<file>../releasenotes.txt</file>
<file>images/9xdb.png</file>
<file>images/9xdl.png</file>
<file>images/9xdr.png</file>
<file>images/9xdt.png</file>
<file>images/9xdb-bl.png</file>
<file>images/9xdl-bl.png</file>
<file>images/9xdr-bl.png</file>
<file>images/9xdt-bl.png</file>
<file>images/9xdb-gr.png</file>
<file>images/9xdl-gr.png</file>
<file>images/9xdr-gr.png</file>
<file>images/9xdt-gr.png</file>
<file>images/9xdb-or.png</file>
<file>images/9xdl-or.png</file>
<file>images/9xdr-or.png</file>
<file>images/9xdt-or.png</file>
<file>images/9xdb-yl.png</file>
<file>images/9xdl-yl.png</file>
<file>images/9xdr-yl.png</file>
<file>images/9xdt-yl.png</file>
<file>images/9xdb-rd.png</file>
<file>images/9xdl-rd.png</file>
<file>images/9xdr-rd.png</file>
<file>images/9xdt-rd.png</file>
<file>images/9xmenu.png</file>
<file>images/9xmenumenu.png</file>
<file>images/9xmenuexit.png</file>
<file>images/9xcurs.png</file>
<file>images/9xcursup.png</file>
<file>images/9xcursplus.png</file>
<file>images/9xcursmin.png</file>
<file>images/9xcursdown.png</file>
<file>images/9xcursphoto.png</file>
<file>images/copy.png</file>
<file>images/cut.png</file>
<file>images/currentmodel.png</file>
<file>images/new.png</file>
<file>images/open.png</file>
<file>images/paste.png</file>
<file>images/save.png</file>
<file>images/saveas.png</file>
<file>images/screenshot.png</file>
<file>images/splash.png</file>
<file>images/splasht.png</file>
<file>images/companion9x-title.png</file>
<file>images/read_eeprom.png</file>
<file>images/write_eeprom.png</file>
<file>images/write_flash.png</file>
<file>images/read_flash.png</file>
<file>images/simulate.png</file>
<file>images/configure.png</file>
<file>images/customize.png</file>
<file>images/print.png</file>
<file>images/clear.png</file>
<file>images/add.png</file>
<file>images/edit.png</file>
<file>images/wizard.png</file>
<file>images/duplicate.png</file>
<file>images/fuses.png</file>
<file>images/list.png</file>
<file>images/play.png</file>
<file>images/stop.png</file>
<file>images/read_eeprom_file.png</file>
<file>images/write_eeprom_file.png</file>
<file>images/moveup.png</file>
<file>images/movedown.png</file>
<file>images/update.png</file>
<file>images/contributors.png</file>
<file>images/changelog.png</file>
<file>images/preferences.png</file>
<file>images/switch_dir.png</file>
<file>images/exit.png</file>
<file>images/recentdocument.png</file>
<file>images/profiles.png</file>
<file>images/library.png</file>
<file>images/logs.png</file>
<file>images/arrow-left.png</file>
<file>images/arrow-right.png</file>
<file>images/compare.png</file>
<file>images/x9b0.png</file>
<file>images/x9l0.png</file>
<file>images/x9l1.png</file>
<file>images/x9l2.png</file>
<file>images/x9l3.png</file>
<file>images/x9l4.png</file>
<file>images/x9r0.png</file>
<file>images/x9r1.png</file>
<file>images/x9r2.png</file>
<file>images/x9r3.png</file>
<file>images/x9s0.png</file>
<file>images/x9t0.png</file>
<file>images/mcw/aicon.png</file>
<file>images/mcw/dicon.png</file>
<file>images/mcw/gicon.png</file>
<file>images/mcw/hicon.png</file>
<file>images/mcw/at1e1r.png</file>
<file>images/mcw/at2e1r.png</file>
<file>images/mcw/atailv.png</file>
<file>images/mcw/aw0a0f.png</file>
<file>images/mcw/aw1a0f.png</file>
<file>images/mcw/aw1a1f.png</file>
<file>images/mcw/aw1a2f.png</file>
<file>images/mcw/aw2a0f.png</file>
<file>images/mcw/aw2a1f.png</file>
<file>images/mcw/aw2a2f.png</file>
<file>images/mcw/h90.png</file>
<file>images/mcw/h120.png</file>
<file>images/mcw/h120x.png</file>
<file>images/mcw/h140.png</file>
<file>images/mcw/hfbl.png</file>
<file>images/mcw/htailg.png</file>
<file>images/mcw/htailng.png</file>
<file>images/mcw/htailfblg.png</file>
<file>images/mcw/htailfblng.png</file>
<file>images/mcw/gt1e1r.png</file>
<file>images/mcw/gt2e1r.png</file>
<file>images/mcw/gtailv.png</file>
<file>images/mcw/gw0t0a0f0s.png</file>
<file>images/mcw/gw0t1a0f0s.png</file>
<file>images/mcw/gw0t1a0f1s.png</file>
<file>images/mcw/gw0t1a0f2s.png</file>
<file>images/mcw/gw0t1a1f0s.png</file>
<file>images/mcw/gw0t1a1f1s.png</file>
<file>images/mcw/gw0t1a1f2s.png</file>
<file>images/mcw/gw0t1a2f0s.png</file>
<file>images/mcw/gw0t1a2f1s.png</file>
<file>images/mcw/gw0t1a2f2s.png</file>
<file>images/mcw/gw0t2a0f0s.png</file>
<file>images/mcw/gw0t2a0f1s.png</file>
<file>images/mcw/gw0t2a0f2s.png</file>
<file>images/mcw/gw0t2a1f0s.png</file>
<file>images/mcw/gw0t2a1f1s.png</file>
<file>images/mcw/gw0t2a1f2s.png</file>
<file>images/mcw/gw0t2a2f0s.png</file>
<file>images/mcw/gw0t2a2f1s.png</file>
<file>images/mcw/gw0t2a2f2s.png</file>
<file>images/mcw/gw1t0a0f0s.png</file>
<file>images/mcw/gw1t1a0f0s.png</file>
<file>images/mcw/gw1t1a0f1s.png</file>
<file>images/mcw/gw1t1a0f2s.png</file>
<file>images/mcw/gw1t1a1f0s.png</file>
<file>images/mcw/gw1t1a1f1s.png</file>
<file>images/mcw/gw1t1a1f2s.png</file>
<file>images/mcw/gw1t1a2f0s.png</file>
<file>images/mcw/gw1t1a2f1s.png</file>
<file>images/mcw/gw1t1a2f2s.png</file>
<file>images/mcw/gw1t2a0f0s.png</file>
<file>images/mcw/gw1t2a0f1s.png</file>
<file>images/mcw/gw1t2a0f2s.png</file>
<file>images/mcw/gw1t2a1f0s.png</file>
<file>images/mcw/gw1t2a1f1s.png</file>
<file>images/mcw/gw1t2a1f2s.png</file>
<file>images/mcw/gw1t2a2f0s.png</file>
<file>images/mcw/gw1t2a2f1s.png</file>
<file>images/mcw/gw1t2a2f2s.png</file>
<file>images/mcw/db0t2e0f0r.png</file>
<file>images/mcw/db0t2e0f1r.png</file>
<file>images/mcw/db0t2e0f2r.png</file>
<file>images/mcw/db0t2e1f0r.png</file>
<file>images/mcw/db0t2e1f1r.png</file>
<file>images/mcw/db0t2e1f2r.png</file>
<file>images/mcw/db0t2e2f0r.png</file>
<file>images/mcw/db0t2e2f1r.png</file>
<file>images/mcw/db0t2e2f2r.png</file>
<file>images/mcw/db1t2e0f0r.png</file>
<file>images/mcw/db1t2e0f1r.png</file>
<file>images/mcw/db1t2e0f2r.png</file>
<file>images/mcw/db1t2e1f0r.png</file>
<file>images/mcw/db1t2e1f1r.png</file>
<file>images/mcw/db1t2e1f2r.png</file>
<file>images/mcw/db1t2e2f0r.png</file>
<file>images/mcw/db1t2e2f1r.png</file>
<file>images/mcw/db1t2e2f2r.png</file>
<file>images/mcw/dt0t2e0f0r.png</file>
<file>images/mcw/dt0t2e0f1r.png</file>
<file>images/mcw/dt0t2e0f2r.png</file>
<file>images/mcw/dt0t2e1f0r.png</file>
<file>images/mcw/dt0t2e1f1r.png</file>
<file>images/mcw/dt0t2e1f2r.png</file>
<file>images/mcw/dt0t2e2f0r.png</file>
<file>images/mcw/dt0t2e2f1r.png</file>
<file>images/mcw/dt0t2e2f2r.png</file>
<file>images/mcw/dt1t2e0f0r.png</file>
<file>images/mcw/dt1t2e0f1r.png</file>
<file>images/mcw/dt1t2e0f2r.png</file>
<file>images/mcw/dt1t2e1f0r.png</file>
<file>images/mcw/dt1t2e1f1r.png</file>
<file>images/mcw/dt1t2e1f2r.png</file>
<file>images/mcw/dt1t2e2f0r.png</file>
<file>images/mcw/dt1t2e2f1r.png</file>
<file>images/mcw/dt1t2e2f2r.png</file>
<file>images/library/00001.png</file>
<file>images/library/00002.png</file>
<file>images/library/00003.png</file>
<file>images/library/00004.png</file>
<file>images/library/00005.png</file>
<file>images/library/00006.png</file>
<file>images/library/00007.png</file>
<file>images/library/00008.png</file>
<file>images/library/00009.png</file>
<file>images/library/00010.png</file>
<file>images/library/00011.png</file>
<file>images/library/00012.png</file>
<file>images/library/00013.png</file>
<file>images/library/00014.png</file>
<file>images/library/00015.png</file>
<file>images/library/00016.png</file>
<file>images/library/01001.png</file>
<file>images/library/01002.png</file>
<file>images/library/01003.png</file>
<file>images/library/01004.png</file>
<file>images/library/01005.png</file>
<file>images/library/01006.png</file>
<file>images/library/01007.png</file>
<file>images/library/01008.png</file>
<file>images/library/10001.png</file>
<file>images/library/10002.png</file>
<file>images/library/10003.png</file>
<file>images/library/10004.png</file>
<file>images/library/10005.png</file>
<file>images/library/10006.png</file>
<file>images/library/10007.png</file>
<file>images/library/10008.png</file>
<file>images/library/10009.png</file>
<file>images/library/10010.png</file>
<file>images/library/10011.png</file>
<file>images/library/10012.png</file>
<file>images/library/10013.png</file>
<file>images/library/10014.png</file>
<file>images/library/10015.png</file>
<file>images/library/10016.png</file>
<file>images/library/10017.png</file>
<file>images/library/10018.png</file>
<file>images/library/10019.png</file>
<file>images/library/10020.png</file>
<file>images/library/10021.png</file>
<file>images/library/10022.png</file>
<file>images/library/10023.png</file>
<file>images/library/10024.png</file>
<file>images/library/10033.png</file>
<file>images/library/10034.png</file>
<file>images/library/10035.png</file>
<file>images/library/10036.png</file>
<file>images/library/10049.png</file>
<file>images/library/10050.png</file>
<file>images/library/10051.png</file>
<file>images/library/10052.png</file>
<file>images/library/10037.png</file>
<file>images/library/10038.png</file>
<file>images/library/10039.png</file>
<file>images/library/10040.png</file>
<file>images/library/10053.png</file>
<file>images/library/10054.png</file>
<file>images/library/10055.png</file>
<file>images/library/10056.png</file>
<file>images/library/10025.png</file>
<file>images/library/10026.png</file>
<file>images/library/10027.png</file>
<file>images/library/10028.png</file>
<file>images/library/10029.png</file>
<file>images/library/10030.png</file>
<file>images/library/10031.png</file>
<file>images/library/10032.png</file>
<file>images/library/10041.png</file>
<file>images/library/10042.png</file>
<file>images/library/10043.png</file>
<file>images/library/10044.png</file>
<file>images/library/10057.png</file>
<file>images/library/10058.png</file>
<file>images/library/10059.png</file>
<file>images/library/10060.png</file>
<file>images/library/10045.png</file>
<file>images/library/10046.png</file>
<file>images/library/10047.png</file>
<file>images/library/10048.png</file>
<file>images/library/10061.png</file>
<file>images/library/10062.png</file>
<file>images/library/10063.png</file>
<file>images/library/10064.png</file>
<file>images/library/10065.png</file>
<file>images/library/10066.png</file>
<file>images/library/10067.png</file>
<file>images/library/10068.png</file>
<file>images/library/10081.png</file>
<file>images/library/10082.png</file>
<file>images/library/10083.png</file>
<file>images/library/10084.png</file>
<file>images/library/10069.png</file>
<file>images/library/10070.png</file>
<file>images/library/10071.png</file>
<file>images/library/10072.png</file>
<file>images/library/10085.png</file>
<file>images/library/10086.png</file>
<file>images/library/10087.png</file>
<file>images/library/10088.png</file>
<file>images/library/10073.png</file>
<file>images/library/10074.png</file>
<file>images/library/10075.png</file>
<file>images/library/10076.png</file>
<file>images/library/10089.png</file>
<file>images/library/10090.png</file>
<file>images/library/10091.png</file>
<file>images/library/10092.png</file>
<file>images/library/10077.png</file>
<file>images/library/10078.png</file>
<file>images/library/10079.png</file>
<file>images/library/10080.png</file>
<file>images/library/10093.png</file>
<file>images/library/10094.png</file>
<file>images/library/10095.png</file>
<file>images/library/10096.png</file>
<file>images/library/10097.png</file>
<file>images/library/10098.png</file>
<file>images/library/10099.png</file>
<file>images/library/10100.png</file>
<file>images/library/10101.png</file>
<file>images/library/10102.png</file>
<file>images/library/10103.png</file>
<file>images/library/10104.png</file>
<file>images/library/20001.png</file>
<file>images/library/20002.png</file>
<file>images/library/20003.png</file>
<file>images/library/20004.png</file>
<file>images/library/30001.png</file>
<file>images/library/30002.png</file>
<file>images/library/30003.png</file>
<file>images/library/30004.png</file>
</qresource>
</RCC>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,95 @@
#ifndef COMPAREDIALOG_H
#define COMPAREDIALOG_H
#include <QDialog>
#include <QtGui>
#include <QDir>
#include "eeprominterface.h"
namespace Ui {
class compareDialog;
}
class compareDialog : public QDialog
{
Q_OBJECT
public:
explicit compareDialog(QWidget *parent = 0, GeneralSettings *gg = 0);
~compareDialog();
void closeEvent(QCloseEvent *event);
ModelData * g_model1;
ModelData * g_model2;
ModelData * modeltemp;
int model1;
int model2;
GeneralSettings *g_eeGeneral;
EEPROMInterface *eepromInterface;
private:
Ui::compareDialog *ui;
QString doTC(const QString s, const QString color, bool bold);
QString doTR(const QString s, const QString color, bool bold);
QString doTL(const QString s, const QString color, bool bold);
QString fv(const QString name, const QString value,const QString color);
template<class T> QString getColor1(T val1, T val2) {
if (val1!=val2)
return "green";
else
return "grey";
}
template<class T> QString getColor2(T val1, T val2) {
if (val1!=val2)
return "red";
else
return "grey";
}
QString getColor1(char * val1, char * val2) {
if (strcmp(val1,val2)!=0)
return "green";
else
return "grey";
}
QString getColor2(char * val1, char * val2) {
if (strcmp(val1,val2)!=0)
return "red";
else
return "grey";
}
int ModelHasExpo(ExpoData * ExpoArray, ExpoData expo, bool * expoused);
bool ChannelHasExpo(ExpoData * expoArray, uint8_t destCh);
int ModelHasMix(MixData * mixArray, MixData mix, bool * mixused);
bool ChannelHasMix(MixData * mixArray, uint8_t destCh);
QTextEdit * te;
QString curvefile5;
QString curvefile9;
QDir *qd;
private slots:
void on_printButton_clicked();
void on_printFileButton_clicked();
protected:
void dropEvent(QDropEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void printDiff();
void printSetup();
void printPhases();
void printLimits();
void printExpos();
void printMixers();
void printCurves();
void printGvars();
void printSwitches();
void printSafetySwitches();
void printFSwitches();
void printFrSky();
};
#endif // COMPAREDIALOG_H

View file

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>compareDialog</class>
<widget class="QDialog" name="compareDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>580</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>780</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/images/print.png</normaloff>:/images/print.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_1">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">color:green;</string>
</property>
<property name="text">
<string>Drag first model here</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">color:red;</string>
</property>
<property name="text">
<string>Drag second model here</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="textEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="printButton">
<property name="text">
<string>Print</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="printFileButton">
<property name="text">
<string>Print to file</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>compareDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>739</x>
<y>636</y>
</hint>
<hint type="destinationlabel">
<x>565</x>
<y>623</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -0,0 +1,82 @@
#include "contributorsdialog.h"
#include "ui_contributorsdialog.h"
#include <QtGui>
#define CLINESEP "=====================================================\n"
contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnurl) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::contributorsDialog)
{
ui->setupUi(this);
switch (contest) {
case 0: {
ui->textBrowser->insertPlainText(CLINESEP);
ui->textBrowser->insertPlainText(tr("People who have contributed to this project")+"\n");
ui->textBrowser->insertPlainText(CLINESEP);
QFile file(":/contributors");
if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textBrowser->insertPlainText(file.readAll());
}
ui->textBrowser->insertPlainText("\n");
ui->textBrowser->insertPlainText(CLINESEP);
ui->textBrowser->insertPlainText(tr("Coders")+"\n");
ui->textBrowser->insertPlainText(CLINESEP);
QFile file2(":/coders");
if(file2.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textBrowser->insertPlainText(file2.readAll());
}
ui->textBrowser->insertPlainText("\n\n\n");
ui->textBrowser->insertPlainText(tr("Honors go to Rafal Tomczak (RadioClone) and Thomas Husterer (th9x) \nof course. Also to Erez Raviv (er9x) and it's fantastic eePe, from which\ncompanion9x was forked out."));
ui->textBrowser->insertPlainText("\n\n");
ui->textBrowser->insertPlainText(tr("Thank you all !!!"));
ui->textBrowser->setReadOnly(true);
ui->textBrowser->verticalScrollBar()->setValue(0);
this->setWindowTitle(tr("Contributors"));
}
break;
case 1:{
QFile file(":/releasenotes");
if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textBrowser->insertHtml(file.readAll());
}
ui->textBrowser->setReadOnly(true);
ui->textBrowser->verticalScrollBar()->setValue(0);
this->setWindowTitle(tr("Companion9x Release Notes"));
}
break;
case 2:{
if (!rnurl.isEmpty()) {
this->setWindowTitle(tr("OpenTX Release Notes"));
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
QUrl url(rnurl);
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
manager->get(request);
} else {
QTimer::singleShot(0, this, SLOT(forceClose()));
}
break;
}
}
}
void contributorsDialog::showEvent ( QShowEvent * )
{
ui->textBrowser->verticalScrollBar()->setValue(0);
}
contributorsDialog::~contributorsDialog()
{
delete ui;
}
void contributorsDialog::replyFinished(QNetworkReply * reply)
{
ui->textBrowser->insertHtml(reply->readAll());
}
void contributorsDialog::forceClose() {
accept();;
}

View file

@ -0,0 +1,31 @@
#ifndef CONTRIBUTORSDIALOG_H
#define CONTRIBUTORSDIALOG_H
#include <QDialog>
#include "eeprominterface.h"
#include "downloaddialog.h"
namespace Ui {
class contributorsDialog;
}
class contributorsDialog : public QDialog
{
Q_OBJECT
public:
explicit contributorsDialog(QWidget *parent = 0, int contest = 0, QString rnurl = QString() );
~contributorsDialog();
private:
Ui::contributorsDialog *ui;
QNetworkAccessManager *manager;
void showEvent ( QShowEvent * );
private slots:
void forceClose();
void replyFinished(QNetworkReply * reply);
};
#endif // CONTRIBUTORSDIALOG_H

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>contributorsDialog</class>
<widget class="QDialog" name="contributorsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>926</width>
<height>333</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser"/>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,106 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef CURSORWIDGET_H
#define CURSORWIDGET_H
#include <QWidget>
#include <QtGui>
class cursorWidget : public QWidget {
Q_OBJECT
public:
explicit cursorWidget(QWidget * parent = 0):
QWidget(parent)
{
}
protected:
virtual void mousePressEvent(QMouseEvent * event)
{
float upx[] = {68,28,51,83,105,68};
float upy[] = {83,45,32,32,45,83};
float minx[] = {74,114,127,127,114,74};
float miny[] = {90,51,80,106,130,90};
float dox[] = {68,28,51,83,105,68};
float doy[] = {98,137,151,151,137,98};
float plusx[] = { 80,20,7,7,20,80};
float plusy[] = {90,51,80,106,130,90};
int x=event->x();
int y=event->y();
setFocus();
if (event->button()==Qt::LeftButton) {
if (pnpoly(6,upx,upy,(float)x,(float)y)==1) {
setStyleSheet("background:url(:/images/9xcursup.png);");
emit buttonPressed(Qt::Key_Up);
}
else if (pnpoly(6,minx,miny,(float)x,(float)y)==1) {
setStyleSheet("background:url(:/images/9xcursmin.png);");
emit buttonPressed(Qt::Key_Right);
}
else if (pnpoly(6,dox,doy,(float)x,(float)y)==1) {
setStyleSheet("background:url(:/images/9xcursdown.png);");
emit buttonPressed(Qt::Key_Down);
}
else if (pnpoly(6,plusx,plusy,(float)x,(float)y)==1) {
setStyleSheet("background:url(:/images/9xcursplus.png);");
emit buttonPressed(Qt::Key_Left);
} else if (sqrt(((float)x-22)*((float)x-22)+((float)y-165)*((float)y-165))<17) {
setStyleSheet("background:url(:/images/9xcursphoto.png);");
emit buttonPressed(Qt::Key_Print);
}
}
// QWidget::mousePressEvent(event);
}
virtual void mouseReleaseEvent(QMouseEvent * event)
{
setStyleSheet("background:url(:/images/9xcurs.png);");
emit buttonPressed(0);
setFocus();
//QWidget::mouseReleaseEvent(event);
}
void paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c;
}
signals:
void buttonPressed(int button);
};
#endif /* CURSORWIDGET_H */

View file

@ -0,0 +1,187 @@
#include "customizesplashdialog.h"
#include "ui_customizesplashdialog.h"
#include <QtGui>
#include "helpers.h"
#include "burndialog.h"
#include "splashlibrary.h"
#include "flashinterface.h"
customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::customizeSplashDialog) {
ui->setupUi(this);
ui->HowToLabel->clear();
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
}
customizeSplashDialog::~customizeSplashDialog() {
delete ui;
}
void customizeSplashDialog::on_FlashLoadButton_clicked()
{
QString fileName;
QSettings settings("companion9x", "companion9x");
ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true);
ui->SaveFlashButton->setDisabled(true);
ui->SaveImageButton->setDisabled(true);
ui->ImageFileName->clear();
ui->imageLabel->clear();
ui->HowToLabel->clear();
ui->HowToLabel->setStyleSheet("background:rgb(255, 255, 0)");
fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
QFile file(fileName);
if (!file.exists()) {
ui->FWFileName->clear();
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
return;
}
if (fileName.isEmpty()) {
ui->FWFileName->clear();
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
return;
}
ui->FWFileName->setText(fileName);
FlashInterface flash(fileName);
if (flash.hasSplash()) {
ui->HowToLabel->append("<center>" + tr("Select an image to customize your splash <br />or save actual firmware splash") + "</center>");
ui->ImageLoadButton->setEnabled(true);
ui->libraryButton->setEnabled(true);
ui->SaveImageButton->setEnabled(true);
ui->imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash()));
ui->imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2);
} else {
QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file"));
return;
}
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
}
void customizeSplashDialog::on_ImageLoadButton_clicked() {
QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
QSettings settings("companion9x", "companion9x");
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
ui->HowToLabel->clear();
ui->ImageFileName->setText(fileName);
if (ui->imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2)));
} else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
ui->SaveFlashButton->setEnabled(true);
ui->HowToLabel->append("<center>" + tr("Save your custimized firmware") + "</center>");
}
}
void customizeSplashDialog::on_libraryButton_clicked() {
QString fileName;
splashLibrary *ld = new splashLibrary(this,&fileName);
ld->exec();
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
ui->HowToLabel->clear();
ui->ImageFileName->setText(fileName);
if (ui->imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2)));
} else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
ui->SaveFlashButton->setEnabled(true);
ui->HowToLabel->append("<center>" + tr("Save your custimized firmware") + "</center>");
}
}
void customizeSplashDialog::on_SaveFlashButton_clicked()
{
QString fileName;
QSettings settings("companion9x", "companion9x");
ui->HowToLabel->clear();
fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER, 0, QFileDialog::DontConfirmOverwrite);
if (fileName.isEmpty()) {
return;
}
FlashInterface flash(ui->FWFileName->text());
if (!flash.hasSplash()) {
QMessageBox::critical(this, tr("Error"), tr("Error reading file %1").arg(fileName));
return;
}
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
QImage image = ui->imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
flash.setSplash(image);
if (flash.saveFlash(fileName) > 0) {
ui->HowToLabel->setStyleSheet("background:rgb(0,255.0);");
ui->HowToLabel->append("<center>" + tr("Firmware correctly saved.") + "</center>");
} else {
ui->HowToLabel->setStyleSheet("background:rgb(255.0.0);");
ui->HowToLabel->append("<center>" + tr("Firmware not saved.") + "</center>");
}
}
void customizeSplashDialog::on_InvertColorButton_clicked()
{
QImage image = ui->imageLabel->pixmap()->toImage();
image.invertPixels();
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
}
void customizeSplashDialog::on_SaveImageButton_clicked()
{
QString fileName;
QSettings settings("companion9x", "companion9x");
fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastImagesDir").toString(), tr("PNG images (*.png);;"), 0, QFileDialog::DontConfirmOverwrite);
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
image.save(fileName, "PNG");
}
}

View file

@ -0,0 +1,33 @@
#ifndef CUSTOMIZESPLASHDIALOG_H
#define CUSTOMIZESPLASHDIALOG_H
#include <QtGui>
#include <QDialog>
#include "flashinterface.h"
namespace Ui
{
class customizeSplashDialog;
}
class customizeSplashDialog : public QDialog
{
Q_OBJECT
public:
explicit customizeSplashDialog(QWidget *parent = 0);
~customizeSplashDialog();
private slots:
void on_FlashLoadButton_clicked();
void on_ImageLoadButton_clicked();
void on_libraryButton_clicked();
void on_SaveFlashButton_clicked();
void on_InvertColorButton_clicked();
void on_SaveImageButton_clicked();
private:
Ui::customizeSplashDialog *ui;
};
#endif // CUSTOMIZESPLASHDIALOG_H

View file

@ -0,0 +1,270 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>customizeSplashDialog</class>
<widget class="QDialog" name="customizeSplashDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>366</width>
<height>303</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Customize Splash</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/images/c_home.png</normaloff>:/images/c_home.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="companion9x.qrc">:/images/customize.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="SaveImageButton">
<property name="text">
<string>Save Image</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="InvertColorButton">
<property name="text">
<string>Invert Color</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="HowToLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:rgb(255, 255, 0);</string>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLineEdit" name="FWFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QPushButton" name="FlashLoadButton">
<property name="text">
<string>Load Firmware</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="ImageFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="ImageLoadButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Image</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="libraryButton">
<property name="toolTip">
<string>Open Splash Library</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="companion9x.qrc">
<normaloff>:/images/library.png</normaloff>:/images/library.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>208</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="SaveFlashButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save Firmware</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,88 @@
#include "downloaddialog.h"
#include "ui_downloaddialog.h"
#include <QMessageBox>
#include <QtGui>
downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt) :
QDialog(parent),
ui(new Ui::downloadDialog)
{
ui->setupUi(this);
ui->progressBar->setValue(1);
ui->progressBar->setMinimum(0);
ui->progressBar->setMaximum(0);
if(tgt.isEmpty())
{
setWindowTitle(src);
return; // just show wait dialog.
}
file = new QFile(tgt);
if (!file->open(QIODevice::WriteOnly)) {
QMessageBox::critical(this, "companion9x",
tr("Unable to save the file %1: %2.")
.arg(tgt).arg(file->errorString()));
QTimer::singleShot(0, this, SLOT(fileError()));
} else {
reply = qnam.get(QNetworkRequest(QUrl(src)));
connect(reply, SIGNAL(finished()),
this, SLOT(httpFinished()));
connect(reply, SIGNAL(readyRead()),
this, SLOT(httpReadyRead()));
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(updateDataReadProgress(qint64,qint64)));
}
}
downloadDialog::~downloadDialog()
{
delete ui;
}
void downloadDialog::httpFinished()
{
file->flush();
file->close();
bool ok = true;
if (reply->error())
{
file->remove();
QMessageBox::information(this, tr("companion9x"),
tr("Download failed: %1.")
.arg(reply->errorString()));
ok = false;
}
reply->deleteLater();
reply = 0;
delete file;
file = 0;
if(ok)
accept();
else
reject();
}
void downloadDialog::httpReadyRead()
{
if (file)
file->write(reply->readAll());
}
void downloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{
ui->progressBar->setMaximum(totalBytes);
ui->progressBar->setValue(bytesRead);
}
void downloadDialog::fileError()
{
delete file;
file = 0;
reject();
}

View file

@ -0,0 +1,38 @@
#ifndef DOWNLOADDIALOG_H
#define DOWNLOADDIALOG_H
#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QFile>
namespace Ui {
class downloadDialog;
}
class downloadDialog : public QDialog
{
Q_OBJECT
public:
explicit downloadDialog(QWidget *parent = 0, QString src = "", QString tgt = "");
~downloadDialog();
private slots:
void fileError();
void httpFinished();
void httpReadyRead();
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
private:
Ui::downloadDialog *ui;
QNetworkAccessManager qnam;
QNetworkReply *reply;
QFile *file;
};
#endif // DOWNLOADDIALOG_H

View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>downloadDialog</class>
<widget class="QDialog" name="downloadDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>82</height>
</rect>
</property>
<property name="windowTitle">
<string>Downloading: </string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>downloadDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>downloadDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

132
companion/src/edge.cpp Normal file
View file

@ -0,0 +1,132 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QPainter>
#include "edge.h"
#include "node.h"
#include <math.h>
static const double Pi = 3.14159265358979323846264338327950288419717;
Edge::Edge(Node *sourceNode, Node *destNode)
: arrowSize(10)
{
setAcceptedMouseButtons(0);
source = sourceNode;
dest = destNode;
source->addEdge(this);
dest->addEdge(this);
adjust();
}
Edge::~Edge()
{
}
Node *Edge::sourceNode() const
{
return source;
}
void Edge::setSourceNode(Node *node)
{
source = node;
adjust();
}
Node *Edge::destNode() const
{
return dest;
}
void Edge::setDestNode(Node *node)
{
dest = node;
adjust();
}
void Edge::adjust()
{
if (!source || !dest)
return;
QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
qreal length = line.length();
prepareGeometryChange();
int ballSize = source->getBallSize();
if (length > qreal(ballSize)) {
QPointF edgeOffset((line.dx() * ballSize / 2) / length, (line.dy() * ballSize / 2) / length);
sourcePoint = line.p1() + edgeOffset;
destPoint = line.p2() - edgeOffset;
} else {
sourcePoint = destPoint = line.p1();
}
}
QRectF Edge::boundingRect() const
{
if (!source || !dest)
return QRectF();
qreal penWidth = 1;
qreal extra = (penWidth + arrowSize) / 2.0;
return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
destPoint.y() - sourcePoint.y()))
.normalized()
.adjusted(-extra, -extra, extra, extra);
}
void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if (!source || !dest)
return;
QLineF line(sourcePoint, destPoint);
if (qFuzzyCompare(line.length(), qreal(0.)))
return;
// Draw the line itself
painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter->drawLine(line);
}

78
companion/src/edge.h Normal file
View file

@ -0,0 +1,78 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef EDGE_H
#define EDGE_H
#include <QGraphicsItem>
class Node;
class Edge : public QGraphicsItem
{
public:
Edge(Node *sourceNode, Node *destNode);
~Edge();
Node *sourceNode() const;
void setSourceNode(Node *node);
Node *destNode() const;
void setDestNode(Node *node);
void adjust();
enum { Type = UserType + 2 };
int type() const { return Type; }
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
Node *source, *dest;
QPointF sourcePoint;
QPointF destPoint;
qreal arrowSize;
};
#endif

View file

@ -0,0 +1,663 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef eeprom_importexport_h
#define eeprom_importexport_h
#define DIM(arr) (sizeof((arr))/sizeof((arr)[0]))
class DataField {
public:
DataField(const char *name=""):
name(name)
{
}
virtual const char *getName() { return name; }
virtual ~DataField() { }
virtual void ExportBits(QBitArray & output) = 0;
virtual void ImportBits(QBitArray & input) = 0;
virtual unsigned int size() = 0;
QBitArray bytesToBits(QByteArray bytes)
{
QBitArray bits(bytes.count()*8);
// Convert from QByteArray to QBitArray
for (int i=0; i<bytes.count(); ++i)
for (int b=0; b<8; ++b)
bits.setBit(i*8+b, bytes.at(i)&(1<<b));
return bits;
}
QByteArray bitsToBytes(QBitArray bits, int offset=0)
{
QByteArray bytes;
bytes.resize((offset+bits.count()+7)/8);
bytes.fill(0);
// Convert from QBitArray to QByteArray
for (int b=0; b<bits.count(); ++b)
bytes[(b+offset)/8] = ( bytes.at((b+offset)/8) | ((bits[b]?1:0)<<((b+offset)%8)));
return bytes;
}
int Export(QByteArray & output)
{
QBitArray result;
ExportBits(result);
output = bitsToBytes(result);
return 0;
}
int Import(QByteArray & input)
{
QBitArray bits = bytesToBits(input);
ImportBits(bits);
return 0;
}
virtual int Dump(int level=0, int offset=0)
{
QBitArray bits;
ExportBits(bits);
QByteArray bytes = bitsToBytes(bits);
int result = (offset+bits.count()) % 8;
for (int i=0; i<level; i++) printf(" ");
printf("%s ", getName());
for (int i=0; i<bytes.count(); i++) {
unsigned char c = bytes[i];
if ((i==0 && offset) || (i==bytes.count()-1 && result!=0))
printf("(%02x) ", c);
else
printf("%02x ", c);
}
printf("\n"); fflush(stdout);
return result;
}
protected:
const char *name;
};
template<int N>
class UnsignedField: public DataField {
public:
explicit UnsignedField(unsigned int & field):
DataField("Unsigned"),
field(field),
min(0),
max(UINT_MAX)
{
}
UnsignedField(unsigned int & field, const char *name):
DataField(name),
field(field),
min(0),
max(UINT_MAX)
{
}
UnsignedField(unsigned int & field, unsigned int min, unsigned int max, const char *name="Unsigned"):
DataField(name),
field(field),
min(min),
max(max)
{
}
virtual void ExportBits(QBitArray & output)
{
unsigned int value = field;
if (value > max) value = max;
if (value < min) value = min;
output.resize(N);
for (int i=0; i<N; i++) {
if (value & (1<<i))
output.setBit(i);
}
}
virtual void ImportBits(QBitArray & input)
{
field = 0;
for (int i=0; i<N; i++) {
if (input[i])
field |= (1<<i);
}
}
virtual unsigned int size()
{
return N;
}
protected:
unsigned int & field;
unsigned int min;
unsigned int max;
private:
UnsignedField();
};
template<int N>
class BoolField: public DataField {
public:
explicit BoolField(bool & field):
DataField("Bool"),
field(field)
{
}
virtual void ExportBits(QBitArray & output)
{
output.resize(N);
if (field) {
output.setBit(0);
}
}
virtual void ImportBits(QBitArray & input)
{
field = input[0] ? true : false;
}
virtual unsigned int size()
{
return N;
}
protected:
bool & field;
private:
BoolField();
};
template<int N>
class SignedField: public DataField {
public:
SignedField(int & field):
DataField("Signed"),
field(field),
min(INT_MIN),
max(INT_MAX)
{
}
SignedField(int & field, const char *name):
DataField(name),
field(field),
min(INT_MIN),
max(INT_MAX)
{
}
SignedField(int & field, int min, int max, const char *name="Signed"):
DataField(name),
field(field),
min(min),
max(max)
{
}
virtual void ExportBits(QBitArray & output)
{
int value = field;
if (value > max) value = max;
if (value < min) value = min;
output.resize(N);
for (int i=0; i<N; i++) {
if (((unsigned int)value) & (1<<i))
output.setBit(i);
}
}
virtual void ImportBits(QBitArray & input)
{
unsigned int value = 0;
for (int i=0; i<N; i++) {
if (input[i])
value |= (1<<i);
}
if (input[N-1]) {
for (unsigned int i=N; i<8*sizeof(int); i++) {
value |= (1<<i);
}
}
field = (int)value;
}
virtual unsigned int size()
{
return N;
}
protected:
int & field;
int min;
int max;
};
template<int N>
class SpareBitsField: public UnsignedField<N> {
public:
SpareBitsField():
UnsignedField<N>(spare, 0, 0, "Spare"),
spare(0)
{
}
protected:
unsigned int spare;
};
template<int N>
class CharField: public DataField {
public:
CharField(char *field):
DataField("Char"),
field(field)
{
}
virtual void ExportBits(QBitArray & output)
{
output.resize(N*8);
int b = 0;
int len = strlen(field);
for (int i=0; i<N; i++) {
int idx = (i>=len ? 0 : field[i]);
for (int j=0; j<8; j++, b++) {
if (idx & (1<<j))
output.setBit(b);
}
}
}
virtual void ImportBits(QBitArray & input)
{
unsigned int b = 0;
for (int i=0; i<N; i++) {
int8_t idx = 0;
for (int j=0; j<8; j++) {
if (input[b++])
idx |= (1<<j);
}
field[i] = idx;
}
}
virtual unsigned int size()
{
return 8*N;
}
protected:
char * field;
};
int8_t char2idx(char c);
char idx2char(int8_t idx);
template<int N>
class ZCharField: public DataField {
public:
ZCharField(char *field):
DataField("ZChar"),
field(field)
{
}
virtual void ExportBits(QBitArray & output)
{
output.resize(N*8);
int b = 0;
int len = strlen(field);
for (int i=0; i<N; i++) {
int idx = i>=len ? 0 : char2idx(field[i]);
for (int j=0; j<8; j++, b++) {
if (idx & (1<<j))
output.setBit(b);
}
}
}
virtual void ImportBits(QBitArray & input)
{
unsigned int b = 0;
for (int i=0; i<N; i++) {
int8_t idx = 0;
for (int j=0; j<8; j++) {
if (input[b++])
idx |= (1<<j);
}
field[i] = idx2char(idx);
}
field[N] = '\0';
for (int i=N-1; i>=0; i--) {
if (field[i] == ' ')
field[i] = '\0';
else
break;
}
}
virtual unsigned int size()
{
return 8*N;
}
protected:
char * field;
};
class StructField: public DataField {
public:
StructField(const char *name="Struct"):
DataField(name)
{
}
~StructField() {
foreach(DataField *field, fields) {
delete field;
}
}
inline void Append(DataField *field) {
fields.append(field);
}
virtual void ExportBits(QBitArray & output)
{
int offset = 0;
output.resize(size());
foreach(DataField *field, fields) {
QBitArray bits;
field->ExportBits(bits);
for (int i=0; i<bits.size(); i++)
output[offset++] = bits[i];
}
}
virtual void ImportBits(QBitArray & input)
{
int offset = 0;
foreach(DataField *field, fields) {
unsigned int size = field->size();
QBitArray bits(size);
for (unsigned int i=0; i<size; i++) {
bits[i] = input[offset++];
}
field->ImportBits(bits);
}
}
virtual unsigned int size()
{
unsigned int result = 0;
foreach(DataField *field, fields) {
result += field->size();
}
return result;
}
virtual int Dump(int level=0, int offset=0)
{
for (int i=0; i<level; i++) printf(" ");
printf("%s\n", getName());
foreach(DataField *field, fields) {
offset = field->Dump(level+1, offset);
}
return offset;
}
protected:
QList<DataField *> fields;
};
class TransformedField: public DataField {
public:
TransformedField(DataField & field):
DataField(),
field(field)
{
}
virtual ~TransformedField()
{
}
virtual void ExportBits(QBitArray & output)
{
beforeExport();
field.ExportBits(output);
}
virtual void ImportBits(QBitArray & input)
{
field.ImportBits(input);
afterImport();
}
virtual const char *getName()
{
return field.getName();
}
virtual unsigned int size()
{
return field.size();
}
virtual void beforeExport() = 0;
virtual void afterImport() = 0;
virtual int Dump(int level=0, int offset=0)
{
beforeExport();
return field.Dump(level, offset);
}
protected:
DataField & field;
};
class ConversionTable {
public:
bool exportValue(const int before, int &after)
{
after = 0;
for (std::list<ConversionTuple>::iterator it=internalTable.begin(); it!=internalTable.end(); it++) {
ConversionTuple tuple = *it;
if (before == tuple.a) {
after = tuple.b;
return true;
}
}
return false;
}
bool importValue(const int before, int &after)
{
after = 0;
for (std::list<ConversionTuple>::iterator it=internalTable.begin(); it!=internalTable.end(); it++) {
ConversionTuple tuple = *it;
if (before == tuple.b) {
after = tuple.a;
return true;
}
}
return false;
}
protected:
class ConversionTuple {
public:
ConversionTuple(const int a, const int b):
a(a),
b(b)
{
}
int a;
int b;
};
void addConversion(const int a, const int b)
{
internalTable.push_back(ConversionTuple(a, b));
}
std::list<ConversionTuple> internalTable;
};
template<class T>
class ConversionField: public TransformedField {
public:
ConversionField(int & field, ConversionTable *table, const char *name, const QString & error = ""):
TransformedField(internalField),
internalField(_field, name),
field(field),
_field(0),
table(table),
shift(0),
min(INT_MIN),
max(INT_MAX),
exportFunc(NULL),
importFunc(NULL),
error(error)
{
}
ConversionField(unsigned int & field, ConversionTable *table, const char *name, const QString & error = ""):
TransformedField(internalField),
internalField((unsigned int &)_field, name),
field((int &)field),
_field(0),
table(table),
shift(0),
min(INT_MIN),
max(INT_MAX),
exportFunc(NULL),
importFunc(NULL),
error(error)
{
}
ConversionField(int & field, int (*exportFunc)(int), int (*importFunc)(int)):
TransformedField(internalField),
internalField(_field),
field(field),
_field(0),
table(NULL),
shift(0),
min(INT_MIN),
max(INT_MAX),
exportFunc(exportFunc),
importFunc(importFunc),
error("")
{
}
ConversionField(int & field, int shift, int min=INT_MIN, int max=INT_MAX, const char *name = "Signed shifted"):
TransformedField(internalField),
internalField(_field, name),
field(field),
_field(0),
table(NULL),
shift(shift),
min(min),
max(max),
exportFunc(NULL),
importFunc(NULL),
error("")
{
}
ConversionField(unsigned int & field, int shift):
TransformedField(internalField),
internalField((unsigned int &)_field),
field((int &)field),
_field(0),
table(NULL),
shift(shift),
min(INT_MIN),
max(INT_MAX),
exportFunc(NULL),
importFunc(NULL),
error("")
{
}
virtual void beforeExport()
{
if (table) {
if (table->exportValue(field, _field))
return;
if (!error.isEmpty())
EEPROMWarnings += error + "\n";
}
else if (shift) {
if (field < min) _field = min + shift;
else if (field > max) _field = max + shift;
else _field = field + shift;
}
else {
_field = exportFunc(field);
}
}
virtual void afterImport()
{
if (table) {
if (table->importValue(_field, field))
return;
}
else if (shift) {
field = _field - shift;
}
else {
field = importFunc(_field);
}
}
protected:
T internalField;
int & field;
int _field;
ConversionTable * table;
int shift;
int min;
int max;
int (*exportFunc)(int);
int (*importFunc)(int);
const QString error;
};
#endif

View file

@ -0,0 +1,766 @@
#include <stdio.h>
#include <list>
#include "eeprominterface.h"
#include "firmwares/er9x/er9xinterface.h"
#include "firmwares/th9x/th9xinterface.h"
#include "firmwares/gruvin9x/gruvin9xinterface.h"
#include "firmwares/opentx/open9xinterface.h"
#include "firmwares/ersky9x/ersky9xinterface.h"
#include "qsettings.h"
QString EEPROMWarnings;
void setEEPROMString(char *dst, const char *src, int size)
{
memcpy(dst, src, size);
for (int i=size-1; i>=0; i--) {
if (dst[i] == '\0')
dst[i] = ' ';
else
break;
}
}
void getEEPROMString(char *dst, const char *src, int size)
{
memcpy(dst, src, size);
dst[size] = '\0';
for (int i=size-1; i>=0; i--) {
if (dst[i] == ' ')
dst[i] = '\0';
else
break;
}
}
int RawSource::getDecimals(const ModelData & Model)
{
if(type==SOURCE_TYPE_TELEMETRY) {
switch (index) {
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].type==0 ? 2: 0);
case TELEMETRY_SOURCE_CELL:
return 2;
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
case TELEMETRY_SOURCE_CURRENT:
return 1;
default:
return 0;
}
}
return 0;
}
double RawSource::getMin(const ModelData & Model)
{
switch (type) {
case SOURCE_TYPE_TELEMETRY:
switch (index) {
/*case TELEMETRY_SOURCE_NONE:
case TELEMETRY_SOURCE_TX_BATT:
case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2:
return 0; */
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
if (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].type==0) {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].offset*Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio)/2550.0;
}
else {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].offset*Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio)/255.0;
}
case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_GPS_ALT:
return -500;
case TELEMETRY_SOURCE_T1:
case TELEMETRY_SOURCE_T2:
return -30;
default:
return 0;
}
break;
default:
return (Model.extendedLimits ? -125 :-100);
}
}
double RawSource::getMax(const ModelData & Model)
{
switch (type) {
case SOURCE_TYPE_TELEMETRY:
switch (index) {
case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2:
return 765;
case TELEMETRY_SOURCE_RSSI_TX:
case TELEMETRY_SOURCE_RSSI_RX:
return 100;
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
if (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].type==0) {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio-(Model.frsky.channels[index-TELEMETRY_SOURCE_A1].offset*Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio)/255.0)/10;
} else {
return Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio-(Model.frsky.channels[index-TELEMETRY_SOURCE_A1].offset*Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio)/255.0;
}
case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_GPS_ALT:
return 1540;
case TELEMETRY_SOURCE_RPM:
return 12750;
case TELEMETRY_SOURCE_FUEL:
return 100;
case TELEMETRY_SOURCE_T1:
case TELEMETRY_SOURCE_T2:
return 225;
case TELEMETRY_SOURCE_SPEED:
return 944;
case TELEMETRY_SOURCE_DIST:
return 2040;
case TELEMETRY_SOURCE_CELL:
return 5.1;
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
return 25.5;
case TELEMETRY_SOURCE_CURRENT:
return 127.5;
case TELEMETRY_SOURCE_CONSUMPTION:
return 5100;
case TELEMETRY_SOURCE_POWER:
return 1275;
default:
return 125;
}
break;
default:
return (Model.extendedLimits ? 125 :100);
}
}
double RawSource::getOffset(const ModelData & Model)
{
if (type==SOURCE_TYPE_TELEMETRY) {
switch (index) {
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
if (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].type==0) {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].offset*Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio)/2550.0;
}
else {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].offset*Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio)/255.0;
}
case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_GPS_ALT:
return 524;
case TELEMETRY_SOURCE_RPM:
return 6400;
case TELEMETRY_SOURCE_FUEL:
return 0;
case TELEMETRY_SOURCE_T1:
case TELEMETRY_SOURCE_T2:
return 98;
case TELEMETRY_SOURCE_SPEED:
return 474;
case TELEMETRY_SOURCE_DIST:
return 1024;
case TELEMETRY_SOURCE_CELL:
return 2.56;
default:
return 0;
}
}
return 0;
}
int RawSource::getRawOffset(const ModelData & Model)
{
switch (type) {
case SOURCE_TYPE_TELEMETRY:
switch (index) {
case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2:
case TELEMETRY_SOURCE_RSSI_TX:
case TELEMETRY_SOURCE_RSSI_RX:
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
case TELEMETRY_SOURCE_FUEL:
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
case TELEMETRY_SOURCE_CURRENT:
case TELEMETRY_SOURCE_CONSUMPTION:
case TELEMETRY_SOURCE_POWER:
return 128;
default:
return 0;
}
default:
return 0;
}
}
double RawSource::getStep(const ModelData & Model)
{
switch (type) {
case SOURCE_TYPE_TELEMETRY:
switch (index) {
case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2:
return 3;
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
if (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].type==0) {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio/2550.0);
}
else {
return (Model.frsky.channels[index-TELEMETRY_SOURCE_A1].ratio/255.0);
}
case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_GPS_ALT:
return 8;
case TELEMETRY_SOURCE_RPM:
return 50;
case TELEMETRY_SOURCE_SPEED:
return 4;
case TELEMETRY_SOURCE_DIST:
return 8;
case TELEMETRY_SOURCE_CELL:
return 0.02;
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
return 0.1;
case TELEMETRY_SOURCE_CURRENT:
return 0.5;
case TELEMETRY_SOURCE_CONSUMPTION:
return 20;
case TELEMETRY_SOURCE_POWER:
return 5;
default:
return 1;
}
break;
default:
return 1;
}
}
QString RawSource::toString()
{
static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") };
static const QString trims[] = { QObject::tr("TrmR"), QObject::tr("TrmE"), QObject::tr("TrmT"), QObject::tr("TrmA")};
static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") };
static const QString potsX9D[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS") };
static const QString rotary[] = { QObject::tr("REa"), QObject::tr("REb") };
static const QString switches9X[] = { QObject::tr("3POS"),
QObject::tr("THR"), QObject::tr("RUD"), QObject::tr("ELE"),
QObject::tr("AIL"), QObject::tr("GEA"), QObject::tr("TRN"),
};
static const QString switchesX9D[] = { QObject::tr("SA"), QObject::tr("SB"), QObject::tr("SC"), QObject::tr("SD"),
QObject::tr("SE"), QObject::tr("SF"), QObject::tr("SG"), QObject::tr("SH"),
};
static const QString telemetry[] = { QObject::tr("Batt"), QObject::tr("Timer1"), QObject::tr("Timer2"),
(IS_TARANIS(GetEepromInterface()->getBoard()) ? QObject::tr("SWR") : QObject::tr("Tx")), (IS_TARANIS(GetEepromInterface()->getBoard()) ? QObject::tr("RSSI") : QObject::tr("Rx")), QObject::tr("A1"), QObject::tr("A2"), QObject::tr("Alt"), QObject::tr("Rpm"), QObject::tr("Fuel"), QObject::tr("T1"),
QObject::tr("T2"), QObject::tr("Speed"), QObject::tr("Dist"), QObject::tr("GPS Alt"), QObject::tr("Cell"), QObject::tr("Cels"), QObject::tr("Vfas"), QObject::tr("Curr"),
QObject::tr("Cnsp"), QObject::tr("Powr"), QObject::tr("AccX"), QObject::tr("AccY"), QObject::tr("AccZ"), QObject::tr("HDG "), QObject::tr("VSpd"), QObject::tr("A1-"),
QObject::tr("A2-"), QObject::tr("Alt-"), QObject::tr("Alt+"), QObject::tr("Rpm+"), QObject::tr("T1+"), QObject::tr("T2+"), QObject::tr("Spd+"), QObject::tr("Dst+"),
QObject::tr("Cur+"), QObject::tr("Pwr+"), QObject::tr("ACC "), QObject::tr("Time"),
};
static const QString virtualSwitches[] = { QObject::tr("CS1"), QObject::tr("CS2"), QObject::tr("CS3"), QObject::tr("CS4"), QObject::tr("CS5"), QObject::tr("CS6"), QObject::tr("CS7"), QObject::tr("CS8"), QObject::tr("CS9"), QObject::tr("CSA"),
QObject::tr("CSB"), QObject::tr("CSC"), QObject::tr("CSD"), QObject::tr("CSE"), QObject::tr("CSF"), QObject::tr("CSG"), QObject::tr("CSH"), QObject::tr("CSI"), QObject::tr("CSJ"), QObject::tr("CSK"),
QObject::tr("CSL"), QObject::tr("CSM"), QObject::tr("CSN"), QObject::tr("CSO"), QObject::tr("CSP"), QObject::tr("CSQ"), QObject::tr("CSR"), QObject::tr("CSS"), QObject::tr("CST"), QObject::tr("CSU"),
QObject::tr("CSV"), QObject::tr("CSW")
};
if (index<0) {
return QObject::tr("----");
}
switch(type) {
case SOURCE_TYPE_STICK:
if (index < 4)
return CHECK_IN_ARRAY(sticks, index);
else
return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsX9D, index-4) : CHECK_IN_ARRAY(pots9X, index-4));
case SOURCE_TYPE_TRIM:
return CHECK_IN_ARRAY(trims, index);
case SOURCE_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotary, index);
case SOURCE_TYPE_MAX:
return QObject::tr("MAX");
case SOURCE_TYPE_SWITCH:
return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(switchesX9D, index) : CHECK_IN_ARRAY(switches9X, index));
case SOURCE_TYPE_CUSTOM_SWITCH:
return virtualSwitches[index];
case SOURCE_TYPE_CYC:
return QObject::tr("CYC%1").arg(index+1);
case SOURCE_TYPE_PPM:
return QObject::tr("PPM%1").arg(index+1);
case SOURCE_TYPE_CH:
if (index < GetEepromInterface()->getCapability(Outputs))
return QObject::tr("CH%1%2").arg((index+1)/10).arg((index+1)%10);
else
return QObject::tr("X%1").arg(index-GetEepromInterface()->getCapability(Outputs)+1);
case SOURCE_TYPE_TELEMETRY:
return CHECK_IN_ARRAY(telemetry, index);
case SOURCE_TYPE_GVAR:
return QObject::tr("GV%1").arg(index+1);
default:
return QObject::tr("----");
}
}
QString SwitchUp(const char sw)
{
const char result[] = {'S', sw, (char)0xE2, (char)0x86, (char)0x91, 0};
return QString::fromUtf8(result);
}
QString SwitchDn(const char sw)
{
const char result[] = {'S', sw, (char)0xE2, (char)0x86, (char)0x93, 0};
return QString::fromUtf8(result);
}
QString RawSwitch::toString()
{
static const QString switches9X[] = { QObject::tr("THR"), QObject::tr("RUD"), QObject::tr("ELE"),
QObject::tr("ID0"), QObject::tr("ID1"), QObject::tr("ID2"),
QObject::tr("AIL"), QObject::tr("GEA"), QObject::tr("TRN")
};
static const QString switchesX9D[] = { SwitchUp('A'), QString::fromUtf8("SA-"), SwitchDn('A'),
SwitchUp('B'), QString::fromUtf8("SB-"), SwitchDn('B'),
SwitchUp('C'), QString::fromUtf8("SC-"), SwitchDn('C'),
SwitchUp('D'), QString::fromUtf8("SD-"), SwitchDn('D'),
SwitchUp('E'), QString::fromUtf8("SE-"), SwitchDn('E'),
SwitchUp('F'), SwitchDn('F'),
SwitchUp('G'), QString::fromUtf8("SG-"), SwitchDn('G'),
SwitchUp('H'), SwitchDn('H'),
};
static const QString virtualSwitches[] = { QObject::tr("CS1"), QObject::tr("CS2"), QObject::tr("CS3"), QObject::tr("CS4"), QObject::tr("CS5"), QObject::tr("CS6"), QObject::tr("CS7"), QObject::tr("CS8"), QObject::tr("CS9"), QObject::tr("CSA"),
QObject::tr("CSB"), QObject::tr("CSC"), QObject::tr("CSD"), QObject::tr("CSE"), QObject::tr("CSF"), QObject::tr("CSG"), QObject::tr("CSH"), QObject::tr("CSI"), QObject::tr("CSJ"), QObject::tr("CSK"),
QObject::tr("CSL"), QObject::tr("CSM"), QObject::tr("CSN"), QObject::tr("CSO"), QObject::tr("CSP"), QObject::tr("CSQ"), QObject::tr("CSR"), QObject::tr("CSS"), QObject::tr("CST"), QObject::tr("CSU"),
QObject::tr("CSV"), QObject::tr("CSW")
};
switch(type) {
case SWITCH_TYPE_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1);
else
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1);
case SWITCH_TYPE_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1);
case SWITCH_TYPE_ON:
return QObject::tr("ON");
case SWITCH_TYPE_ONM:
if (index==0) {
return QObject::tr("ONE");
}
else if (index==1) {
return QObject::tr("!ONE");
}
break;
case SWITCH_TYPE_TRN:
if (index==0) {
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return SwitchDn('H')+"s";
else
return QObject::tr("TRNs");
} else if (index==1) {
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return SwitchDn('H')+"l";
else
return QObject::tr("TRNl");
}
break;
case SWITCH_TYPE_REA:
if (index==0) {
if (GetEepromInterface()->getBoard() == BOARD_SKY9X)
return QObject::tr("REAs");
} else if (index==1) {
if (GetEepromInterface()->getBoard() == BOARD_SKY9X)
return QObject::tr("REAl");
}
break;
case SWITCH_TYPE_OFF:
return QObject::tr("OFF");
case SWITCH_TYPE_MOMENT_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switchesX9D, -index-1)+QString("t");
else
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switches9X, -index-1)+QString("t");
case SWITCH_TYPE_MOMENT_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(virtualSwitches, -index-1)+QString("t");
default:
break;
}
return QObject::tr("----");
}
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
contrast = 25;
vBatWarn = 90;
for (int i=0; i<(NUM_STICKS+C9X_NUM_POTS ); ++i) {
calibMid[i] = 0x200;
calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180;
}
QSettings settings("companion9x", "companion9x");
templateSetup = settings.value("default_channel_order", 0).toInt();
stickMode = settings.value("default_mode", 1).toInt();
int profile_id = settings.value("ActiveProfile", 0).toInt();
if (profile_id>0) {
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id);
settings.beginGroup(profile);
QString t_calib=settings.value("StickPotCalib","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) {
settings.endGroup();
settings.endGroup();
return;
} else {
QString t_trainercalib=settings.value("TrainerCalib","").toString();
int8_t t_vBatCalib=(int8_t)settings.value("VbatCalib", vBatCalib).toInt();
int8_t t_currentCalib=(int8_t)settings.value("currentCalib", currentCalib).toInt();
int8_t t_PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", PPM_Multiplier).toInt();
uint8_t t_stickMode=(uint8_t)settings.value("GSStickMode", stickMode).toUInt();
uint8_t t_vBatWarn=(uint8_t)settings.value("vBatWarn",vBatWarn).toUInt();
QString t_DisplaySet=settings.value("Display","").toString();
QString t_BeeperSet=settings.value("Beeper","").toString();
QString t_HapticSet=settings.value("Haptic","").toString();
QString t_SpeakerSet=settings.value("Speaker","").toString();
QString t_CountrySet=settings.value("countryCode","").toString();
settings.endGroup();
settings.endGroup();
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=t_calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibMid[i]=byte16;
Byte=t_calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanNeg[i]=byte16;
Byte=t_calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanPos[i]=byte16;
}
for (int i=0; i<4; i++) {
Byte=t_trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
trainer.calib[i]=byte16;
}
currentCalib=t_currentCalib;
vBatCalib=t_vBatCalib;
vBatWarn=t_vBatWarn;
PPM_Multiplier=t_PPM_Multiplier;
stickMode = t_stickMode;
}
if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) {
uint8_t byte8u;
int8_t byte8;
bool ok;
byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16);
if (ok)
optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16);
if (ok)
contrast=byte8u;
byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16);
if (ok)
backlightBright=byte8u;
byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
beeperMode=(BeeperMode)byte8;
byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
beeperLength=byte8;
byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16);
if (ok)
hapticStrength=byte8u;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
hapticLength=byte8;
byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
speakerMode=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
speakerPitch=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
speakerVolume=byte8u;
if (t_CountrySet.length()==6) {
byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16);
if (ok)
countryCode=byte8u;
byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16);
if (ok)
imperial=byte8u;
QString chars=t_CountrySet.mid(4,2);
ttsLanguage[0]=chars[0].toAscii();
ttsLanguage[1]=chars[1].toAscii();
}
}
}
}
}
ModelData::ModelData()
{
clear();
}
void ModelData::clear()
{
memset(this, 0, sizeof(ModelData));
moduleData[0].channelsCount = 8;
moduleData[1].channelsStart = 0;
moduleData[1].channelsCount = 8;
moduleData[0].ppmDelay = 300;
moduleData[1].ppmDelay = 300;
moduleData[2].ppmDelay = 300;
int board=GetEepromInterface()->getBoard();
if (IS_TARANIS(board)) {
moduleData[0].protocol=PXX_XJT_X16;
moduleData[1].protocol=OFF;
} else {
moduleData[0].protocol=PPM;
moduleData[1].protocol=OFF;
}
for (int i=0; i<C9X_MAX_PHASES; i++)
phaseData[i].clear();
for (int i=0; i<C9X_MAX_EXPOS; i++)
expoData[i].clear();
for (int i=0; i<C9X_MAX_MIXERS; i++)
mixData[i].clear();
for(int i=0; i<4; i++){
mixData[i].destCh = i+1;
mixData[i].srcRaw = RawSource(SOURCE_TYPE_STICK, i);
mixData[i].weight = 100;
}
for (int i=0; i<C9X_NUM_CHNOUT; i++)
limitData[i].clear();
for (int i=0; i<NUM_STICKS; i++)
expoData[i].clear();
for (int i=0; i<C9X_NUM_CSW; i++)
customSw[i].clear();
bool custom = GetEepromInterface()->getCapability(CustomCurves);
for (int i=0; i<C9X_MAX_CURVES; i++) {
if (!custom && i>=8)
curves[i].clear(9);
else
curves[i].clear(5);
}
swashRingData.clear();
frsky.clear();
}
bool ModelData::isempty()
{
return !used;
}
void ModelData::setDefault(uint8_t id)
{
clear();
used = true;
sprintf(name, "MODEL%02d", id+1);
}
unsigned int ModelData::getTrimFlightPhase(uint8_t idx, int8_t phase)
{
// if (phase == -1) phase = getFlightPhase();
for (uint8_t i=0; i<C9X_MAX_PHASES; i++) {
if (phase == 0 || phaseData[phase].trimRef[idx] < 0) return phase;
phase = phaseData[phase].trimRef[idx];
}
return 0;
}
void ModelData::removeGlobalVar(int & var)
{
if (var >= 126 && var <= 130)
var = phaseData[0].gvars[var-126];
else if (var <= -126 && var >= -130)
var = - phaseData[0].gvars[-126-var];
}
ModelData ModelData::removeGlobalVars()
{
ModelData result = *this;
for (int i=0; i<C9X_MAX_MIXERS; i++) {
removeGlobalVar(mixData[i].weight);
removeGlobalVar(mixData[i].differential);
removeGlobalVar(mixData[i].sOffset);
}
for (int i=0; i<C9X_MAX_EXPOS; i++) {
removeGlobalVar(expoData[i].weight);
removeGlobalVar(expoData[i].expo);
}
return result;
}
QList<EEPROMInterface *> eepromInterfaces;
void RegisterEepromInterfaces()
{
QSettings settings("companion9x", "companion9x");
int rev4a = settings.value("rev4asupport",0).toInt();
eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK));
eepromInterfaces.push_back(new Open9xInterface(BOARD_M128));
eepromInterfaces.push_back(new Open9xInterface(BOARD_GRUVIN9X));
eepromInterfaces.push_back(new Open9xInterface(BOARD_SKY9X));
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS));
if (rev4a)
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS_REV4a));
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK));
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X));
eepromInterfaces.push_back(new Ersky9xInterface());
eepromInterfaces.push_back(new Th9xInterface());
eepromInterfaces.push_back(new Er9xInterface());
}
QList<FirmwareInfo *> firmwares;
FirmwareVariant default_firmware_variant;
FirmwareVariant current_firmware_variant;
const char * ER9X_STAMP = "http://er9x.googlecode.com/svn/trunk/src/stamp-er9x.h";
const char * ERSKY9X_STAMP = "http://ersky9x.googlecode.com/svn/trunk/src/stamp-ersky9x.h";
void RegisterFirmwares()
{
firmwares.push_back(new FirmwareInfo("th9x", QObject::tr("th9x"), new Th9xInterface(), "http://th9x.googlecode.com/svn/trunk/%1.bin", "http://th9x.googlecode.com/svn/trunk/src/stamp-th9x.h"));
firmwares.push_back(new FirmwareInfo("er9x", QObject::tr("er9x"), new Er9xInterface(), "http://er9x.googlecode.com/svn/trunk/%1.hex", ER9X_STAMP));
FirmwareInfo * er9x = firmwares.last();
Option er9x_options[] = { { "noht", "", 0 }, { "frsky", "", 0 }, { "frsky-noht", "", 0 }, { "jeti", "", 0 }, { "ardupilot", "", 0 }, { "nmea", "", 0 }, { NULL } };
er9x->addOptions(er9x_options);
er9x->addOption("noht");
RegisterOpen9xFirmwares();
#ifndef __APPLE__
firmwares.push_back(new FirmwareInfo("ersky9x", QObject::tr("ersky9x"), new Ersky9xInterface(), "http://ersky9x.googlecode.com/svn/trunk/ersky9x_rom.bin", ERSKY9X_STAMP));
#endif
default_firmware_variant = GetFirmwareVariant("opentx-stock-heli-templates-en");
RegisterEepromInterfaces();
}
bool LoadEeprom(RadioData &radioData, uint8_t *eeprom, int size)
{
foreach(EEPROMInterface *eepromInterface, eepromInterfaces) {
if (eepromInterface->load(radioData, eeprom, size))
return true;
}
return false;
}
bool LoadBackup(RadioData &radioData, uint8_t *eeprom, int size, int index)
{
foreach(EEPROMInterface *eepromInterface, eepromInterfaces) {
if (eepromInterface->loadBackup(radioData, eeprom, size, index))
return true;
}
return false;
}
bool LoadEepromXml(RadioData &radioData, QDomDocument &doc)
{
foreach(EEPROMInterface *eepromInterface, eepromInterfaces) {
if (eepromInterface->loadxml(radioData, doc))
return true;
}
return false;
}
FirmwareVariant GetFirmwareVariant(QString id)
{
FirmwareVariant result;
foreach(FirmwareInfo * firmware, firmwares) {
if (id.contains(firmware->id+"-") || (!id.contains("-") && id.contains(firmware->id))) {
result.id = id;
result.firmware = firmware;
result.variant = firmware->getVariant(id);
return result;
}
}
return default_firmware_variant;
}
void FirmwareInfo::addOption(const char *option, QString tooltip, uint32_t variant)
{
Option options[] = { { option, tooltip, variant }, { NULL } };
addOptions(options);
}
unsigned int FirmwareInfo::getVariant(const QString & variantId)
{
unsigned int variant = variantBase;
QStringList options = variantId.mid(id.length()+1).split("-", QString::SkipEmptyParts);
foreach(QString option, options) {
foreach(QList<Option> group, opts) {
foreach(Option opt, group) {
if (opt.name == option) {
variant += opt.variant;
}
}
}
}
return variant;
}
void FirmwareInfo::addLanguage(const char *lang)
{
languages.push_back(lang);
}
void FirmwareInfo::addTTSLanguage(const char *lang)
{
ttslanguages.push_back(lang);
}
void FirmwareInfo::addOptions(Option options[])
{
QList<Option> opts;
for (int i=0; options[i].name; i++) {
opts.push_back(options[i]);
}
this->opts.push_back(opts);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,334 @@
#include "expodialog.h"
#include "ui_expodialog.h"
#include "eeprominterface.h"
#include "helpers.h"
ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
QDialog(parent),
ui(new Ui::ExpoDialog),
ed(expoData)
{
ui->setupUi(this);
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn)));
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==0) {
ui->expoGV->setDisabled(true);
ui->weightGV->setDisabled(true);
ui->expoCurveGV->setDisabled(true);
if (ed->expo>100) {
ed->expo=0;
}
if (ed->weight>100 || ed->weight<-100) {
ed->weight=100;
}
if (ed->curveParam>100 || ed->curveParam<-100) {
ed->curveParam=0;
}
}
populateGVCB(ui->expoCB,ed->expo);
populateGVCB(ui->weightCB,ed->weight);
populateGVCB(ui->expoCurveCB,ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
if (ed->weight>100 || ed->weight<0) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(ed->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
if (ed->expo>100 || ed->expo<-100) {
ui->expoGV->setChecked(true);
ui->expoSB->hide();
ui->expoCB->show();
} else {
ui->expoGV->setChecked(false);
ui->expoSB->setValue(ed->expo);
ui->expoSB->show();
ui->expoCB->hide();
}
ui->expoCurveSB->setMinimum(-100);
ui->expoCurveSB->setMaximum(100);
if (ed->curveParam>100 || ed->curveParam<-100) {
ui->expoCurveGV->setChecked(true);
ui->expoCurveSB->hide();
ui->expoCurveCB->show();
} else {
ui->expoCurveGV->setChecked(false);
ui->expoCurveSB->setValue(ed->curveParam);
ui->expoCurveSB->show();
ui->expoCurveCB->hide();
}
} else {
ui->expoGV->hide();
ui->weightGV->hide();
ui->expoCurveGV->hide();
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
ui->expoSB->setValue(ed->expo);
ui->expoCurveSB->setMinimum(-100);
ui->expoCurveSB->setMaximum(100);
ui->expoCurveSB->setValue(ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
ui->weightSB->setValue(ed->weight);
}
populateSwitchCB(ui->switchesCB,ed->swtch);
if (ed->curveMode==0) {
populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x
} else {
populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x
}
ui->modeCB->setCurrentIndex(ed->mode-1);
if (!GetEepromInterface()->getCapability(HasExpoCurves)) {
ui->label_curves->hide();
ui->curvesCB->hide();
ed->curveMode=1;
}
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
ui->label_curves->setText(tr("Curve"));
} else {
ui->label_expo->hide();
ui->expoCB->hide();
ui->expoGV->hide();
ui->expoSB->hide();
}
if (!GetEepromInterface()->getCapability(FlightPhases)) {
ui->label_phases->hide();
for (int i=0; i<9; i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
} else {
int mask=1;
for (int i=0; i<9 ; i++) {
if ((ed->phases & mask)==0) {
cb_fp[i]->setChecked(true);
}
mask <<= 1;
}
for (int i=GetEepromInterface()->getCapability(FlightPhases); i<9;i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
}
int expolength=GetEepromInterface()->getCapability(HasExpoNames);
if (!expolength) {
ui->label_name->hide();
ui->expoName->hide();
} else {
ui->expoName->setMaxLength(expolength);
}
ui->expoName->setValidator(new QRegExpValidator(rx, this));
ui->expoName->setText(ed->name);
valuesChanged();
connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->expoCurveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoCurveSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->expoCurveGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
for (int i=0; i<9; i++) {
connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
}
QTimer::singleShot(0, this, SLOT(shrink()));
}
ExpoDialog::~ExpoDialog()
{
delete ui;
}
void ExpoDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void ExpoDialog::widgetChanged()
{
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==1) {
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
if (ui->expoGV->isChecked()) {
ui->expoCB->show();
ui->expoSB->hide();
} else {
ui->expoCB->hide();
ui->expoSB->show();
}
} else {
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
}
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
}
}
void ExpoDialog::valuesChanged()
{
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
if (ui->curvesCB->currentIndex()==0) {
if (GetEepromInterface()->getCapability(ExpoIsCurve)) {
ed->curveMode = 0;
ui->expoCurveGV->show();
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
ed->curveParam = ui->expoCurveSB->value();
}
ed->expo = ed->curveParam;
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
ed->curveMode = 0;
if (ui->expoGV->isChecked()) {
ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt();
} else {
ed->expo = ui->expoSB->value();
}
ed->curveParam = ed->expo;
}
} else {
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
ed->curveMode = 1;
ed->curveParam = ui->curvesCB->currentIndex();
if (ui->expoGV->isChecked()) {
ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt();
} else {
ed->expo = ui->expoSB->value();
}
} else {
ed->curveMode = 1;
ed->curveParam = ui->curvesCB->currentIndex();
ed->expo = 0;
}
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
}
if (ui->weightGV->isChecked()) {
ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt();
} else {
ed->weight = ui->weightSB->value();
}
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
ed->mode = ui->modeCB->currentIndex() + 1;
int i=0;
for (i=0; i<ui->expoName->text().toAscii().length(); i++) {
ed->name[i]=ui->expoName->text().toAscii().at(i);
}
ed->name[i]=0;
ed->phases=0;
for (int i=8; i>=0 ; i--) {
if (!cb_fp[i]->checkState()) {
ed->phases+=1;
}
ed->phases<<=1;
}
ed->phases>>=1;
if (GetEepromInterface()->getCapability(FlightPhases)) {
int zeros=0;
int ones=0;
int phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (phtemp & 1) {
ones++;
}
else {
zeros++;
}
phtemp >>=1;
}
if (zeros==1) {
phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if ((phtemp & 1)==0) {
break;
}
phtemp >>=1;
}
}
else if (ones==1) {
phtemp=ed->phases;
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) {
if (phtemp & 1) {
break;
}
phtemp >>=1;
}
}
} else {
ed->phases=0;
}
}
void ExpoDialog::shrink()
{
resize(0,0);
}

View file

@ -0,0 +1,30 @@
#ifndef EXPODIALOG_H
#define EXPODIALOG_H
#include <QDialog>
#include "eeprominterface.h"
namespace Ui {
class ExpoDialog;
}
class ExpoDialog : public QDialog {
Q_OBJECT
public:
ExpoDialog(QWidget *parent, ExpoData *mixdata, int stickMode);
~ExpoDialog();
protected:
void changeEvent(QEvent *e);
private slots:
void valuesChanged();
void widgetChanged();
void shrink();
private:
Ui::ExpoDialog *ui;
ExpoData *ed;
};
#endif // EXPODIALOG_H

443
companion/src/expodialog.ui Normal file
View file

@ -0,0 +1,443 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExpoDialog</class>
<widget class="QDialog" name="ExpoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>289</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string/>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_name">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="expoName">
<property name="maxLength">
<number>6</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
<item>
<widget class="QCheckBox" name="weightGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="weightSB"/>
</item>
<item>
<widget class="QComboBox" name="weightCB">
<property name="whatsThis">
<string>Phase used by the expo.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_expo">
<property name="text">
<string>Expo</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,1,0">
<item>
<widget class="QCheckBox" name="expoGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="expoSB"/>
</item>
<item>
<widget class="QComboBox" name="expoCB">
<property name="whatsThis">
<string>Phase used by the expo.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Flight modes</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lb_FP0">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lb_FP1">
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lb_FP2">
<property name="text">
<string>2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="lb_FP3">
<property name="text">
<string>3</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lb_FP4">
<property name="text">
<string>4</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="lb_FP5">
<property name="text">
<string>5</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="lb_FP6">
<property name="text">
<string>6</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="lb_FP7">
<property name="text">
<string>7</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QLabel" name="lb_FP8">
<property name="text">
<string>8</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cb_FP0">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cb_FP1">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="cb_FP2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="cb_FP3">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="cb_FP4">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QCheckBox" name="cb_FP5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QCheckBox" name="cb_FP6">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QCheckBox" name="cb_FP7">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QCheckBox" name="cb_FP8">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Switch</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="switchesCB">
<property name="whatsThis">
<string>Switch used by the expo.
If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_curves">
<property name="text">
<string>Curve/Exponential</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0,1">
<item>
<widget class="QComboBox" name="curvesCB">
<property name="toolTip">
<string/>
</property>
<property name="whatsThis">
<string>The curve used by the expo</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="expoCurveGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="expoCurveSB"/>
</item>
<item>
<widget class="QComboBox" name="expoCurveCB">
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Stick Side</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="modeCB">
<item>
<property name="text">
<string>NEG</string>
</property>
</item>
<item>
<property name="text">
<string>POS</string>
</property>
</item>
<item>
<property name="text">
<string>ALL</string>
</property>
</item>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExpoDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>354</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExpoDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>360</y>
</hint>
<hint type="destinationlabel">
<x>208</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

611
companion/src/file.cpp Normal file
View file

@ -0,0 +1,611 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "stdio.h"
#include "inttypes.h"
#include "string.h"
#include "file.h"
#include <assert.h>
#include <algorithm>
#include "eeprominterface.h"
EFile::EFile():
eeprom(NULL),
eeprom_size(0),
eeFs(NULL),
eeFsArm(NULL)
{
}
void EFile::EeFsCreate(uint8_t *eeprom, int size, BoardEnum board)
{
this->eeprom = eeprom;
this->eeprom_size = size;
this->board = board;
if (board == BOARD_SKY9X) {
memset(eeprom, 0xFF, size);
}
else if (IS_TARANIS(board)) {
eeFsArm = (EeFsArm *)eeprom;
eeFsVersion = 5;
eeFsSize = 8+4*62;
eeFsBlockSize = 64;
eeFsFirstBlock = 1;
eeFsBlocksOffset = eeFsSize - eeFsBlockSize;
if (board == BOARD_TARANIS_REV4a)
eeFsBlocksMax = 1 + (EESIZE_TARANIS_REV4a-eeFsSize)/eeFsBlockSize;
else
eeFsBlocksMax = 1 + (EESIZE_TARANIS-eeFsSize)/eeFsBlockSize;
eeFsLinkSize = sizeof(int16_t);
memset(eeprom, 0, size);
eeFsArm->version = eeFsVersion;
eeFsArm->mySize = eeFsSize;
eeFsArm->freeList = 0;
eeFsArm->bs = 64;
for (unsigned int i=eeFsFirstBlock; i<eeFsBlocksMax-1; i++)
EeFsSetLink(i, i+1);
EeFsSetLink(eeFsBlocksMax-1, 0);
eeFsArm->freeList = eeFsFirstBlock;
// EeFsFlush();
}
else {
eeFs = (EeFs *)eeprom;
eeFsVersion = (board==BOARD_GRUVIN9X || board==BOARD_M128) ? 5 : 4;
eeFsBlockSize = 16;
eeFsLinkSize = 1;
if (eeFsVersion == 5) {
eeFsSize = 4+3*36;
eeFsFirstBlock = 1;
eeFsBlocksOffset = 112 - 16;
eeFsBlocksMax = 1 + (4096-112)/16;
}
else {
eeFsSize = 4+3*20;
eeFsFirstBlock = 4;
eeFsBlocksOffset = 0;
eeFsBlocksMax = 2048/16;
}
memset(eeprom, 0, size);
eeFs->version = eeFsVersion;
eeFs->mySize = eeFsSize;
eeFs->freeList = 0;
eeFs->bs = eeFsBlockSize;
for (unsigned int i=eeFsFirstBlock; i<eeFsBlocksMax-1; i++)
EeFsSetLink(i, i+1);
EeFsSetLink(eeFsBlocksMax-1, 0);
eeFs->freeList = eeFsFirstBlock;
// EeFsFlush();
}
}
bool EFile::EeFsOpen(uint8_t *eeprom, int size, BoardEnum board)
{
this->eeprom = eeprom;
this->eeprom_size = size;
this->board = board;
if (board == BOARD_SKY9X) {
return 1;
}
else if (IS_TARANIS(board)) {
eeFsArm = (EeFsArm *)eeprom;
eeFsVersion = eeFsArm->version;
eeFsSize = 8+4*62;
eeFsBlockSize = 64;
eeFsLinkSize = sizeof(int16_t);
eeFsFirstBlock = 1;
eeFsBlocksOffset = eeFsSize - eeFsBlockSize;
if (board == BOARD_TARANIS_REV4a)
eeFsBlocksMax = 1 + (EESIZE_TARANIS_REV4a-eeFsSize)/eeFsBlockSize;
else
eeFsBlocksMax = 1 + (EESIZE_TARANIS-eeFsSize)/eeFsBlockSize;
return eeFsArm->mySize == eeFsSize;
}
else {
eeFs = (EeFs *)eeprom;
eeFsVersion = eeFs->version;
eeFsBlockSize = 16;
eeFsLinkSize = 1;
if (eeFsVersion == 5) {
eeFsSize = 4+3*36;
eeFsFirstBlock = 1;
eeFsBlocksOffset = 112 - 16;
eeFsBlocksMax = 1 + (4096-112)/16;
}
else if (eeFsVersion == 4) {
eeFsSize = 4+3*20;
eeFsFirstBlock = 4;
eeFsBlocksOffset = 0;
eeFsBlocksMax = 2048/16;
}
else {
return 0;
}
return eeFs->mySize == eeFsSize;
}
}
void EFile::eeprom_read_block (void *pointer_ram, unsigned int pointer_eeprom, size_t size)
{
memcpy(pointer_ram, &eeprom[pointer_eeprom], size);
}
void EFile::eeprom_write_block(const void *pointer_ram, unsigned int pointer_eeprom, size_t size)
{
memcpy(&eeprom[pointer_eeprom], pointer_ram, size);
}
uint8_t EFile::EeFsRead(unsigned int blk, unsigned int ofs)
{
uint8_t ret;
eeprom_read_block(&ret, blk*eeFsBlockSize+ofs+eeFsBlocksOffset, 1);
return ret;
}
void EFile::EeFsWrite(unsigned int blk, unsigned int ofs, uint8_t val)
{
eeprom_write_block(&val, blk*eeFsBlockSize+ofs+eeFsBlocksOffset, 1);
}
unsigned int EFile::EeFsGetLink(unsigned int blk)
{
if (IS_ARM(board)) {
int16_t ret;
eeprom_read_block((uint8_t *)&ret, blk*eeFsBlockSize+eeFsBlocksOffset, eeFsLinkSize);
return ret;
}
else {
return EeFsRead(blk, 0);
}
}
void EFile::EeFsSetLink(unsigned int blk, unsigned int val)
{
if (IS_ARM(board)) {
int16_t s_link = val;
eeprom_write_block((uint8_t *)&s_link, (blk*eeFsBlockSize)+eeFsBlocksOffset, eeFsLinkSize);
}
else {
EeFsWrite(blk, 0, val);
}
}
uint8_t EFile::EeFsGetDat(unsigned int blk, unsigned int ofs)
{
return EeFsRead(blk, ofs+eeFsLinkSize);
}
void EFile::EeFsSetDat(unsigned int blk, unsigned int ofs, const uint8_t *buf, unsigned int len)
{
eeprom_write_block(buf, blk*eeFsBlockSize+ofs+eeFsLinkSize+eeFsBlocksOffset, len);
}
unsigned int EFile::EeFsGetFree()
{
unsigned int ret = 0;
unsigned int i;
if (IS_ARM(board))
i = eeFsArm->freeList;
else
i = eeFs->freeList;
while (i) {
ret += eeFsBlockSize-eeFsLinkSize;
i = EeFsGetLink(i);
}
return ret;
}
/*
* free one or more blocks
*/
void EFile::EeFsFree(unsigned int blk)
{
unsigned int i = blk;
while (EeFsGetLink(i)) i = EeFsGetLink(i);
if (IS_ARM(board)) {
EeFsSetLink(i, eeFsArm->freeList);
eeFsArm->freeList = blk; //chain in front
}
else {
EeFsSetLink(i, eeFs->freeList);
eeFs->freeList = blk; //chain in front
}
}
/*
* alloc one block from freelist
*/
unsigned int EFile::EeFsAlloc()
{
unsigned int ret = (IS_ARM(board) ? eeFsArm->freeList : eeFs->freeList);
if (ret) {
if (IS_ARM(board))
eeFsArm->freeList = EeFsGetLink(ret);
else
eeFs->freeList = EeFsGetLink(ret);
EeFsSetLink(ret, 0);
}
return ret;
}
unsigned int EFile::size(unsigned int id)
{
return IS_ARM(board) ? eeFsArm->files[id].size : eeFs->files[id].size;
}
unsigned int EFile::openRd(unsigned int i_fileId)
{
if (board == BOARD_SKY9X) {
m_fileId = get_current_block_number(i_fileId * 2, &m_size);
m_pos = sizeof(t_eeprom_header);
return 1;
}
else {
m_fileId = i_fileId;
m_pos = 0;
m_currBlk = (IS_ARM(board) ? eeFsArm->files[m_fileId].startBlk : eeFs->files[m_fileId].startBlk);
m_ofs = 0;
m_zeroes = 0;
m_bRlc = 0;
m_err = ERR_NONE; //error reasons
if (IS_ARM(board))
return eeFsArm->files[m_fileId].typ;
else
return eeFs->files[m_fileId].typ;
}
}
unsigned int EFile::read(uint8_t *buf, unsigned int i_len)
{
unsigned int len = IS_ARM(board) ? eeFsArm->files[m_fileId].size : eeFs->files[m_fileId].size;
len -= m_pos;
if (i_len > len) i_len = len;
len = i_len;
while(len) {
if (!m_currBlk) break;
*buf++ = EeFsGetDat(m_currBlk, m_ofs++);
if (m_ofs >= (eeFsBlockSize-(IS_ARM(board)? 2 : 1))) {
m_ofs = 0;
m_currBlk = EeFsGetLink(m_currBlk);
}
len--;
}
m_pos += i_len - len;
return i_len - len;
}
// G: Read runlength (RLE) compressed bytes into buf.
unsigned int EFile::readRlc12(uint8_t *buf, unsigned int i_len, bool rlc2)
{
memset(buf, 0, i_len);
if (board == BOARD_SKY9X) {
int len = std::min((int)i_len, (int)m_size + (int)sizeof(t_eeprom_header) - (int)m_pos);
if (len > 0) {
eeprom_read_block(buf, (m_fileId << 12) + m_pos, len);
m_pos += len;
}
return len;
}
else {
unsigned int i=0;
for( ; 1; ) {
uint8_t ln = std::min<uint16_t>(m_zeroes, i_len-i);
memset(&buf[i], 0, ln);
i += ln;
m_zeroes -= ln;
if(m_zeroes) break;
ln = std::min<uint16_t>(m_bRlc, i_len-i);
uint8_t lr = read(&buf[i], ln);
i += lr ;
m_bRlc -= lr;
if(m_bRlc) break;
if (read(&m_bRlc, 1) !=1) break; //read how many bytes to read
assert(m_bRlc & 0x7f);
if (rlc2) {
if(m_bRlc&0x80){ // if contains high byte
m_zeroes =(m_bRlc>>4) & 0x7;
m_bRlc = m_bRlc & 0x0f;
}
else if(m_bRlc&0x40){
m_zeroes = m_bRlc & 0x3f;
m_bRlc = 0;
}
//else m_bRlc
}
else {
if(m_bRlc&0x80){ // if contains high byte
m_zeroes = m_bRlc & 0x7f;
m_bRlc = 0;
}
}
}
return i;
}
}
unsigned int EFile::write1(uint8_t b)
{
return write(&b, 1);
}
unsigned int EFile::write(const uint8_t *buf, unsigned int i_len)
{
unsigned int len = i_len;
if (!m_currBlk && m_pos==0)
{
if (IS_ARM(board))
eeFsArm->files[m_fileId].startBlk = m_currBlk = EeFsAlloc();
else
eeFs->files[m_fileId].startBlk = m_currBlk = EeFsAlloc();
}
while (len)
{
if (!m_currBlk) {
m_err = ERR_FULL;
return 0;
}
if (m_ofs >= eeFsBlockSize-eeFsLinkSize) {
m_ofs = 0;
if (!EeFsGetLink(m_currBlk) ){
EeFsSetLink(m_currBlk, EeFsAlloc());
}
m_currBlk = EeFsGetLink(m_currBlk);
}
if (!m_currBlk) {
m_err = ERR_FULL;
return 0;
}
uint8_t l = eeFsBlockSize-eeFsLinkSize-m_ofs; if(l>len) l=len;
EeFsSetDat(m_currBlk, m_ofs, buf, l);
buf +=l;
m_ofs +=l;
len -=l;
}
m_pos += i_len - len;
return i_len - len;
}
void EFile::create(unsigned int i_fileId, unsigned int typ)
{
openRd(i_fileId); //internal use
if (IS_ARM(board)) {
eeFsArm->files[i_fileId].typ = typ;
eeFsArm->files[i_fileId].size = 0;
}
else {
eeFs->files[i_fileId].typ = typ;
eeFs->files[i_fileId].size = 0;
}
}
void EFile::closeTrunc()
{
unsigned int fri=0;
if (IS_ARM(board))
eeFsArm->files[m_fileId].size = m_pos;
else
eeFs->files[m_fileId].size = m_pos;
if (m_currBlk && ( fri = EeFsGetLink(m_currBlk))) EeFsSetLink(m_currBlk, 0);
if(fri) EeFsFree( fri ); //chain in
}
unsigned int EFile::writeRlc1(unsigned int i_fileId, unsigned int typ, const uint8_t *buf, unsigned int i_len)
{
create(i_fileId, typ);
bool state0 = true;
uint8_t cnt = 0;
uint16_t i;
//RLE compression:
//rb = read byte
//if (rb | 0x80) write rb & 0x7F zeros
//else write rb bytes
for (i=0; i<=i_len; i++)
{
bool nst0 = (buf[i] == 0);
if (nst0 && !state0 && buf[i+1]!=0) nst0 = false ;
if (nst0 != state0 || cnt>=0x7f || i==i_len) {
if (state0) {
if(cnt>0) {
cnt |= 0x80;
if (write(&cnt,1)!=1) goto error;
cnt=0;
}
}
else {
if (cnt>0) {
if (write(&cnt,1) !=1) goto error;
uint8_t ret=write(&buf[i-cnt],cnt);
if (ret!=cnt) { cnt-=ret; goto error;}
cnt=0;
}
}
state0 = nst0;
}
cnt++;
}
if(0){
error:
i_len = i - (cnt & 0x7f);
}
closeTrunc();
return i_len;
}
/*
* Write runlength (RLE) compressed bytes
*/
unsigned int EFile::writeRlc2(unsigned int i_fileId, unsigned int typ, const uint8_t *buf, unsigned int i_len)
{
if (board == BOARD_SKY9X) {
openRd(i_fileId);
eeprom_write_block(buf, (m_fileId << 12) + m_pos, i_len);
t_eeprom_header header;
header.sequence_no = 1;
header.data_size = i_len;
header.flags = 0;
header.hcsum = byte_checksum((uint8_t *) &header, 7);
eeprom_write_block(&header, (m_fileId << 12), sizeof(header));
return i_len;
}
else {
create(i_fileId, typ);
bool run0 = buf[0] == 0;
uint8_t cnt = 1;
uint8_t cnt0 = 0;
uint16_t i = 0;
if (i_len==0) goto close;
//RLE compression:
//rb = read byte
//if (rb | 0x80) write rb & 0x7F zeros
//else write rb bytes
for (i=1; 1; i++) { // !! laeuft ein byte zu weit !!
bool cur0 = buf[i] == 0;
if (i==i_len || cur0 != run0 || cnt==0x3f || (cnt0 && cnt==0xf)) {
if (run0){
assert(cnt0==0);
if (cnt<8 && i!=i_len)
cnt0 = cnt; //aufbew fuer spaeter
else {
if (write1(cnt|0x40)!=1) goto error;//-cnt&0x3f
}
}
else {
if (cnt0) {
if (write1(0x80 | (cnt0<<4) | cnt)!=1) goto error;//-cnt0xx-cnt
cnt0 = 0;
}
else {
if (write1(cnt)!=1) goto error;//-cnt
}
uint8_t ret = write(&buf[i-cnt], cnt);
if (ret != cnt) { cnt-=ret; goto error;}//-cnt
}
cnt=0;
if (i==i_len) break;
run0 = cur0;
}
cnt++;
}
if (0) {
error:
i-=cnt+cnt0;
}
close:
closeTrunc();
return i;
}
}
uint8_t EFile::byte_checksum( uint8_t *p, unsigned int size )
{
uint32_t csum ;
csum = 0 ;
while( size )
{
csum += *p++ ;
size -= 1 ;
}
return csum ;
}
uint32_t EFile::ee32_check_header( struct t_eeprom_header *hptr )
{
uint8_t csum ;
csum = byte_checksum( ( uint8_t *) hptr, 7 ) ;
if ( csum == hptr->hcsum )
{
return 1 ;
}
return 0 ;
}
// Pass in an even block number, this and the next block will be checked
// to see which is the most recent, the block_no of the most recent
// is returned, with the corresponding data size if required
// and the sequence number if required
uint32_t EFile::get_current_block_number( uint32_t block_no, uint16_t *p_size)
{
struct t_eeprom_header b0 ;
struct t_eeprom_header b1 ;
// uint32_t sequence_no ;
uint16_t size ;
eeprom_read_block( ( uint8_t *)&b0, block_no << 12, sizeof(b0) ) ; // Sequence # 0
eeprom_read_block( ( uint8_t *)&b1, (block_no+1) << 12, sizeof(b1) ) ; // Sequence # 1
if ( ee32_check_header( &b0 ) == 0 )
{
b0.sequence_no = 0 ;
b0.data_size = 0 ;
b0.flags = 0 ;
}
size = b0.data_size ;
// sequence_no = b0.sequence_no ;
if ( ee32_check_header( &b0 ) == 0 )
{
if ( ee32_check_header( &b1 ) != 0 )
{
size = b1.data_size ;
// sequence_no = b1.sequence_no ;
block_no += 1 ;
}
else
{
size = 0 ;
// sequence_no = 1 ;
}
}
else
{
if ( ee32_check_header( &b1 ) != 0 )
{
if ( b1.sequence_no > b0.sequence_no )
{
size = b1.data_size ;
// sequence_no = b1.sequence_no ;
block_no += 1 ;
}
}
}
if ( size == 0xFFFF )
{
size = 0 ;
}
if ( p_size )
{
*p_size = size ;
}
return block_no ;
}

155
companion/src/file.h Normal file
View file

@ -0,0 +1,155 @@
// TODO should be rle
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef file_h
#define file_h
#if __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#else
#include "../winbuild/winbuild.h"
#endif
#include "eeprominterface.h"
#define ERR_NONE 0
#define ERR_FULL 1
#define ERR_TMO 2
PACK(struct DirEnt {
uint8_t startBlk;
uint16_t size:12;
uint16_t typ:4;
});
PACK(struct DirEntArm {
uint16_t startBlk;
uint16_t size:12;
uint16_t typ:4;
});
PACK(struct EeFs{
uint8_t version;
uint8_t mySize;
uint8_t freeList;
uint8_t bs;
DirEnt files[36];
});
PACK(struct EeFsArm {
uint8_t version;
uint16_t mySize;
uint16_t freeList;
uint8_t bs;
uint8_t spare[2];
DirEntArm files[62];
});
struct t_eeprom_header
{
uint32_t sequence_no ; // sequence # to decide which block is most recent
uint16_t data_size ; // # bytes in data area
uint8_t flags ;
uint8_t hcsum ;
};
class EFile
{
uint8_t m_fileId; //index of file in directory = filename
unsigned int m_pos; //over all filepos
unsigned int m_currBlk; //current block.id
unsigned int m_ofs; //offset inside of the current block
uint8_t m_zeroes; //control byte for run length decoder
uint8_t m_bRlc; //control byte for run length decoder
unsigned int m_err; //error reasons
uint16_t m_size;
BoardEnum board;
uint8_t *eeprom;
unsigned int eeprom_size;
EeFs *eeFs;
EeFsArm *eeFsArm;
unsigned int eeFsVersion;
unsigned int eeFsBlockSize;
unsigned int eeFsSize;
unsigned int eeFsFirstBlock;
unsigned int eeFsBlocksOffset;
unsigned int eeFsBlocksMax;
unsigned int eeFsLinkSize;
void eeprom_read_block (void *pointer_ram, unsigned int pointer_eeprom, size_t size);
void eeprom_write_block(const void *pointer_ram, unsigned int pointer_eeprom, size_t size);
uint8_t EeFsRead(unsigned int blk, unsigned int ofs);
void EeFsWrite(unsigned int blk, unsigned int ofs, uint8_t val);
unsigned int EeFsGetLink(unsigned int blk);
void EeFsSetLink(unsigned int blk, unsigned int val);
uint8_t EeFsGetDat(unsigned int blk, unsigned int ofs);
void EeFsSetDat(unsigned int blk, unsigned int ofs, const uint8_t *buf, unsigned int len);
unsigned int EeFsGetFree();
void EeFsFree(unsigned int blk); // free one or more blocks
unsigned int EeFsAlloc(); // alloc one block from freelist
public:
EFile();
void EeFsCreate(uint8_t *eeprom, int size, BoardEnum board);
bool EeFsOpen(uint8_t *eeprom, int size, BoardEnum board);
///open file for reading, no close necessary
///for writing use writeRlc() or create()
unsigned int openRd(unsigned int i_fileId);
/// create a new file with given fileId,
/// !!! if this file already exists, then all blocks are reused
/// and all contents will be overwritten.
/// after writing closeTrunc has to be called
void create(unsigned int i_fileId, unsigned int typ);
/// close file and truncate the blockchain if to long.
void closeTrunc();
///open file, write to file and close it.
///If file existed before, then contents is overwritten.
///If file was larger before, then unused blocks are freed
unsigned int writeRlc1(unsigned int i_fileId, unsigned int typ, const uint8_t *buf, unsigned int i_len);
unsigned int writeRlc2(unsigned int i_fileId, unsigned int typ, const uint8_t *buf, unsigned int i_len);
unsigned int read(uint8_t *buf, unsigned int i_len);
unsigned int write1(uint8_t b);
unsigned int write(const uint8_t *buf, unsigned int i_len);
///return size of compressed file without block overhead
unsigned int size(unsigned int id);
///read from opened file and decode rlc-coded data
unsigned int readRlc12(uint8_t *buf, unsigned int i_len, bool rlc2);
inline unsigned int readRlc1(uint8_t *buf, unsigned int i_len)
{
return readRlc12(buf, i_len, false);
}
inline unsigned int readRlc2(uint8_t *buf, unsigned int i_len)
{
return readRlc12(buf, i_len, true);
}
uint8_t byte_checksum(uint8_t *p, unsigned int size);
unsigned int ee32_check_header(struct t_eeprom_header *hptr);
unsigned int get_current_block_number(unsigned int block_no, uint16_t *p_size);
};
#endif

View file

@ -0,0 +1,955 @@
#include <algorithm>
#include "er9xeeprom.h"
#include "helpers.h"
#include <QObject>
int8_t er9xFromSwitch(const RawSwitch & sw)
{
switch (sw.type) {
case SWITCH_TYPE_SWITCH:
return sw.index;
case SWITCH_TYPE_VIRTUAL:
return sw.index > 0 ? (9 + sw.index) : (-9 + sw.index);
case SWITCH_TYPE_ON:
return 22;
case SWITCH_TYPE_OFF:
return -22;
case SWITCH_TYPE_MOMENT_SWITCH:
return sw.index > 0 ? (22 + sw.index) : (-22 + sw.index);
case SWITCH_TYPE_MOMENT_VIRTUAL:
return sw.index > 0 ? (31 + sw.index) : (-31 + sw.index);
default:
return 0;
}
}
RawSwitch er9xToSwitch(int8_t sw)
{
uint8_t swa = abs(sw);
if (swa == 0)
return RawSwitch(SWITCH_TYPE_NONE);
else if (swa <= 9)
return RawSwitch(SWITCH_TYPE_SWITCH, sw);
else if (swa <= 21)
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-9 : sw+9);
else if (sw == 22)
return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-22 : sw+22);
else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
}
t_Er9xTrainerMix::t_Er9xTrainerMix()
{
memset(this, 0, sizeof(t_Er9xTrainerMix));
}
t_Er9xTrainerMix::t_Er9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Er9xTrainerMix));
srcChn = c9x.src;
swtch = er9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Er9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
c9x.src = srcChn;
c9x.swtch = er9xToSwitch(swtch);
c9x.weight = (25 * studWeight) / 8;
c9x.mode = mode;
return c9x;
}
t_Er9xTrainerData::t_Er9xTrainerData()
{
memset(this, 0, sizeof(t_Er9xTrainerData));
}
t_Er9xTrainerData::t_Er9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Er9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Er9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
for (int i=0; i<NUM_STICKS; i++) {
c9x.calib[i] = calib[i];
c9x.mix[i] = mix[i];
}
return c9x;
}
t_Er9xGeneral::t_Er9xGeneral()
{
memset(this, 0, sizeof(t_Er9xGeneral));
}
t_Er9xGeneral::t_Er9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Er9xGeneral));
myVers = MDVERS;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
uint16_t sum = 0;
for (int i=0; i<12; i++)
sum += calibMid[i];
chkSum = sum;
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
trainer = c9x.trainer;
view = c9x.view;
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else
beeperVal = c9x.beeperLength + 4;
disableAlarmWarning = c9x.disableAlarmWarning;
stickMode = c9x.stickMode;
inactivityTimer = c9x.inactivityTimer - 10;
throttleReversed = c9x.throttleReversed;
minuteBeep = c9x.minuteBeep;
preBeep = c9x.preBeep;
flashBeep = c9x.flashBeep;
disableSplashScreen = c9x.splashMode;
disablePotScroll=(c9x.disablePotScroll ? 1 : 0);
disableBG=(c9x.disableBG ? 1 :0);
frskyinternalalarm = c9x.frskyinternalalarm;
blightinv=(c9x.blightinv ? 1 : 0);
stickScroll=(c9x.stickScroll ? 1 : 0);
if (c9x.backlightMode == 4)
lightSw = 22;
if (c9x.backlightMode & 1)
lightAutoOff = c9x.backlightDelay;
if (c9x.backlightMode & 2)
lightOnStickMove = c9x.backlightDelay;
templateSetup = c9x.templateSetup;
PPM_Multiplier = c9x.PPM_Multiplier;
setEEPROMString(ownerName, c9x.ownerName, sizeof(ownerName));
speakerPitch = c9x.speakerPitch;
hapticStrength = c9x.hapticStrength;
hideNameOnSplash = (c9x.hideNameOnSplash ? 1 : 0);
enablePpmsim = (c9x.enablePpmsim ? 1 : 0);;
speakerMode = c9x.speakerMode;
switchWarningStates =c9x.switchWarningStates;
crosstrim=(c9x.crosstrim ? 1 : 0);
}
Er9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
result.version = myVers;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
result.calibMid[i] = calibMid[i];
result.calibSpanNeg[i] = calibSpanNeg[i];
result.calibSpanPos[i] = calibSpanPos[i];
}
result.currModel = currModel;
result.contrast = contrast;
result.vBatWarn = vBatWarn;
result.vBatCalib = vBatCalib;
result.trainer = trainer;
result.blightinv=blightinv;
result.stickScroll=stickScroll;
result.crosstrim=crosstrim;
result.hideNameOnSplash=hideNameOnSplash;
result.enablePpmsim=enablePpmsim;
result.view = std::min((uint8_t)4, view);
result.disableThrottleWarning = disableThrottleWarning;
result.switchWarning = disableSwitchWarning ? 0 : -1;
result.disableMemoryWarning = disableMemoryWarning;
switch (beeperVal) {
case 0:
result.beeperMode = e_quiet;
break;
case 1:
result.beeperMode = e_no_keys;
break;
default:
result.beeperMode = e_all;
result.beeperLength = beeperVal - 4;
break;
}
result.disableAlarmWarning = disableAlarmWarning;
result.stickMode = std::max((uint8_t)0, std::min(stickMode, (uint8_t)3));
result.inactivityTimer = inactivityTimer + 10;
result.throttleReversed = throttleReversed;
result.minuteBeep = minuteBeep;
result.preBeep = preBeep;
result.flashBeep = flashBeep;
result.splashMode = disableSplashScreen;
result.disablePotScroll=(disablePotScroll==1);
result.disableBG=(disableBG==1);
result.frskyinternalalarm = frskyinternalalarm;
result.backlightMode = 0;
if (lightSw == 22) {
result.backlightMode = 4;
}
else if (lightAutoOff) {
result.backlightMode |= 1;
result.backlightDelay = lightAutoOff;
}
else if (lightOnStickMove) {
result.backlightMode |= 2;
result.backlightDelay = lightOnStickMove;
}
result.templateSetup = templateSetup;
result.PPM_Multiplier = PPM_Multiplier;
getEEPROMString(result.ownerName, ownerName, sizeof(ownerName));
result.speakerPitch = speakerPitch;
result.hapticStrength = hapticStrength;
result.speakerMode = speakerMode;
result.switchWarningStates =switchWarningStates;
return result;
}
t_Er9xLimitData::t_Er9xLimitData()
{
memset(this, 0, sizeof(t_Er9xLimitData));
}
t_Er9xLimitData::t_Er9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Er9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Er9xLimitData::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.revert = revert;
c9x.offset = offset;
return c9x;
}
t_Er9xMixData::t_Er9xMixData()
{
memset(this, 0, sizeof(t_Er9xMixData));
}
t_Er9xMixData::t_Er9xMixData(MixData &c9x)
{
memset(this, 0, sizeof(t_Er9xMixData));
destCh = c9x.destCh;
swtch = er9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = er9xFromSwitch(RawSwitch(c9x.srcRaw.index));
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_GVAR) {
srcRaw = 38 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
if (abs(c9x.weight)>125) {
if (c9x.weight>0) {
int index=abs(c9x.weight)-10000;
int gvar=125+index;
if (gvar>127) {
gvar-=256;
}
weight = gvar;
} else {
EEPROMWarnings += ::QObject::tr("er9x doesn't have negative gvars as weight") + "\n";
weight=0;
}
} else {
weight = c9x.weight;
}
if (abs(c9x.sOffset)>125) {
if (c9x.sOffset>0) {
int index=abs(c9x.sOffset)-10000;
int gvar=125+index;
if (gvar>127) {
gvar-=256;
}
sOffset = gvar;
} else {
EEPROMWarnings += ::QObject::tr("er9x doesn't have negative gvars as offset") + "\n";
sOffset=0;
}
} else {
sOffset = c9x.sOffset;
}
if (c9x.curve!=0) {
curve = c9x.curve;
differential=0;
} else {
if (c9x.differential!=0) {
curve=c9x.differential;
differential=1;
} else {
curve=0;
differential=0;
}
}
lateOffset=c9x.lateOffset;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
mixWarn = c9x.mixWarn;
enableFmTrim=c9x.enableFmTrim;
}
t_Er9xMixData::operator MixData ()
{
MixData c9x;
c9x.destCh = destCh;
if (abs(weight)>125) {
int gvar;
if (weight>0) {
gvar=weight-125;
} else {
gvar=weight+131;
}
gvar+=10000;
c9x.weight=gvar;
} else {
c9x.weight = weight;
}
if (abs(sOffset)>125) {
int gvar;
if (sOffset>0) {
gvar=sOffset-125;
} else {
gvar=sOffset+131;
}
gvar+=10000;
c9x.sOffset=gvar;
} else {
c9x.sOffset=sOffset;
}
c9x.swtch = er9xToSwitch(swtch);
if (srcRaw == 0) {
c9x.srcRaw = RawSource(SOURCE_TYPE_NONE);
}
else if (srcRaw <= 7) {
c9x.srcRaw = RawSource(SOURCE_TYPE_STICK, srcRaw-1);
}
else if (srcRaw == 8) {
c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
}
else if (srcRaw == 9) {
if (swtch < 0) {
c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, swtch < -3 ? -swtch-3 : -swtch);
c9x.weight = -weight;
}
else if (swtch > 0) {
c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, swtch > 3 ? swtch-3 : swtch);
}
else {
c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
}
if (mltpx != MLTPX_REP)
c9x.swtch = RawSwitch(SWITCH_TYPE_NONE);
}
else if (srcRaw <= 12) {
c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-10);
}
else if (srcRaw <= 20) {
c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-13);
}
else if (srcRaw <=37) {
c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
}
else {
c9x.srcRaw = RawSource(SOURCE_TYPE_GVAR, srcRaw-38);
}
if (differential==1) {
c9x.differential=curve;
c9x.curve=0;
} else {
c9x.differential=0;
c9x.curve=curve;
}
c9x.lateOffset=lateOffset;
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
c9x.speedUp = speedUp;
c9x.speedDown = speedDown;
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
c9x.enableFmTrim=enableFmTrim;
return c9x;
}
int8_t er9xFromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
RawSource er9xToSource(int8_t value)
{
if (value == 0) {
return RawSource(SOURCE_TYPE_NONE);
}
else if (value <= 7) {
return RawSource(SOURCE_TYPE_STICK, value - 1);
}
else if (value == 8) {
return RawSource(SOURCE_TYPE_MAX);
}
else if (value == 9) {
return RawSource(SOURCE_TYPE_MAX);
}
else if (value <= 12) {
return RawSource(SOURCE_TYPE_CYC, value-10);
}
else if (value <= 20) {
return RawSource(SOURCE_TYPE_PPM, value-13);
}
else if (value <= 36) {
return RawSource(SOURCE_TYPE_CH, value-21);
}
else {
return RawSource(SOURCE_TYPE_TELEMETRY, value-36);
}
}
t_Er9xCustomSwData::t_Er9xCustomSwData(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = er9xFromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = er9xFromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = er9xFromSwitch(RawSwitch(c9x.val1));
v2 = er9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>ER9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("er9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Er9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
c9x.val1 = er9xToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
c9x.val2 = er9xToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue();
}
return c9x;
}
t_Er9xSafetySwData::t_Er9xSafetySwData()
{
memset(this, 0, sizeof(t_Er9xSafetySwData));
}
t_Er9xSafetySwData::t_Er9xSafetySwData(SafetySwData &c9x)
{
memset(this, 0, sizeof(t_Er9xSafetySwData));
swtch = er9xFromSwitch(c9x.swtch);
val = c9x.val;
}
t_Er9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = er9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData()
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
if (c9x.type==0) {
if (c9x.multiplier==0) {
type = 0;
} else if (c9x.multiplier==1) {
type = 2;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this range for A1/A2") + "\n";
}
} else if (c9x.type==1 || c9x.type==3) {
type=c9x.type;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this telemetry units") + "\n";
}
}
t_Er9xFrSkyChannelData::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
c9x.ratio = ratio;
c9x.alarms[0].value = alarms_value[0];
c9x.alarms[0].level = alarms_level & 3;
c9x.alarms[0].greater = alarms_greater & 1;
c9x.alarms[1].value = alarms_value[1];
c9x.alarms[1].level = (alarms_level >> 2) & 3;
c9x.alarms[1].greater = (alarms_greater >> 1) & 1;
if (type==2) {
c9x.type = 0;
c9x.multiplier=1;
} else {
c9x.type = type;
}
return c9x;
}
t_Er9xFrSkyData::t_Er9xFrSkyData()
{
memset(this, 0, sizeof(t_Er9xFrSkyData));
}
t_Er9xFrSkyData::t_Er9xFrSkyData(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Er9xFrSkyData));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Er9xFrSkyData::operator FrSkyData ()
{
FrSkyData c9x;
c9x.channels[0] = channels[0];
c9x.channels[1] = channels[1];
return c9x;
}
int setEr9xTimerMode(TimerMode mode)
{
if (mode == TMRMODE_OFF || mode == TMRMODE_ABS)
return mode;
else if (mode == TMRMODE_THs || mode == TMRMODE_THp)
return mode + 4;
else if (mode >= TMRMODE_FIRST_MOMENT_SWITCH)
return 37+mode-TMRMODE_FIRST_MOMENT_SWITCH;
else if (mode >= TMRMODE_FIRST_SWITCH)
return 16+mode-TMRMODE_FIRST_SWITCH;
else if (mode <= TMRMODE_FIRST_NEG_MOMENT_SWITCH)
return -37+mode-TMRMODE_FIRST_NEG_MOMENT_SWITCH;
else if (mode <= TMRMODE_FIRST_NEG_SWITCH)
return -16+mode-TMRMODE_FIRST_NEG_SWITCH;
else
return 0;
}
TimerMode getEr9xTimerMode(int mode)
{
if (mode <= -33)
return TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+33));
else if (mode <= -1)
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 16)
return TimerMode(mode);
else if (mode < 16+21)
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16));
else
return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21));
}
t_Er9xModelData::t_Er9xModelData(ModelData &c9x)
{
memset(this, 0, sizeof(t_Er9xModelData));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
modelVoice=c9x.modelVoice;
tmrMode = setEr9xTimerMode(c9x.timers[0].mode);
tmrModeB = c9x.timers[0].modeB;
tmrDir = c9x.timers[0].dir;
tmrVal = c9x.timers[0].val;
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case PPM16:
protocol = 3;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Er9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
traineron = c9x.traineron;
t2throttle = c9x.t2throttle;
ppmFrameLength = c9x.moduleData[0].ppmFrameLength;
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncInstantTrim && c9x.funcSw[i].swtch.type != SWITCH_TYPE_NONE) {
trimSw = er9xFromSwitch(c9x.funcSw[i].swtch);
break;
}
beepANACenter = (uint8_t)(c9x.beepANACenter & 0x7F);
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
swashInvertELE = c9x.swashRingData.invertELE;
swashInvertAIL = c9x.swashRingData.invertAIL;
swashInvertCOL = c9x.swashRingData.invertCOL;
swashType = c9x.swashRingData.type;
swashCollectiveSource = er9xFromSource(c9x.swashRingData.collectiveSource);
swashRingValue = c9x.swashRingData.value;
for (int i=0; i<ER9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
// expoData
for (unsigned int i=0; i<NUM_STICKS; i++) {
// first we find the switches
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i) {
if (c9x.expoData[e].swtch.type!=SWITCH_TYPE_NONE) {
if (!expoData[i].drSw1)
expoData[i].drSw1 = -er9xFromSwitch(c9x.expoData[e].swtch);
else if (er9xFromSwitch(c9x.expoData[e].swtch) != -expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw2 = -er9xFromSwitch(c9x.expoData[e].swtch);
}
}
}
}
if (expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw1 = -expoData[i].drSw1;
}
for (int pos=0; pos<3; pos++) {
int swtch1=0, swtch2=0;
if (expoData[i].drSw1 && !expoData[i].drSw2) {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
break;
default:
swtch1 = expoData[i].drSw1;
break;
}
}
else {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
swtch2 = -expoData[i].drSw2;
break;
default:
swtch1 = expoData[i].drSw1;
swtch2 = expoData[i].drSw2;
break;
}
}
for (int mode=0; mode<2; mode++) {
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i && !c9x.expoData[e].phases) {
if (c9x.expoData[e].swtch.type==SWITCH_TYPE_NONE || c9x.expoData[e].swtch == er9xToSwitch(swtch1) || c9x.expoData[e].swtch == er9xToSwitch(swtch2)) {
if (c9x.expoData[e].mode == 3 || (c9x.expoData[e].mode==2 && mode==0) || (c9x.expoData[e].mode==1 && mode==1)) {
expoData[i].expo[pos][0][mode] = c9x.expoData[e].expo;
expoData[i].expo[pos][1][mode] = c9x.expoData[e].weight - 100;
break;
}
}
}
}
}
}
}
for (int i=0; i<NUM_STICKS; i++)
trim[i] = std::max(-125, std::min(125, c9x.phaseData[0].trim[i]));
for (int i=0; i<ER9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("Er9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("Er9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<ER9X_MAX_CURVE9; i++)
if (c9x.curves[i+ER9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+ER9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("Er9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+ER9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+ER9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("Er9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+ER9X_MAX_CURVE5].count).arg(i+1+ER9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<ER9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
safetySw[i] = c9x.safetySw[i];
frsky = c9x.frsky;
FrSkyUsrProto = c9x.frsky.usrProto;
FrSkyImperial = c9x.frsky.imperial;
FrSkyGpsAlt = c9x.frsky.FrSkyGpsAlt;
}
}
t_Er9xModelData::operator ModelData ()
{
ModelData c9x;
c9x.used = true;
c9x.modelVoice = modelVoice;
getEEPROMString(c9x.name, name, sizeof(name));
c9x.timers[0].mode = getEr9xTimerMode(tmrMode);
c9x.timers[0].dir = tmrDir;
c9x.timers[0].val = tmrVal;
c9x.timers[0].modeB = tmrModeB;
switch(protocol) {
case 1:
c9x.moduleData[0].protocol = PXX_DJT;
break;
case 2:
c9x.moduleData[0].protocol = DSM2;
break;
case 3:
c9x.moduleData[0].protocol = PPM16;
break;
default:
c9x.moduleData[0].protocol = PPM;
break;
}
c9x.traineron= traineron;
c9x.t2throttle = t2throttle;
c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.funcSw[0].func = FuncInstantTrim;
if (trimSw) {
c9x.funcSw[0].swtch = er9xToSwitch(trimSw);
}
c9x.beepANACenter = beepANACenter;
c9x.moduleData[0].ppmPulsePol = pulsePol;
c9x.extendedLimits = extendedLimits;
c9x.swashRingData.invertELE = swashInvertELE;
c9x.swashRingData.invertAIL = swashInvertAIL;
c9x.swashRingData.invertCOL = swashInvertCOL;
c9x.swashRingData.type = swashType;
c9x.swashRingData.collectiveSource = er9xToSource(swashCollectiveSource);
c9x.swashRingData.value = swashRingValue;
for (int i=0; i<ER9X_MAX_MIXERS; i++) {
Er9xMixData mix = mixData[i];
c9x.mixData[i] = mix;
}
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
c9x.limitData[i] = limitData[i];
// expoData
int e = 0;
for (int ch = 0; ch < 4 && e < C9X_MAX_EXPOS; ch++) {
for (int dr = 0, pos = 0; dr < 3 && e < C9X_MAX_EXPOS; dr++, pos++) {
if ((dr == 0 && !expoData[ch].drSw1) || (dr == 1 && !expoData[ch].drSw2))
dr = 2;
if (dr == 2 && !expoData[ch].expo[0][0][0] && !expoData[ch].expo[0][0][1] && !expoData[ch].expo[0][1][0] && !expoData[ch].expo[0][1][1])
break;
if (expoData[ch].drSw1 && !expoData[ch].drSw2) {
c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? expoData[ch].drSw1 : 0);
pos = dr == 0 ? 1 : 0;
}
else {
c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
}
c9x.expoData[e].chn = ch;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][0];
c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
c9x.expoData[e++].mode = 3;
}
else {
c9x.expoData[e].mode = 2;
if (e < C9X_MAX_EXPOS - 1) {
c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
c9x.expoData[++e].chn = ch;
c9x.expoData[e].mode = 1;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][1];
c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
}
}
}
}
for (int i=0; i<NUM_STICKS; i++)
c9x.phaseData[0].trim[i] = trim[i];
for (int i=0; i<ER9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
c9x.curves[i].points[j].y = curves5[i][j];
}
}
for (int i=0; i<ER9X_MAX_CURVE9; i++) {
c9x.curves[ER9X_MAX_CURVE5 + i].custom = false;
c9x.curves[ER9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[ER9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
c9x.curves[ER9X_MAX_CURVE5 + i].points[j].y = curves9[i][j];
}
}
for (int i=0; i<ER9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto;
c9x.frsky.imperial=FrSkyImperial;
c9x.frsky.FrSkyGpsAlt=FrSkyGpsAlt;
return c9x;
}

View file

@ -0,0 +1,276 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef er9xeeprom_h
#define er9xeeprom_h
#include <inttypes.h>
#include "eeprominterface.h"
//eeprom data
#define ER9X_MAX_MIXERS 32
#define ER9X_MAX_CURVE5 8
#define ER9X_MAX_CURVE9 8
#define ER9X_MAX_CSFUNC 13
#define MDVERS 10
#define ER9X_NUM_CHNOUT 16 //number of real outputchannels CH1-CH8
#define ER9X_NUM_CSW 12 //number of custom switches
#define NUM_STICKSnPOTS 7 //number of sticks and pots
#define ER9X_MAX_GVARS 7
#define ER9X_MAX_MODES 4
PACK(typedef struct t_Er9xTrainerMix {
uint8_t srcChn:3; //0-7 = ch1-8
int8_t swtch:5;
int8_t studWeight:6;
uint8_t mode:2; // off, add-mode, subst-mode
operator TrainerMix();
t_Er9xTrainerMix();
t_Er9xTrainerMix(TrainerMix&);
}) Er9xTrainerMix; //
PACK(typedef struct t_Er9xTrainerData {
int16_t calib[4];
Er9xTrainerMix mix[4];
operator TrainerData();
t_Er9xTrainerData();
t_Er9xTrainerData(TrainerData&);
}) Er9xTrainerData;
PACK(typedef struct t_Er9xGeneral {
uint8_t myVers;
int16_t calibMid[NUM_STICKSnPOTS];
int16_t calibSpanNeg[NUM_STICKSnPOTS];
int16_t calibSpanPos[NUM_STICKSnPOTS];
uint16_t chkSum;
uint8_t currModel; //0..15
uint8_t contrast;
uint8_t vBatWarn;
int8_t vBatCalib;
int8_t lightSw;
Er9xTrainerData trainer;
uint8_t view;
uint8_t disableThrottleWarning:1;
uint8_t disableSwitchWarning:1;
uint8_t disableMemoryWarning:1;
uint8_t beeperVal:3;
uint8_t reserveWarning:1;
uint8_t disableAlarmWarning:1;
uint8_t stickMode;
int8_t inactivityTimer;
uint8_t throttleReversed:1;
uint8_t minuteBeep:1;
uint8_t preBeep:1;
uint8_t flashBeep:1;
uint8_t disableSplashScreen:1;
uint8_t disablePotScroll:1;
uint8_t disableBG:1;
uint8_t frskyinternalalarm:1;
uint8_t spare_filter ; // No longer needed, left for eepe compatibility for now
uint8_t lightAutoOff;
uint8_t templateSetup; //RETA order according to chout_ar array
int8_t PPM_Multiplier;
uint8_t unused1;
uint8_t unused2:4;
uint8_t hideNameOnSplash:1;
uint8_t enablePpmsim:1;
uint8_t blightinv:1;
uint8_t stickScroll:1;
uint8_t speakerPitch;
uint8_t hapticStrength;
uint8_t speakerMode;
uint8_t lightOnStickMove;
char ownerName[10];
uint8_t switchWarningStates;
uint8_t volume ;
uint8_t res[3];
uint8_t crosstrim:1;
uint8_t spare1:7;
operator GeneralSettings();
t_Er9xGeneral();
t_Er9xGeneral(GeneralSettings&);
}) Er9xGeneral;
PACK(typedef struct t_Er9xExpoData {
int8_t expo[3][2][2];
int8_t drSw1;
int8_t drSw2;
t_Er9xExpoData() { memset(this, 0, sizeof(t_Er9xExpoData)); }
}) Er9xExpoData;
PACK(typedef struct t_Er9xLimitData {
int8_t min;
int8_t max;
bool revert;
int16_t offset;
operator LimitData();
t_Er9xLimitData();
t_Er9xLimitData(LimitData&);
}) Er9xLimitData;
#define MLTPX_ADD 0
#define MLTPX_MUL 1
#define MLTPX_REP 2
PACK(typedef struct t_Er9xMixData {
uint8_t destCh; // 1..C9X_NUM_CHNOUT
uint8_t srcRaw; //
int8_t weight;
int8_t swtch;
uint8_t curve; //0=symmetrisch 1=no neg 2=no pos
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint8_t carryTrim:1;
uint8_t mltpx:2; // multiplex method 0=+ 1=* 2=replace
uint8_t lateOffset:1; // Add offset later
uint8_t mixWarn:2; // mixer warning
uint8_t enableFmTrim:1;
uint8_t differential:1;
int8_t sOffset;
int8_t res;
operator MixData();
t_Er9xMixData();
t_Er9xMixData(MixData&);
}) Er9xMixData;
PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func:4;
uint8_t andsw:4;
operator CustomSwData();
t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); }
t_Er9xCustomSwData(CustomSwData&);
}) Er9xCustomSwData;
PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Er9xSafetySwData();
t_Er9xSafetySwData(SafetySwData&);
}) Er9xSafetySwData;
PACK(typedef struct t_Er9xFrSkyChannelData {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level:4;
uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>)
uint8_t type:2; // future use: 0=volts, ...
operator FrSkyChannelData();
t_Er9xFrSkyChannelData();
t_Er9xFrSkyChannelData(FrSkyChannelData&);
}) Er9xFrSkyChannelData;
PACK(typedef struct t_Er9xFrSkyData {
Er9xFrSkyChannelData channels[2];
operator FrSkyData();
t_Er9xFrSkyData();
t_Er9xFrSkyData(FrSkyData&);
}) Er9xFrSkyData;
PACK(typedef struct t_gvar {
int8_t gvar ;
uint8_t gvsource ;
// int8_t gvswitch ;
}) Er9xGvarData ;
PACK(typedef struct t_PhaseData {
// Trim store as -1001 to -1, trim value-501, 0-5 use trim of phase 0-5
int16_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of modes 1|2|3|4 instead
int8_t swtch; // Try 0-5 use trim of phase 0-5, 1000-2000, trim + 1500 ???
uint8_t fadeIn:4;
uint8_t fadeOut:4;
}) Er9xPhaseData;
PACK(typedef struct t_Er9xModelData {
char name[10]; // 10 must be first for eeLoadModelName
uint8_t modelVoice ; // Index to model name voice (260+value)
int8_t tmrMode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
uint8_t tmrDir:1; //0=>Count Down, 1=>Count Up
uint8_t traineron:1; // 0 disable trainer, 1 allow trainer
uint8_t t2throttle:1 ; // Start timer2 using throttle
uint8_t FrSkyUsrProto:1 ; // Protocol in FrSky User Data, 0=FrSky Hub, 1=WS HowHigh
uint8_t FrSkyGpsAlt:1 ; // Use Gps Altitude as main altitude reading
uint8_t FrSkyImperial:1 ; // Convert FrSky values to imperial units
uint8_t FrSkyAltAlarm:2;
uint16_t tmrVal;
uint8_t protocol;
int8_t ppmNCH;
uint8_t thrTrim:1; // Enable Throttle Trim
uint8_t xnumBlades:2; // RPM scaling
uint8_t spare10:1;
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t ppmStart:3 ; // Start channel for PPM
int8_t trimInc; // Trim Increments
int8_t ppmDelay;
int8_t trimSw;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t swashInvertELE:1;
uint8_t swashInvertAIL:1;
uint8_t swashInvertCOL:1;
uint8_t swashType:3;
uint8_t swashCollectiveSource;
uint8_t swashRingValue;
int8_t ppmFrameLength;
Er9xMixData mixData[ER9X_MAX_MIXERS];
Er9xLimitData limitData[ER9X_NUM_CHNOUT];
Er9xExpoData expoData[4];
int8_t trim[4];
int8_t curves5[ER9X_MAX_CURVE5][5];
int8_t curves9[ER9X_MAX_CURVE9][9];
Er9xCustomSwData customSw[ER9X_NUM_CSW];
uint8_t frSkyVoltThreshold ;
int8_t tmrModeB;
uint8_t numVoice;
Er9xSafetySwData safetySw[ER9X_NUM_CHNOUT];
Er9xFrSkyData frsky;
uint8_t numBlades ;
uint8_t unused1[8] ;
uint8_t CustomDisplayIndex[6] ;
Er9xGvarData gvars[ER9X_MAX_GVARS] ;
Er9xPhaseData phaseData[ER9X_MAX_MODES] ;
operator ModelData();
t_Er9xModelData() { memset(this, 0, sizeof(t_Er9xModelData)); }
t_Er9xModelData(ModelData&);
}) Er9xModelData;
#endif
/*eof*/

View file

@ -0,0 +1,474 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include <iostream>
#include "er9xinterface.h"
#include "er9xeeprom.h"
#include "er9xsimulator.h"
#include "file.h"
#define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2
#define FILE_GENERAL 0
#define FILE_MODEL(n) (1+n)
Er9xInterface::Er9xInterface():
EEPROMInterface(BOARD_STOCK),
efile(new EFile())
{
}
Er9xInterface::~Er9xInterface()
{
delete efile;
}
const char * Er9xInterface::getName()
{
return "Er9x";
}
const int Er9xInterface::getEEpromSize()
{
QSettings settings("companion9x", "companion9x");
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK;
}
return EESIZE_STOCK;
}
const int Er9xInterface::getMaxModels()
{
return 16;
}
inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode)
{
for (int i=0; i<2; i++) {
int stick = applyStickMode(i+1, mode) - 1;
{
int tmp = model.trim[i];
model.trim[i] = model.trim[stick];
model.trim[stick] = tmp;
}
{
Er9xExpoData tmp = model.expoData[i];
model.expoData[i] = model.expoData[stick];
model.expoData[stick] = tmp;
}
}
for (int i=0; i<ER9X_MAX_MIXERS; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ER9X_NUM_CSW; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break
case CS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break;
default:
break;
}
}
model.swashCollectiveSource = applyStickMode(model.swashCollectiveSource, mode);
}
bool Er9xInterface::loadxml(RadioData &radioData, QDomDocument &doc)
{
std::cout << "trying er9x xml import... ";
Er9xGeneral er9xGeneral;
memset(&er9xGeneral,0,sizeof(er9xGeneral));
if(!loadGeneralDataXML(&doc, &er9xGeneral)) {
return false;
} else {
radioData.generalSettings=er9xGeneral;
std::cout << "version " << (unsigned int)er9xGeneral.myVers << " ";
}
for(int i=0; i<getMaxModels(); i++)
{
Er9xModelData er9xModel;
memset(&er9xModel,0,sizeof(er9xModel));
if(loadModelDataXML(&doc, &er9xModel, i)) {
applyStickModeToModel(er9xModel, radioData.generalSettings.stickMode+1);
radioData.models[i] = er9xModel;
}
}
std::cout << "ok\n";
return true;
}
bool Er9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size)
{
std::cout << "trying er9x import... ";
if (size != getEEpromSize()) {
std::cout << "wrong size\n";
return false;
}
if (!efile->EeFsOpen(eeprom, size, BOARD_STOCK)) {
std::cout << "wrong file system\n";
return false;
}
efile->openRd(FILE_GENERAL);
Er9xGeneral er9xGeneral;
if (efile->readRlc1((uint8_t*)&er9xGeneral, 1) != 1) {
std::cout << "no\n";
return false;
}
std::cout << "version " << (unsigned int)er9xGeneral.myVers << " ";
switch(er9xGeneral.myVers) {
case 3:
std::cout << "(old gruvin9x) ";
case 4:
// case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
break;
default:
std::cout << "not er9x\n";
return false;
}
efile->openRd(FILE_GENERAL);
if (!efile->readRlc1((uint8_t*)&er9xGeneral, sizeof(Er9xGeneral))) {
std::cout << "ko\n";
return false;
}
radioData.generalSettings = er9xGeneral;
for (int i=0; i<getMaxModels(); i++) {
Er9xModelData er9xModel;
efile->openRd(FILE_MODEL(i));
if (!efile->readRlc1((uint8_t*)&er9xModel, sizeof(Er9xModelData))) {
radioData.models[i].clear();
}
else {
applyStickModeToModel(er9xModel, radioData.generalSettings.stickMode+1);
radioData.models[i] = er9xModel;
}
}
std::cout << "ok\n";
return true;
}
bool Er9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index)
{
return false;
}
int Er9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
efile->EeFsCreate(eeprom, getEEpromSize(), BOARD_STOCK);
Er9xGeneral er9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc1(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&er9xGeneral, sizeof(Er9xGeneral));
if(sz != sizeof(Er9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Er9xModelData er9xModel(radioData.models[i]);
applyStickModeToModel(er9xModel, radioData.generalSettings.stickMode+1);
sz = efile->writeRlc1(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&er9xModel, sizeof(Er9xModelData));
if(sz != sizeof(Er9xModelData)) {
return 0;
}
}
}
return getEEpromSize();
}
int Er9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Er9xModelData er9xModel(model);
int sz = efile->writeRlc1(0, FILE_TYP_MODEL, (uint8_t*)&er9xModel, sizeof(Er9xModelData));
if(sz != sizeof(Er9xModelData)) {
return -1;
}
return efile->size(0);
}
int Er9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Er9xGeneral er9xGeneral(settings);
int sz = efile->writeRlc1(0, FILE_TYP_GENERAL, (uint8_t*)&er9xGeneral, sizeof(Er9xGeneral));
if(sz != sizeof(Er9xGeneral)) {
return -1;
}
return efile->size(0);
}
int Er9xInterface::getCapability(const Capability capability)
{
switch (capability) {
case FlightPhases:
return 4;
case Mixes:
return ER9X_MAX_MIXERS;
case NumCurves5:
return ER9X_MAX_CURVE5;
case NumCurves9:
return ER9X_MAX_CURVE5;
case MixFmTrim:
return 1;
case PPMExtCtrl:
return 1;
case ModelTrainerEnable:
return 1;
case Timer2ThrTrig:
return 1;
case TrainerSwitch:
return 1;
case OffsetWeight:
return 125;
case BandgapMeasure:
return 1;
case PotScrolling:
return 1;
case SoundMod:
return 1;
case SoundPitch:
return 1;
case Haptic:
return 1;
case OwnerName:
return 10;
case Timers:
return 1;
case Pots:
return 3;
case Switches:
return 7;
case SwitchesPositions:
return 9;
case CustomFunctions:
return 0;
case CustomSwitches:
return 12;
case CustomAndSwitches:
return 5;
case GvarsNum:
return 7;
case GvarsOfsNum:
return 5;
case CSFunc:
return 13;
case Outputs:
return 16;
case ExtraChannels:
return 0;
case Simulation:
return 1;
case gsSwitchMask:
return 1;
case BLonStickMove:
return 1;
case Telemetry:
return TM_HASTELEMETRY|TM_HASWSHH;
case TelemetryUnits:
return 1;
case TimerTriggerB:
return 1;
case TelemetryMaxMultiplier:
return 2;
case MaxVolume:
return 7;
case SlowScale:
return 1;
case SlowRange:
return 15;
case LCDWidth:
return 128;
case VoicesAsNumbers:
case TelemetryInternalAlarm:
case HasPPMSim:
case HasCrossTrims:
case HasStickScroll:
case HasAltitudeSel:
case HasContrast:
case InstantTrimSW:
case HasVolume:
case HasBlInvert:
case ModelVoice:
case DiffMixers:
case HasNegCurves:
case HasFixOffset:
case Gvars:
case GvarsHaveSources:
case GvarsAsSources:
case GvarsAsWeight:
return 1;
case GetThrSwitch:
return DSW_THR;
default:
return 0;
}
}
int Er9xInterface::isAvailable(Protocol prot, int port)
{
switch (prot) {
case PPM:
case DSM2:
case PXX_DJT:
case PPM16:
return 1;
default:
return 0;
}
}
SimulatorInterface * Er9xInterface::getSimulator()
{
return new Er9xSimulator(this);
}
void Er9xInterface::appendTextElement(QDomDocument * qdoc, QDomElement * pe, QString name, QString value)
{
QDomElement e = qdoc->createElement(name);
QDomText t = qdoc->createTextNode(name);
t.setNodeValue(value);
e.appendChild(t);
pe->appendChild(e);
}
void Er9xInterface::appendNumberElement(QDomDocument * qdoc, QDomElement * pe,QString name, int value, bool forceZeroWrite)
{
if(value || forceZeroWrite) {
QDomElement e = qdoc->createElement(name);
QDomText t = qdoc->createTextNode(name);
t.setNodeValue(QString("%1").arg(value));
e.appendChild(t);
pe->appendChild(e);
}
}
void Er9xInterface::appendCDATAElement(QDomDocument * qdoc, QDomElement * pe,QString name, const char * data, int size)
{
QDomElement e = qdoc->createElement(name);
QDomCDATASection t = qdoc->createCDATASection(name);
t.setData(QByteArray(data, size).toBase64());
e.appendChild(t);
pe->appendChild(e);
}
QDomElement Er9xInterface::getGeneralDataXML(QDomDocument * qdoc, Er9xGeneral * tgen)
{
QDomElement gd = qdoc->createElement("GENERAL_DATA");
appendNumberElement(qdoc, &gd, "Version", tgen->myVers, true); // have to write value here
appendTextElement(qdoc, &gd, "Owner", QString::fromAscii(tgen->ownerName,sizeof(tgen->ownerName)).trimmed());
appendCDATAElement(qdoc, &gd, "Data", (const char *)tgen,sizeof(Er9xGeneral));
return gd;
}
QDomElement Er9xInterface::getModelDataXML(QDomDocument * qdoc, Er9xModelData * tmod, int modelNum, int mdver)
{
QDomElement md = qdoc->createElement("MODEL_DATA");
md.setAttribute("number", modelNum);
appendNumberElement(qdoc, &md, "Version", mdver, true); // have to write value here
appendTextElement(qdoc, &md, "Name", QString::fromAscii(tmod->name,sizeof(tmod->name)).trimmed());
appendCDATAElement(qdoc, &md, "Data", (const char *)tmod,sizeof(Er9xModelData));
return md;
}
bool Er9xInterface::loadGeneralDataXML(QDomDocument * qdoc, Er9xGeneral * tgen)
{
//look for "GENERAL_DATA" tag
QDomElement gde = qdoc->elementsByTagName("GENERAL_DATA").at(0).toElement();
if(gde.isNull()) // couldn't find
return false;
//load cdata into tgen
QDomNode n = gde.elementsByTagName("Data").at(0).firstChild();// get all children in Data
while (!n.isNull()) {
if (n.isCDATASection()) {
QString ds = n.toCDATASection().data();
QByteArray ba = QByteArray::fromBase64(ds.toAscii());
const char * data = ba.data();
memcpy(tgen, data, sizeof(Er9xGeneral));
break;
}
n = n.nextSibling();
}
//check version?
return true;
}
bool Er9xInterface::loadModelDataXML(QDomDocument * qdoc, Er9xModelData * tmod, int modelNum)
{
//look for MODEL_DATA with modelNum attribute.
//if modelNum = -1 then just pick the first one
QDomNodeList ndl = qdoc->elementsByTagName("MODEL_DATA");
//cycle through nodes to find correct model number
QDomNode k = ndl.at(0);
if(modelNum>=0) {
while(!k.isNull()) {
int a = k.toElement().attribute("number").toInt();
if(a==modelNum)
break;
k = k.nextSibling();
}
}
if(k.isNull()) // couldn't find
return false;
//load cdata into tgen
QDomNode n = k.toElement().elementsByTagName("Data").at(0).firstChild();// get all children in Data
while (!n.isNull()) {
if (n.isCDATASection()) {
QString ds = n.toCDATASection().data();
QByteArray ba = QByteArray::fromBase64(ds.toAscii());
const char * data = ba.data();
memcpy(tmod, data, sizeof(Er9xModelData));
break;
}
n = n.nextSibling();
}
//check version?
return true;
}

View file

@ -0,0 +1,76 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef er9x_interface_h
#define er9x_interface_h
#include <QtXml>
#include "eeprominterface.h"
#include "er9xeeprom.h"
class EFile;
class Er9xInterface : public EEPROMInterface
{
public:
Er9xInterface();
virtual ~Er9xInterface();
virtual const char * getName();
virtual const int getEEpromSize();
virtual const int getMaxModels();
virtual bool load(RadioData &, uint8_t * eeprom, int size);
virtual bool loadBackup(RadioData &, uint8_t * eeprom, int esize, int index);
virtual bool loadxml(RadioData &radioData, QDomDocument &doc);
virtual int save(uint8_t * eeprom, RadioData & radioData, uint32_t variant=0, uint8_t version=0);
virtual int getSize(ModelData &);
virtual int getSize(GeneralSettings &settings);
virtual int getCapability(const Capability);
virtual int isAvailable(Protocol proto, int port=0);
virtual SimulatorInterface * getSimulator();
protected:
EFile *efile;
private:
void appendTextElement(QDomDocument * qdoc, QDomElement * pe, QString name, QString value);
void appendNumberElement(QDomDocument * qdoc, QDomElement * pe,QString name, int value, bool forceZeroWrite = false);
void appendCDATAElement(QDomDocument * qdoc, QDomElement * pe,QString name, const char * data, int size);
QDomElement getGeneralDataXML(QDomDocument * qdoc, Er9xGeneral * tgen); //parse out data to XML format
QDomElement getModelDataXML(QDomDocument * qdoc, Er9xModelData * tmod, int modelNum, int mdver); //parse out data to XML format
bool loadGeneralDataXML(QDomDocument * qdoc, Er9xGeneral * tgen); // get data from XML
bool loadModelDataXML(QDomDocument * qdoc, Er9xModelData * tmod, int modelNum = -1); // get data from XML
};
#endif

View file

@ -0,0 +1,228 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "firmwares/er9x/er9xsimulator.h"
#include "firmwares/er9x/er9xinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS
#define FRSKY
#define PHASES
#undef min
#undef max
#define NUM_POTS 3
#define SWSRC_SW1 DSW_SW1
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Er9x {
#include "simpgmspace.h"
#include "er9x.cpp"
#include "stamp.cpp"
#include "menus.cpp"
#include "pers.cpp"
#include "file.cpp"
#include "lcd.cpp"
#include "drivers.cpp"
#include "simpgmspace.cpp"
#include "templates.cpp"
#include "frsky.cpp"
#include "audio.cpp"
uint8_t pxxFlag = 0;
int16_t g_anas[7];
#define IS_BACKLIGHT_ON() (PORTB & (1<<OUT_B_LIGHT))
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 1500;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return false;
}
void setTrim(uint8_t idx, int8_t value)
{
g_model.trim[idx] = value;
}
void getTrims(int16_t values[4])
{
for (int i=0; i<4; i++)
values[i] = g_model.trim[i];
}
#define GPIO_TRIM_LH_L pind
#define GPIO_TRIM_LV_DN pind
#define GPIO_TRIM_RV_UP pind
#define GPIO_TRIM_RH_L pind
#define GPIO_TRIM_LH_R pind
#define GPIO_TRIM_LV_UP pind
#define GPIO_TRIM_RV_DN pind
#define GPIO_TRIM_RH_R pind
#define PIN_TRIM_LH_L (1<<INP_D_TRM_LH_DWN)
#define PIN_TRIM_LV_DN (1<<INP_D_TRM_LV_DWN)
#define PIN_TRIM_RV_UP (1<<INP_D_TRM_RV_UP)
#define PIN_TRIM_RH_L (1<<INP_D_TRM_RH_DWN)
#define PIN_TRIM_LH_R (1<<INP_D_TRM_LH_UP)
#define PIN_TRIM_LV_UP (1<<INP_D_TRM_LV_UP)
#define PIN_TRIM_RV_DN (1<<INP_D_TRM_RV_DWN)
#define PIN_TRIM_RH_R (1<<INP_D_TRM_RH_UP)
#define TRIM_CASE(key, pin, mask) \
case key: \
if (state) pin |= mask; else pin &= ~mask;\
break;
void simuSetTrim(uint8_t trim, bool state)
{
switch (trim) {
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
}
}
#define SWITCH_CASE(swtch, pin, mask) \
case swtch: \
if (state) pin &= ~(mask); else pin |= (mask); \
break;
#define SWITCH_3_CASE(swtch, pin1, pin2, mask1, mask2) \
case swtch: \
if (state >= 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if (state <= 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
break;
void simuSetSwitch(uint8_t swtch, int8_t state)
{
switch (swtch) {
SWITCH_CASE(0, pinc, 1<<INP_C_ThrCt)
SWITCH_CASE(4, pinc, 1<<INP_C_AileDR)
SWITCH_3_CASE(3, ping, pine, (1<<INP_G_ID1), (1<<INP_E_ID2))
SWITCH_CASE(1, ping, 1<<INP_G_RuddDR)
SWITCH_CASE(2, pine, 1<<INP_E_ElevDR)
SWITCH_CASE(5, pine, 1<<INP_E_Gear)
SWITCH_CASE(6, pine, 1<<INP_E_Trainer)
default:
break;
}
}
#define KEY_CASE(key, pin, mask) \
case key: \
if (state) pin |= mask; else pin &= ~mask;\
break;
void simuSetKey(uint8_t key, bool state)
{
switch (key) {
KEY_CASE(KEY_MENU, pinb, (1<<INP_B_KEY_MEN))
KEY_CASE(KEY_EXIT, pinb, (1<<INP_B_KEY_EXT))
KEY_CASE(KEY_RIGHT, pinb, (1<<INP_B_KEY_RGT))
KEY_CASE(KEY_LEFT, pinb, (1<<INP_B_KEY_LFT))
KEY_CASE(KEY_UP, pinb, (1<<INP_B_KEY_UP))
KEY_CASE(KEY_DOWN, pinb, (1<<INP_B_KEY_DWN))
}
}
#define IS_BACKLIGHT_ON() (PORTB & (1<<OUT_B_LIGHT))
}
using namespace Er9x;
Er9xSimulator::Er9xSimulator(Er9xInterface * er9xInterface):
er9xInterface(er9xInterface)
{
}
bool Er9xSimulator::timer10ms()
{
AUDIO_DRIVER(); // the tone generator
AUDIO_HEARTBEAT(); // the queue processing
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Er9xSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Er9xSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Er9xSimulator::start(RadioData &radioData, bool tests)
{
er9xInterface->save(&eeprom[0], radioData);
StartMainThread(tests);
}
void Er9xSimulator::stop()
{
StopMainThread();
}
void Er9xSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#include "simulatorimport.h"
outputs.beep = audio.busy();
}
void Er9xSimulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Er9xSimulator::setTrim(unsigned int idx, int value)
{
Er9x::setTrim(idx, value);
}
void Er9xSimulator::getTrims(Trims & trims)
{
trims.extended = false;
Er9x::getTrims(trims.values);
}
const char * Er9xSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef er9x_simulator_h
#define er9x_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Er9xInterface;
class Er9xSimulator : public SimulatorInterface {
public:
Er9xSimulator(Er9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase() { return 0; }
virtual void wheelEvent(uint8_t steps) { }
virtual const char * getError();
protected:
Er9xInterface * er9xInterface;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,456 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef ersky9xeeprom_h
#define ersky9xeeprom_h
#include <inttypes.h>
#include "eeprominterface.h"
extern TimerMode getEr9xTimerMode(int mode);
extern int setEr9xTimerMode(TimerMode mode);
//eeprom data
#define ERSKY9X_MAX_MIXERS_V10 32
#define ERSKY9X_MAX_MIXERS_V11 48
#define ERSKY9X_MAX_CURVE5 8
#define ERSKY9X_MAX_CURVE9 8
#define ERSKY9X_MAX_CSFUNC 13
#define ERSKY9X_MDVERS10 10
#define ERSKY9X_MDVERS11 11
#define ERSKY9X_GENERAL_OWNER_NAME_LEN 10
#define ERSKY9X_NUM_CHNOUT_V10 16 //number of real outputchannels CH1-CH8
#define ERSKY9X_NUM_CHNOUT_V11 24 //number of real outputchannels CH1-CH8
#define ERSKY9X_NUM_CSW_V10 12 //number of custom switches
#define ERSKY9X_NUM_CSW_V11 24
#define ERSKY9X_NUM_FSW 16
#define ERSKY9X_NUM_VOICE 8
#define ERSKY9X_MAX_GVARS 7
#define NUM_STICKSnPOTS 7 //number of sticks and pots
PACK(typedef struct t_Ersky9xTrainerMix {
uint8_t srcChn:3; //0-7 = ch1-8
int8_t swtch:5;
int8_t studWeight:6;
uint8_t mode:2; // off, add-mode, subst-mode
operator TrainerMix();
t_Ersky9xTrainerMix();
t_Ersky9xTrainerMix(TrainerMix&);
}) Ersky9xTrainerMix; //
PACK(typedef struct t_Ersky9xTrainerData {
int16_t calib[4];
Ersky9xTrainerMix mix[4];
operator TrainerData();
t_Ersky9xTrainerData();
t_Ersky9xTrainerData(TrainerData&);
}) Ersky9xTrainerData;
PACK(typedef struct t_Ersky9xGeneral {
uint8_t myVers;
int16_t calibMid[NUM_STICKSnPOTS];
int16_t calibSpanNeg[NUM_STICKSnPOTS];
int16_t calibSpanPos[NUM_STICKSnPOTS];
uint16_t chkSum;
uint8_t currModel; //0..15
uint8_t contrast;
uint8_t vBatWarn;
int8_t vBatCalib;
int8_t lightSw;
Ersky9xTrainerData trainer;
uint8_t view;
uint8_t disableThrottleWarning:1;
uint8_t disableSwitchWarning:1;
uint8_t disableMemoryWarning:1;
uint8_t beeperVal:3;
uint8_t reserveWarning:1;
uint8_t disableAlarmWarning:1;
uint8_t stickMode;
int8_t inactivityTimer;
uint8_t throttleReversed:1;
uint8_t minuteBeep:1;
uint8_t preBeep:1;
uint8_t flashBeep:1;
uint8_t disableSplashScreen:1;
uint8_t disablePotScroll:1;
uint8_t disableBG:1;
uint8_t res1:1;
uint8_t filterInput;
uint8_t lightAutoOff;
uint8_t templateSetup; //RETA order according to chout_ar array
int8_t PPM_Multiplier;
uint8_t FRSkyYellow:4;
uint8_t FRSkyOrange:4;
uint8_t FRSkyRed:4; //mike please check these are correct
uint8_t hideNameOnSplash:1;
uint8_t optrexDisplay:1;
uint8_t spare:2;
uint8_t speakerPitch;
uint8_t hapticStrength;
uint8_t speakerMode;
uint8_t lightOnStickMove;
char ownerName[10];
uint8_t switchWarningStates;
uint8_t volume ;
uint8_t bright ; // backlight
uint8_t stickGain;
uint8_t mAh_alarm ;
uint16_t mAh_used ;
uint16_t run_time ;
int8_t current_calib ;
uint8_t bt_baudrate ;
uint8_t rotaryDivisor ;
operator GeneralSettings();
t_Ersky9xGeneral();
t_Ersky9xGeneral(GeneralSettings&);
}) Ersky9xGeneral;
PACK(typedef struct t_Ersky9xExpoData {
int8_t expo[3][2][2];
int8_t drSw1;
int8_t drSw2;
t_Ersky9xExpoData() { memset(this, 0, sizeof(t_Ersky9xExpoData)); }
}) Ersky9xExpoData;
PACK(typedef struct t_Ersky9xLimitData {
int8_t min;
int8_t max;
bool revert;
int16_t offset;
operator LimitData();
t_Ersky9xLimitData() ;
t_Ersky9xLimitData(LimitData&);
}) Ersky9xLimitData;
#define MLTPX_ADD 0
#define MLTPX_MUL 1
#define MLTPX_REP 2
PACK(typedef struct t_Ersky9xMixData_v10 {
uint8_t destCh; // 1..C9X_NUM_CHNOUT
uint8_t srcRaw; //
int8_t weight;
int8_t swtch;
uint8_t curve; //0=symmetrisch 1=no neg 2=no pos
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint8_t carryTrim:1;
uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace
uint8_t mixWarn:2; // mixer warning
uint8_t enableFmTrim:1;
uint8_t mixres:1;
int8_t sOffset;
int8_t res;
operator MixData();
t_Ersky9xMixData_v10();
t_Ersky9xMixData_v10(MixData&);
}) Ersky9xMixData_v10;
PACK(typedef struct t_Ersky9xMixData_v11 {
uint8_t destCh; // 1..C9X_NUM_CHNOUT
uint8_t srcRaw; //
int8_t weight;
int8_t swtch;
uint8_t curve; //0=symmetrisch 1=no neg 2=no pos
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown; // 0 nichts
uint8_t carryTrim:1;
uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace
uint8_t mixWarn:2; // mixer warning
uint8_t enableFmTrim:1;
uint8_t mixres:1;
int8_t sOffset;
uint8_t res[4];
operator MixData();
t_Ersky9xMixData_v11();
t_Ersky9xMixData_v11(MixData&);
}) Ersky9xMixData_v11;
PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); }
t_Ersky9xCustomSwData_v10(CustomSwData&);
}) Ersky9xCustomSwData_v10;
PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
uint8_t andsw;
uint8_t res ;
operator CustomSwData();
t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); }
t_Ersky9xCustomSwData_v11(CustomSwData&);
}) Ersky9xCustomSwData_v11;
PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Ersky9xSafetySwData_v10();
t_Ersky9xSafetySwData_v10(SafetySwData&);
}) Ersky9xSafetySwData_v10;
PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
union opt {
struct ss {
int8_t swtch ;
uint8_t mode ;
int8_t val ;
uint8_t res ;
} ss ;
struct vs {
uint8_t vswtch ;
uint8_t vmode ; // ON, OFF, BOTH, 15Secs, 30Secs, 60Secs, Varibl
uint8_t vval;
uint8_t vres ;
} vs ;
} opt ;
operator SafetySwData();
t_Ersky9xSafetySwData_v11();
t_Ersky9xSafetySwData_v11(SafetySwData&);
}) Ersky9xSafetySwData_v11;
PACK(typedef struct t_Ersky9xgvar {
int8_t gvar ;
uint8_t gvsource ;
// int8_t gvswitch ;
}) Ersky9xGvarData ;
PACK(typedef struct t_Ersky9xPhaseData {
int16_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
uint16_t spare ; // Future expansion
}) Ersky9xPhaseData;
PACK(typedef struct t_Ersky9xFuncSwData { // Function Switches data
int8_t swtch; //input
uint8_t func;
char param[6];
uint8_t delay;
uint8_t spare;
}) Ersky9xFuncSwData;
PACK(typedef struct t_Ersky9xFrSkyChannelData_v10 {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level:4;
uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>)
uint8_t type:2; // future use: 0=volts, ...
operator FrSkyChannelData();
t_Ersky9xFrSkyChannelData_v10();
t_Ersky9xFrSkyChannelData_v10(FrSkyChannelData&);
}) Ersky9xFrSkyChannelData_v10;
PACK(typedef struct t_Ersky9xFrSkyData_v10 {
Ersky9xFrSkyChannelData_v10 channels[2];
operator FrSkyData();
t_Ersky9xFrSkyData_v10();
t_Ersky9xFrSkyData_v10(FrSkyData&);
}) Ersky9xFrSkyData_v10;
PACK(typedef struct t_Ersky9xFrSkyChannelData_v11 {
uint8_t ratio ; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t offset ; //
uint8_t gain ; //
uint8_t alarms_value[2] ; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level ;
uint8_t alarms_greater ; // 0=LT(<), 1=GT(>)
uint8_t type ; // 0=volts, 1=raw, 2=volts*2, 3=Amps
operator FrSkyChannelData();
t_Ersky9xFrSkyChannelData_v11();
t_Ersky9xFrSkyChannelData_v11(FrSkyChannelData&);
}) Ersky9xFrSkyChannelData_v11;
PACK(typedef struct t_Ersky9xFrSkyData_v11 {
Ersky9xFrSkyChannelData_v11 channels[2];
operator FrSkyData();
t_Ersky9xFrSkyData_v11();
t_Ersky9xFrSkyData_v11(FrSkyData&);
}) Ersky9xFrSkyData_v11;
PACK(typedef struct t_Ersky9xFrSkyalarms_v11 {
uint8_t frskyAlarmType ;
uint8_t frskyAlarmLimit ;
uint8_t frskyAlarmSound ;
}) Ersky9xFrSkyAlData_v11;
PACK(typedef struct t_Ersky9xFrSkyAlarmData_v11 {
Ersky9xFrSkyAlData_v11 alarmData[8] ;
}) Ersky9xFrSkyAlarmData_v11;
PACK(typedef struct t_Ersky9xTimerMode_v10 {
uint8_t tmrModeA:7 ; // timer trigger source -> off, abs, stk, stk%, cx%
uint8_t tmrDir:1 ; // Timer direction
int8_t tmrModeB ; // timer trigger source -> !sw, none, sw, m_sw
uint16_t tmrVal ;
}) Ersky9xTimerMode_v10;
PACK(typedef struct t_Ersky9xTimerMode_v11 {
uint8_t tmrModeA:7 ; // timer trigger source -> off, abs, stk, stk%, cx%
uint8_t tmrDir:1 ; // Timer direction
int8_t tmrModeB ; // timer trigger source -> !sw, none, sw, m_sw
uint16_t tmrVal ;
}) Ersky9xTimerMode_v11;
PACK(typedef struct te_Ersky9xswVoice {
uint8_t swtch ;
uint8_t mode ; // ON, OFF, BOTH, 15Secs, 30Secs, 60Secs
uint8_t val ;
uint8_t vres ;
}) Ersky9xvoiceSwData ;
PACK(typedef struct t_Ersky9xModelData_v10 {
char name[10]; // 10 must be first for eeLoadModelName
uint8_t reserved_spare; //used to be MDVERS - now depreciated
int8_t spare21; // was timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
// uint8_t sparex:1; // was tmrDir, now use tmrVal>0 => count down
uint8_t sparex:1; // was tmrDir, now use tmrVal>0 => count down
// uint8_t tmrDir:1; // was tmrDir, now use tmrVal>0 => count down
uint8_t traineron:1; // 0 disable trainer, 1 allow trainer
uint8_t spare22:1 ; // Start timer2 using throttle
uint8_t FrSkyUsrProto:1 ; // Protocol in FrSky User Data, 0=FrSky Hub, 1=WS HowHigh
uint8_t FrSkyGpsAlt:1 ; // Use Gps Altitude as main altitude reading
uint8_t FrSkyImperial:1 ; // Convert FrSky values to imperial units
uint8_t FrSkyAltAlarm:2;
uint16_t spare_u16 ; // Was timerval
uint8_t protocol;
int8_t ppmNCH;
int8_t thrTrim:4; // Enable Throttle Trim
int8_t thrExpo:4; // Enable Throttle Expo
int8_t trimInc; // Trim Increments
int8_t ppmDelay;
int8_t trimSw;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t swashInvertELE:1;
uint8_t swashInvertAIL:1;
uint8_t swashInvertCOL:1;
uint8_t swashType:3;
uint8_t swashCollectiveSource;
uint8_t swashRingValue;
int8_t ppmFrameLength; //0=22.5 (10msec-30msec) 0.5msec increments
Ersky9xMixData_v10 mixData[ERSKY9X_MAX_MIXERS_V10];
Ersky9xLimitData limitData[ERSKY9X_NUM_CHNOUT_V10];
Ersky9xExpoData expoData[4];
int8_t trim[4];
int8_t curves5[ERSKY9X_MAX_CURVE5][5];
int8_t curves9[ERSKY9X_MAX_CURVE9][9];
Ersky9xCustomSwData_v10 customSw[ERSKY9X_NUM_CSW_V10];
uint8_t frSkyVoltThreshold ;
uint8_t res3[2];
Ersky9xSafetySwData_v10 safetySw[ERSKY9X_NUM_CHNOUT_V10];
Ersky9xFrSkyData_v10 frsky;
Ersky9xTimerMode_v10 timer[2] ;
operator ModelData();
t_Ersky9xModelData_v10() { memset(this, 0, sizeof(t_Ersky9xModelData_v10)); }
t_Ersky9xModelData_v10(ModelData&);
}) Ersky9xModelData_v10;
PACK(typedef struct t_Ersky9xModelData_v11 {
char name[10]; // 10 must be first for eeLoadModelName
uint8_t modelVoice ; // Index to model name voice (261+value)
uint8_t RxNum ; // was timer trigger source, now RxNum for model match
uint8_t sparex:1; // was tmrDir, now use tmrVal>0 => count down
uint8_t traineron:1; // 0 disable trainer, 1 allow trainer
uint8_t spare22:1 ; // Start timer2 using throttle
uint8_t FrSkyUsrProto:1 ; // Protocol in FrSky User Data, 0=FrSky Hub, 1=WS HowHigh
uint8_t FrSkyGpsAlt:1 ; // Use Gps Altitude as main altitude reading
uint8_t FrSkyImperial:1 ; // Convert FrSky values to imperial units
uint8_t FrSkyAltAlarm:2;
uint8_t version ;
uint8_t protocol;
int8_t ppmNCH;
uint8_t thrTrim:1; // Enable Throttle Trim
uint8_t numBlades:2; // RPM scaling
uint8_t spare10:1;
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t spare11:3;
int8_t trimInc; // Trim Increments
int8_t ppmDelay;
int8_t trimSw;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t swashInvertELE:1;
uint8_t swashInvertAIL:1;
uint8_t swashInvertCOL:1;
uint8_t swashType:3;
uint8_t swashCollectiveSource;
uint8_t swashRingValue;
int8_t ppmFrameLength; //0=22.5 (10msec-30msec) 0.5msec increments
Ersky9xMixData_v11 mixData[ERSKY9X_MAX_MIXERS_V11];
Ersky9xLimitData limitData[ERSKY9X_NUM_CHNOUT_V11];
Ersky9xExpoData expoData[4];
int8_t trim[4];
int8_t curves5[ERSKY9X_MAX_CURVE5][5];
int8_t curves9[ERSKY9X_MAX_CURVE9][9];
int8_t curvexy[18];
Ersky9xCustomSwData_v11 customSw[ERSKY9X_NUM_CSW_V11];
uint8_t frSkyVoltThreshold ;
uint8_t bt_telemetry;
uint8_t numVoice; // 0-16, rest are Safety switches
Ersky9xSafetySwData_v11 safetySw[ERSKY9X_NUM_CHNOUT_V11];
Ersky9xvoiceSwData voiceSwitches[ERSKY9X_NUM_VOICE] ;
Ersky9xFrSkyData_v11 frsky;
Ersky9xTimerMode_v11 timer[2] ;
Ersky9xFrSkyAlarmData_v11 frskyAlarms ;
// Add 6 bytes for custom telemetry screen
uint8_t customDisplayIndex[6] ;
Ersky9xFuncSwData funcSw[ERSKY9X_NUM_FSW];
Ersky9xPhaseData phaseData[6] ;
Ersky9xGvarData gvars[ERSKY9X_MAX_GVARS] ;
operator ModelData();
t_Ersky9xModelData_v11() { memset(this, 0, sizeof(t_Ersky9xModelData_v11)); }
t_Ersky9xModelData_v11(ModelData&);
}) Ersky9xModelData_v11;
#endif
/*eof*/

View file

@ -0,0 +1,503 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include <iostream>
#include <QMessageBox>
#include "ersky9xinterface.h"
#include "ersky9xeeprom.h"
#include "ersky9xsimulator.h"
#include "file.h"
#define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2
/// fileId of general file
#define FILE_GENERAL 0
/// convert model number 0..MAX_MODELS-1 int fileId
#define FILE_MODEL(n) (1+n)
#define FILE_TMP (1+16)
Ersky9xInterface::Ersky9xInterface():
EEPROMInterface(BOARD_SKY9X),
efile(new EFile())
{
}
Ersky9xInterface::~Ersky9xInterface()
{
delete efile;
}
const char * Ersky9xInterface::getName()
{
return "Ersky9x";
}
const int Ersky9xInterface::getEEpromSize()
{
return EESIZE_SKY9X;
}
const int Ersky9xInterface::getMaxModels()
{
return 20;
}
inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mode)
{
for (int i=0; i<2; i++) {
int stick = applyStickMode(i+1, mode) - 1;
{
int tmp = model.trim[i];
model.trim[i] = model.trim[stick];
model.trim[stick] = tmp;
}
{
Ersky9xExpoData tmp = model.expoData[i];
model.expoData[i] = model.expoData[stick];
model.expoData[stick] = tmp;
}
}
for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break
case CS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break;
default:
break;
}
}
model.swashCollectiveSource = applyStickMode(model.swashCollectiveSource, mode);
}
inline void applyStickModeToModel(Ersky9xModelData_v11 & model, unsigned int mode)
{
for (int i=0; i<2; i++) {
int stick = applyStickMode(i+1, mode) - 1;
{
int tmp = model.trim[i];
model.trim[i] = model.trim[stick];
model.trim[stick] = tmp;
}
{
Ersky9xExpoData tmp = model.expoData[i];
model.expoData[i] = model.expoData[stick];
model.expoData[stick] = tmp;
}
}
for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break
case CS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break;
default:
break;
}
}
model.swashCollectiveSource = applyStickMode(model.swashCollectiveSource, mode);
}
bool Ersky9xInterface::loadxml(RadioData &radioData, QDomDocument &doc)
{
std::cout << "trying ersky9x xml import... ";
Ersky9xGeneral ersky9xGeneral;
memset(&ersky9xGeneral,0,sizeof(ersky9xGeneral));
if(!loadGeneralDataXML(&doc, &ersky9xGeneral)) {
return false;
}
else {
radioData.generalSettings=ersky9xGeneral;
std::cout << "version " << (unsigned int)ersky9xGeneral.myVers << " ";
}
for(int i=0; i<getMaxModels(); i++) {
if (ersky9xGeneral.myVers == 10) {
if (!loadModelDataXML<Ersky9xModelData_v10>(&doc, &radioData.models[i], i, radioData.generalSettings.stickMode+1)) {
std::cout << "ko\n";
return false;
}
}
else {
if (!loadModelDataXML<Ersky9xModelData_v11>(&doc, &radioData.models[i], i, radioData.generalSettings.stickMode+1)) {
std::cout << "ko\n";
return false;
}
}
}
std::cout << "ok\n";
return true;
}
bool Ersky9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size)
{
std::cout << "trying ersky9x import... ";
if (size != EESIZE_SKY9X) {
std::cout << "wrong size\n";
return false;
}
if (!efile->EeFsOpen(eeprom, size, BOARD_SKY9X)) {
std::cout << "wrong file system\n";
return false;
}
efile->openRd(FILE_GENERAL);
Ersky9xGeneral ersky9xGeneral;
if (efile->readRlc2((uint8_t*)&ersky9xGeneral, 1) != 1) {
std::cout << "no\n";
return false;
}
std::cout << "version " << (unsigned int)ersky9xGeneral.myVers << " ";
switch(ersky9xGeneral.myVers) {
case 10:
break;
case 11:
break;
default:
std::cout << "not ersky9x\n";
return false;
}
efile->openRd(FILE_GENERAL);
if (!efile->readRlc2((uint8_t*)&ersky9xGeneral, sizeof(Ersky9xGeneral))) {
std::cout << "ko\n";
return false;
}
radioData.generalSettings = ersky9xGeneral;
for (int i=0; i<getMaxModels(); i++) {
uint8_t buffer[4096];
uint size;
memset(buffer,0,sizeof(buffer));
efile->openRd(FILE_MODEL(i));
// if (!efile->readRlc2((uint8_t*)&ersky9xModel, sizeof(Ersky9xModelData))) {
size=efile->readRlc2(buffer, 4096);
if (!size) {
radioData.models[i].clear();
}
else {
if (size<720) {
Ersky9xModelData_v10 ersky9xModel;
memcpy(&ersky9xModel, buffer, sizeof(ersky9xModel));
applyStickModeToModel(ersky9xModel, radioData.generalSettings.stickMode+1);
radioData.models[i] = ersky9xModel;
} else {
Ersky9xModelData_v11 ersky9xModel;
memcpy(&ersky9xModel, buffer, sizeof(ersky9xModel));
applyStickModeToModel(ersky9xModel, radioData.generalSettings.stickMode+1);
radioData.models[i] = ersky9xModel;
}
}
}
std::cout << "ok\n";
return true;
}
bool Ersky9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index)
{
return false;
}
int Ersky9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
efile->EeFsCreate(eeprom, EESIZE_SKY9X, BOARD_SKY9X);
Ersky9xGeneral ersky9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&ersky9xGeneral, sizeof(Ersky9xGeneral));
if(sz != sizeof(Ersky9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Ersky9xModelData_v11 ersky9xModel(radioData.models[i]);
applyStickModeToModel(ersky9xModel, radioData.generalSettings.stickMode+1);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&ersky9xModel, sizeof(Ersky9xModelData_v11));
if(sz != sizeof(Ersky9xModelData_v11)) {
return 0;
}
}
}
if (!EEPROMWarnings.isEmpty())
QMessageBox::warning(NULL,
QObject::tr("Warning"),
QObject::tr("EEPROM saved with these warnings:") + "\n- " + EEPROMWarnings.remove(EEPROMWarnings.length()-1, 1).replace("\n", "\n- "));
return EESIZE_SKY9X;
}
int Ersky9xInterface::getSize(ModelData &model)
{
return 0;
}
int Ersky9xInterface::getSize(GeneralSettings &settings)
{
return 0;
}
int Ersky9xInterface::getCapability(const Capability capability)
{
switch (capability) {
case Mixes:
return ERSKY9X_MAX_MIXERS_V11;
case NumCurves5:
return ERSKY9X_MAX_CURVE5;
case NumCurves9:
return ERSKY9X_MAX_CURVE9;
case MixFmTrim:
return 1;
case PPMExtCtrl:
return 1;
case ModelTrainerEnable:
return 1;
case Timer2ThrTrig:
return 1;
case TrainerSwitch:
return 1;
case BandgapMeasure:
return 1;
case PotScrolling:
return 1;
case SoundMod:
return 1;
case SoundPitch:
return 1;
case Haptic:
return 1;
case OwnerName:
return 10;
case HasInputFilter:
return 0;
case ModelVoice:
return 1;
case Timers:
return 2;
case Pots:
return 3;
case GvarsNum:
return 7;
case GvarsOfsNum:
return 5;
case Switches:
return 7;
case SwitchesPositions:
return 9;
case CustomFunctions:
return 0;
case CustomSwitches:
return ERSKY9X_NUM_CSW_V11;
case CustomAndSwitches:
return 1;
case CSFunc:
return 13;
case Outputs:
return ERSKY9X_NUM_CHNOUT_V11;
case ExtraChannels:
return 0;
case Simulation:
return 1;
case gsSwitchMask:
return 1;
case BLonStickMove:
return 1;
case Telemetry:
return TM_HASTELEMETRY|TM_HASWSHH;
case TelemetryUnits:
return 1;
case OptrexDisplay:
return 1;
case TimerTriggerB:
return 2;
case HasAltitudeSel:
case HasCurrentCalibration:
case HasVolume:
case HasBrightness:
case HasContrast:
return 1;
case OffsetWeight:
return 125;
case MaxVolume:
return 23;
case Gvars:
case GvarsHaveSources:
case GvarsAsSources:
case GvarsAsWeight:
return 1;
case InstantTrimSW:
return 1;
case TelemetryMaxMultiplier:
return 2;
case LCDWidth:
return 128;
case GetThrSwitch:
return DSW_THR;
default:
return 0;
}
}
int Ersky9xInterface::isAvailable(Protocol prot, int port)
{
switch (prot) {
case PPM:
case DSM2:
case PXX_DJT:
case PPM16:
return 1;
default:
return 0;
}
}
SimulatorInterface * Ersky9xInterface::getSimulator()
{
return new Ersky9xSimulator(this);
}
void Ersky9xInterface::appendTextElement(QDomDocument * qdoc, QDomElement * pe, QString name, QString value)
{
QDomElement e = qdoc->createElement(name);
QDomText t = qdoc->createTextNode(name);
t.setNodeValue(value);
e.appendChild(t);
pe->appendChild(e);
}
void Ersky9xInterface::appendNumberElement(QDomDocument * qdoc, QDomElement * pe,QString name, int value, bool forceZeroWrite)
{
if(value || forceZeroWrite) {
QDomElement e = qdoc->createElement(name);
QDomText t = qdoc->createTextNode(name);
t.setNodeValue(QString("%1").arg(value));
e.appendChild(t);
pe->appendChild(e);
}
}
void Ersky9xInterface::appendCDATAElement(QDomDocument * qdoc, QDomElement * pe,QString name, const char * data, int size)
{
QDomElement e = qdoc->createElement(name);
QDomCDATASection t = qdoc->createCDATASection(name);
t.setData(QByteArray(data, size).toBase64());
e.appendChild(t);
pe->appendChild(e);
}
QDomElement Ersky9xInterface::getGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen)
{
QDomElement gd = qdoc->createElement("GENERAL_DATA");
appendNumberElement(qdoc, &gd, "Version", tgen->myVers, true); // have to write value here
appendTextElement(qdoc, &gd, "Owner", QString::fromAscii(tgen->ownerName,sizeof(tgen->ownerName)).trimmed());
appendCDATAElement(qdoc, &gd, "Data", (const char *)tgen,sizeof(Ersky9xGeneral));
return gd;
}
QDomElement Ersky9xInterface::getModelDataXML(QDomDocument * qdoc, Ersky9xModelData_v11 * tmod, int modelNum, int mdver)
{
QDomElement md = qdoc->createElement("MODEL_DATA");
md.setAttribute("number", modelNum);
appendNumberElement(qdoc, &md, "Version", mdver, true); // have to write value here
appendTextElement(qdoc, &md, "Name", QString::fromAscii(tmod->name,sizeof(tmod->name)).trimmed());
appendCDATAElement(qdoc, &md, "Data", (const char *)tmod,sizeof(Ersky9xModelData_v11));
return md;
}
bool Ersky9xInterface::loadGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen)
{
//look for "GENERAL_DATA" tag
QDomElement gde = qdoc->elementsByTagName("GENERAL_DATA").at(0).toElement();
if(gde.isNull()) // couldn't find
return false;
//load cdata into tgen
QDomNode n = gde.elementsByTagName("Data").at(0).firstChild();// get all children in Data
while (!n.isNull()) {
if (n.isCDATASection()) {
QString ds = n.toCDATASection().data();
QByteArray ba = QByteArray::fromBase64(ds.toAscii());
const char * data = ba.data();
memcpy(tgen, data, std::min((unsigned int)ba.size(), (unsigned int)sizeof(Ersky9xGeneral)));
break;
}
n = n.nextSibling();
}
//check version?
return true;
}
template <class T>
bool Ersky9xInterface::loadModelDataXML(QDomDocument * qdoc, ModelData *model, int modelNum, int stickMode)
{
T ersky9xModel;
memset(&ersky9xModel, 0, sizeof(ersky9xModel));
//look for MODEL_DATA with modelNum attribute.
//if modelNum = -1 then just pick the first one
QDomNodeList ndl = qdoc->elementsByTagName("MODEL_DATA");
//cycle through nodes to find correct model number
QDomNode k = ndl.at(0);
if (modelNum>=0) {
while(!k.isNull()) {
int a = k.toElement().attribute("number").toInt();
if(a==modelNum)
break;
k = k.nextSibling();
}
}
if (k.isNull()) // couldn't find
return false;
//load cdata into tgen
QDomNode n = k.toElement().elementsByTagName("Data").at(0).firstChild();// get all children in Data
while (!n.isNull()) {
if (n.isCDATASection()) {
QString ds = n.toCDATASection().data();
QByteArray ba = QByteArray::fromBase64(ds.toAscii());
const char * data = ba.data();
memcpy(&ersky9xModel, data, std::min(ba.size(), (int)sizeof(ersky9xModel)));
break;
}
n = n.nextSibling();
}
applyStickModeToModel(ersky9xModel, stickMode);
*model = ersky9xModel;
return true;
}

View file

@ -0,0 +1,77 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef ersky9x_interface_h
#define ersky9x_interface_h
#include <QtXml>
#include "eeprominterface.h"
#include "ersky9xeeprom.h"
class EFile;
class Ersky9xInterface : public EEPROMInterface
{
public:
Ersky9xInterface();
virtual ~Ersky9xInterface();
virtual const char * getName();
virtual const int getEEpromSize();
virtual const int getMaxModels();
virtual bool load(RadioData &, uint8_t * eeprom, int size);
virtual bool loadBackup(RadioData &, uint8_t * eeprom, int esize, int index);
virtual bool loadxml(RadioData &radioData, QDomDocument &doc);
virtual int save(uint8_t * eeprom, RadioData & radioData, uint32_t variant=0, uint8_t version=0);
virtual int getSize(ModelData &);
virtual int getSize(GeneralSettings &settings);
virtual int getCapability(const Capability);
virtual int isAvailable(Protocol proto, int port=0);
virtual SimulatorInterface * getSimulator();
protected:
EFile *efile;
private:
void appendTextElement(QDomDocument * qdoc, QDomElement * pe, QString name, QString value);
void appendNumberElement(QDomDocument * qdoc, QDomElement * pe,QString name, int value, bool forceZeroWrite = false);
void appendCDATAElement(QDomDocument * qdoc, QDomElement * pe,QString name, const char * data, int size);
QDomElement getGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen); //parse out data to XML format
QDomElement getModelDataXML(QDomDocument * qdoc, Ersky9xModelData_v11 * tmod, int modelNum, int mdver); //parse out data to XML format
bool loadGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen); // get data from XML
template <class T>
bool loadModelDataXML(QDomDocument * qdoc, ModelData * model, int modelNum, int stickMode); // get data from XML
};
#endif

View file

@ -0,0 +1,251 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "firmwares/ersky9x/ersky9xsimulator.h"
#include "firmwares/ersky9x/ersky9xinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS
#define PCBSKY9X
#define PCBSKY
#define STAMP
#define FRSKY
#define FRSKY_HUB
#define WS_HOW_HIGH
#define TEMPLATES
#define HELI
#define HAPTIC
#define AUDIO
#define REVB
#define NUM_POTS 3
#define SWSRC_SW1 DSW_SW1
#undef min
#undef max
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Ersky9x {
#include "../ersky9x/timers.h"
#include "../ersky9x/ersky9x.cpp"
#include "../ersky9x/stamp.cpp"
#include "../ersky9x/menus.cpp"
#include "../ersky9x/pers.cpp"
#include "../ersky9x/file.cpp"
#include "../ersky9x/lcd.cpp"
#include "../ersky9x/drivers.cpp"
#include "../ersky9x/logicio.cpp"
#include "../ersky9x/timers.cpp"
#include "../ersky9x/simpgmspace.cpp"
#include "../ersky9x/templates.cpp"
#include "../ersky9x/frsky.cpp"
#include "../ersky9x/audio.cpp"
#include "../ersky9x/sound.cpp"
#include "../ersky9x/diskio.cpp"
#define IS_BACKLIGHT_ON() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100)
//uint8_t pxxFlag = 0;
int16_t g_anas[7];
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 1500;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return false;
}
void setTrim(uint8_t idx, int8_t value)
{
g_model.trim[idx] = value;
}
void getTrims(int16_t values[4])
{
for (int i=0; i<4; i++)
values[i] = g_model.trim[i];
}
#define SWITCH_CASE(swtch, pin, mask) \
case swtch: \
if (state) pin |= (mask); else pin &= ~(mask); \
break;
#define SWITCH_3_CASE(swtch, pin1, pin2, mask1, mask2) \
case swtch: \
if (state < 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if (state > 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
break;
void simuSetSwitch(uint8_t swtch, int8_t state)
{
// printf("swtch=%d state=%d\n", swtch, state); fflush(stdout);
switch (swtch) {
SWITCH_CASE(0, PIOC->PIO_PDSR, 1<<20)
SWITCH_CASE(1, PIOA->PIO_PDSR, 1<<15)
SWITCH_CASE(2, PIOC->PIO_PDSR, 1<<31)
SWITCH_3_CASE(3, PIOC->PIO_PDSR, PIOC->PIO_PDSR, 0x00004000, 0x00000800)
SWITCH_CASE(4, PIOA->PIO_PDSR, 1<<2)
SWITCH_CASE(5, PIOC->PIO_PDSR, 1<<16)
SWITCH_CASE(6, PIOC->PIO_PDSR, 1<<8)
default:
break;
}
}
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
#define GPIO_BUTTON_EXIT PIOC->PIO_PDSR
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
#define PIN_BUTTON_MENU 0x00000020
#define PIN_BUTTON_EXIT 0x01000000
#define PIN_BUTTON_UP 0x00000002
#define PIN_BUTTON_DOWN 0x00000020
#define PIN_BUTTON_RIGHT 0x00000010
#define PIN_BUTTON_LEFT 0x00000008
#define KEY_CASE(key, pin, mask) \
case key: \
if (state) pin &= ~mask; else pin |= mask;\
break;
void simuSetKey(uint8_t key, bool state)
{
switch (key) {
KEY_CASE(KEY_MENU, GPIO_BUTTON_MENU, PIN_BUTTON_MENU)
KEY_CASE(KEY_EXIT, GPIO_BUTTON_EXIT, PIN_BUTTON_EXIT)
KEY_CASE(KEY_RIGHT, GPIO_BUTTON_RIGHT, PIN_BUTTON_RIGHT)
KEY_CASE(KEY_LEFT, GPIO_BUTTON_LEFT, PIN_BUTTON_LEFT)
KEY_CASE(KEY_UP, GPIO_BUTTON_UP, PIN_BUTTON_UP)
KEY_CASE(KEY_DOWN, GPIO_BUTTON_DOWN, PIN_BUTTON_DOWN)
}
}
#define GPIO_TRIM_LH_L PIOA->PIO_PDSR
#define GPIO_TRIM_LV_DN PIOA->PIO_PDSR
#define GPIO_TRIM_RV_UP PIOA->PIO_PDSR
#define GPIO_TRIM_RH_L PIOA->PIO_PDSR
#define GPIO_TRIM_LH_R PIOB->PIO_PDSR
#define GPIO_TRIM_LV_UP PIOC->PIO_PDSR
#define GPIO_TRIM_RV_DN PIOC->PIO_PDSR
#define GPIO_TRIM_RH_R PIOC->PIO_PDSR
#define PIN_TRIM_LH_L 0x00800000
#define PIN_TRIM_LV_DN 0x01000000
#define PIN_TRIM_RV_UP 0x00000002
#define PIN_TRIM_RH_L 0x00000001
#define PIN_TRIM_LH_R 0x00000010
#define PIN_TRIM_LV_UP 0x10000000
#define PIN_TRIM_RV_DN 0x00000400
#define PIN_TRIM_RH_R 0x00000200
#define TRIM_CASE KEY_CASE
void simuSetTrim(uint8_t trim, bool state)
{
switch (trim) {
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
}
}
}
using namespace Ersky9x;
Ersky9xSimulator::Ersky9xSimulator(Ersky9xInterface * ersky9xInterface):
ersky9xInterface(ersky9xInterface)
{
}
bool Ersky9xSimulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Ersky9xSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Ersky9xSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Ersky9xSimulator::start(RadioData &radioData, bool tests)
{
ersky9xInterface->save(Ersky9x::eeprom, radioData);
StartEepromThread(NULL);
StartMainThread(tests);
}
void Ersky9xSimulator::stop()
{
StopMainThread();
StopEepromThread();
}
void Ersky9xSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#include "simulatorimport.h"
}
void Ersky9xSimulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Ersky9xSimulator::setTrim(unsigned int idx, int value)
{
Ersky9x::setTrim(idx, value);
}
void Ersky9xSimulator::getTrims(Trims & trims)
{
trims.extended = false;
Ersky9x::getTrims(trims.values);
}
const char * Ersky9xSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef ersky9x_simulator_h
#define ersky9x_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Ersky9xInterface;
class Ersky9xSimulator : public SimulatorInterface {
public:
Ersky9xSimulator(Ersky9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase() { return 0; }
virtual void wheelEvent(uint8_t steps) { }
virtual const char * getError();
protected:
Ersky9xInterface * ersky9xInterface;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,453 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef gruvin9xeeprom_h
#define gruvin9xeeprom_h
#include <inttypes.h>
#include "eeprominterface.h"
#define GR9X_MAX_CSFUNC 13
PACK(typedef struct t_Gruvin9xTrainerMix_v103 {
uint8_t srcChn:3; //0-7 = ch1-8
int8_t swtch:5;
int8_t studWeight:6;
uint8_t mode:2; //off,add-mode,subst-mode
operator TrainerMix();
t_Gruvin9xTrainerMix_v103() { memset(this, 0, sizeof(t_Gruvin9xTrainerMix_v103)); }
}) Gruvin9xTrainerMix_v103; //
PACK(typedef struct t_Gruvin9xTrainerMix_v104 {
uint8_t srcChn:6; // 0-7 = ch1-8
uint8_t mode:2; // off,add-mode,subst-mode
int8_t studWeight;
operator TrainerMix();
t_Gruvin9xTrainerMix_v104() { memset(this, 0, sizeof(t_Gruvin9xTrainerMix_v104)); }
t_Gruvin9xTrainerMix_v104(TrainerMix&);
}) Gruvin9xTrainerMix_v104; //
PACK(typedef struct t_Gruvin9xTrainerData_v103 {
int16_t calib[4];
Gruvin9xTrainerMix_v103 mix[4];
operator TrainerData();
}) Gruvin9xTrainerData_v103;
PACK(typedef struct t_Gruvin9xTrainerData_v104 {
int16_t calib[4];
Gruvin9xTrainerMix_v104 mix[4];
operator TrainerData();
t_Gruvin9xTrainerData_v104() { memset(this, 0, sizeof(t_Gruvin9xTrainerData_v104)); }
t_Gruvin9xTrainerData_v104(TrainerData&);
}) Gruvin9xTrainerData_v104;
PACK(typedef struct t_Gruvin9xFrSkyRSSIAlarm {
uint8_t level:2;
int8_t value:6;
}) Gruvin9xFrSkyRSSIAlarm;
PACK(typedef struct t_Gruvin9xGeneral_v103 {
uint8_t myVers;
int16_t calibMid[7];
int16_t calibSpanNeg[7];
int16_t calibSpanPos[7];
uint16_t chkSum;
uint8_t currModel; //0..15
uint8_t contrast;
uint8_t vBatWarn;
int8_t vBatCalib;
int8_t lightSw;
Gruvin9xTrainerData_v103 trainer;
uint8_t view; //index of subview in main scrren
uint8_t disableThrottleWarning:1;
int8_t switchWarning:2; // -1=down, 0=off, 1=up
uint8_t beeperVal:3;
uint8_t disableMemoryWarning:1;
uint8_t disableAlarmWarning:1;
uint8_t stickMode;
uint8_t inactivityTimer;
uint8_t throttleReversed:1;
uint8_t minuteBeep:1;
uint8_t preBeep:1;
uint8_t flashBeep:1;
uint8_t disableSplashScreen:1;
uint8_t enableTelemetryAlarm:1; // 0=no, 1=yes (Sound alarm when there's no telem. data coming in)
uint8_t spare:2;
uint8_t filterInput;
uint8_t lightAutoOff;
uint8_t templateSetup; //RETA order according to chout_ar array
int8_t PPM_Multiplier;
Gruvin9xFrSkyRSSIAlarm frskyRssiAlarms[2];
operator GeneralSettings();
t_Gruvin9xGeneral_v103() { memset(this, 0, sizeof(t_Gruvin9xGeneral_v103)); }
}) Gruvin9xGeneral_v103;
PACK(typedef struct t_Gruvin9xGeneral_v104 {
uint8_t myVers;
int16_t calibMid[7];
int16_t calibSpanNeg[7];
int16_t calibSpanPos[7];
uint16_t chkSum;
uint8_t currModel; //0..15
uint8_t contrast;
uint8_t vBatWarn;
int8_t vBatCalib;
int8_t lightSw;
Gruvin9xTrainerData_v104 trainer;
uint8_t view; //index of subview in main scrren
uint8_t disableThrottleWarning:1;
int8_t switchWarning:2; // -1=down, 0=off, 1=up
uint8_t beeperVal:3;
uint8_t disableMemoryWarning:1;
uint8_t disableAlarmWarning:1;
uint8_t stickMode;
uint8_t inactivityTimer;
uint8_t throttleReversed:1;
uint8_t minuteBeep:1;
uint8_t preBeep:1;
uint8_t flashBeep:1;
uint8_t disableSplashScreen:1;
uint8_t enableTelemetryAlarm:1; // 0=no, 1=yes (Sound alarm when there's no telem. data coming in)
uint8_t spare:2;
uint8_t filterInput;
uint8_t lightAutoOff;
uint8_t templateSetup; //RETA order according to chout_ar array
int8_t PPM_Multiplier;
Gruvin9xFrSkyRSSIAlarm frskyRssiAlarms[2];
operator GeneralSettings();
t_Gruvin9xGeneral_v104() { memset(this, 0, sizeof(t_Gruvin9xGeneral_v104)); }
t_Gruvin9xGeneral_v104(GeneralSettings&);
}) Gruvin9xGeneral_v104;
typedef Gruvin9xGeneral_v104 Gruvin9xGeneral;
// eeprom modelspec
PACK(typedef struct t_Gruvin9xExpoData {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn:2;
uint8_t curve:4; // 0=no curve, 1-6=std curves, 7-10=CV1-CV4, 11-15=CV9-CV13
int8_t swtch:5;
uint8_t phase:3; // if negPhase is 0: 0=normal, 5=FP4 if negPhase is 1: 5=!FP4
uint8_t negPhase:1;
uint8_t weight:7;
int8_t expo;
operator ExpoData();
t_Gruvin9xExpoData();
t_Gruvin9xExpoData(ExpoData&);
}) Gruvin9xExpoData;
PACK(typedef struct t_Gruvin9xLimitData {
int8_t min;
int8_t max;
bool revert;
int16_t offset;
operator LimitData();
t_Gruvin9xLimitData();
t_Gruvin9xLimitData(LimitData&);
}) Gruvin9xLimitData;
#define MLTPX_ADD 0
#define MLTPX_MUL 1
#define MLTPX_REP 2
PACK(typedef struct t_Gruvin9xMixData {
uint8_t destCh:5; // 0, 1..C9X_NUM_CHNOUT
uint8_t mixWarn:3; // mixer warning
uint8_t srcRaw; //
int8_t weight;
int8_t swtch;
uint8_t curve; // 0=symmetrisch, 1=no neg, 2=no pos
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint8_t carryTrim:1;
uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t sOffset;
operator MixData();
t_Gruvin9xMixData();
t_Gruvin9xMixData(MixData&);
}) Gruvin9xMixData;
PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); }
t_Gruvin9xCustomSwData(CustomSwData&);
}) Gruvin9xCustomSwData;
PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); }
t_Gruvin9xSafetySwData(SafetySwData&);
}) Gruvin9xSafetySwData;
PACK(typedef struct t_Gruvin9xFuncSwData { // Function Switches data
int8_t swtch; // input
uint8_t func;
operator FuncSwData();
t_Gruvin9xFuncSwData() { memset(this, 0, sizeof(t_Gruvin9xFuncSwData)); }
t_Gruvin9xFuncSwData(FuncSwData&);
}) Gruvin9xFuncSwData;
PACK(typedef struct t_Gruvin9xFrSkyChannelData {
uint16_t ratio:12; // (Maximum resistor divider input volts +/- calibration. 0 means channel not used.
// 0.01v steps from 0 to 40.95V. Ex. 6.60 Volts = 660. 40.95V = 4095
uint16_t type:4; // channel display unit (0=volts, 1=raw, 2-15=reserverd.)
uint8_t alarms_value[2]; // raw sample values 0..255
uint8_t alarms_level:4; // two pairs of 2bits. none=0, yel=1, org=2, red=3
uint8_t alarms_greater:2; // two alarms, 1 bit each. 0=LT(<), 1=GT(>)
uint8_t spare:2;
uint8_t barMin; // minimum for bar display (raw ADC value)
uint8_t barMax; // ditto for max display (would G:NOT usually = ratio)
operator FrSkyChannelData();
t_Gruvin9xFrSkyChannelData();
t_Gruvin9xFrSkyChannelData(FrSkyChannelData&);
}) Gruvin9xFrSkyChannelData;
PACK(typedef struct t_Gruvin9xFrSkyData {
Gruvin9xFrSkyChannelData channels[2];
operator FrSkyData();
t_Gruvin9xFrSkyData();
t_Gruvin9xFrSkyData(FrSkyData&);
}) Gruvin9xFrSkyData;
PACK(typedef struct t_Gruvin9xSwashRingData { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Gruvin9xSwashRingData();
t_Gruvin9xSwashRingData(SwashRingData&);
}) Gruvin9xSwashRingData;
PACK(typedef struct t_Gruvin9xPhaseData_v102 {
int8_t trim[4]; // -125..125 => trim value, 127 => use trim of phase 0, -128, -127, -126 => use trim of phases 1|2|3|4 instead
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
operator PhaseData();
t_Gruvin9xPhaseData_v102() { memset(this, 0, sizeof(t_Gruvin9xPhaseData_v102)); }
}) Gruvin9xPhaseData_v102;
PACK(typedef struct t_Gruvin9xPhaseData_v106 {
int8_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t trim_ext:8; // 2 less significant extra bits per trim (10bits trims)
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
operator PhaseData();
t_Gruvin9xPhaseData_v106() { memset(this, 0, sizeof(t_Gruvin9xPhaseData_v106)); }
t_Gruvin9xPhaseData_v106(PhaseData &eepe);
}) Gruvin9xPhaseData_v106;
PACK(typedef struct t_Gruvin9xTimerData {
int8_t mode:7; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
uint8_t dir:1; // 0=>Count Down, 1=>Count Up
uint16_t val;
operator TimerData();
t_Gruvin9xTimerData() { memset(this, 0, sizeof(t_Gruvin9xTimerData)); }
t_Gruvin9xTimerData(TimerData &eepe);
}) Gruvin9xTimerData;
#define G9X_MAX_PHASES 5
#define G9X_MAX_MIXERS 32
#define G9X_MAX_EXPOS 14
#define G9X_MAX_CURVE5 8
#define G9X_MAX_CURVE9 8
#define G9X_NUM_CHNOUT 16 // number of real output channels CH1-CH16
#define G9X_NUM_CSW 12 // number of custom switches
#define G9X_NUM_FSW 12 // number of functions assigned to switches
// TODO
PACK(typedef struct t_Gruvin9xModelData_v102 {
char name[10]; // 10 must be first for eeLoadModelName
Gruvin9xTimerData timer1;
uint8_t protocol:3;
int8_t ppmNCH:3;
uint8_t thrTrim:1; // Enable Throttle Trim
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Gruvin9xTimerData timer2;
Gruvin9xMixData mixData[G9X_MAX_MIXERS];
Gruvin9xLimitData limitData[G9X_NUM_CHNOUT];
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
Gruvin9xFrSkyData frsky;
operator ModelData();
t_Gruvin9xModelData_v102() { memset(this, 0, sizeof(t_Gruvin9xModelData_v102)); }
}) Gruvin9xModelData_v102;
PACK(typedef struct t_Gruvin9xModelData_v103 {
char name[10]; // 10 must be first for eeLoadModelName
Gruvin9xTimerData timer1;
uint8_t protocol:3;
int8_t ppmNCH:3;
uint8_t thrTrim:1; // Enable Throttle Trim
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Gruvin9xTimerData timer2;
Gruvin9xMixData mixData[G9X_MAX_MIXERS];
Gruvin9xLimitData limitData[G9X_NUM_CHNOUT];
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
Gruvin9xFrSkyData frsky;
operator ModelData();
t_Gruvin9xModelData_v103() { memset(this, 0, sizeof(t_Gruvin9xModelData_v103)); }
}) Gruvin9xModelData_v103;
PACK(typedef struct t_Gruvin9xModelData_v105 {
char name[10]; // 10 must be first for eeLoadModelName
Gruvin9xTimerData timer1;
uint8_t protocol:3;
int8_t ppmNCH:3;
uint8_t thrTrim:1; // Enable Throttle Trim
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Gruvin9xTimerData timer2;
Gruvin9xMixData mixData[G9X_MAX_MIXERS];
Gruvin9xLimitData limitData[G9X_NUM_CHNOUT];
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xFuncSwData funcSw[G9X_NUM_FSW];
Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
int16_t subtrim[NUM_STICKS];
Gruvin9xFrSkyData frsky;
operator ModelData();
t_Gruvin9xModelData_v105() { memset(this, 0, sizeof(t_Gruvin9xModelData_v105)); }
t_Gruvin9xModelData_v105(ModelData&);
}) Gruvin9xModelData_v105;
PACK(typedef struct t_Gruvin9xModelData_v106 {
char name[10]; // 10 must be first for eeLoadModelName
Gruvin9xTimerData timer1;
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Gruvin9xTimerData timer2;
Gruvin9xMixData mixData[G9X_MAX_MIXERS];
Gruvin9xLimitData limitData[G9X_NUM_CHNOUT];
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xFuncSwData funcSw[G9X_NUM_FSW];
Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v106 phaseData[G9X_MAX_PHASES];
Gruvin9xFrSkyData frsky;
operator ModelData();
t_Gruvin9xModelData_v106() { memset(this, 0, sizeof(t_Gruvin9xModelData_v106)); }
t_Gruvin9xModelData_v106(ModelData&);
}) Gruvin9xModelData_v106;
typedef Gruvin9xModelData_v106 Gruvin9xModelData;
#endif
/*eof*/

View file

@ -0,0 +1,341 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include <iostream>
#include "gruvin9xinterface.h"
#include "gruvin9xeeprom.h"
#include "file.h"
#define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2
#define FILE_GENERAL 0
#define FILE_MODEL(n) (1+n)
Gruvin9xInterface::Gruvin9xInterface(BoardEnum board):
EEPROMInterface(board),
efile(new EFile())
{
}
Gruvin9xInterface::~Gruvin9xInterface()
{
delete efile;
}
const char * Gruvin9xInterface::getName()
{
if (board == BOARD_STOCK)
return "Gruvin9x";
else
return "Gruvin9x v4";
}
const int Gruvin9xInterface::getEEpromSize()
{
if (board == BOARD_STOCK) {
QSettings settings("companion9x", "companion9x");
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) {
return EESIZE_STOCK*2;
}
return EESIZE_STOCK;
} else {
return EESIZE_GRUVIN9X;
}
}
const int Gruvin9xInterface::getMaxModels()
{
return 16;
}
template <class T>
void Gruvin9xInterface::loadModel(ModelData &model, unsigned int stickMode, int version)
{
T _model;
if ((version == 2 && efile->readRlc2((uint8_t*)&_model, sizeof(T))) ||
(version == 1 && efile->readRlc1((uint8_t*)&_model, sizeof(T)))) {
model = _model;
if (stickMode) {
applyStickModeToModel(model, stickMode);
}
}
else {
model.clear();
}
}
template <class T>
bool Gruvin9xInterface::loadGeneral(GeneralSettings &settings, int version)
{
T _settings;
if ((version == 2 && efile->readRlc2((uint8_t*)&_settings, sizeof(T))) ||
(version == 1 && efile->readRlc1((uint8_t*)&_settings, sizeof(T)))) {
settings = _settings;
return true;
}
std::cerr << "error when loading general settings";
return false;
}
bool Gruvin9xInterface::loadxml(RadioData &radioData, QDomDocument &doc)
{
return false;
}
bool Gruvin9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size)
{
std::cout << "trying " << getName() << " import... ";
if (size != this->getEEpromSize()) {
std::cout << "wrong size\n";
return false;
}
if (!efile->EeFsOpen(eeprom, size, BOARD_STOCK)) {
std::cout << "wrong file system\n";
return false;
}
efile->openRd(FILE_GENERAL);
uint8_t version;
if (efile->readRlc2(&version, 1) != 1) {
std::cout << "no\n";
return false;
}
if (version == 0) {
efile->openRd(FILE_GENERAL);
if (efile->readRlc1(&version, 1) != 1) {
std::cout << "no\n";
return false;
}
}
std::cout << "version " << (unsigned int)version << " ";
switch(version) {
case 5:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
// subtrims(16bits) + function switches added
case 106:
// trims(10bits), no subtrims
break;
default:
std::cout << "not gruvin9x\n";
return false;
}
efile->openRd(FILE_GENERAL);
if (version == 5) {
if (!loadGeneral<Gruvin9xGeneral_v103>(radioData.generalSettings, 1))
return false;
}
else if (version < 104) {
if (!loadGeneral<Gruvin9xGeneral_v103>(radioData.generalSettings))
return false;
}
else if (version <= 106) {
if (!loadGeneral<Gruvin9xGeneral_v104>(radioData.generalSettings))
return false;
}
else {
std::cout << "ko\n";
return false;
}
for (int i=0; i<getMaxModels(); i++) {
efile->openRd(FILE_MODEL(i));
if (version == 5) {
loadModel<Gruvin9xModelData_v102>(radioData.models[i], radioData.generalSettings.stickMode+1, 1);
}
else if (version < 103) {
loadModel<Gruvin9xModelData_v102>(radioData.models[i], radioData.generalSettings.stickMode+1);
}
else if (version == 103) {
loadModel<Gruvin9xModelData_v103>(radioData.models[i], radioData.generalSettings.stickMode+1);
}
else if (version == 105) {
loadModel<Gruvin9xModelData_v105>(radioData.models[i], radioData.generalSettings.stickMode+1);
}
else if (version == 106) {
loadModel<Gruvin9xModelData_v106>(radioData.models[i], radioData.generalSettings.stickMode+1);
}
else {
std::cout << "ko\n";
return false;
}
}
std::cout << "ok\n";
return true;
}
bool Gruvin9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index)
{
return false;
}
int Gruvin9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
int size = getEEpromSize();
efile->EeFsCreate(eeprom, size, BOARD_STOCK);
Gruvin9xGeneral gruvin9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&gruvin9xGeneral, sizeof(Gruvin9xGeneral));
if(sz != sizeof(Gruvin9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
ModelData model = radioData.models[i];
if (1/*version < */) {
applyStickModeToModel(model, radioData.generalSettings.stickMode+1);
}
Gruvin9xModelData gruvin9xModel(model);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&gruvin9xModel, sizeof(Gruvin9xModelData));
if(sz != sizeof(Gruvin9xModelData)) {
return 0;
}
}
}
return size;
}
int Gruvin9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[EESIZE_GRUVIN9X];
efile->EeFsCreate(tmp, EESIZE_GRUVIN9X, BOARD_STOCK);
Gruvin9xModelData gruvin9xModel(model);
int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (uint8_t*)&gruvin9xModel, sizeof(Gruvin9xModelData));
if(sz != sizeof(Gruvin9xModelData)) {
return -1;
}
return efile->size(0);
}
int Gruvin9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[EESIZE_GRUVIN9X];
efile->EeFsCreate(tmp, EESIZE_GRUVIN9X, BOARD_STOCK);
Gruvin9xGeneral gruvin9xGeneral(settings);
int sz = efile->writeRlc1(0, FILE_TYP_GENERAL, (uint8_t*)&gruvin9xGeneral, sizeof(gruvin9xGeneral));
if(sz != sizeof(gruvin9xGeneral)) {
return -1;
}
return efile->size(0);
}
int Gruvin9xInterface::getCapability(const Capability capability)
{
switch (capability) {
case OwnerName:
return 0;
case NumCurves5:
return G9X_MAX_CURVE5;
case NumCurves9:
return G9X_MAX_CURVE9;
case Mixes:
return G9X_MAX_MIXERS;
case FlightPhases:
return G9X_MAX_PHASES;
case FlightPhasesHaveFades:
return 1;
case Timers:
return 2;
case Pots:
return 3;
case Switches:
return 7;
case SwitchesPositions:
return 9;
case CustomFunctions:
return 12;
case CustomSwitches:
return 12;
case CSFunc:
return 13;
case Outputs:
return 16;
case ExtraChannels:
return 0;
case ExtendedTrims:
return 500;
case Simulation:
return true;
case OffsetWeight:
return 125;
case HasExpoCurves:
case HasContrast:
return true;
case Telemetry:
return TM_HASTELEMETRY|TM_HASWSHH;
case TelemetryMaxMultiplier:
return 1;
case SlowScale:
return 2;
case SlowRange:
return 15;
case LCDWidth:
return 128;
case HasSDLogs:
case Haptic:
return 1;
case GetThrSwitch:
return DSW_THR;
default:
return false;
}
}
int Gruvin9xInterface::isAvailable(Protocol proto, int port)
{
switch (proto) {
case PPM:
case SILV_A:
case SILV_B:
case SILV_C:
case CTP1009:
case DSM2:
return 1;
default:
return 0;
}
}
SimulatorInterface * Gruvin9xInterface::getSimulator()
{
return NULL;
}

View file

@ -0,0 +1,68 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef gruvin9x_interface_h
#define gruvin9x_interface_h
#include "eeprominterface.h"
class EFile;
class Gruvin9xInterface : public EEPROMInterface
{
public:
Gruvin9xInterface(BoardEnum board);
virtual ~Gruvin9xInterface();
virtual const char * getName();
virtual const int getEEpromSize();
virtual const int getMaxModels();
virtual bool load(RadioData &, uint8_t *eeprom, int size);
virtual bool loadBackup(RadioData &, uint8_t *eeprom,int esize, int index);
virtual bool loadxml(RadioData &radioData, QDomDocument &doc);
virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0);
virtual int getSize(ModelData &);
virtual int getSize(GeneralSettings &settings);
virtual int getCapability(const Capability);
virtual int isAvailable(Protocol proto, int port=0);
virtual SimulatorInterface * getSimulator();
protected:
template <class T>
void loadModel(ModelData &model, unsigned int stickMode=0, int version=2);
template <class T>
bool loadGeneral(GeneralSettings &settings, int version=2);
EFile *efile;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,395 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xGruvin9xeeprom_h
#define open9xGruvin9xeeprom_h
#define O9X_V4_MAX_CSFUNCOLD 13
#define O9X_V4_MAX_CSFUNC 15
#include "open9xStockeeprom.h"
PACK(typedef struct t_Open9xGruvin9xPhaseData_v207 {
int8_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t trim_ext:8; // 2 less significant extra bits per trim (10bits trims)
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
int16_t rotaryEncoders[2];
operator PhaseData();
t_Open9xGruvin9xPhaseData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xPhaseData_v207)); }
t_Open9xGruvin9xPhaseData_v207(PhaseData &eepe);
}) Open9xGruvin9xPhaseData_v207;
PACK(typedef struct t_Open9xGruvin9xPhaseData_v208 {
int16_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
int16_t rotaryEncoders[2];
operator PhaseData();
t_Open9xGruvin9xPhaseData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xPhaseData_v208)); }
t_Open9xGruvin9xPhaseData_v208(PhaseData &eepe);
}) Open9xGruvin9xPhaseData_v208;
PACK(typedef struct t_Open9xGruvin9xMixData_v207 {
uint8_t destCh:4; // 0, 1..C9X_NUM_CHNOUT
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch:6;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve:6;
uint8_t mixWarn:2; // mixer warning
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint16_t srcRaw:7; //
uint16_t differential:7;
uint16_t carryTrim:2;
int8_t sOffset;
operator MixData();
t_Open9xGruvin9xMixData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v207)); }
t_Open9xGruvin9xMixData_v207(MixData&);
}) Open9xGruvin9xMixData_v207;
PACK(typedef struct t_Open9xGruvin9xMixData_v209 {
uint8_t destCh:4; // 0, 1..C9X_NUM_CHNOUT
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch:6;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve:6;
uint8_t mixWarn:2; // mixer warning
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint16_t srcRaw:6; //
int16_t differential:7;
int16_t carryTrim:3;
int8_t sOffset;
operator MixData();
t_Open9xGruvin9xMixData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v209)); }
t_Open9xGruvin9xMixData_v209(MixData&);
}) Open9xGruvin9xMixData_v209;
PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
uint8_t destCh:4; // 0, 1..C9X_NUM_CHNOUT
uint8_t curveMode:1; // O=curve, 1=differential
uint8_t noExpo:1;
uint8_t spare:2;
int8_t weight;
int8_t swtch:6;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t phases:5;
int8_t carryTrim:3;
uint8_t srcRaw:6;
uint8_t mixWarn:2; // mixer warning
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4;
uint8_t speedDown:4;
int8_t curveParam;
int8_t sOffset;
operator MixData();
t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); }
t_Open9xGruvin9xMixData_v211(MixData&);
}) Open9xGruvin9xMixData_v211;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); }
t_Open9xGruvin9xCustomSwData_v207(CustomSwData&);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v207;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); }
t_Open9xGruvin9xCustomSwData_v209(CustomSwData&);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v209;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
int8_t swtch; // input
uint8_t func;
uint8_t param;
operator FuncSwData();
t_Open9xGruvin9xFuncSwData_v203() { memset(this, 0, sizeof(t_Open9xGruvin9xFuncSwData_v203)); }
t_Open9xGruvin9xFuncSwData_v203(FuncSwData&);
}) Open9xGruvin9xFuncSwData_v203;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v210 { // Function Switches data
int8_t swtch; // input
uint8_t func:5;
uint8_t delay:3;
uint8_t param;
operator FuncSwData();
t_Open9xGruvin9xFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xGruvin9xFuncSwData_v210)); }
t_Open9xGruvin9xFuncSwData_v210(FuncSwData&);
}) Open9xGruvin9xFuncSwData_v210;
PACK(typedef struct t_Open9xGruvin9xSwashRingData_v208 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xGruvin9xSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xSwashRingData_v208)); }
t_Open9xGruvin9xSwashRingData_v208(SwashRingData&);
}) Open9xGruvin9xSwashRingData_v208;
PACK(typedef struct t_Open9xGruvin9xSwashRingData_v209 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xGruvin9xSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xSwashRingData_v209)); }
t_Open9xGruvin9xSwashRingData_v209(SwashRingData&);
}) Open9xGruvin9xSwashRingData_v209;
PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xGruvin9xMixData_v207 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v208 swashR;
Open9xGruvin9xPhaseData_v207 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v205 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
operator ModelData();
t_Open9xGruvin9xModelData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v207)); }
t_Open9xGruvin9xModelData_v207(ModelData&);
}) Open9xGruvin9xModelData_v207;
PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xGruvin9xMixData_v207 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v208 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v208 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
operator ModelData();
t_Open9xGruvin9xModelData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v208)); }
t_Open9xGruvin9xModelData_v208(ModelData&);
}) Open9xGruvin9xModelData_v208;
PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xGruvin9xMixData_v209 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v208 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
uint8_t switchWarningStates;
operator ModelData();
t_Open9xGruvin9xModelData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v209)); }
t_Open9xGruvin9xModelData_v209(ModelData&);
}) Open9xGruvin9xModelData_v209;
PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xGruvin9xMixData_v209 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
int8_t servoCenter[O9X_NUM_CHNOUT];
uint8_t switchWarningStates;
Open9xFrSkyData_v210 frsky;
operator ModelData();
t_Open9xGruvin9xModelData_v210() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v210)); }
t_Open9xGruvin9xModelData_v210(ModelData&);
}) Open9xGruvin9xModelData_v210;
PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare1:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xGruvin9xMixData_v211 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v211 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v211 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t switchWarningStates;
Open9xFrSkyData_v210 frsky;
Open9xTimerDataExtra timersXtra[O9X_MAX_TIMERS];
operator ModelData();
t_Open9xGruvin9xModelData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v211)); }
t_Open9xGruvin9xModelData_v211(ModelData&);
}) Open9xGruvin9xModelData_v211;
#endif

View file

@ -0,0 +1,202 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "open9xGruvin9xsimulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#define SIMU
#define SIMU_EXCEPTIONS
#define PCBGRUVIN9X
#define CPUM2560
#define ROTARY_ENCODERS 2
#define HELI
#define TEMPLATES
#define SPLASH
#define FLIGHT_MODES
#define FRSKY
#define FRSKY_HUB
#define WS_HOW_HIGH
#define VARIO
#define PPM_UNIT_PERCENT_PREC1
#define BUZZER
#define AUDIO
#define HAPTIC
#define AUTOSWITCH
#define GRAPHICS
#define CURVES
#define XCURVES
#define GVARS
#define BOLD_FONT
#define VOICE
#define PPM_CENTER_ADJUSTABLE
#define PPM_LIMITS_SYMETRICAL
#define GAUGES
#define GPS
#define FAI_CHOICE
#define EEPROM_VARIANT 3
#undef min
#undef max
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Open9xGruvin9x {
#include "radio/src/targets/gruvin9x/board_gruvin9x.cpp"
#include "radio/src/eeprom_common.cpp"
#include "radio/src/eeprom_rlc.cpp"
#include "radio/src/opentx.cpp"
#include "radio/src/protocols/pulses_avr.cpp"
#include "radio/src/stamp.cpp"
#include "radio/src/maths.cpp"
#include "radio/src/gui/menus.cpp"
#include "radio/src/gui/menu_model.cpp"
#include "radio/src/gui/menu_general.cpp"
#include "radio/src/gui/view_main.cpp"
#include "radio/src/gui/view_statistics.cpp"
#include "radio/src/gui/view_telemetry.cpp"
#include "radio/src/lcd.cpp"
#include "radio/src/keys.cpp"
#include "radio/src/simpgmspace.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/audio_avr.cpp"
#include "radio/src/buzzer.cpp"
#include "radio/src/targets/gruvin9x/somo14d.cpp"
#include "radio/src/telemetry/frsky.cpp"
#include "radio/src/translations/tts_en.cpp"
#include "radio/src/haptic.cpp"
int16_t g_anas[NUM_STICKS+BOARD_9X_NUM_POTS];
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 150;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return g_model.extendedTrims;
}
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
}
}
using namespace Open9xGruvin9x;
Open9xGruvin9xSimulator::Open9xGruvin9xSimulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface)
{
}
bool Open9xGruvin9xSimulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Open9xGruvin9xSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Open9xGruvin9xSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Open9xGruvin9xSimulator::start(RadioData &radioData, bool tests)
{
g_rotenc[0] = 0;
g_rotenc[1] = 0;
open9xInterface->save(&eeprom[0], radioData, SIMU_GRUVIN9X_VARIANTS);
StartEepromThread(NULL);
StartMainThread(tests);
}
void Open9xGruvin9xSimulator::stop()
{
StopMainThread();
StopEepromThread();
}
void Open9xGruvin9xSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#define g_chans512 channelOutputs
#include "simulatorimport.h"
outputs.beep = g_beepCnt;
g_beepCnt = 0;
}
void Open9xGruvin9xSimulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Open9xGruvin9xSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9xGruvin9x::modn12x3[4*getStickMode() + idx] - 1;
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
void Open9xGruvin9xSimulator::getTrims(Trims & trims)
{
uint8_t phase = getFlightPhase();
trims.extended = hasExtendedTrims();
for (uint8_t idx=0; idx<4; idx++) {
trims.values[idx] = getTrimValue(getTrimFlightPhase(phase, idx), idx);
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xGruvin9x::modn12x3[4*getStickMode() + i] - 1;
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
}
}
void Open9xGruvin9xSimulator::wheelEvent(uint8_t steps)
{
g_rotenc[0] += steps;
}
unsigned int Open9xGruvin9xSimulator::getPhase()
{
return getFlightPhase();
}
const char * Open9xGruvin9xSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xGruvin9x_simulator_h
#define open9xGruvin9x_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Open9xInterface;
class Open9xGruvin9xSimulator : public SimulatorInterface {
public:
Open9xGruvin9xSimulator(Open9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase();
virtual void wheelEvent(uint8_t steps);
virtual const char * getError();
protected:
Open9xInterface * open9xInterface;
};
#endif

View file

@ -0,0 +1,195 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "open9xM128simulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#define SIMU
#define SIMU_EXCEPTIONS
#define PCBSTD
#define CPUM128
#define HELI
#define TEMPLATES
#define SPLASH
#define FLIGHT_MODES
#define FRSKY
#define FRSKY_HUB
#define WS_HOW_HIGH
#define VARIO
#define PPM_UNIT_PERCENT_PREC1
#define AUDIO
#define HAPTIC
#define AUTOSWITCH
#define GRAPHICS
#define CURVES
#define XCURVES
#define GVARS
#define BOLD_FONT
#define VOICE
#define PPM_CENTER_ADJUSTABLE
#define PPM_LIMITS_SYMETRICAL
#define GAUGES
#define GPS
#define FAI_CHOICE
#define EEPROM_VARIANT SIMU_M128_VARIANTS
#define GAUGES
#undef min
#undef max
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Open9xM128 {
#include "radio/src/targets/stock/board_stock.cpp"
#include "radio/src/eeprom_common.cpp"
#include "radio/src/eeprom_rlc.cpp"
#include "radio/src/opentx.cpp"
#include "radio/src/protocols/pulses_avr.cpp"
#include "radio/src/stamp.cpp"
#include "radio/src/maths.cpp"
#include "radio/src/gui/menus.cpp"
#include "radio/src/gui/menu_model.cpp"
#include "radio/src/gui/menu_general.cpp"
#include "radio/src/gui/view_main.cpp"
#include "radio/src/gui/view_statistics.cpp"
#include "radio/src/gui/view_telemetry.cpp"
#include "radio/src/lcd.cpp"
#include "radio/src/keys.cpp"
#include "radio/src/simpgmspace.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/audio_avr.cpp"
#include "radio/src/targets/stock/voice.cpp"
#include "radio/src/telemetry/frsky.cpp"
#include "radio/src/translations/tts_en.cpp"
#include "radio/src/haptic.cpp"
int16_t g_anas[NUM_STICKS+BOARD_9X_NUM_POTS];
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 150;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return g_model.extendedTrims;
}
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
}
}
using namespace Open9xM128;
Open9xM128Simulator::Open9xM128Simulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface)
{
}
bool Open9xM128Simulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Open9xM128Simulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Open9xM128Simulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Open9xM128Simulator::start(RadioData &radioData, bool tests)
{
open9xInterface->save(&eeprom[0], radioData, SIMU_M128_VARIANTS);
StartEepromThread(NULL);
StartMainThread(tests);
}
void Open9xM128Simulator::stop()
{
StopMainThread();
StopEepromThread();
}
void Open9xM128Simulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#define g_chans512 channelOutputs
#include "simulatorimport.h"
}
void Open9xM128Simulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Open9xM128Simulator::setTrim(unsigned int idx, int value)
{
idx = Open9xM128::modn12x3[4*getStickMode() + idx] - 1;
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
void Open9xM128Simulator::getTrims(Trims & trims)
{
uint8_t phase = getFlightPhase();
trims.extended = hasExtendedTrims();
for (uint8_t idx=0; idx<4; idx++) {
trims.values[idx] = getTrimValue(getTrimFlightPhase(phase, idx), idx);
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xM128::modn12x3[4*getStickMode() + i] - 1;
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
}
}
void Open9xM128Simulator::wheelEvent(uint8_t steps)
{
}
unsigned int Open9xM128Simulator::getPhase()
{
return getFlightPhase();
}
const char * Open9xM128Simulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xM128_simulator_h
#define open9xM128_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Open9xInterface;
class Open9xM128Simulator : public SimulatorInterface {
public:
Open9xM128Simulator(Open9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase();
virtual void wheelEvent(uint8_t steps);
virtual const char * getError();
protected:
Open9xInterface * open9xInterface;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,562 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xSky9xeeprom_h
#define open9xSky9xeeprom_h
#include "open9xStockeeprom.h"
#define O9X_ARM_MAX_PHASES 9
#define O9X_ARM_MAX_MIXERS 64
#define O9X_ARM_MAX_EXPOS 32
#define O9X_ARM_NUM_CHNOUT 32 // number of real output channels CH1-CH16
#define O9X_ARM_NUM_CSW 32 // number of custom switches
#define O9X_ARM_NUM_FSW 32 // number of functions assigned to switches
#define O9X_ARM_MAX_CURVES 16
#define O9X_ARM_NUM_POINTS 512
#define O9X_ARM_MAX_CSFUNCOLD 13
#define O9X_ARM_MAX_CSFUNC 15
PACK(typedef struct t_Open9xArmTimerData_v202 {
int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
uint16_t val;
operator TimerData();
t_Open9xArmTimerData_v202() { memset(this, 0, sizeof(t_Open9xArmTimerData_v202)); }
t_Open9xArmTimerData_v202(TimerData &eepe);
}) Open9xArmTimerData_v202;
PACK(typedef struct t_Open9xArmExpoData_v208 {
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn;
int8_t curve; // 0=no curve, 1-6=std curves, 7-10=CV1-CV4, 11-15=CV9-CV13
int8_t swtch;
int8_t phase; // if negPhase is 0: 0=normal, 5=FP4 if negPhase is 1: 5=!FP4
uint8_t weight;
int8_t expo;
operator ExpoData();
t_Open9xArmExpoData_v208() { memset(this, 0, sizeof(t_Open9xArmExpoData_v208)); }
t_Open9xArmExpoData_v208(ExpoData&);
}) Open9xArmExpoData_v208;
PACK(typedef struct t_Open9xArmExpoData_v210 {
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn;
int8_t curve; // 0=no curve, 1-6=std curves, 7-10=CV1-CV4, 11-15=CV9-CV13
int8_t swtch;
int8_t phase; // if negPhase is 0: 0=normal, 5=FP4 if negPhase is 1: 5=!FP4
uint8_t weight;
int8_t expo;
char name[6];
uint8_t spare[4];
operator ExpoData();
t_Open9xArmExpoData_v210() { memset(this, 0, sizeof(t_Open9xArmExpoData_v210)); }
t_Open9xArmExpoData_v210(ExpoData&);
}) Open9xArmExpoData_v210;
PACK(typedef struct t_Open9xArmExpoData_v212 {
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn;
int8_t swtch;
uint16_t phases;
int8_t weight;
uint8_t curveMode;
char name[6];
int8_t curveParam;
operator ExpoData();
t_Open9xArmExpoData_v212() { memset(this, 0, sizeof(t_Open9xArmExpoData_v212)); }
t_Open9xArmExpoData_v212(ExpoData&);
}) Open9xArmExpoData_v212;
PACK(typedef struct t_Open9xArmMixData_v208 {
uint8_t destCh; // 0, 1..C9X_NUM_CHNOUT
int8_t phase; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch;
uint8_t mltpx; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve;
uint8_t mixWarn; // mixer warning
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown; // 0 nichts
uint8_t srcRaw; //
int8_t differential;
uint8_t carryTrim;
int8_t sOffset;
operator MixData();
t_Open9xArmMixData_v208() { memset(this, 0, sizeof(t_Open9xArmMixData_v208)); }
t_Open9xArmMixData_v208(MixData&);
}) Open9xArmMixData_v208;
PACK(typedef struct t_Open9xArmMixData_v209 {
uint8_t destCh; // 0, 1..C9X_NUM_CHNOUT
int8_t phase; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch;
uint8_t mltpx; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve;
uint8_t mixWarn; // mixer warning
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown; // 0 nichts
uint8_t srcRaw; //
int8_t differential;
int8_t carryTrim;
int8_t sOffset;
operator MixData();
t_Open9xArmMixData_v209() { memset(this, 0, sizeof(t_Open9xArmMixData_v209)); }
t_Open9xArmMixData_v209(MixData&);
}) Open9xArmMixData_v209;
PACK(typedef struct t_Open9xArmMixData_v210 {
uint8_t destCh; // 0, 1..C9X_NUM_CHNOUT
int8_t phase; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch;
uint8_t mltpx; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve;
uint8_t mixWarn; // mixer warning
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown; // 0 nichts
uint8_t srcRaw; //
int8_t differential;
int8_t carryTrim;
int8_t sOffset;
char name[6];
uint8_t spare[4];
operator MixData();
t_Open9xArmMixData_v210() { memset(this, 0, sizeof(t_Open9xArmMixData_v210)); }
t_Open9xArmMixData_v210(MixData&);
}) Open9xArmMixData_v210;
PACK(typedef struct t_Open9xArmMixData_v212 {
uint8_t destCh;
uint16_t phases;
uint8_t curveMode:1; // O=curve, 1=differential
uint8_t noExpo:1;
int8_t carryTrim:3;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t spare:1;
int8_t weight;
int8_t swtch;
int8_t curveParam;
uint8_t mixWarn; // mixer warning
uint8_t delayUp;
uint8_t delayDown;
uint8_t speedUp;
uint8_t speedDown;
uint8_t srcRaw;
int8_t sOffset;
char name[6];
operator MixData();
t_Open9xArmMixData_v212() { memset(this, 0, sizeof(t_Open9xArmMixData_v212)); }
t_Open9xArmMixData_v212(MixData&);
}) Open9xArmMixData_v212;
PACK(typedef struct t_Open9xArmPhaseData_v208 {
int16_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
operator PhaseData();
t_Open9xArmPhaseData_v208() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v208)); }
t_Open9xArmPhaseData_v208(PhaseData &eepe);
}) Open9xArmPhaseData_v208;
PACK(typedef struct t_Open9xArmPhaseData_v212 {
int16_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
int16_t rotaryEncoders[1];
operator PhaseData();
t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); }
t_Open9xArmPhaseData_v212(PhaseData &eepe);
}) Open9xArmPhaseData_v212;
PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); }
t_Open9xArmCustomSwData_v208(CustomSwData&);
}) Open9xArmCustomSwData_v208;
PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); }
t_Open9xArmCustomSwData_v209(CustomSwData&);
}) Open9xArmCustomSwData_v209;
PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
uint8_t delay;
uint8_t duration;
operator CustomSwData();
t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); }
t_Open9xArmCustomSwData_v210(CustomSwData&);
}) Open9xArmCustomSwData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
int8_t swtch; // input
uint8_t func;
uint8_t param;
operator FuncSwData();
t_Open9xArmFuncSwData_v208() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v208)); }
t_Open9xArmFuncSwData_v208(FuncSwData&);
}) Open9xArmFuncSwData_v208;
PACK(typedef struct t_Open9xArmFuncSwData_v210 { // Function Switches data
int8_t swtch; // input
uint8_t func;
char param[6];
operator FuncSwData();
t_Open9xArmFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v210)); }
t_Open9xArmFuncSwData_v210(FuncSwData&);
}) Open9xArmFuncSwData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v211 { // Function Switches data
int8_t swtch; // input
uint8_t func;
char param[6];
uint8_t delay;
uint8_t spare;
operator FuncSwData();
t_Open9xArmFuncSwData_v211() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v211)); }
t_Open9xArmFuncSwData_v211(FuncSwData&);
}) Open9xArmFuncSwData_v211;
PACK(typedef struct t_Open9xArmSwashRingData_v208 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xArmSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v208)); }
t_Open9xArmSwashRingData_v208(SwashRingData&);
}) Open9xArmSwashRingData_v208;
PACK(typedef struct t_Open9xArmSwashRingData_v209 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xArmSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v209)); }
t_Open9xArmSwashRingData_v209(SwashRingData&);
}) Open9xArmSwashRingData_v209;
PACK(typedef struct t_Open9xArmSwashRingData_v210 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xArmSwashRingData_v210() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v210)); }
t_Open9xArmSwashRingData_v210(SwashRingData&);
}) Open9xArmSwashRingData_v210;
PACK(typedef struct t_Open9xArmFrSkyBarData_v210 {
uint8_t source;
uint8_t barMin; // minimum for bar display
uint8_t barMax; // ditto for max display (would usually = ratio)
}) Open9xArmFrSkyBarData_v210;
PACK(typedef struct t_Open9xArmFrSkyData_v210 {
Open9xFrSkyChannelData_v208 channels[2];
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t voltsSource:2;
uint8_t blades:2;
uint8_t currentSource:2;
Open9xArmFrSkyBarData_v210 bars[4];
Open9xFrSkyRSSIAlarm rssiAlarms[2];
uint8_t lines[4*2*2];
uint8_t spare[4];
operator FrSkyData();
t_Open9xArmFrSkyData_v210() { memset(this, 0, sizeof(t_Open9xArmFrSkyData_v210)); }
t_Open9xArmFrSkyData_v210(FrSkyData&);
}) Open9xArmFrSkyData_v210;
PACK(typedef struct t_Open9xArmFrSkyData_v211 {
Open9xFrSkyChannelData_v208 channels[2];
Open9xFrSkyRSSIAlarm rssiAlarms[2];
uint8_t usrProto; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t voltsSource;
uint8_t blades; // How many blades for RPMs, 0=2 blades, 1=3 blades
uint8_t currentSource;
Open9xArmFrSkyBarData_v210 bars[4];
uint8_t lines[4*2*2];
uint8_t varioSource;
uint8_t varioSpeedUpMin; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
uint8_t spare[4];
operator FrSkyData();
t_Open9xArmFrSkyData_v211() { memset(this, 0, sizeof(t_Open9xArmFrSkyData_v211)); }
t_Open9xArmFrSkyData_v211(FrSkyData&);
}) Open9xArmFrSkyData_v211;
PACK(typedef struct t_Open9xArmModelData_v208 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xArmTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xArmMixData_v208 mixData[O9X_ARM_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_ARM_NUM_CHNOUT];
Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v208 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v208 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
Open9xFrSkyData_v208 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_ARM_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
operator ModelData();
t_Open9xArmModelData_v208() { memset(this, 0, sizeof(t_Open9xArmModelData_v208)); }
t_Open9xArmModelData_v208(ModelData&);
}) Open9xArmModelData_v208;
PACK(typedef struct t_Open9xArmModelData_v209 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xArmTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xArmMixData_v209 mixData[O9X_ARM_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_ARM_NUM_CHNOUT];
Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v209 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
Open9xFrSkyData_v208 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_ARM_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
uint8_t switchWarningStates;
operator ModelData();
t_Open9xArmModelData_v209() { memset(this, 0, sizeof(t_Open9xArmModelData_v209)); }
t_Open9xArmModelData_v209(ModelData&);
}) Open9xArmModelData_v209;
PACK(typedef struct t_Open9xArmModelData_v210 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xArmTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xArmMixData_v210 mixData[O9X_ARM_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_ARM_NUM_CHNOUT];
Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v210 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
Open9xArmFrSkyData_v210 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
int8_t servoCenter[O9X_ARM_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
uint8_t switchWarningStates;
operator ModelData();
t_Open9xArmModelData_v210() { memset(this, 0, sizeof(t_Open9xArmModelData_v210)); }
t_Open9xArmModelData_v210(ModelData&);
}) Open9xArmModelData_v210;
PACK(typedef struct t_Open9xArmModelData_v211 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xArmTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xArmMixData_v210 mixData[O9X_ARM_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_ARM_NUM_CHNOUT];
Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS];
int16_t curves[O9X_ARM_MAX_CURVES];
int8_t points[O9X_ARM_NUM_POINTS];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
int8_t servoCenter[O9X_ARM_NUM_CHNOUT];
uint8_t switchWarningStates;
Open9xArmFrSkyData_v211 frsky;
operator ModelData();
t_Open9xArmModelData_v211() { memset(this, 0, sizeof(t_Open9xArmModelData_v211)); }
t_Open9xArmModelData_v211(ModelData&);
}) Open9xArmModelData_v211;
PACK(typedef struct t_Open9xArmModelData_v212 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xArmTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare1:1;
int8_t ppmDelay;
uint16_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xArmMixData_v212 mixData[O9X_ARM_MAX_MIXERS];
Open9xLimitData_v211 limitData[O9X_ARM_NUM_CHNOUT];
Open9xArmExpoData_v212 expoData[O9X_ARM_MAX_EXPOS];
int16_t curves[O9X_ARM_MAX_CURVES];
int8_t points[O9X_ARM_NUM_POINTS];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v210 swashR;
Open9xArmPhaseData_v212 phaseData[O9X_ARM_MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t switchWarningStates;
Open9xArmFrSkyData_v211 frsky;
Open9xTimerDataExtra timersXtra[O9X_MAX_TIMERS];
operator ModelData();
t_Open9xArmModelData_v212() { memset(this, 0, sizeof(t_Open9xArmModelData_v212)); }
t_Open9xArmModelData_v212(ModelData&);
}) Open9xArmModelData_v212;
#endif

View file

@ -0,0 +1,235 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "open9xSky9xsimulator.h"
#include "open9xinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS
#define PCBSKY9X
#define CPUARM
#define REVB
#define ROTARY_ENCODERS 1
#define HELI
#define TEMPLATES
#define SPLASH
#define FLIGHT_MODES
#define FRSKY
#define FRSKY_HUB
#define WS_HOW_HIGH
#define VARIO
#define PPM_UNIT_PERCENT_PREC1
#define BUZZER
#define AUDIO
#define VOICE
#define HAPTIC
#define PXX
#define DSM2
#define DSM2_PPM
#define DBLKEYS
#define AUTOSWITCH
#define GRAPHICS
#define SDCARD
#define CURVES
#define XCURVES
#define GVARS
#define BOLD_FONT
#define PPM_CENTER_ADJUSTABLE
#define PPM_LIMITS_SYMETRICAL
#define GAUGES
#define GPS
#define FAI_CHOICE
#define EEPROM_VARIANT 3
#undef min
#undef max
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Open9xSky9x {
#include "radio/src/targets/sky9x/board_sky9x.cpp"
#include "radio/src/protocols/ppm_arm.cpp"
#include "radio/src/protocols/pxx_arm.cpp"
#include "radio/src/protocols/dsm2_arm.cpp"
#include "radio/src/targets/sky9x/pwr_driver.cpp"
#include "radio/src/targets/sky9x/eeprom_driver.cpp"
#include "radio/src/eeprom_common.cpp"
#include "radio/src/eeprom_raw.cpp"
#include "radio/src/eeprom_conversions.cpp"
#include "radio/src/opentx.cpp"
#include "radio/src/targets/sky9x/pulses_driver.cpp"
#include "radio/src/protocols/pulses_arm.cpp"
#include "radio/src/stamp.cpp"
#include "radio/src/maths.cpp"
#include "radio/src/gui/menus.cpp"
#include "radio/src/gui/menu_model.cpp"
#include "radio/src/gui/menu_general.cpp"
#include "radio/src/gui/view_main.cpp"
#include "radio/src/gui/view_statistics.cpp"
#include "radio/src/gui/view_telemetry.cpp"
#include "radio/src/gui/view_about.cpp"
#include "radio/src/lcd.cpp"
#include "radio/src/logs.cpp"
#include "radio/src/targets/sky9x/keys_driver.cpp"
#include "radio/src/keys.cpp"
#include "radio/src/simpgmspace.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/telemetry/frsky.cpp"
#include "radio/src/targets/sky9x/audio_driver.cpp"
#include "radio/src/audio_arm.cpp"
#include "radio/src/buzzer.cpp"
#include "radio/src/targets/sky9x/sdcard_driver.cpp"
#include "radio/src/targets/sky9x/coproc_driver.cpp"
#include "radio/src/targets/sky9x/haptic_driver.cpp"
#include "radio/src/haptic.cpp"
#include "radio/src/translations/tts_cz.cpp"
#include "radio/src/translations/tts_de.cpp"
#include "radio/src/translations/tts_en.cpp"
#include "radio/src/translations/tts_es.cpp"
#include "radio/src/translations/tts_se.cpp"
#include "radio/src/translations/tts_it.cpp"
#include "radio/src/translations/tts_fr.cpp"
#include "radio/src/translations/tts_pt.cpp"
#include "radio/src/translations/tts_sk.cpp"
#include "radio/src/translations/tts_pl.cpp"
int16_t g_anas[NUM_STICKS+BOARD_9X_NUM_POTS];
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 1500;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return g_model.extendedTrims;
}
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
}
}
using namespace Open9xSky9x;
Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface)
{
QSettings settings("companion9x", "companion9x");
QString path=settings.value("sdPath", ".").toString()+"/";
int i=0;
for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii();
}
simuSdDirectory[i]=0;
}
bool Open9xSky9xSimulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Open9xSky9xSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Open9xSky9xSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Open9xSky9xSimulator::start(RadioData &radioData, bool tests)
{
g_rotenc[0] = 0;
open9xInterface->save(&eeprom[0], radioData);
StartEepromThread(NULL);
StartMainThread(tests);
}
void Open9xSky9xSimulator::stop()
{
StopMainThread();
StopEepromThread();
}
void Open9xSky9xSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#define g_chans512 channelOutputs
#include "simulatorimport.h"
outputs.beep = g_beepCnt;
g_beepCnt = 0;
}
void Open9xSky9xSimulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Open9xSky9xSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9xSky9x::modn12x3[4*getStickMode() + idx] - 1;
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
void Open9xSky9xSimulator::getTrims(Trims & trims)
{
uint8_t phase = getFlightPhase();
trims.extended = hasExtendedTrims();
for (uint8_t idx=0; idx<4; idx++) {
trims.values[idx] = getTrimValue(getTrimFlightPhase(phase, idx), idx);
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xSky9x::modn12x3[4*getStickMode() + i] - 1;
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
}
}
void Open9xSky9xSimulator::wheelEvent(uint8_t steps)
{
g_rotenc[0] += steps*4;
}
unsigned int Open9xSky9xSimulator::getPhase()
{
return getFlightPhase();
}
const char * Open9xSky9xSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xSky9x_simulator_h
#define open9xSky9x_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Open9xInterface;
class Open9xSky9xSimulator : public SimulatorInterface {
public:
Open9xSky9xSimulator(Open9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase();
virtual void wheelEvent(uint8_t steps);
virtual const char * getError();
protected:
Open9xInterface * open9xInterface;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,891 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xstockeeprom_h
#define open9xstockeeprom_h
#define O9X_MAX_CSFUNCOLD 13
#define O9X_MAX_CSFUNC 15
#include <inttypes.h>
#include "eeprominterface.h"
#include <qbytearray.h>
int8_t open9xV4209FromSource(RawSource source);
int8_t open9xStock209FromSource(RawSource source);
RawSource open9xV4209ToSource(int8_t value);
RawSource open9xStock209ToSource(int8_t value);
int8_t open9xStockFromSwitch(const RawSwitch & sw);
RawSwitch open9xStockToSwitch(int8_t sw);
struct CurveInfo {
int8_t *crv;
uint8_t points;
bool custom;
};
template <class T>
int8_t *curveaddress(T * model, uint8_t idx)
{
return &model->points[idx==0 ? 0 : 5*idx+model->curves[idx-1]];
}
template <class T>
extern CurveInfo curveinfo(T * model, uint8_t idx)
{
CurveInfo result;
result.crv = curveaddress(model, idx);
int8_t *next = curveaddress(model, idx+1);
uint8_t size = next - result.crv;
if (size % 2 == 0) {
result.points = (size / 2) + 1;
result.custom = true;
}
else {
result.points = size;
result.custom = false;
}
return result;
}
PACK(typedef struct t_Open9xFrSkyRSSIAlarm {
uint8_t level:2;
int8_t value:6;
FrSkyRSSIAlarm get(int index);
t_Open9xFrSkyRSSIAlarm() { memset(this, 0, sizeof(t_Open9xFrSkyRSSIAlarm)); }
t_Open9xFrSkyRSSIAlarm(int index, FrSkyRSSIAlarm&);
}) Open9xFrSkyRSSIAlarm;
PACK(typedef struct t_Open9xExpoData_v201 {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
uint8_t chn:2;
uint8_t curve:4; // 0=no curve, 1-6=std curves, 7-10=CV1-CV4, 11-15=CV9-CV13
int8_t swtch:5;
uint8_t phase:3; // if negPhase is 0: 0=normal, 5=FP4 if negPhase is 1: 5=!FP4
uint8_t negPhase:1;
uint8_t weight:7;
int8_t expo;
operator ExpoData();
t_Open9xExpoData_v201() { memset(this, 0, sizeof(t_Open9xExpoData_v201)); }
t_Open9xExpoData_v201(ExpoData&);
}) Open9xExpoData_v201;
PACK(typedef struct t_Open9xExpoData_v211 {
uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both
int8_t swtch:6;
uint8_t chn:2;
uint8_t phases:5;
uint8_t curveMode:1;
uint8_t weight; // we have one bit spare here :)
int8_t curveParam;
operator ExpoData();
t_Open9xExpoData_v211() { memset(this, 0, sizeof(t_Open9xExpoData_v211)); }
t_Open9xExpoData_v211(ExpoData&);
}) Open9xExpoData_v211;
PACK(typedef struct t_Open9xLimitData_v201 {
int8_t min;
int8_t max;
bool revert;
int16_t offset;
operator LimitData();
t_Open9xLimitData_v201() { memset(this, 0, sizeof(t_Open9xLimitData_v201)); }
t_Open9xLimitData_v201(LimitData&);
}) Open9xLimitData_v201;
PACK(typedef struct t_Open9xLimitData_v211 {
int8_t min;
int8_t max;
int8_t ppmCenter;
int16_t offset:14;
uint16_t symetrical:1;
uint16_t revert:1;
operator LimitData();
t_Open9xLimitData_v211() { memset(this, 0, sizeof(t_Open9xLimitData_v211)); }
t_Open9xLimitData_v211(LimitData&);
}) Open9xLimitData_v211;
PACK(typedef struct t_Open9xMixData_v201 {
uint8_t destCh:5; // 0, 1..C9X_NUM_CHNOUT
uint8_t mixWarn:3; // mixer warning
uint8_t srcRaw; //
int8_t weight;
int8_t swtch;
uint8_t curve; // 0=symmetrisch, 1=no neg, 2=no pos
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint8_t carryTrim:1;
uint8_t mltpx:3; // multiplex method 0=+ 1=* 2=replace
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t sOffset;
operator MixData();
t_Open9xMixData_v201() { memset(this, 0, sizeof(t_Open9xMixData_v201)); }
t_Open9xMixData_v201(MixData&);
}) Open9xMixData_v201;
PACK(typedef struct t_Open9xMixData_v203 {
uint8_t destCh:5; // 0, 1..C9X_NUM_CHNOUT
uint8_t mixWarn:3; // mixer warning
uint8_t srcRaw; //
int8_t weight;
int8_t swtch;
uint8_t curve;
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint8_t carryTrim:2;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t sOffset;
operator MixData();
t_Open9xMixData_v203() { memset(this, 0, sizeof(t_Open9xMixData_v203)); }
t_Open9xMixData_v203(MixData&);
}) Open9xMixData_v203;
PACK(typedef struct t_Open9xMixData_v205 {
uint8_t destCh:4; // 0, 1..C9X_NUM_CHNOUT
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch:6;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve:6;
uint8_t mixWarn:2; // mixer warning
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint16_t srcRaw:7; //
int16_t differential:7;
uint16_t carryTrim:2;
int8_t sOffset;
operator MixData();
t_Open9xMixData_v205() { memset(this, 0, sizeof(t_Open9xMixData_v205)); }
t_Open9xMixData_v205(MixData&);
}) Open9xMixData_v205;
PACK(typedef struct t_Open9xMixData_v209 {
uint8_t destCh:4; // 0, 1..C9X_NUM_CHNOUT
int8_t phase:4; // -5=!FP4, 0=normal, 5=FP4
int8_t weight;
int8_t swtch:6;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
int8_t curve:6;
uint8_t mixWarn:2; // mixer warning
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
uint16_t srcRaw:6;
int16_t differential:7;
int16_t carryTrim:3;
int8_t sOffset;
operator MixData();
t_Open9xMixData_v209() { memset(this, 0, sizeof(t_Open9xMixData_v209)); }
t_Open9xMixData_v209(MixData&);
}) Open9xMixData_v209;
PACK(typedef struct t_Open9xMixData_v211 {
uint8_t destCh:4; // 0, 1..C9X_NUM_CHNOUT
uint8_t curveMode:1; // O=curve, 1=differential
uint8_t noExpo:1;
uint8_t spare:2;
int8_t weight;
int8_t swtch:6;
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t phases:5;
int8_t carryTrim:3;
uint8_t srcRaw:6;
uint8_t mixWarn:2; // mixer warning
uint8_t delayUp:4;
uint8_t delayDown:4;
uint8_t speedUp:4;
uint8_t speedDown:4;
int8_t curveParam;
int8_t sOffset;
operator MixData();
t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); }
t_Open9xMixData_v211(MixData&);
}) Open9xMixData_v211;
PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xCustomSwData_v208)); }
t_Open9xCustomSwData_v208(CustomSwData&);
}) Open9xCustomSwData_v208;
PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); }
t_Open9xCustomSwData_v209(CustomSwData&);
}) Open9xCustomSwData_v209;
PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); }
t_Open9xSafetySwData(SafetySwData&);
}) Open9xSafetySwData;
PACK(typedef struct t_Open9xFuncSwData_v201 { // Function Switches data
int8_t swtch; // input
uint8_t func;
operator FuncSwData();
t_Open9xFuncSwData_v201() { memset(this, 0, sizeof(t_Open9xFuncSwData_v201)); }
t_Open9xFuncSwData_v201(FuncSwData&);
}) Open9xFuncSwData_v201;
PACK(typedef struct t_Open9xFuncSwData_v203 { // Function Switches data
int8_t swtch; // input
uint8_t func;
uint8_t param;
operator FuncSwData();
t_Open9xFuncSwData_v203() { memset(this, 0, sizeof(t_Open9xFuncSwData_v203)); }
t_Open9xFuncSwData_v203(FuncSwData&);
}) Open9xFuncSwData_v203;
PACK(typedef struct t_Open9xFuncSwData_v210 { // Function Switches data
int8_t swtch; // input
uint8_t func:5;
uint8_t delay:3;
uint8_t param;
operator FuncSwData();
t_Open9xFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xFuncSwData_v210)); }
t_Open9xFuncSwData_v210(FuncSwData&);
}) Open9xFuncSwData_v210;
PACK(typedef struct t_Open9xFrSkyChannelData_v201 {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t type:4; // channel unit (0=volts, ...)
int8_t offset:4; // calibration offset. Signed 0.1V steps. EG. -4 to substract 0.4V
uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level:4;
uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>)
uint8_t spare:2;
uint8_t barMin; // minimum for bar display
uint8_t barMax; // ditto for max display (would usually = ratio)
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v201)); }
t_Open9xFrSkyChannelData_v201(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v201;
PACK(typedef struct t_Open9xFrSkyChannelData_v203 {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t type; // channel unit (0=volts, ...)
uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level:4;
uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>)
uint8_t spare:2;
uint8_t barMin:4; // minimum for bar display
uint8_t barMax:4; // ditto for max display (would usually = ratio)
int8_t offset; // calibration offset. Signed 0.1V steps. EG. -4 to substract 0.4V
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v203)); }
t_Open9xFrSkyChannelData_v203(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v203;
PACK(typedef struct t_Open9xFrSkyChannelData_v204 {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t type; // channel unit (0=volts, ...)
uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level:4;
uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>)
uint8_t multiplier:2;
int8_t offset; // calibration offset. Signed 0.1V steps. EG. -4 to substract 0.4V
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v204)); }
t_Open9xFrSkyChannelData_v204(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v204;
PACK(typedef struct t_Open9xFrSkyChannelData_v208 {
uint8_t ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
int16_t offset:12;
uint16_t type:4; // channel unit (0=volts, ...)
uint8_t alarms_value[2]; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
uint8_t alarms_level:4;
uint8_t alarms_greater:2; // 0=LT(<), 1=GT(>)
uint8_t multiplier:2;
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v208() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v208)); }
t_Open9xFrSkyChannelData_v208(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v208;
PACK(typedef struct t_Open9xFrSkyData_v201 {
Open9xFrSkyChannelData_v201 channels[2];
operator FrSkyData();
t_Open9xFrSkyData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyData_v201)); }
}) Open9xFrSkyData_v201;
PACK(typedef struct t_Open9xFrSkyData_v202 {
Open9xFrSkyChannelData_v201 channels[2];
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t spare:6;
operator FrSkyData();
t_Open9xFrSkyData_v202() { memset(this, 0, sizeof(t_Open9xFrSkyData_v202)); }
t_Open9xFrSkyData_v202(FrSkyData&);
}) Open9xFrSkyData_v202;
PACK(typedef struct t_Open9xFrSkyData_v203 {
Open9xFrSkyChannelData_v203 channels[2];
uint8_t usrProto; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
operator FrSkyData();
t_Open9xFrSkyData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyData_v203)); }
t_Open9xFrSkyData_v203(FrSkyData&);
}) Open9xFrSkyData_v203;
PACK(typedef struct t_Open9xFrSkyBarData_v204 {
uint16_t source:4;
uint16_t barMin:6; // minimum for bar display
uint16_t barMax:6; // ditto for max display (would usually = ratio)
operator FrSkyBarData();
t_Open9xFrSkyBarData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyBarData_v204)); }
t_Open9xFrSkyBarData_v204(FrSkyBarData&);
}) Open9xFrSkyBarData_v204;
PACK(typedef struct t_Open9xFrSkyData_v204 {
Open9xFrSkyChannelData_v204 channels[2];
uint8_t usrProto:3; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t imperial:1;
uint8_t blades:2;
uint8_t spare:2;
Open9xFrSkyBarData_v204 bars[4];
operator FrSkyData();
t_Open9xFrSkyData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyData_v204)); }
t_Open9xFrSkyData_v204(FrSkyData&);
}) Open9xFrSkyData_v204;
PACK(typedef struct t_Open9xFrSkyData_v205 {
Open9xFrSkyChannelData_v204 channels[2];
uint8_t usrProto:3; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t imperial:1;
uint8_t blades:2;
uint8_t spare:2;
Open9xFrSkyBarData_v204 bars[4];
Open9xFrSkyRSSIAlarm rssiAlarms[2];
operator FrSkyData();
t_Open9xFrSkyData_v205() { memset(this, 0, sizeof(t_Open9xFrSkyData_v205)); }
t_Open9xFrSkyData_v205(FrSkyData&);
}) Open9xFrSkyData_v205;
PACK(typedef struct t_Open9xFrSkyData_v208 {
Open9xFrSkyChannelData_v208 channels[2];
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t voltsSource:2;
uint8_t blades:2;
uint8_t currentSource:2;
Open9xFrSkyBarData_v204 bars[4];
Open9xFrSkyRSSIAlarm rssiAlarms[2];
operator FrSkyData();
t_Open9xFrSkyData_v208() { memset(this, 0, sizeof(t_Open9xFrSkyData_v208)); }
t_Open9xFrSkyData_v208(FrSkyData&);
}) Open9xFrSkyData_v208;
PACK(typedef struct t_Open9xFrSkyData_v210 {
Open9xFrSkyChannelData_v208 channels[2];
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh
uint8_t blades:2; // How many blades for RPMs, 0=2 blades, 1=3 blades
uint8_t spare1:4;
uint8_t voltsSource:3;
uint8_t currentSource:3;
uint8_t spare2:2;
Open9xFrSkyBarData_v204 bars[4];
Open9xFrSkyRSSIAlarm rssiAlarms[2];
uint8_t lines[4];
uint16_t linesXtra;
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
operator FrSkyData();
t_Open9xFrSkyData_v210() { memset(this, 0, sizeof(t_Open9xFrSkyData_v210)); }
t_Open9xFrSkyData_v210(FrSkyData&);
}) Open9xFrSkyData_v210;
PACK(typedef struct t_Open9xSwashRingData_v208 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xSwashRingData_v208)); }
t_Open9xSwashRingData_v208(SwashRingData&);
}) Open9xSwashRingData_v208;
PACK(typedef struct t_Open9xSwashRingData_v209 { // Swash Ring data
uint8_t invertELE:1;
uint8_t invertAIL:1;
uint8_t invertCOL:1;
uint8_t type:5;
uint8_t collectiveSource;
uint8_t value;
operator SwashRingData();
t_Open9xSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xSwashRingData_v209)); }
t_Open9xSwashRingData_v209(SwashRingData&);
}) Open9xSwashRingData_v209;
PACK(typedef struct t_Open9xPhaseData_v201 {
int8_t trim[4]; // -500..500 => trim value, 501 => use trim of phase 0, 502, 503, 504 => use trim of phases 1|2|3|4 instead
int8_t trim_ext:8; // 2 less significant extra bits per trim (10bits trims)
int8_t swtch; // swtch of phase[0] is not used
char name[6];
uint8_t fadeIn:4;
uint8_t fadeOut:4;
operator PhaseData();
t_Open9xPhaseData_v201() { memset(this, 0, sizeof(t_Open9xPhaseData_v201)); }
t_Open9xPhaseData_v201(PhaseData &eepe);
}) Open9xPhaseData_v201;
PACK(typedef struct t_Open9xTimerData_v201 {
int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
uint16_t val:14;
uint16_t persistent:1;
uint16_t dir:1; // 0=>Count Down, 1=>Count Up
operator TimerData();
t_Open9xTimerData_v201() { memset(this, 0, sizeof(t_Open9xTimerData_v201)); }
}) Open9xTimerData_v201;
PACK(typedef struct t_Open9xTimerData_v202 {
int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
uint16_t val;
operator TimerData();
t_Open9xTimerData_v202() { memset(this, 0, sizeof(t_Open9xTimerData_v202)); }
t_Open9xTimerData_v202(TimerData &eepe);
}) Open9xTimerData_v202;
PACK(typedef struct t_Open9xTimerDataExtra {
uint16_t remanent:1;
uint16_t value:15;
t_Open9xTimerDataExtra() { memset(this, 0, sizeof(t_Open9xTimerDataExtra)); }
}) Open9xTimerDataExtra;
#define O9X_MAX_TIMERS 2
#define O9X_MAX_PHASES 5
#define O9X_MAX_MIXERS 32
#define O9X_MAX_EXPOS 14
#define O9X_NUM_CHNOUT 16 // number of real output channels CH1-CH16
#define O9X_NUM_CSW 12 // number of custom switches
#define O9X_NUM_FSW 16 // number of functions assigned to switches
#define O9X_MAX_CURVES 8
#define O9X_NUM_POINTS (112-O9X_MAX_CURVES)
#define O9X_MAX_GVARS 5
#define O9X_209_MAX_CURVE5 8
#define O9X_209_MAX_CURVE9 8
PACK(typedef struct t_Open9xModelData_v201 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v201 timer1;
uint8_t protocol:3;
int8_t ppmNCH:3;
uint8_t thrTrim:1; // Enable Throttle Trim
uint8_t thrExpo:1; // Enable Throttle Expo
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xTimerData_v201 timer2;
Open9xMixData_v201 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xSafetySwData safetySw[O9X_NUM_CHNOUT];
Open9xFuncSwData_v201 funcSw[12];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v201 frsky;
operator ModelData();
t_Open9xModelData_v201() { memset(this, 0, sizeof(t_Open9xModelData_v201)); }
t_Open9xModelData_v201(ModelData&);
}) Open9xModelData_v201;
PACK(typedef struct t_Open9xModelData_v202 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timer1;
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xTimerData_v202 timer2;
Open9xMixData_v201 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xSafetySwData safetySw[O9X_NUM_CHNOUT];
Open9xFuncSwData_v201 funcSw[12];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v202 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
operator ModelData();
t_Open9xModelData_v202() { memset(this, 0, sizeof(t_Open9xModelData_v202)); }
t_Open9xModelData_v202(ModelData&);
}) Open9xModelData_v202;
PACK(typedef struct t_Open9xModelData_v203 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timer1;
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xTimerData_v202 timer2;
Open9xMixData_v203 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v202 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
operator ModelData();
t_Open9xModelData_v203() { memset(this, 0, sizeof(t_Open9xModelData_v203)); }
t_Open9xModelData_v203(ModelData&);
}) Open9xModelData_v203;
PACK(typedef struct t_Open9xModelData_v204 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timer1;
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xTimerData_v202 timer2;
Open9xMixData_v203 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v204 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
Open9xFrSkyRSSIAlarm frskyRssiAlarms[2];
operator ModelData();
t_Open9xModelData_v204() { memset(this, 0, sizeof(t_Open9xModelData_v204)); }
t_Open9xModelData_v204(ModelData&);
}) Open9xModelData_v204;
PACK(typedef struct t_Open9xModelData_v205 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t spare1:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xMixData_v205 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v205 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_NUM_CHNOUT];
operator ModelData();
t_Open9xModelData_v205() { memset(this, 0, sizeof(t_Open9xModelData_v205)); }
t_Open9xModelData_v205(ModelData&);
}) Open9xModelData_v205;
PACK(typedef struct t_Open9xModelData_v208 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xMixData_v205 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v208 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
operator ModelData();
t_Open9xModelData_v208() { memset(this, 0, sizeof(t_Open9xModelData_v208)); }
t_Open9xModelData_v208(ModelData&);
}) Open9xModelData_v208;
PACK(typedef struct t_Open9xModelData_v209 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xMixData_v209 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
Open9xFrSkyData_v208 frsky;
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t frskyLines[4];
uint16_t frskyLinesXtra;
int8_t servoCenter[O9X_NUM_CHNOUT];
uint8_t varioSource:3;
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
uint8_t varioSpeedDownMin;
uint8_t switchWarningStates;
operator ModelData();
t_Open9xModelData_v209() { memset(this, 0, sizeof(t_Open9xModelData_v209)); }
t_Open9xModelData_v209(ModelData&);
}) Open9xModelData_v209;
PACK(typedef struct t_Open9xModelData_v210 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare2:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xMixData_v209 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v201 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
int8_t servoCenter[O9X_NUM_CHNOUT];
uint8_t switchWarningStates;
Open9xFrSkyData_v210 frsky;
operator ModelData();
t_Open9xModelData_v210() { memset(this, 0, sizeof(t_Open9xModelData_v210)); }
t_Open9xModelData_v210(ModelData&);
}) Open9xModelData_v210;
PACK(typedef struct t_Open9xModelData_v211 {
char name[10]; // 10 must be first for eeLoadModelName
Open9xTimerData_v202 timers[O9X_MAX_TIMERS];
uint8_t protocol:3;
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4;
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t pulsePol:1;
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t spare1:1;
int8_t ppmDelay;
uint8_t beepANACenter; // 1<<0->A1.. 1<<6->A7
Open9xMixData_v211 mixData[O9X_MAX_MIXERS];
Open9xLimitData_v211 limitData[O9X_NUM_CHNOUT];
Open9xExpoData_v211 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5msec increments
uint8_t thrTraceSrc;
uint8_t modelId;
uint8_t switchWarningStates;
Open9xFrSkyData_v210 frsky;
operator ModelData();
t_Open9xModelData_v211() { memset(this, 0, sizeof(t_Open9xModelData_v211)); }
t_Open9xModelData_v211(ModelData&);
}) Open9xModelData_v211;
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,136 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9xeeprom_h
#define open9xeeprom_h
#include <inttypes.h>
#include "eeprominterface.h"
#include "eepromimportexport.h"
#include <qbytearray.h>
#define GVARS_VARIANT 0x0001
#define FRSKY_VARIANT 0x0002
#define POS3_VARIANT 0x0004
#define MAVLINK_VARIANT 0x0008
#define M128_VARIANT 0x8000
#define SIMU_STOCK_VARIANTS (GVARS_VARIANT|FRSKY_VARIANT)
#define SIMU_M128_VARIANTS (M128_VARIANT|SIMU_STOCK_VARIANTS)
#define SIMU_GRUVIN9X_VARIANTS (0)
#define SIMU_ARM_VARIANTS (0)
#define O9X_MAX_TIMERS 2
#define O9X_MAX_PHASES 5
#define O9X_MAX_MIXERS 32
#define O9X_MAX_EXPOS 14
#define O9X_NUM_CHNOUT 16 // number of real output channels CH1-CH16
#define O9X_NUM_CSW 12 // number of custom switches
#define O9X_NUM_FSW 16 // number of functions assigned to switches
#define O9X_MAX_CURVES 8
#define O9X_NUM_POINTS (112-O9X_MAX_CURVES)
#define O9X_MAX_GVARS 5
#define O9X_ARM_MAX_PHASES 9
#define O9X_ARM_MAX_MIXERS 64
#define O9X_ARM_MAX_EXPOS 32
#define O9X_ARM_NUM_CHNOUT 32 // number of real output channels CH1-CH16
#define O9X_ARM_NUM_CSW 32 // number of custom switches
#define O9X_ARM_NUM_FSW 32 // number of functions assigned to switches
#define O9X_ARM_MAX_CURVES 16
#define O9X_ARM_NUM_POINTS 512
#define O9X_ARM_MAX_CSFUNCOLD 13
#define O9X_ARM_MAX_CSFUNC 15
class Open9xGeneralDataNew: public TransformedField {
public:
Open9xGeneralDataNew(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant=0);
protected:
virtual void beforeExport();
virtual void afterImport();
StructField internalField;
GeneralSettings & generalData;
BoardEnum board;
int inputsCount;
unsigned int chkSum;
};
class ProtocolsConversionTable: public ConversionTable
{
public:
ProtocolsConversionTable(BoardEnum board)
{
int val = 0;
if (IS_TARANIS(board))
addConversion(OFF, val++);
addConversion(PPM, val++);
if (!IS_ARM(board)) {
addConversion(PPM16, val++);
addConversion(PPMSIM, val++);
}
if (IS_TARANIS(board)) {
addConversion(PXX_XJT_X16, val);
addConversion(PXX_XJT_D8, val);
addConversion(PXX_XJT_LR12, val++);
}
addConversion(PXX_DJT, val++);
if (IS_TARANIS(board)) {
addConversion(DSM2, val++);
}
else {
addConversion(LP45, val++);
addConversion(DSM2, val++);
addConversion(DSMX, val++);
}
}
};
class ChannelsConversionTable: public ConversionTable
{
public:
ChannelsConversionTable()
{
for (int i=4; i<=16; i+= 2)
addConversion(i, -4+i/2);
}
};
class Open9xModelDataNew: public TransformedField {
public:
Open9xModelDataNew(ModelData & modelData, BoardEnum board, unsigned int version, unsigned int variant);
const char * getName() { return name; }
protected:
virtual void beforeExport();
virtual void afterImport();
StructField internalField;
ModelData & modelData;
BoardEnum board;
unsigned int variant;
private:
char name[256];
signed int subprotocols[C9X_NUM_MODULES+1/*trainer*/];
ProtocolsConversionTable protocolsConversionTable;
ChannelsConversionTable channelsConversionTable;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,166 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9x_interface_h
#define open9x_interface_h
#include "eeprominterface.h"
class EFile;
class Open9xInterface : public EEPROMInterface
{
public:
Open9xInterface(BoardEnum board);
virtual ~Open9xInterface();
virtual const char * getName();
virtual const int getEEpromSize();
virtual const int getMaxModels();
virtual bool load(RadioData &, uint8_t *eeprom, int size);
virtual bool loadBackup(RadioData &, uint8_t *eeprom, int esize, int index);
virtual bool loadxml(RadioData &radioData, QDomDocument &doc);
virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0);
virtual int getSize(ModelData &);
virtual int getSize(GeneralSettings &);
virtual int getCapability(const Capability);
virtual int isAvailable(Protocol proto, int port=0);
virtual SimulatorInterface * getSimulator();
protected:
bool checkVersion(unsigned int version);
bool checkVariant(unsigned int version, unsigned int variant);
template <class T>
bool loadModel(ModelData &model, uint8_t *data, int index, unsigned int stickMode=0);
template <class T>
bool loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant);
bool loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode=0);
template <class T>
bool saveModel(unsigned int index, ModelData &model);
template <class T>
bool saveModelVariant(unsigned int index, ModelData &model, unsigned int version, unsigned int variant);
template <class T>
bool loadGeneral(GeneralSettings &settings, unsigned int version);
template <class T>
bool saveGeneral(GeneralSettings &settings, BoardEnum board, uint32_t version, uint32_t variant);
EFile *efile;
};
class Open9xFirmware: public FirmwareInfo {
public:
Open9xFirmware(const QString & id, const QString & name, EEPROMInterface * eepromInterface, const QString & url = QString(), const QString & stamp = QString(), const QString & rnurl = QString(), bool voice = false):
FirmwareInfo(id, name, eepromInterface, url, stamp, rnurl, voice)
{
addLanguage("en");
addLanguage("fr");
addLanguage("it");
addLanguage("de");
addLanguage("se");
addLanguage("cz");
addLanguage("es");
addLanguage("pt");
addTTSLanguage("en");
addTTSLanguage("fr");
addTTSLanguage("it");
addTTSLanguage("de");
addTTSLanguage("se");
addTTSLanguage("cz");
addTTSLanguage("sk");
addTTSLanguage("pt");
addTTSLanguage("es");
}
virtual unsigned int getEepromVersion(unsigned int revision) {
switch(this->eepromInterface->getBoard()) {
case BOARD_SKY9X:
if (revision == 0)
return 212;
if (revision >= 1217)
return 212;
if (revision >= 1174)
return 211;
if (revision >= 1031)
return 210;
if (revision >= 791)
return 209;
if (revision >= 641)
return 208;
break;
case BOARD_GRUVIN9X:
if (revision == 0)
return 211;
if (revision >= 1217)
return 211;
if (revision >= 1174)
return 210;
if (revision >= 791)
return 209;
if (revision >= 641)
return 208;
if (revision >= 547)
return 207;
break;
default:
if (revision == 0)
return 211;
if (revision >= 1217)
return 211;
if (revision >= 1174)
return 210;
if (revision >= 791)
return 209;
if (revision >= 641)
return 208;
break;
}
if (revision >= 321)
return 205;
else if (revision >= 217)
return 204;
else if (revision >= 184)
return 203;
else
return 202;
}
};
void RegisterOpen9xFirmwares();
#endif

View file

@ -0,0 +1,199 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "open9xsimulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#define HELI
#define SIMU
#define SIMU_EXCEPTIONS
#define PCBSTD
#define CPUM64
#define SPLASH
#define FLIGHT_MODES
#define PPM_UNIT_PERCENT_PREC1
#define HELI
#define TEMPLATES
#define FRSKY
#define FRSKY_HUB
#define WS_HOW_HIGH
#define PXX
#define DSM2
#define DSM2_PPM
#define VARIO
#define HAPTIC
#define AUTOSWITCH
#define GRAPHICS
#define CURVES
#define XCURVES
#define GVARS
#define BOLD_FONT
#define VOICE
#define PPM_CENTER_ADJUSTABLE
#define PPM_LIMITS_SYMETRICAL
#define BUZZER
#define GAUGES
#define GPS
#define FAI_CHOICE
#define EEPROM_VARIANT SIMU_STOCK_VARIANTS
#define GAUGES
#undef min
#undef max
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Open9x {
#include "radio/src/targets/stock/board_stock.cpp"
#include "radio/src/eeprom_common.cpp"
#include "radio/src/eeprom_rlc.cpp"
#include "radio/src/opentx.cpp"
#include "radio/src/protocols/pulses_avr.cpp"
#include "radio/src/stamp.cpp"
#include "radio/src/maths.cpp"
#include "radio/src/gui/menus.cpp"
#include "radio/src/gui/menu_model.cpp"
#include "radio/src/gui/menu_general.cpp"
#include "radio/src/gui/view_main.cpp"
#include "radio/src/gui/view_statistics.cpp"
#include "radio/src/gui/view_telemetry.cpp"
#include "radio/src/lcd.cpp"
#include "radio/src/keys.cpp"
#include "radio/src/simpgmspace.cpp"
#include "radio/src/telemetry/frsky.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/targets/stock/voice.cpp"
#include "radio/src/buzzer.cpp"
#include "radio/src/translations/tts_en.cpp"
#include "radio/src/haptic.cpp"
int16_t g_anas[NUM_STICKS+BOARD_9X_NUM_POTS];
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 1500;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return g_model.extendedTrims;
}
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
}
}
using namespace Open9x;
Open9xSimulator::Open9xSimulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface)
{
#define INIT_IMPORT
#include "simulatorimport.h"
}
bool Open9xSimulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Open9xSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Open9xSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Open9xSimulator::start(RadioData &radioData, bool tests)
{
open9xInterface->save(&Open9x::eeprom[0], radioData, SIMU_STOCK_VARIANTS);
StartEepromThread(NULL);
StartMainThread(tests);
}
void Open9xSimulator::stop()
{
StopMainThread();
StopEepromThread();
}
void Open9xSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#define g_chans512 channelOutputs
#include "simulatorimport.h"
outputs.beep = g_beepCnt;
g_beepCnt = 0;
}
void Open9xSimulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Open9xSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9x::modn12x3[4*getStickMode() + idx] - 1;
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
void Open9xSimulator::getTrims(Trims & trims)
{
uint8_t phase = getFlightPhase();
trims.extended = hasExtendedTrims();
for (uint8_t idx=0; idx<4; idx++) {
trims.values[idx] = getTrimValue(getTrimFlightPhase(phase, idx), idx);
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9x::modn12x3[4*getStickMode() + i] - 1;
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
}
}
unsigned int Open9xSimulator::getPhase()
{
return getFlightPhase();
}
const char * Open9xSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef open9x_simulator_h
#define open9x_simulator_h
#include "simulatorinterface.h"
class Open9xInterface;
class Open9xSimulator : public SimulatorInterface {
public:
Open9xSimulator(Open9xInterface *);
virtual void start(RadioData &radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase();
virtual void wheelEvent(uint8_t steps) { }
virtual const char * getError();
protected:
Open9xInterface * open9xInterface;
};
#endif

View file

@ -0,0 +1,242 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "opentxTaranisSimulator.h"
#include "open9xinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS
#define PCBTARANIS
#define CPUARM
#define HELI
#define TEMPLATES
#define SPLASH
#define FLIGHT_MODES
#define FRSKY
#define FRSKY_HUB
#define FRSKY_SPORT
#define GPS
#define VARIO
#define GAUGES
#define PPM_UNIT_PERCENT_PREC1
#define AUDIO
#define VOICE
#define PXX
#define DBLKEYS
#define AUTOSWITCH
#define GRAPHICS
#define SDCARD
#define RTCLOCK
#define CURVES
#define XCURVES
#define GVARS
#define BOLD_FONT
#define PPM_CENTER_ADJUSTABLE
#define PPM_LIMITS_SYMETRICAL
#define FAI_CHOICE
#define EEPROM_VARIANT 3
#undef min
#undef max
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
namespace Open9xX9D {
int taranisSimulatorBoard = 0;
inline int geteepromsize() {
return taranisSimulatorBoard==BOARD_TARANIS_REV4a ? 64*1024 : 32*1024;
}
#define EESIZE geteepromsize()
#include "radio/src/targets/taranis/board_taranis.cpp"
#include "radio/src/protocols/ppm_arm.cpp"
#include "radio/src/protocols/pxx_arm.cpp"
#include "radio/src/targets/taranis/pwr_driver.cpp"
#include "radio/src/eeprom_common.cpp"
#include "radio/src/eeprom_conversions.cpp"
#include "radio/src/eeprom_rlc.cpp"
#include "radio/src/opentx.cpp"
#include "radio/src/targets/taranis/pulses_driver.cpp"
#include "radio/src/targets/taranis/rtc_driver.cpp"
#include "radio/src/targets/taranis/trainer_driver.cpp"
#include "radio/src/protocols/pulses_arm.cpp"
#include "radio/src/stamp.cpp"
#include "radio/src/maths.cpp"
#include "radio/src/gui/menus.cpp"
#include "radio/src/gui/menu_model.cpp"
#include "radio/src/gui/menu_general.cpp"
#include "radio/src/gui/view_main.cpp"
#include "radio/src/gui/view_statistics.cpp"
#include "radio/src/gui/view_channels.cpp"
#include "radio/src/gui/view_telemetry.cpp"
#include "radio/src/gui/view_text.cpp"
#include "radio/src/gui/view_about.cpp"
#include "radio/src/lcd.cpp"
#include "radio/src/logs.cpp"
#include "radio/src/rtc.cpp"
#include "radio/src/targets/taranis/keys_driver.cpp"
#include "radio/src/keys.cpp"
#include "radio/src/bmp.cpp"
// TODO Because FatFS in not C++ there cannot be namespaces there and the functions are defined several times!
#undef SDCARD
#include "radio/src/simpgmspace.cpp"
#define SDCARD
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/telemetry/frsky_sport.cpp"
#include "radio/src/targets/taranis/audio_driver.cpp"
#include "radio/src/audio_arm.cpp"
#include "radio/src/translations/tts_cz.cpp"
#include "radio/src/translations/tts_de.cpp"
#include "radio/src/translations/tts_en.cpp"
#include "radio/src/translations/tts_es.cpp"
#include "radio/src/translations/tts_se.cpp"
#include "radio/src/translations/tts_it.cpp"
#include "radio/src/translations/tts_fr.cpp"
#include "radio/src/translations/tts_pt.cpp"
#include "radio/src/translations/tts_sk.cpp"
#include "radio/src/translations/tts_pl.cpp"
int16_t g_anas[NUM_STICKS+BOARD_X9D_NUM_POTS];
uint16_t anaIn(uint8_t chan)
{
if (chan == 8)
return 1800;
else
return g_anas[chan];
}
bool hasExtendedTrims()
{
return g_model.extendedTrims;
}
uint8_t getStickMode()
{
return g_eeGeneral.stickMode;
}
void resetTrims()
{
GPIOE->IDR |= PIN_TRIM_LH_L | PIN_TRIM_LH_R | PIN_TRIM_LV_DN | PIN_TRIM_LV_UP;
GPIOC->IDR |= PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R;
}
}
using namespace Open9xX9D;
OpentxTaranisSimulator::OpentxTaranisSimulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface)
{
taranisSimulatorBoard = GetEepromInterface()->getBoard();
QSettings settings("companion9x", "companion9x");
QString path=settings.value("sdPath", ".").toString()+"/";
int i=0;
for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii();
}
simuSdDirectory[i]=0;
}
bool OpentxTaranisSimulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * OpentxTaranisSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool OpentxTaranisSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void OpentxTaranisSimulator::start(RadioData &radioData, bool tests)
{
open9xInterface->save(Open9xX9D::eeprom, radioData);
StartEepromThread(NULL);
StartMainThread(tests);
}
void OpentxTaranisSimulator::stop()
{
StopMainThread();
StopEepromThread();
}
void OpentxTaranisSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#define g_chans512 channelOutputs
#include "simulatorimport.h"
}
void OpentxTaranisSimulator::setValues(TxInputs &inputs)
{
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void OpentxTaranisSimulator::setTrim(unsigned int idx, int value)
{
idx = Open9xX9D::modn12x3[4*getStickMode() + idx] - 1;
uint8_t phase = getTrimFlightPhase(getFlightPhase(), idx);
setTrimValue(phase, idx, value);
}
void OpentxTaranisSimulator::getTrims(Trims & trims)
{
uint8_t phase = getFlightPhase();
trims.extended = hasExtendedTrims();
for (uint8_t idx=0; idx<4; idx++) {
trims.values[idx] = getTrimValue(getTrimFlightPhase(phase, idx), idx);
}
for (int i=0; i<2; i++) {
uint8_t idx = Open9xX9D::modn12x3[4*getStickMode() + i] - 1;
int16_t tmp = trims.values[i];
trims.values[i] = trims.values[idx];
trims.values[idx] = tmp;
}
}
void OpentxTaranisSimulator::wheelEvent(uint8_t steps)
{
// g_rotenc[0] += steps*4;
}
unsigned int OpentxTaranisSimulator::getPhase()
{
return getFlightPhase();
}
const char * OpentxTaranisSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef opentx_taranis_simulator_h
#define opentx_taranis_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Open9xInterface;
class OpentxTaranisSimulator : public SimulatorInterface {
public:
OpentxTaranisSimulator(Open9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase();
virtual void wheelEvent(uint8_t steps);
virtual const char * getError();
protected:
Open9xInterface * open9xInterface;
};
#endif

View file

@ -0,0 +1,6 @@
// Automatically generated file (CMake) - do not edit
#define DATE_STR "@DATE@"
#define TIME_STR "@TIME@"
#define VERS_STR "c9x"
#define SVN_STR "@FIRMWARE@-r@G9X_WC_REVISION@"
#define MOD_STR "FH"

View file

@ -0,0 +1,538 @@
#include <algorithm>
#include "helpers.h"
#include "th9xeeprom.h"
int8_t th9xFromSwitch(const RawSwitch & sw)
{
switch (sw.type) {
case SWITCH_TYPE_SWITCH:
return sw.index;
case SWITCH_TYPE_VIRTUAL:
return sw.index > 0 ? (9 + sw.index) : (-9 -sw.index);
default:
return 0;
}
}
RawSwitch th9xToSwitch(int8_t sw)
{
if (sw == 0)
return RawSwitch(SWITCH_TYPE_NONE);
else if (sw <= 9)
return RawSwitch(SWITCH_TYPE_SWITCH, sw);
else
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-9 : sw+9);
}
t_Th9xTrainerMix::t_Th9xTrainerMix()
{
memset(this, 0, sizeof(t_Th9xTrainerMix));
}
t_Th9xTrainerMix::t_Th9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Th9xTrainerMix));
srcChn = c9x.src;
swtch = th9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Th9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
c9x.src = srcChn;
c9x.swtch = th9xToSwitch(swtch);
c9x.weight = (25 * studWeight) / 8;
c9x.mode = mode;
return c9x;
}
t_Th9xTrainerData::t_Th9xTrainerData()
{
memset(this, 0, sizeof(t_Th9xTrainerData));
}
t_Th9xTrainerData::t_Th9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Th9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Th9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
for (int i=0; i<NUM_STICKS; i++) {
c9x.calib[i] = calib[i];
c9x.mix[i] = mix[i];
}
return c9x;
}
t_Th9xGeneral::t_Th9xGeneral()
{
memset(this, 0, sizeof(t_Th9xGeneral));
}
t_Th9xGeneral::t_Th9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Th9xGeneral));
myVers = MDVERS;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
inactivityMin = c9x.inactivityTimer;
// iTrimSwitch =
// iTrimTme1
// iTrimTme2
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
// lightSw = th9xFromSwitch(c9x.lightSw);
trainer = c9x.trainer;
adcFilt = c9x.filterInput;
// keySpeed
thr0pos = c9x.throttleReversed;
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else if (c9x.beeperLength < 2)
beeperVal = 2;
else
beeperVal = 3;
view = c9x.view;
stickMode = c9x.stickMode;
// naviMode
}
Th9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
result.version = myVers;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
result.calibMid[i] = calibMid[i];
result.calibSpanNeg[i] = calibSpanNeg[i];
result.calibSpanPos[i] = calibSpanPos[i];
}
result.currModel = currModel;
result.contrast = contrast;
result.vBatWarn = vBatWarn;
result.vBatCalib = vBatCalib;
// result.lightSw = th9xToSwitch(lightSw);
result.trainer = trainer;
result.view = view;
result.disableThrottleWarning = disableThrottleWarning;
result.switchWarning = disableSwitchWarning ? 0 : -1;
result.disableMemoryWarning = disableMemoryWarning;
switch (beeperVal) {
case 0:
result.beeperMode = e_quiet;
break;
case 1:
result.beeperMode = e_no_keys;
break;
case 2:
result.beeperMode = e_all;
break;
case 3:
result.beeperMode = e_all;
result.beeperLength = 2;
}
result.stickMode = stickMode;
result.inactivityTimer = inactivityMin;
result.throttleReversed = thr0pos;
result.filterInput = adcFilt;
return result;
}
t_Th9xExpoData::t_Th9xExpoData()
{
memset(this, 0, sizeof(t_Th9xExpoData));
}
t_Th9xExpoData::t_Th9xExpoData(ExpoData &c9x)
{
memset(this, 0, sizeof(t_Th9xLimitData));
exp5 = c9x.expo;
mode3 = c9x.mode;
weight6 = c9x.weight;
chn = c9x.chn;
drSw = th9xFromSwitch(c9x.swtch);
if (c9x.curveMode==1)
curve = c9x.curveParam;
else
curve = 0;
}
t_Th9xExpoData::operator ExpoData ()
{
ExpoData c9x;
c9x.expo = exp5;
c9x.mode = mode3;
c9x.weight = weight6;
c9x.chn = chn;
c9x.swtch = th9xToSwitch(drSw);
if (curve) {
c9x.curveMode=1;
c9x.curveParam = curve;
} else {
c9x.curveMode = 0;
c9x.curveParam = exp5;
}
return c9x;
}
t_Th9xLimitData::t_Th9xLimitData()
{
memset(this, 0, sizeof(t_Th9xLimitData));
}
t_Th9xLimitData::t_Th9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Th9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Th9xLimitData::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.revert = revert;
c9x.offset = offset;
return c9x;
}
t_Th9xMixData::t_Th9xMixData()
{
memset(this, 0, sizeof(t_Th9xMixData));
}
t_Th9xMixData::t_Th9xMixData(MixData &c9x)
{
memset(this, 0, sizeof(t_Th9xMixData));
destCh = c9x.destCh;
mixMode = c9x.mltpx;
if (c9x.srcRaw.type == SOURCE_TYPE_STICK)
srcRaw = c9x.srcRaw.index;
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX)
srcRaw = 10;
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM)
srcRaw = 24 + c9x.srcRaw.index;
else if (c9x.srcRaw.type == SOURCE_TYPE_CH)
srcRaw = 12 + c9x.srcRaw.index;
else
srcRaw = 0; // TODO
switchMode = 1;
curveNeg = 0;
weight = c9x.weight;
swtch = th9xFromSwitch(c9x.swtch);
curve = c9x.curve;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
}
t_Th9xMixData::operator MixData ()
{
MixData c9x;
c9x.destCh = destCh;
if (srcRaw < 7)
c9x.srcRaw = RawSource(SOURCE_TYPE_STICK, srcRaw);
else if (srcRaw < 10)
c9x.srcRaw = RawSource(SOURCE_TYPE_NONE); // TODO
else if (srcRaw == 10)
c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
else if (srcRaw == 11)
c9x.srcRaw = RawSource(SOURCE_TYPE_NONE); // TODO CUR
else if (srcRaw < 24)
c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-12);
else /* always true if (srcRaw < 32) */
c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-24);
c9x.weight = weight;
c9x.swtch = th9xToSwitch(swtch);
c9x.curve = curve;
c9x.speedUp = speedUp;
c9x.speedDown = speedDown;
c9x.mltpx = (MltpxValue)mixMode;
return c9x;
}
t_Th9xCustomSwData::t_Th9xCustomSwData(CustomSwData &c9x)
{
opCmp = c9x.func;
val1 = c9x.val1;
val2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
val1 = fromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
val2 = fromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
val1 = th9xFromSwitch(RawSwitch(c9x.val1));
val2 = th9xFromSwitch(RawSwitch(c9x.val2));
}
if (opCmp>TH9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("th9x does not support Custom Switch function %1").arg(getFuncName(opCmp)) + "\n";
opCmp=0;
val1=0;
val2=0;
}
}
t_Th9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
c9x.func = opCmp;
c9x.val1 = val1;
c9x.val2 = val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
c9x.val1 = toSource(val1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
c9x.val2 = toSource(val2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
c9x.val1 = th9xToSwitch(val1).toValue();
c9x.val2 = th9xToSwitch(val2).toValue();
}
return c9x;
}
int8_t t_Th9xCustomSwData::fromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("th9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
/* else if (source.type == SOURCE_TYPE_3POS)
v1 = 9; */
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
RawSource t_Th9xCustomSwData::toSource(int8_t value)
{
if (value == 0) {
return RawSource(SOURCE_TYPE_NONE);
}
else if (value <= 7) {
return RawSource(SOURCE_TYPE_STICK, value - 1);
}
else if (value == 8) {
return RawSource(SOURCE_TYPE_MAX);
}
/* else if (value == 9) {
return RawSource(SOURCE_TYPE_3POS);
} */
else if (value <= 12) {
return RawSource(SOURCE_TYPE_CYC, value-10);
}
else if (value <= 20) {
return RawSource(SOURCE_TYPE_PPM, value-13);
}
else if (value <= 36) {
return RawSource(SOURCE_TYPE_CH, value-21);
}
else {
return RawSource(SOURCE_TYPE_TELEMETRY, value-36);
}
}
t_Th9xModelData::t_Th9xModelData()
{
memset(this, 0, sizeof(t_Th9xModelData));
}
t_Th9xModelData::t_Th9xModelData(ModelData &c9x)
{
memset(this, 0, sizeof(t_Th9xModelData));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
mdVers = MDVERS;
if (c9x.timers[0].mode == TMRMODE_ABS)
tmrMode = 1;
if (c9x.timers[0].mode == TMRMODE_THs)
tmrMode = 2;
if (c9x.timers[0].mode == TMRMODE_THp)
tmrMode = 3;
else
tmrMode = 0;
// TODO tmrDir = c9x.timers[0].dir;
tmrVal = c9x.timers[0].val;
//protocol = c9x.protocol;
/*
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncTrims2Offsets && c9x.funcSw[i].swtch) trimSw = c9x.funcSw[i].swtch;
beepANACenter = c9x.beepANACenter;
pulsePol = c9x.pulsePol;*/
for (int i=0; i<TH9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
for (int i=0; i<TH9X_MAX_EXPOS; i++)
expoTab[i] = c9x.expoData[i];
for (int i=0; i<TH9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<NUM_STICKS; i++)
trimData[i].itrim = std::max(-30, std::min(30, c9x.phaseData[0].trim[i]));
for (int i=0; i<TH9X_MAX_CURVES3; i++)
if (c9x.curves[i].count==3) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<3; j++)
curves3[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<TH9X_MAX_CURVES5; i++)
if (c9x.curves[i+TH9X_MAX_CURVES3].count==5) {
if (c9x.curves[i+TH9X_MAX_CURVES3].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+TH9X_MAX_CURVES3) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i+TH9X_MAX_CURVES3].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+TH9X_MAX_CURVES3].count).arg(i+1+TH9X_MAX_CURVES3) + "\n";
}
for (int i=0; i<TH9X_MAX_CURVES9; i++)
if (c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count==9) {
if (c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5) + "\n";
for (int j=0; j<9; j++)
curves5[i][j] = c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count).arg(i+1+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5) + "\n";
}
/*for (int i=0; i<TH9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];*/
}
}
t_Th9xModelData::operator ModelData ()
{
ModelData c9x;
c9x.used = true;
getEEPROMString(c9x.name, name, sizeof(name));
switch(tmrMode) {
case 1:
c9x.timers[0].mode = TMRMODE_ABS;
break;
case 2:
c9x.timers[0].mode = TMRMODE_THs;
break;
case 3:
c9x.timers[0].mode = TMRMODE_THp;
break;
default:
c9x.timers[0].mode = TMRMODE_OFF;
break;
}
// c9x.timers[0].dir = tmrDir;
c9x.timers[0].val = tmrVal;
/*c9x.protocol = (Protocol)protocol;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.funcSw[0].func = FuncTrims2Offsets;
if (trimSw) {
c9x.funcSw[0].swtch = trimSw;
}
c9x.beepANACenter = beepANACenter;
c9x.pulsePol = pulsePol;
c9x.extendedLimits = extendedLimits;
c9x.swashRingData.invertELE = swashInvertELE;
c9x.swashRingData.invertAIL = swashInvertAIL;
c9x.swashRingData.invertCOL = swashInvertCOL;
c9x.swashRingData.type = swashType;
c9x.swashRingData.collectiveSource = swashCollectiveSource;
c9x.swashRingData.value = swashRingValue;*/
for (int i=0; i<TH9X_NUM_CHNOUT; i++)
c9x.limitData[i] = limitData[i];
for (int i=0; i<TH9X_MAX_EXPOS; i++)
c9x.expoData[i] = expoTab[i];
for (int i=0; i<TH9X_MAX_MIXERS; i++)
c9x.mixData[i] = mixData[i];
for (int i=0; i<NUM_STICKS; i++)
c9x.phaseData[0].trim[i] = trimData[i].itrim;
for (int i=0; i<TH9X_MAX_CURVES3; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 3;
for (int j=0; j<3; j++) {
c9x.curves[i].points[j].x = -100 + 100*i;
c9x.curves[i].points[j].y = curves3[i][j];
}
}
for (int i=0; i<TH9X_MAX_CURVES5; i++) {
c9x.curves[i+TH9X_MAX_CURVES3].custom = false;
c9x.curves[i+TH9X_MAX_CURVES3].count = 5;
for (int j=0; j<5; j++) {
c9x.curves[i+TH9X_MAX_CURVES3].points[j].x = -100 + 50*i;
c9x.curves[i+TH9X_MAX_CURVES3].points[j].y = curves5[i][j];
}
}
for (int i=0; i<TH9X_MAX_CURVES9; i++) {
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].custom = false;
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count = 5;
for (int j=0; j<9; j++) {
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].x = -100 + 50*i;
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y = curves9[i][j];
}
}
/*for (int i=0; i<TH9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];*/
return c9x;
}

View file

@ -0,0 +1,195 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef th9xeeprom_h
#define th9xeeprom_h
#include <inttypes.h>
#include "eeprominterface.h"
//eeprom data
#define TH9X_NUM_CHNOUT 8
#define TH9X_MAX_EXPOS 15
#define TH9X_MAX_MIXERS 25
#define TH9X_MAX_SWITCHES 16
#define TH9X_MAX_CURVES3 3
#define TH9X_MAX_CURVES5 2
#define TH9X_MAX_CURVES9 2
#define TH9X_MAX_CSFUNC 13
#define MDVERS 6
#define TH9X_NUM_CSW 12 //number of custom switches
#define NUM_STICKSnPOTS 7 //number of sticks and pots
PACK(typedef struct t_Th9xTrainerMix {
uint8_t srcChn:3; //0-7 = ch1-8
int8_t swtch:5;
int8_t studWeight:6;
uint8_t mode:2; // off, add-mode, subst-mode
operator TrainerMix();
t_Th9xTrainerMix();
t_Th9xTrainerMix(TrainerMix&);
}) Th9xTrainerMix; //
PACK(typedef struct t_Th9xTrainerData {
int16_t calib[8];
Th9xTrainerMix mix[4];
operator TrainerData();
t_Th9xTrainerData();
t_Th9xTrainerData(TrainerData&);
}) Th9xTrainerData;
PACK(typedef struct t_Th9xGeneral {
uint8_t myVers;
int16_t calibMid[NUM_STICKSnPOTS];
int16_t calibSpanNeg[NUM_STICKSnPOTS];
int16_t calibSpanPos[NUM_STICKSnPOTS];
uint8_t inactivityMin; //ge150
uint8_t iTrimSwitch:4; //ge192
uint8_t iTrimTme1:2;
uint8_t iTrimTme2:2;
uint8_t currModel; //0..15
uint8_t contrast;
uint8_t vBatWarn;
int8_t vBatCalib;
int8_t lightSw;
Th9xTrainerData trainer;
uint8_t adcFilt:2;
uint8_t keySpeed:2;
uint8_t thr0pos:4;
uint8_t disableThrottleWarning:1;
uint8_t disableSwitchWarning:1;
uint8_t disableMemoryWarning:1;
uint8_t beeperVal:2;
uint8_t view:3;
uint8_t stickMode:2;
uint8_t naviMode:2;
operator GeneralSettings();
t_Th9xGeneral();
t_Th9xGeneral(GeneralSettings&);
}) Th9xGeneral;
/*
* ModelData
*/
PACK(typedef struct t_Th9xExpoData {
int8_t exp5:5;
uint8_t mode3:3; //0=end 1=pos 2=neg 3=both 4=trimNeg
int8_t weight6:6;
uint8_t chn:2; //
int8_t drSw:5;
uint8_t curve:3; //
operator ExpoData();
t_Th9xExpoData();
t_Th9xExpoData(ExpoData&);
}) Th9xExpoData;
PACK(typedef struct t_Th9xLimitData {
int8_t min:7;
bool scale:1;
int8_t max:7;
bool resv:1;
bool revert:1;
int8_t offset:7;
operator LimitData();
t_Th9xLimitData();
t_Th9xLimitData(LimitData&);
}) Th9xLimitData;
#define MLTPX_ADD 0
#define MLTPX_MUL 1
#define MLTPX_REP 2
PACK(typedef struct t_Th9xMixData {
uint8_t destCh:4; // 1..C9X_NUM_CHNOUT,X1-X4
uint8_t mixMode:2; // + * =
uint8_t dmy1:2; //
uint8_t srcRaw:5; // S1-4,P1-3,max,cur,X1-X4,p1-3,T1-8 24
uint8_t switchMode:2; // switchMode oOff\tiNeg\tiNul\tiPos
uint8_t curveNeg:1; // Cv cV
int8_t weight;
int8_t swtch:5;
uint8_t curve:3; // 0=off 1..7=cv1..7
uint8_t speedUp:4; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
uint8_t speedDown:4; // 0 nichts
operator MixData();
t_Th9xMixData();
t_Th9xMixData(MixData&);
}) Th9xMixData;
PACK(typedef struct t_Th9xCustomSwData {
uint8_t sw:3; // 0..7
uint8_t opCmp:2; // < & | ^
uint8_t opRes:3; // 0 => 1=> 0=> !=> & | ^
int8_t val1;
int8_t val2;
operator CustomSwData();
t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); }
t_Th9xCustomSwData(CustomSwData &);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Th9xCustomSwData;
PACK(typedef struct t_Th9xTrimData {
int8_t itrim:6; //trim index
uint8_t tmode:2;
t_Th9xTrimData() { }
}) Th9xTrimData;
PACK(typedef struct t_Th9xModelData {
char name[10]; // 10 must be first for eeLoadModelName
uint8_t mdVers; // 1
uint8_t tmrMode:3; // 1
int8_t tmrSw:5; //
uint16_t tmrVal; // 2
uint8_t protocol:5; // 1
uint8_t protocolPar:3; //
char res[3]; // 3
Th9xLimitData limitData[TH9X_NUM_CHNOUT];// 3*8
Th9xExpoData expoTab[TH9X_MAX_EXPOS]; // 5*4 -> 3*15
Th9xMixData mixData[TH9X_MAX_MIXERS]; //0 5*25
int8_t curves3[TH9X_MAX_CURVES3][3]; // 9 new143
int8_t curves5[TH9X_MAX_CURVES5][5]; // 10
int8_t curves9[TH9X_MAX_CURVES9][9]; // 18
Th9xCustomSwData switchTab[TH9X_MAX_SWITCHES];//
Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4
operator ModelData();
t_Th9xModelData();
t_Th9xModelData(ModelData&);
}) Th9xModelData;
#endif
/*eof*/

View file

@ -0,0 +1,248 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include <iostream>
#include "th9xinterface.h"
#include "th9xeeprom.h"
#include "th9xsimulator.h"
#include "file.h"
#define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2
#define FILE_GENERAL 0
#define FILE_MODEL(n) (1+n)
Th9xInterface::Th9xInterface():
EEPROMInterface(BOARD_STOCK),
efile(new EFile())
{
}
Th9xInterface::~Th9xInterface()
{
delete efile;
}
const char * Th9xInterface::getName()
{
return "Th9x";
}
const int Th9xInterface::getEEpromSize()
{
QSettings settings("companion9x", "companion9x");
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK;
}
return EESIZE_STOCK;
}
const int Th9xInterface::getMaxModels()
{
return 16;
}
bool Th9xInterface::loadxml(RadioData &radioData, QDomDocument &doc)
{
return false;
}
bool Th9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size)
{
std::cout << "trying th9x import... ";
if (size != getEEpromSize()) {
std::cout << "wrong size\n";
return false;
}
if (!efile->EeFsOpen(eeprom, size, BOARD_STOCK)) {
std::cout << "wrong file system\n";
return false;
}
efile->openRd(FILE_GENERAL);
Th9xGeneral th9xGeneral;
if (efile->readRlc2((uint8_t*)&th9xGeneral, 1) != 1) {
std::cout << "no\n";
return false;
}
std::cout << "version " << (unsigned int)th9xGeneral.myVers << " ";
switch(th9xGeneral.myVers) {
case 6:
break;
default:
std::cout << "not th9x\n";
return false;
}
efile->openRd(FILE_GENERAL);
int len = efile->readRlc2((uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if (len != sizeof(Th9xGeneral)) {
std::cout << "not th9x\n";
return false;
}
radioData.generalSettings = th9xGeneral;
for (int i=0; i<getMaxModels(); i++) {
Th9xModelData th9xModel;
efile->openRd(FILE_MODEL(i));
if (!efile->readRlc2((uint8_t*)&th9xModel, sizeof(Th9xModelData))) {
radioData.models[i].clear();
}
else {
radioData.models[i] = th9xModel;
}
}
std::cout << "ok\n";
return true;
}
bool Th9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index)
{
return false;
}
int Th9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
efile->EeFsCreate(eeprom, getEEpromSize(), BOARD_STOCK);
Th9xGeneral th9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if(sz != sizeof(Th9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Th9xModelData th9xModel(radioData.models[i]);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&th9xModel, sizeof(Th9xModelData));
if(sz != sizeof(Th9xModelData)) {
return 0;
}
}
}
return getEEpromSize();
}
int Th9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Th9xModelData th9xModel(model);
int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (uint8_t*)&th9xModel, sizeof(Th9xModelData));
if(sz != sizeof(Th9xModelData)) {
return -1;
}
return efile->size(0);
}
int Th9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Th9xGeneral th9xGeneral(settings);
int sz = efile->writeRlc2(0, FILE_TYP_GENERAL, (uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if(sz != sizeof(th9xGeneral)) {
return -1;
}
return efile->size(0);
}
int Th9xInterface::getCapability(const Capability capability)
{
switch (capability) {
case Mixes:
return TH9X_MAX_MIXERS;
case NumCurves3:
return TH9X_MAX_CURVES3;
case NumCurves5:
return TH9X_MAX_CURVES5;
case NumCurves9:
return TH9X_MAX_CURVES9;
case OwnerName:
return 0;
case Timers:
return 1;
case Pots:
return 3;
case Switches:
return 7;
case SwitchesPositions:
return 9;
case CustomFunctions:
return 0;
case CustomSwitches:
return TH9X_MAX_SWITCHES;
case Outputs:
return 8;
case ExtraChannels:
return 4;
case OffsetWeight:
return 125;
case Simulation:
return 1;
case HasContrast:
case HasInputFilter:
return 1;
case CSFunc:
return 13;
case SlowScale:
return 1;
case SlowRange:
return 10;
case LCDWidth:
return 128;
case GetThrSwitch:
return DSW_THR;
default:
return 0;
}
}
int Th9xInterface::isAvailable(Protocol proto, int port)
{
switch (proto) {
case PPM:
case SILV_A:
case SILV_B:
case SILV_C:
case CTP1009:
return 1;
default:
return 0;
}
}
SimulatorInterface * Th9xInterface::getSimulator()
{
return new Th9xSimulator(this);
}

View file

@ -0,0 +1,61 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef th9x_interface_h
#define th9x_interface_h
#include "eeprominterface.h"
class EFile;
class Th9xInterface : public EEPROMInterface
{
public:
Th9xInterface();
virtual ~Th9xInterface();
virtual const char * getName();
virtual const int getEEpromSize();
virtual const int getMaxModels();
virtual bool load(RadioData &, uint8_t *eeprom, int size);
virtual bool loadBackup(RadioData &, uint8_t *eeprom, int esize, int index);
virtual bool loadxml(RadioData &radioData, QDomDocument &doc);
virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0);
virtual int getSize(ModelData &);
virtual int getSize(GeneralSettings &);
virtual int getCapability(const Capability);
virtual int isAvailable(Protocol proto, int port=0);
virtual SimulatorInterface * getSimulator();
protected:
EFile *efile;
};
#endif

View file

@ -0,0 +1,237 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "firmwares/th9x/th9xsimulator.h"
#include "firmwares/th9x/th9xinterface.h"
#define SIM
#define SIMU
#define SIMU_EXCEPTIONS
#undef min
#undef max
#define NUM_POTS 3
#define NUM_CSW 12
#define SWSRC_SW1 10
#ifndef __GNUC__
#include "../winbuild/winbuild.h"
#endif
#include <exception>
#include <algorithm>
namespace Th9x {
#include "simpgmspace.h"
#include "th9x.cpp"
#include "stamp.cpp"
#include "menus.cpp"
#include "pers.cpp"
#include "file.cpp"
#include "lcd.cpp"
#include "drivers.cpp"
#include "foldedlist.cpp"
#include "simpgmspace.cpp"
#include "pulses.cpp"
int16_t g_anas[7];
char g_title[80] = "";
uint16_t anaIn(uint8_t chan)
{
if (chan == 7)
return 750;
else
return 512 + g_anas[chan];
}
bool hasExtendedTrims()
{
return false;
}
void setTrim(uint8_t idx, int8_t value)
{
g_model.trimData[idx].itrim = trimRevertM(value, g_model.trimData[idx].tmode);
}
void getTrims(int16_t values[4])
{
for (int i=0; i<4; i++) {
values[i] = trimVal(i);
}
}
void eeprom_RESV_mismatch(void)
{
assert(!"Should never been called. Only needed by VC++ (debug mode)");
}
#define GPIO_TRIM_LH_L pind
#define GPIO_TRIM_LV_DN pind
#define GPIO_TRIM_RV_UP pind
#define GPIO_TRIM_RH_L pind
#define GPIO_TRIM_LH_R pind
#define GPIO_TRIM_LV_UP pind
#define GPIO_TRIM_RV_DN pind
#define GPIO_TRIM_RH_R pind
#define PIN_TRIM_LH_L (1<<INP_D_TRM_LH_DWN)
#define PIN_TRIM_LV_DN (1<<INP_D_TRM_LV_DWN)
#define PIN_TRIM_RV_UP (1<<INP_D_TRM_RV_UP)
#define PIN_TRIM_RH_L (1<<INP_D_TRM_RH_DWN)
#define PIN_TRIM_LH_R (1<<INP_D_TRM_LH_UP)
#define PIN_TRIM_LV_UP (1<<INP_D_TRM_LV_UP)
#define PIN_TRIM_RV_DN (1<<INP_D_TRM_RV_DWN)
#define PIN_TRIM_RH_R (1<<INP_D_TRM_RH_UP)
#define TRIM_CASE(key, pin, mask) \
case key: \
if (state) pin |= mask; else pin &= ~mask;\
break;
void simuSetTrim(uint8_t trim, bool state)
{
switch (trim) {
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
}
}
#define SWITCH_CASE(swtch, pin, mask) \
case swtch: \
if (state) pin &= ~(mask); else pin |= (mask); \
break;
#define SWITCH_3_CASE(swtch, pin1, pin2, mask1, mask2) \
case swtch: \
if (state >= 0) pin1 &= ~(mask1); else pin1 |= (mask1); \
if (state <= 0) pin2 &= ~(mask2); else pin2 |= (mask2); \
break;
void simuSetSwitch(uint8_t swtch, int8_t state)
{
switch (swtch) {
SWITCH_CASE(0, pine, 1<<INP_E_ThrCt)
SWITCH_CASE(4, pine, 1<<INP_E_AileDR)
SWITCH_3_CASE(3, ping, pine, (1<<INP_G_ID1), (1<<INP_E_ID2))
SWITCH_CASE(1, ping, 1<<INP_G_RuddDR)
SWITCH_CASE(2, pine, 1<<INP_E_ElevDR)
SWITCH_CASE(5, pine, 1<<INP_E_Gear)
SWITCH_CASE(6, pine, 1<<INP_E_Trainer)
default:
break;
}
}
#define KEY_CASE(key, pin, mask) \
case key: \
if (state) pin |= mask; else pin &= ~mask;\
break;
void simuSetKey(uint8_t key, bool state)
{
switch (key) {
KEY_CASE(KEY_MENU, pinb, (1<<INP_B_KEY_MEN))
KEY_CASE(KEY_EXIT, pinb, (1<<INP_B_KEY_EXT))
KEY_CASE(KEY_RIGHT, pinb, (1<<INP_B_KEY_RGT))
KEY_CASE(KEY_LEFT, pinb, (1<<INP_B_KEY_LFT))
KEY_CASE(KEY_UP, pinb, (1<<INP_B_KEY_UP))
KEY_CASE(KEY_DOWN, pinb, (1<<INP_B_KEY_DWN))
}
}
#define IS_BACKLIGHT_ON() (PORTB & (1<<OUT_B_LIGHT))
}
using namespace Th9x;
Th9xSimulator::Th9xSimulator(Th9xInterface * th9xInterface):
th9xInterface(th9xInterface)
{
}
bool Th9xSimulator::timer10ms()
{
#define TIMER10MS_IMPORT
#include "simulatorimport.h"
}
uint8_t * Th9xSimulator::getLcd()
{
#define GETLCD_IMPORT
#include "simulatorimport.h"
}
bool Th9xSimulator::lcdChanged(bool & lightEnable)
{
#define LCDCHANGED_IMPORT
#include "simulatorimport.h"
}
void Th9xSimulator::start(RadioData &radioData, bool tests)
{
th9xInterface->save(&eeprom[0], radioData);
StartMainThread(tests);
}
void Th9xSimulator::stop()
{
StopMainThread();
}
void Th9xSimulator::getValues(TxOutputs &outputs)
{
#define GETVALUES_IMPORT
#include "simulatorimport.h"
for (int i=0; i<8; i++)
outputs.chans[i] *= 2;
}
void Th9xSimulator::setValues(TxInputs &_inputs)
{
TxInputs inputs = _inputs;
for (int i=0; i<4; i++)
inputs.sticks[i] /= 2;
for (int i=0; i<3; i++)
inputs.pots[i] /= 2;
#define SETVALUES_IMPORT
#include "simulatorimport.h"
}
void Th9xSimulator::setTrim(unsigned int idx, int value)
{
Th9x::setTrim(idx, value);
}
void Th9xSimulator::getTrims(Trims & trims)
{
trims.extended = false;
Th9x::getTrims(trims.values);
}
const char * Th9xSimulator::getError()
{
#define GETERROR_IMPORT
#include "simulatorimport.h"
}

View file

@ -0,0 +1,60 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef th9x_simulator_h
#define th9x_simulator_h
#include "simulatorinterface.h"
class RadioData;
class Th9xInterface;
class Th9xSimulator : public SimulatorInterface {
public:
Th9xSimulator(Th9xInterface *);
virtual void start(RadioData & radioData, bool tests);
virtual void stop();
virtual bool timer10ms();
virtual uint8_t * getLcd();
virtual bool lcdChanged(bool & lightEnable);
virtual void setValues(TxInputs &inputs);
virtual void getValues(TxOutputs &outputs);
virtual void setTrim(unsigned int idx, int value);
virtual void getTrims(Trims & trims);
virtual unsigned int getPhase() { return 0; }
virtual void wheelEvent(uint8_t steps) { }
virtual const char * getError();
protected:
Th9xInterface * th9xInterface;
};
#endif

View file

@ -0,0 +1,502 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include <QtGui>
#include "hexinterface.h"
#include "splash.h"
#include "flashinterface.h"
int getFileType(const QString &fullFileName)
{
if(QFileInfo(fullFileName).suffix().toUpper()=="HEX") return FILE_TYPE_HEX;
if(QFileInfo(fullFileName).suffix().toUpper()=="BIN") return FILE_TYPE_BIN;
if(QFileInfo(fullFileName).suffix().toUpper()=="EEPM") return FILE_TYPE_EEPM;
if(QFileInfo(fullFileName).suffix().toUpper()=="EEPE") return FILE_TYPE_EEPE;
if(QFileInfo(fullFileName).suffix().toUpper()=="XML") return FILE_TYPE_XML;
return 0;
}
FlashInterface::FlashInterface(QString fileName)
{
char * temp = (char *)malloc(MAX_FSIZE);
date = "";
time = "";
svn = "";
build = "";
isValidFlag = true;
QFile file(fileName);
flash_size=0;
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
isValidFlag = false;
}
else {
QTextStream inputStream(&file);
flash_size = HexInterface(inputStream).load((uint8_t *)temp, MAX_FSIZE);
file.close();
inputStream.reset();
if (flash_size == 0) {
QFile file(fileName);
file.open(QIODevice::ReadOnly);
char * bin_flash = (char *)malloc(MAX_FSIZE);
flash_size = file.read(bin_flash, MAX_FSIZE);
flash = QByteArray(bin_flash, flash_size);
free(bin_flash);
}
else {
flash = QByteArray(temp, flash_size);
}
if (flash_size > 0) {
SeekSvn();
SeekDate();
SeekTime();
SeekBuild();
SeekSplash();
}
else {
isValidFlag = false;
}
}
free(temp);
}
QString FlashInterface::getDate(void)
{
return date;
}
QString FlashInterface::getTime(void)
{
return time;
}
QString FlashInterface::getSvn(void)
{
return svn;
}
QString FlashInterface::getBuild(void)
{
return build;
}
int FlashInterface::getSize()
{
return flash_size;
}
void FlashInterface::SeekSvn(void)
{
int i, start = -1, end = -1;
start = flash.indexOf(QString(SVN_MARK));
if (start > 0) {
start += QString(SVN_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
svn = QString(flash.mid(start, (end - start))).trimmed();
}
else {
svn = QString("");
}
}
}
void FlashInterface::SeekDate(void)
{
int i, start = -1, end = -1, startsvn=0;
startsvn = flash.indexOf(QString(SVN_MARK));
if (startsvn>0) {
start = flash.indexOf(QString(DATE_MARK),startsvn);
} else {
start = flash.indexOf(QString(DATE_MARK));
}
if (start > 0) {
start += QString(DATE_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
date = QString(flash.mid(start, (end - start))).trimmed();
}
else {
date = QString("");
}
}
}
void FlashInterface::SeekTime(void)
{
int i, start = -1, end = -1, startsvn=0;
startsvn = flash.indexOf(QString(SVN_MARK));
if (startsvn>0) {
start = flash.indexOf(QString(TIME_MARK),startsvn);
} else {
start = flash.indexOf(QString(TIME_MARK));
}
if (start > 0) {
start += QString(TIME_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
time = QString(flash.mid(start, (end - start))).trimmed();
}
else {
time = QString("");
}
}
}
void FlashInterface::SeekBuild(void)
{
int i, start = -1, end = -1;
start = flash.indexOf(QString(BLD_MARK));
if (start > 0) {
start += QString(BLD_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
build = QString(flash.mid(start, (end - start))).trimmed();
}
else {
build = QString("");
}
}
else {
start = flash.indexOf(QString(VAR_MARK));
if (start > 0) {
start += QString(VAR_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
build = QString(flash.mid(start, (end - start))).trimmed();
}
else {
build = QString("");
}
}
}
}
void FlashInterface::SeekSplash(void)
{
QByteArray splash,spe;
splash_offset=0;
splash.clear();
splash.append((char *)gr9x_splash, sizeof(gr9x_splash));
int start = flash.indexOf(splash);
if (start>0) {
splash_offset=start;
splash_type=1;
splash_size=sizeof(gr9x_splash);
}
if (start==-1) {
splash.clear();
splash.append((char *)er9x_splash, sizeof(er9x_splash));
start = flash.indexOf(splash);
if (start>0) {
splash_offset=start;
splash_type=2;
splash_size=sizeof(er9x_splash);
}
}
if (start==-1) {
splash.clear();
splash.append((char *)opentx_splash, sizeof(opentx_splash));
start = flash.indexOf(splash);
if (start>0) {
splash_offset=start;
splash_type=3;
splash_size=sizeof(opentx_splash);
}
}
if (start==-1) {
splash.clear();
splash.append((char *)opentxtaranis_splash, sizeof(opentxtaranis_splash));
start = flash.indexOf(splash);
if (start>0) {
splash_offset=start;
splash_type=5;
splash_size=sizeof(opentxtaranis_splash);
}
}
if (start==-1) {
splash.clear();
splash.append((char *)gr9xv4_splash, sizeof(gr9xv4_splash));
start = flash.indexOf(splash);
if (start>0) {
splash_offset=start;
splash_type=1;
splash_size=sizeof(gr9xv4_splash);
}
}
if (start==-1) {
splash.clear();
splash.append((char *)ersky9x_splash, sizeof(ersky9x_splash));
start = flash.indexOf(splash);
if (start>0) {
splash_offset=start;
splash_type=4;
splash_size=sizeof(ersky9x_splash);
}
}
if (start==-1) {
start=0;
splash.clear();
splash.append(OTX_SPS);
splash.append('\0');
spe.clear();
spe.append(OTX_SPE);
spe.append('\0');
int diff=0;
int end=0;
while (start>=0) {
start = flash.indexOf(splash,start+1);
if (start>0) {
end=flash.indexOf(spe,start+1);
if (end>0) {
diff=end-start;
while (diff<1030 && end>0) {
end=flash.indexOf(spe,end+1);
diff=end-start;
}
if (end>0) {
diff=end-start;
if (diff==1030) {
splash_offset=start+OTX_OFFSET;
splash_type=2;
splash_size=sizeof(opentx_splash);
break;
}
if (diff==6790) {
splash_offset=start+OTX_OFFSET;
splash_type=5;
splash_size=sizeof(opentxtaranis_splash);
break;
}
}
}
}
}
}
if (start==-1) {
start=0;
splash.clear();
splash.append(ERSKY9X_SPS);
splash.append('\0');
spe.clear();
spe.append(ERSKY9X_SPE);
spe.append('\0');
int diff=0;
int end=0;
while (start>=0) {
start = flash.indexOf(splash,start+1);
if (start>0) {
end=flash.indexOf(spe,start+1);
if (end>0) {
diff=end-start;
while (diff<1031 && end>0) {
end=flash.indexOf(spe,end+1);
diff=end-start;
}
if (end>0) {
diff=end-start;
if (diff==1031) {
splash_offset=start+ERSKY9X_OFFSET;
splash_type=4;
splash_size=sizeof(ersky9x_splash);
break;
}
}
}
}
}
}
if (start==-1) {
splash.clear();
splash.append(ERSPLASH_MARKER);
splash.append('\0');
start = flash.indexOf(splash);
if (start>0) {
splash_offset=start+ERSPLASH_OFFSET;
splash_type=2;
splash_size=sizeof(er9x_splash);
}
}
if (splash_offset>0) {
if (splash_type==5) {
splash_width=SPLASHX9D_WIDTH;
splash_height=SPLASHX9D_HEIGHT;
splash_colors=16;
splash_format=QImage::Format_Indexed8;
} else {
splash_width=SPLASH_WIDTH;
splash_height=SPLASH_HEIGHT;
splash_colors=1;
splash_format=QImage::Format_Mono;
}
}
}
bool FlashInterface::setSplash(const QImage & newsplash)
{
char b[SPLASH_SIZE_MAX] = {0};
QColor color;
QByteArray splash;
if (splash_offset == 0) {
return false;
}
else {
if (splash_colors == 16) {
unsigned int idx = 0;
for (unsigned int y=0; y<splash_height; y+=8) {
for (unsigned int x=0; x<splash_width; x++) {
unsigned int values[] = { 255, 255, 255, 255 };
for (unsigned int z=0; z<8; z++) {
if (y+z < splash_height) {
QRgb gray = qGray(newsplash.pixel(x, y+z));
for (unsigned int i=0; i<4; i++) {
if (gray & (1<<(4+i)))
values[i] -= 1 << z;
}
}
}
for (int i=0; i<4; i++)
b[idx++] = values[i];
}
}
}
else {
QColor black = QColor(0,0,0);
QImage blackNwhite = newsplash.convertToFormat(QImage::Format_MonoLSB);
for (uint y=0; y<splash_height; y++) {
for (uint x=0; x<splash_width; x++) {
color = QColor(blackNwhite.pixel(x,y));
b[splash_width*(y/8) + x] |=((color==black ? 1: 0)<<(y % 8));
}
}
}
splash.clear();
splash.append(b, splash_size);
flash.replace(splash_offset, splash_size, splash);
return true;
}
}
uint FlashInterface::getSplashWidth()
{
return splash_width;
}
uint FlashInterface::getSplashHeight()
{
return splash_height;
}
uint FlashInterface::getSplashColors()
{
return splash_colors;
}
QImage::Format FlashInterface::getSplashFormat()
{
return splash_format;
}
QImage FlashInterface::getSplash()
{
if (splash_colors == 16) {
QImage image(splash_width, splash_height, QImage::Format_RGB888);
if (splash_offset > 0) {
for (unsigned int y=0; y<splash_height; y++) {
unsigned int idx = (y/8)*splash_width*4;
unsigned int mask = (1 << (y%8));
for (unsigned int x=0; x<splash_width; x++, idx+=4) {
unsigned int z = ((flash.at(splash_offset+idx) & mask) ? 0x1 : 0) + ((flash.at(splash_offset+idx+1) & mask) ? 0x2 : 0) + ((flash.at(splash_offset+idx+2) & mask) ? 0x4 : 0) + ((flash.at(splash_offset+idx+3) & mask) ? 0x8 : 0);
z = 255-(z*255)/15;
QRgb rgb = qRgb(z, z, z);
image.setPixel(x, y, rgb);
}
}
}
return image;
}
else {
QImage image(splash_width, splash_height, QImage::Format_Mono);
if (splash_offset > 0) {
for (unsigned int y=0; y<splash_height; y++)
for(unsigned int x=0; x<splash_width; x++)
image.setPixel(x, y, (flash.at(splash_offset+(splash_width*(y/8)+x)) & (1<<(y % 8))) ? 0 : 1);
}
return image;
}
}
bool FlashInterface::hasSplash()
{
return (splash_offset > 0 ? true : false);
}
bool FlashInterface::isValid()
{
return isValidFlag;
}
uint FlashInterface::saveFlash(QString fileName)
{
uint8_t binflash[MAX_FSIZE];
memcpy(&binflash, flash.constData(), flash_size);
QFile file(fileName);
int fileType = getFileType(fileName);
if (fileType == FILE_TYPE_HEX) {
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { //reading HEX TEXT file
return -1;
}
QTextStream outputStream(&file);
HexInterface hex=HexInterface(outputStream);
hex.save(binflash, flash_size);
}
else {
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) { //reading HEX TEXT file
return -1;
}
file.write((char*)binflash, flash_size);
}
file.close();
return flash_size;
}

View file

@ -0,0 +1,96 @@
/*
* Author - Romolo Manfredini <romolo.manfredini@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef FLASHINTERFACE_H
#define FLASHINTERFACE_H
#include <QDialog>
#include <QtGui>
#include <inttypes.h>
#include "file.h"
#define MAX_FSIZE (512*1024)
#define SPLASH_WIDTH (128)
#define SPLASH_HEIGHT (64)
#define SPLASHX9D_WIDTH (212)
#define SPLASHX9D_HEIGHT (64)
#define SPLASH_SIZE_MAX (SPLASHX9D_WIDTH*SPLASHX9D_HEIGHT/2)
#define ERSPLASH_MARKER "Splash"
#define ERSPLASH_OFFSET (10)
#define OTX_SPS "SPS"
#define OTX_SPE "SPE"
#define OTX_OFFSET (6)
#define ERSKY9X_SPS "SPS"
#define ERSKY9X_SPE "SPE"
#define ERSKY9X_OFFSET (7)
#define VERS_MARK "VERS:"
#define SVN_MARK "SVN:"
#define DATE_MARK "DATE:"
#define TIME_MARK "TIME:"
#define BLD_MARK "BLD:"
#define VAR_MARK "EEPR:"
#define FILE_TYPE_BIN 1
#define FILE_TYPE_HEX 2
#define FILE_TYPE_EEPE 3
#define FILE_TYPE_EEPM 4
#define FILE_TYPE_XML 5
int getFileType(const QString &fullFileName);
class FlashInterface
{
public:
FlashInterface(QString filename);
QString getDate();
QString getTime();
QString getSvn();
int getSize();
QString getBuild();
QImage getSplash();
bool setSplash(const QImage & newsplash);
bool hasSplash();
uint getSplashWidth();
uint getSplashHeight();
uint getSplashColors();
QImage::Format getSplashFormat();
uint saveFlash(QString fileName);
bool isValid();
private:
QByteArray flash;
void SeekVer();
void SeekSvn();
void SeekDate();
void SeekTime();
void SeekBuild();
void SeekSplash();
QString filename;
QString date;
QString time;
QString svn;
QString build;
QByteArray splash;
uint splash_offset;
uint splash_type;
uint splash_size;
uint splash_width;
uint splash_height;
uint splash_colors;
QImage::Format splash_format;
uint flash_size;
protected:
bool isValidFlag;
};
#endif /* FLASHINTERFACE_H */

View file

@ -0,0 +1,34 @@
#include "fusesdialog.h"
#include "ui_fusesdialog.h"
#include "burnconfigdialog.h"
fusesDialog::fusesDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::fusesDialog)
{
ui->setupUi(this);
}
fusesDialog::~fusesDialog()
{
delete ui;
}
void fusesDialog::on_resetFuses_EEprotect_clicked()
{
burnConfigDialog *bcd = new burnConfigDialog(this);
bcd->restFuses(true);
}
void fusesDialog::on_resetFuses_EEdelete_clicked()
{
burnConfigDialog *bcd = new burnConfigDialog(this);
bcd->restFuses(false);
}
void fusesDialog::on_readFuses_clicked()
{
burnConfigDialog *bcd = new burnConfigDialog(this);
bcd->readFuses();
}

View file

@ -0,0 +1,27 @@
#ifndef FUSESDIALOG_H
#define FUSESDIALOG_H
#include <QDialog>
namespace Ui {
class fusesDialog;
}
class fusesDialog : public QDialog
{
Q_OBJECT
public:
explicit fusesDialog(QWidget *parent = 0);
~fusesDialog();
private:
Ui::fusesDialog *ui;
private slots:
void on_readFuses_clicked();
void on_resetFuses_EEdelete_clicked();
void on_resetFuses_EEprotect_clicked();
};
#endif // FUSESDIALOG_H

View file

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>fusesDialog</class>
<widget class="QDialog" name="fusesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle">
<string>Fuses</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<normaloff>:/images/fuses.png</normaloff>:/images/fuses.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="readFuses">
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Reads the current fuses in the AVR controller.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Proper states for &lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;AtMega 64 &lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;EEPROM erase fuse not set: 0E, 81, FF&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;EEPROM erase fuse set: 0E, 89, FF&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Proper states for AtMega 2560 :&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;EEPROM erase fuse not set: D7, 11, FC&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;EEPROM erase fuse set: D7, 19, FC&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Read Fuses</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="resetFuses_EEprotect">
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600; text-decoration: underline;&quot;&gt;Reset Fuses&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Fuses in the AVR tell it how to behave. Pressing this button sets the fuses to the default parameters needed in the FW. These parameters are different for stock and 4.1 MB, please verify you selected the appropriate processor type in preferences.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;This button also sets the &amp;quot;EEPROM protect&amp;quot; Fuse.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;This prevents erasing of the EEPROM when the flash memory is written.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600; text-decoration: underline;&quot;&gt;WARNING&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Setting fuses can lead to problems and even a total lockout from your controller. Do this only if you know what you are doing.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;When in doubt consult either the project's page or the 9xforum (http://9xforums.com/forum/)&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;If you do get locked out - google lookup for &amp;quot;dealing with Fuse Bricks&amp;quot;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Reset Fuses
EEPROM - PROTECT</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="resetFuses_EEdelete">
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600; text-decoration: underline;&quot;&gt;Reset Fuses&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Fuses in the AVR tell it how to behave. Pressing this button sets the fuses to the default parameters needed in the &lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;FW. These parameters are different for stock and 4.1 MB, please verify you selected the appropriate processor type in preferences.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;This button also clears the &amp;quot;EEPROM protect&amp;quot; Fuse.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;This causes erasing of the EEPROM when the flash memory is written.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600; text-decoration: underline;&quot;&gt;WARNING&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Setting fuses can lead to problems and even a total lockout from your controller. Do this only if you know what you are doing.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;When in doubt consult either the project's page or the 9xforum (http://9xforums.com/forum/)&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;If you do get locked out - google lookup for &amp;quot;dealing with Fuse Bricks&amp;quot;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Reset Fuses
EEPROM - DELETE</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;WARNING&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600; text-decoration: underline;&quot;&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Changing the fuses can mess up your radio.&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Proceed only if you know what you are doing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
</resources>
<connections/>
</ui>

File diff suppressed because it is too large Load diff

157
companion/src/generaledit.h Normal file
View file

@ -0,0 +1,157 @@
#ifndef GENERALEDIT_H
#define GENERALEDIT_H
#include <QDialog>
#include "eeprominterface.h"
namespace Ui {
class GeneralEdit;
}
class GeneralEdit : public QDialog
{
Q_OBJECT
public:
explicit GeneralEdit(RadioData &radioData, QWidget *parent = 0);
~GeneralEdit();
void updateSettings();
private:
Ui::GeneralEdit *ui;
RadioData &radioData;
GeneralSettings g_eeGeneral;
bool switchDefPosEditLock;
bool voiceLangEditLock;
bool mavbaudEditLock;
void getGeneralSwitchDefPos(int i, bool val);
void setSwitchDefPos();
signals:
void modelValuesChanged();
private slots:
void on_ownerNameLE_editingFinished();
void on_PotScrollEnableChkB_stateChanged(int);
void on_blinvert_cb_stateChanged(int);
void on_faimode_CB_stateChanged(int );
void on_BandGapEnableChkB_stateChanged(int);
void on_crosstrimChkB_stateChanged(int );
void on_frskyintalarmChkB_stateChanged(int );
void on_StickScrollChkB_stateChanged(int );
void on_PPMSimChkB_stateChanged(int );
void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished();
void on_hapticStrengthSB_editingFinished();
void on_soundModeCB_currentIndexChanged(int index);
void on_beeperlenCB_currentIndexChanged(int index);
void on_volume_SB_editingFinished();
void on_hapticmodeCB_currentIndexChanged(int index);
void on_hapticLengthCB_currentIndexChanged(int index);
void on_PPM_MultiplierDSB_editingFinished();
void on_splashScreenChkB_stateChanged(int );
void on_hideNameOnSplashChkB_stateChanged(int);
void on_beepCountDownChkB_stateChanged(int );
void on_beepMinuteChkB_stateChanged(int );
void on_alarmwarnChkB_stateChanged(int );
void on_enableTelemetryAlarmChkB_stateChanged(int );
void on_gpsFormatCB_currentIndexChanged(int index);
void on_tabWidget_currentChanged(int index);
void on_displayTypeCB_currentIndexChanged(int index);
void on_BLBright_SB_editingFinished();
void on_re_CB_currentIndexChanged(int index);
void on_countrycode_CB_currentIndexChanged(int index);
void on_units_CB_currentIndexChanged(int index);
void on_trnMode_1_currentIndexChanged(int index);
void on_trnChn_1_currentIndexChanged(int index);
void on_swtchCB_1_currentIndexChanged(int index);
void on_trnWeight_1_editingFinished();
void on_trnMode_2_currentIndexChanged(int index);
void on_trnChn_2_currentIndexChanged(int index);
void on_swtchCB_2_currentIndexChanged(int index);
void on_trnWeight_2_editingFinished();
void on_trnMode_3_currentIndexChanged(int index);
void on_trnChn_3_currentIndexChanged(int index);
void on_swtchCB_3_currentIndexChanged(int index);
void on_trnWeight_3_editingFinished();
void on_trnMode_4_currentIndexChanged(int index);
void on_swtchCB_4_currentIndexChanged(int index);
void on_trnChn_4_currentIndexChanged(int index);
void on_trnWeight_4_editingFinished();
void on_battCalib_editingFinished();
void on_CurrentCalib_SB_editingFinished();
void on_ana1Neg_editingFinished();
void on_ana2Neg_editingFinished();
void on_ana3Neg_editingFinished();
void on_ana4Neg_editingFinished();
void on_ana5Neg_editingFinished();
void on_ana6Neg_editingFinished();
void on_ana7Neg_editingFinished();
void on_ana8Neg_editingFinished();
void on_ana1Mid_editingFinished();
void on_ana2Mid_editingFinished();
void on_ana3Mid_editingFinished();
void on_ana4Mid_editingFinished();
void on_ana5Mid_editingFinished();
void on_ana6Mid_editingFinished();
void on_ana7Mid_editingFinished();
void on_ana8Mid_editingFinished();
void on_ana1Pos_editingFinished();
void on_ana2Pos_editingFinished();
void on_ana3Pos_editingFinished();
void on_ana4Pos_editingFinished();
void on_ana5Pos_editingFinished();
void on_ana6Pos_editingFinished();
void on_ana7Pos_editingFinished();
void on_ana8Pos_editingFinished();
void on_PPM1_editingFinished();
void on_PPM2_editingFinished();
void on_PPM3_editingFinished();
void on_PPM4_editingFinished();
void on_beepVolume_SL_valueChanged();
void on_bgVolume_SL_valueChanged();
void on_varioVolume_SL_valueChanged();
void on_wavVolume_SL_valueChanged();
void on_stickmodeCB_currentIndexChanged(int index);
void on_channelorderCB_currentIndexChanged(int index);
void on_beeperCB_currentIndexChanged(int index);
void on_memwarnChkB_stateChanged(int );
void on_swtchWarnCB_currentIndexChanged(int index);
void on_swtchWarnChkB_stateChanged(int );
void on_telalarmsChkB_stateChanged(int );
void on_thrwarnChkB_stateChanged(int );
void on_inputfilterCB_currentIndexChanged(int index);
void on_thrrevChkB_stateChanged(int );
void on_inactimerSB_editingFinished();
void on_backlightautoSB_editingFinished();
void on_backlightswCB_currentIndexChanged(int index);
void on_mavbaud_CB_currentIndexChanged(int index);
void on_voiceLang_CB_currentIndexChanged(int index);
void on_blOnStickMoveSB_editingFinished();
void on_battcalibDSB_editingFinished();
void on_battwarningDSB_editingFinished();
void on_contrastSB_editingFinished();
void on_beepFlashChkB_stateChanged(int );
void on_swTHRChkB_stateChanged(int );
void on_swRUDChkB_stateChanged(int );
void on_swELEChkB_stateChanged(int );
void on_swID0ChkB_stateChanged(int );
void on_swID1ChkB_stateChanged(int );
void on_swID2ChkB_stateChanged(int );
void on_swAILChkB_stateChanged(int );
void on_swGEAChkB_stateChanged(int );
void on_calretrieve_PB_clicked();
void on_calstore_PB_clicked();
void unlockSwitchEdited();
void setValues();
void shrink();
};
#endif // GENERALEDIT_H

3682
companion/src/generaledit.ui Normal file

File diff suppressed because it is too large Load diff

1367
companion/src/helpers.cpp Normal file

File diff suppressed because it is too large Load diff

98
companion/src/helpers.h Normal file
View file

@ -0,0 +1,98 @@
#ifndef HELPERS_H
#define HELPERS_H
#include <QtGui>
#include "eeprominterface.h"
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1)
//convert from mode 1 to mode g_eeGeneral.stickMode
//NOTICE! => 1..4 -> 1..4
#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[g_eeGeneral.stickMode][((x)-1)] : (x))
#define CHANNEL_ORDER(x) (chout_ar[g_eeGeneral.templateSetup*4 + (x)-1])
#define CURVE_BASE 7
#define CH(x) (SRC_CH1+(x)-1-(SRC_SWC-SRC_3POS))
#define CV(x) (CURVE_BASE+(x)-1)
#define CC(x) (CHANNEL_ORDER(x)) //need to invert this to work with dest
#define CURVE5(x) ((x)-1)
#define CURVE9(x) (MAX_CURVE5+(x)-1)
#define TRIM_ON 0
#define TRIM_OFF 1
#define TRIM_OFFSET 2
void populateGvSourceCB(QComboBox *b, int value);
void populateVoiceLangCB(QComboBox *b, QString language);
void populateTTraceCB(QComboBox *b, int value);
void populateRotEncCB(QComboBox *b, int value, int renumber);
void populateBacklightCB(QComboBox *b, const uint8_t value);
#define POPULATE_ONOFF 0x01
#define POPULATE_MSWITCHES 0x02
#define POPULATE_AND_SWITCHES 0x04
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
void populateFuncCB(QComboBox *b, unsigned int value);
void populateRepeatCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
QString FuncParam(uint function, int value, QString paramT="",unsigned int adjustmode=0);
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList);
void populatePhasesCB(QComboBox *b, int value);
void populateTrimUseCB(QComboBox *b, unsigned int phase);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCurvesCB(QComboBox *b, int value);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
void populateExpoCurvesCB(QComboBox *b, int value);
void populateTimerSwitchCB(QComboBox *b, int value, int extrafields=0);
void populateTimerSwitchBCB(QComboBox *b, int value, int extrafields=0);
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
QString getProtocolStr(const int proto);
#define POPULATE_SOURCES 1
#define POPULATE_TRIMS 2
#define POPULATE_SWITCHES 4
#define POPULATE_GVARS 8
#define POPULATE_TELEMETRY 16
#define POPULATE_TELEMETRYEXT 32
#define GVARS_VARIANT 0x0001
#define FRSKY_VARIANT 0x0002
// void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up
void populateGVCB(QComboBox *b, int value);
void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags);
void populateCSWCB(QComboBox *b, int value);
QString getTimerMode(int tm);
QString getTimerModeB(int tm);
QString getPhaseName(int val, char * phasename=NULL);
QString getStickStr(int index);
QString getCSWFunc(int val);
QString getFuncName(unsigned int val);
QString getRepeatString(unsigned int val);
QString getSignedStr(int value);
QString getCurveStr(int curve);
QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image);
QImage qstring2image(QString imagestr);
int findmult(float value, float base);
bool checkbit(int value, int bit);
QString getTrimInc(ModelData * g_model);
QString getTimerStr(TimerData & timer);
QString getProtocol(ModelData * g_model);
QString getCenterBeep(ModelData * g_model);
/* FrSky helpers */
QString getFrSkyAlarmType(int alarm);
QString getFrSkyBlades(int blades);
QString getFrSkyUnits(int units);
QString getFrSkyProtocol(int protocol);
QString getFrSkyMeasure(int units);
QString getFrSkySrc(int index);
float getBarValue(int barId, int value, FrSkyData *fd);
float c9xexpou(float point, float coeff);
float ValToTim(int value);
int TimToVal(float value);
#endif // HELPERS_H

View file

@ -0,0 +1,131 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#include "hexinterface.h"
HexInterface::HexInterface(QTextStream &stream):
stream(stream)
{
}
int HexInterface::getValueFromLine(const QString &line, int pos, int len)
{
bool ok;
int hex = line.mid(pos,len).toInt(&ok, 16);
return ok ? hex : -1;
}
int HexInterface::load(uint8_t *data, int maxsize)
{
int result = 0;
int offset = 0;
while (!stream.atEnd()) {
QString line = stream.readLine();
if(line.left(1)!=":") continue;
int byteCount = getValueFromLine(line,1);
int address = getValueFromLine(line,3,4);
int recType = getValueFromLine(line,7);
if (recType==0x02) {
offset+=0x010000;
}
if(byteCount<0 || address<0 || recType<0)
return 0;
QByteArray ba;
ba.clear();
quint8 chkSum = 0;
chkSum -= byteCount;
chkSum -= recType;
chkSum -= address & 0xFF;
chkSum -= address >> 8;
for(int i=0; i<byteCount; i++)
{
quint8 v = getValueFromLine(line,(i*2)+9) & 0xFF;
chkSum -= v;
ba.append(v);
}
quint8 retV = getValueFromLine(line,(byteCount*2)+9) & 0xFF;
if(chkSum!=retV)
return 0;
if (address+offset + byteCount <= maxsize) {
if (recType == 0x00) { //data record - ba holds record
memcpy(&data[address+offset],ba.data(),byteCount);
result = std::max(result, address+offset+byteCount);
}
}
else {
return 0;
}
}
return result;
}
bool HexInterface::save(uint8_t *data, const int size)
{
int addr = 0;
int nextbank = 1;
while (addr < size) {
if (addr>(nextbank*0x010000)-1) {
stream << iHEXExtRec(nextbank) << "\n";
nextbank++;
}
int llen = 32;
if ((size - addr) < llen)
llen = size - addr;
stream << iHEXLine(data, addr, llen) << "\n";
addr += llen;
}
stream << ":00000001FF\n"; // write EOF
return true;
}
QString HexInterface::iHEXLine(quint8 * data, quint32 addr, quint8 len)
{
unsigned int bankaddr;
bankaddr=addr&0xffff;
QString str = QString(":%1%2000").arg(len, 2, 16, QChar('0')).arg(bankaddr, 4, 16, QChar('0')); //write start, bytecount (32), address and record type
quint8 chkSum = 0;
chkSum = -len; //-bytecount; recordtype is zero
chkSum -= bankaddr & 0xFF;
chkSum -= bankaddr >> 8;
for (int j = 0; j < len; j++) {
str += QString("%1").arg(data[addr + j], 2, 16, QChar('0'));
chkSum -= data[addr + j];
}
str += QString("%1").arg(chkSum, 2, 16, QChar('0'));
return str.toUpper(); // output to file and lf;
}
QString HexInterface::iHEXExtRec(quint8 bank)
{
QString str = QString(":02000002"); //write record type 2 record
quint8 chkSum = 0;
chkSum = -2; //-bytecount; recordtype is zero
chkSum -= 2; // type 2 record type
str += QString("%1000").arg((bank&0x0f)<<4,1,16,QChar('0'));
chkSum -= ((bank&0x0f)<<4); // type 2 record type
str += QString("%1").arg(chkSum, 2, 16, QChar('0'));
return str.toUpper(); // output to file and lf;
}

View file

@ -0,0 +1,38 @@
/*
* Author - Bertrand Songis <bsongis@gmail.com>
*
* Based on th9x -> http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*
*/
#ifndef hex_stream_h
#define hex_stream_h
#include <inttypes.h>
#include <QTextStream>
class HexInterface {
public:
HexInterface(QTextStream &stream);
int load(uint8_t *output, int maxsize);
bool save(uint8_t *data, const int size);
protected:
int getValueFromLine(const QString &line, int pos, int len=2);
QString iHEXLine(quint8 * data, quint32 addr, quint8 len);
QString iHEXExtRec(quint8 bank);
QTextStream & stream;
};
#endif

Some files were not shown because too many files have changed in this diff Show more