Compare commits

...

173 Commits

Author SHA1 Message Date
bsongis 6114245229 Release notes updated 2014-09-16 17:18:31 +02:00
Andre Bernet e76880cf26 French translations 2014-09-16 17:14:56 +02:00
bsongis f30dfa3365 Inversion of S3 on Taranis+ (S3 should be wired as S2) - Issue #1716 2014-09-16 17:14:47 +02:00
Andre Bernet f4aa92ec20 S2 inverted on T+ (Fix #1716) 2014-09-16 17:03:56 +02:00
Bertrand Songis 2640ca9fea Update DONATIONS.txt 2014-09-16 14:30:22 +02:00
bsongis f6a1420ce3 Version and release notes updated 2014-09-15 18:54:32 +02:00
bsongis 6c0f65411a Overflow on OverrideCHxx functions on ARM boards (range is now
-150:+150)
2014-09-15 18:41:25 +02:00
bsongis a7f1ace55b #1647 - bitmap set/get added to the Lua interpreter 2014-09-15 17:37:20 +02:00
bsongis b8dedd7940 #1647 - getCurve exported to the Lua interpreter 2014-09-15 17:32:45 +02:00
bsongis 2703118c56 Makefile typos from #1644 2014-09-15 12:24:09 +02:00
Bertrand Songis 8bfc7a497a Update DONATIONS.txt 2014-09-15 11:58:52 +02:00
bsongis 87870c24a5 Fixes #1709 2014-09-15 11:50:45 +02:00
bsongis 7610fb43d5 Fixes #1669 2014-09-15 11:28:46 +02:00
bsongis 0263784e65 MEGA2560 simu compilation now ok 2014-09-15 09:56:33 +02:00
Bertrand Songis 6f74624371 Update DONATIONS.txt 2014-09-14 22:45:37 +02:00
Bertrand Songis 1c721b3817 Update DONATIONS.txt 2014-09-14 17:51:22 +02:00
bsongis 67d97046bb Fixes #1656 - Throttle Source everywhere (english and french) 2014-09-14 14:56:12 +02:00
bsongis 19d9e6ab19 No THR warning when a new model is created / the wizard is called 2014-09-14 14:46:59 +02:00
bsongis 5d9883d47f Added NANO option in Makefile (default: NANO=NO) 2014-09-14 14:46:59 +02:00
bsongis bb5f1d7d79 Fixes #1715 2014-09-14 14:46:59 +02:00
bsongis 30087b4a3a This luaFree is not needed and could do a mess in RAM 2014-09-14 14:46:59 +02:00
Bertrand Songis 61aa01b9b3 Update DONATIONS.txt 2014-09-14 14:44:29 +02:00
mhotar 16e06cff70 CZ translations - Companion 2014-09-14 02:19:42 +02:00
mhotar 2073a1f033 CZ translations - Radio 2014-09-14 01:17:52 +02:00
bsongis 563b817b46 Fixes #1656 2014-09-13 18:15:28 +02:00
bsongis 8b540a66f6 Companion compilation failure (missing files) 2014-09-13 15:50:24 +02:00
bsongis b0b7657756 Version and release notes updated 2014-09-13 15:45:08 +02:00
bsongis 74d22b623f LTR patch (modified) applied. Saves around 8-10k RAM during the
interpreter initialization
2014-09-13 15:41:52 +02:00
bsongis bee01d9999 Tests added to avoid doing anything in the Lua interpreter after a Lua
Panic
2014-09-13 13:11:05 +02:00
Bertrand Songis d2055edf62 Merge pull request #1712 from opentx/mhotar/CZ_chars_in_Inputs
No special characters in edit fields for CZ language, but enabled in int...
2014-09-13 09:11:13 +02:00
mhotar c926ac557b No special characters in edit fields for CZ language, but enabled in internally defined strings.
It fixes autogenerated Input names.
2014-09-13 01:26:49 +02:00
bsongis 3e2092e32f Revert some last changes so that there is no problem with Lua 2014-09-13 01:03:24 +02:00
bsongis 21054ffc54 Fixes #1675 2014-09-12 12:36:48 +02:00
Bertrand Songis 350ece0b60 Update DONATIONS.txt 2014-09-12 10:24:34 +02:00
bsongis 01a103f2e6 Mega2560 target didn't compile 2014-09-12 07:47:06 +02:00
Bertrand Songis 2e8e439d27 Update DONATIONS.txt 2014-09-11 15:47:25 +02:00
Bertrand Songis 98e6a3dc21 Update DONATIONS.txt 2014-09-11 13:25:47 +02:00
Andre Bernet 3b324d076a Release notes updated 2014-09-10 20:41:00 +02:00
Andre Bernet 91c922d5fb Wording / French translations 2014-09-10 20:27:43 +02:00
Andre Bernet eac918c2da SG switch warning was unreachable on Taranis 2014-09-10 20:13:26 +02:00
Andre Bernet b5f9c0ec84 On Taranis S3 was only hidden when the cursor was in the pot positions line 2014-09-10 20:05:50 +02:00
bsongis d1f54b099b Compilation failure 2014-09-10 20:04:41 +02:00
bsongis 7b98ad55c0 #1692 - We flush the queue instead of stopping the audio (the TADA sound
is cut otherwise)
2014-09-10 19:56:46 +02:00
bsongis d2cb7cb3dd Fixes #1697 2014-09-10 19:28:55 +02:00
bsongis be190b8bb1 Support for Lua dump files removed 2014-09-10 16:19:34 +02:00
bsongis 4b2c02b2c5 The Lua Wizard was broken in 2.0.11 2014-09-10 15:35:06 +02:00
bsongis 142d3fee1a Small alignment problem in protocols on 9X/9XR 2014-09-10 12:12:16 +02:00
bsongis 6a5e938ead Fixes #1692 2014-09-10 12:11:53 +02:00
bsongis 2d9ae108ff Fixes #1566 2014-09-10 12:07:14 +02:00
bsongis bae84e4e8c Navigation bug in protocol selection (9X/9XR only) 2014-09-10 11:51:39 +02:00
bsongis f4944eefdb Fixes the neutral value for PXX as described in #1694 2014-09-10 11:51:00 +02:00
bsongis 5d598cc6a1 Version and release notes updated 2014-09-10 11:32:36 +02:00
bsongis 945808d69b Fixes #1695 2014-09-10 11:32:36 +02:00
Bertrand Songis dbe512e45a Update DONATIONS.txt 2014-09-10 10:58:32 +02:00
bsongis 11efb5121e Fixes #1690 2014-09-10 08:16:57 +02:00
Bertrand Songis f6274f38aa Update DONATIONS.txt 2014-09-09 21:58:17 +02:00
Bertrand Songis cd1f20b8a0 Update DONATIONS.txt 2014-09-09 10:41:57 +02:00
Bertrand Songis e61b931ddb Update DONATIONS.txt 2014-09-09 07:13:13 +02:00
Andre Bernet a7a9b61234 Typo in release notes 2014-09-08 23:01:04 +02:00
bsongis 5ee95673d1 Release notes updated 2014-09-08 22:25:10 +02:00
bsongis 98c5b5e7bd Little display bug in DEBUG page 2014-09-08 22:25:10 +02:00
Bertrand Songis 6d434c0bf9 Update DONATIONS.txt 2014-09-07 21:52:42 +02:00
Bertrand Songis ade7151796 Update DONATIONS.txt 2014-09-07 20:35:50 +02:00
Bertrand Songis a7cd1f9aa0 Update DONATIONS.txt 2014-09-07 11:24:59 +02:00
bsongis cb2c922542 DONATIONS.txt updated 2014-09-05 17:58:40 +02:00
bsongis 8159a559da Release notes updated 2014-09-05 17:20:24 +02:00
bsongis ed826d8c62 [Sky9x] Linker error (no newlib-nano needed, no _sbrk) 2014-09-05 17:17:43 +02:00
bsongis b57f5ab2ce Added DEBUG information (thanks again projectkk2glider!) 2014-09-05 17:03:01 +02:00
bsongis 8fbafa6f05 Fixes #1643 - Thanks to projectkk2glider for his help on this one 2014-09-05 16:23:55 +02:00
Damjan Adamic 9243a59426 Removed lua_fields.txt 2014-09-03 23:33:59 +02:00
Damjan Adamic ccf66831c7 Fixes #1666: fixed bootloader 2014-09-03 23:32:03 +02:00
Damjan Adamic 06792b5696 Fixes #1666: Missing constructor calls for static objects 2014-09-03 23:03:25 +02:00
bsongis 6d4d871849 Various Lua fixes (thanks projectkk2glider!) 2014-09-02 20:53:19 +02:00
bsongis 5a634a7991 Fixes #1656 2014-09-01 09:43:02 +02:00
bsongis 69e504212e Copy/Paste error on second serial port Rx 2014-08-31 22:45:36 +02:00
bsongis 03e049c360 Fixes #1658 2014-08-29 23:05:24 +02:00
bsongis 4ca893da1f Fixes #1655 2014-08-29 15:54:28 +02:00
bsongis 66670cf713 Fixes #1646 2014-08-29 11:53:20 +02:00
bsongis 271bb4a82e Version and release notes updated 2014-08-29 11:46:20 +02:00
bsongis e0eab648ef Fixes #1651 2014-08-28 21:54:33 +02:00
bsongis 3235f43db9 Companion part for #1646
Conflicts:
	companion/src/modeledit/logicalswitches.cpp
2014-08-28 16:42:31 +02:00
bsongis c12b0cfebe Fixes #1650 2014-08-28 15:26:08 +02:00
bsongis 3e590d44f0 Fixes #1646 2014-08-28 15:16:20 +02:00
bsongis 1f6d1799af Fixes #1643 - no more freeze but now I have to understand why we go over
4k there
2014-08-27 23:44:07 +02:00
bsongis 8c813a87c9 Fixes #1635 2014-08-27 23:14:59 +02:00
bsongis 5bdeedbd0e [9X] Display problem of the battery range 2014-08-27 20:44:38 +02:00
bsongis e33f4cf415 Compilation error 2014-08-27 20:44:22 +02:00
bsongis 61d745011a [9XR-PRO] Telemetry fix 2014-08-27 20:44:11 +02:00
bsongis 3e269a04ae lua_fields.txt removed from git as it is automatically generated 2014-08-27 12:25:43 +02:00
bsongis 341feaf78f Fixes #1621 2014-08-27 10:21:55 +02:00
bsongis 19ddf6fc23 [Companion] Servos limits are displayed in us if ppmus option selected 2014-08-26 16:55:58 +02:00
bsongis 9b4b0d3c83 Fixes #1596 2014-08-26 09:01:19 +02:00
bsongis dc1eebf40d RSSI initialization added in google tests 2014-08-25 11:51:15 +02:00
bsongis 752e13b9ab Fixes #1617 2014-08-25 11:39:34 +02:00
bsongis b988bec5bd Fixes #1636 2014-08-25 11:27:46 +02:00
Damjan Adamic 3c72afed20 Fixes #1622: Lua function script not called for SF >= 8 2014-08-25 11:11:06 +02:00
Damjan Adamic e7586f47c3 Re #1547: commit 5949be30fa disabled delay for STICKY (which was wrong) now disabled for EDGE 2014-08-25 10:45:40 +02:00
Bertrand Songis f126b149f0 Merge pull request #1642 from opentx/1641_rx_number_with_DSM
Receiver number wasn't showing up for DSM (Fix #1641)
2014-08-24 23:45:50 +02:00
Andre Bernet 6b15c0c985 Receiver number wasn't showing up for DSM (Fix #1641) 2014-08-24 10:29:36 +02:00
Damjan Adamic db85f39ebc Added generation of Lua fields documentation file: lua_fields.txt 2014-08-21 10:07:39 +02:00
bsongis dee1e4ce8d Fixes #1612 2014-08-16 11:17:45 +02:00
bsongis df96504a85 SWR hidden on Taranis+ 2014-08-15 17:20:35 +02:00
Kjell Kernen 0112a1e3e9 Changed description of the master branch. The text from the next branch had ended up here. 2014-08-14 10:44:04 +02:00
bsongis 36481471a3 Fixes #1595 2014-08-13 11:37:03 +02:00
Bertrand Songis dd08886f2c Update DONATIONS.txt 2014-08-10 19:20:33 +02:00
Bertrand Songis 76ef4b5948 Update DONATIONS.txt 2014-08-10 19:19:41 +02:00
Bertrand Songis eaa247f46d Update DONATIONS.txt 2014-08-08 22:44:53 +02:00
bsongis 3ada9f7cf5 Companion PrintDialog bugfixes 2014-08-08 18:08:42 +02:00
bsongis 10a5e4dc89 Fixes #1527 2014-08-08 17:05:12 +02:00
bsongis 50e4850745 Fixes #1580 2014-08-08 16:29:13 +02:00
bsongis a92de216ac Fixes #1585 2014-08-08 11:48:03 +02:00
bsongis 3f3708f0f1 Fixes #1546
// TODO check if the vario / background music are stopped correctly if
switching to a model which doesn't have these functions enabled
2014-08-08 11:19:04 +02:00
Bertrand Songis 72c433ce9d Update DONATIONS.txt 2014-08-06 20:58:31 +02:00
Damjan Adamic f123b69521 Fixes #1548: bad Swedish Cell translation 2014-08-05 20:35:16 +02:00
Bertrand Songis 80369f0e8f Update DONATIONS.txt 2014-08-05 10:56:27 +02:00
Kjell Kernen 8cd67bf31e Swedish OpenTX translation updated 2014-08-05 10:38:24 +02:00
Kjell Kernen 34ef060e16 Swedish Companion translation updated 2014-08-05 10:24:09 +02:00
Bertrand Songis 1f07f88dce Update DONATIONS.txt 2014-08-04 14:32:05 +02:00
Bertrand Songis 4db5bdd486 Update DONATIONS.txt 2014-08-04 12:03:46 +02:00
bsongis 05ac0682f0 Fixes #1583 2014-08-04 12:02:50 +02:00
bsongis f12c3072b5 Fixes #1579 2014-08-04 11:54:35 +02:00
bsongis 35aea83c89 Fixes #1582 2014-08-04 11:38:39 +02:00
bsongis cf9b5d05a8 Fixes #1568 2014-08-04 11:29:35 +02:00
bsongis d5393be5cb Fixes #1584 2014-08-04 11:20:07 +02:00
Bertrand Songis 10c9936fa0 Merge pull request #1586 from opentx/projectkk2glider/issue_1567
Projectkk2glider/issue 1567
2014-08-04 11:08:00 +02:00
Bertrand Songis 7a74d3ac85 Update DONATIONS.txt 2014-08-04 10:57:23 +02:00
bsongis 39edaff669 Problems with S3 on Taranis (not plus) 2014-08-04 10:19:31 +02:00
bsongis c5aed5f79b Companion MAC compilation fix 2014-08-04 10:01:32 +02:00
bsongis 9b07a77e14 #1566 Companion conversion issue when importing Logical Switches with a
stick as v1 or v2 in previous EEPROM
2014-08-04 10:01:32 +02:00
Bertrand Songis 380fe5e44d Update DONATIONS.txt 2014-08-04 09:58:11 +02:00
Damjan Adamic 8bd2c120d6 Re #1567: cleanup 2014-08-03 19:27:02 +02:00
Damjan Adamic 741ef45f3e Re #1567:
introduced generateProcessUniqueTempFileName() which is used everywhere we need temporary file
renamed unlink() into qunlink()
fixed missing deletion of curve pngs in print dialog
2014-08-03 19:21:46 +02:00
Damjan Adamic 4103adf75d Re #1567: introduced unlink() function that takes QString parameter 2014-08-03 18:03:13 +02:00
Damjan Adamic c0e612531d Re #1567: writeBackup(): added PID to temporary file name 2014-08-03 17:38:24 +02:00
Damjan Adamic 55cb5dce87 Re #1567: readEeprom():
* added PID to temporary file name
 * better error message
 * temporary file deletion
2014-08-03 17:38:24 +02:00
Bertrand Songis 12ba27247e Update DONATIONS.txt 2014-08-02 09:41:10 +02:00
Bertrand Songis 1e33e99655 Update DONATIONS.txt 2014-08-01 07:43:31 +02:00
Damjan Adamic 50acd1fd92 Expanded non regression tests for #1569 2014-07-31 20:23:11 +02:00
bsongis c3626225aa Non regression tests for #1569 2014-07-31 17:24:10 +02:00
Bertrand Songis b71a96ed55 Update DONATIONS.txt 2014-07-31 16:43:23 +02:00
Bertrand Songis d2fcd544d8 Merge pull request #1576 from opentx/projectkk2glider/dirty_hack_issue_1569
Projectkk2glider/dirty hack issue 1569
2014-07-31 16:06:55 +02:00
Damjan Adamic 50997721e2 Using anas instead for getValue 2014-07-31 15:57:50 +02:00
Damjan Adamic 828372ab29 Fix for the case of extended trims
Code cleanup
2014-07-31 15:47:32 +02:00
Damjan Adamic 21ae270c0e Fixes #1569 2014-07-31 15:08:37 +02:00
bsongis 1b2efd1121 Fixes #1572 2014-07-31 11:26:05 +02:00
bsongis 8d6a7c9495 Simu name fixed 2014-07-31 11:22:41 +02:00
bsongis 189becfbb2 Fixes #1569 2014-07-31 11:22:18 +02:00
Bertrand Songis 5a19e147fd Update DONATIONS.txt 2014-07-30 07:45:00 +02:00
Bertrand Songis 062f93ae38 Update DONATIONS.txt 2014-07-28 23:41:37 +02:00
bsongis 9861a08150 Fixes #1562 2014-07-28 21:02:42 +02:00
Bertrand Songis de15d0a5a4 Update DONATIONS.txt 2014-07-28 18:54:56 +02:00
Andre Bernet 1e77bb3c02 French translations 2014-07-27 18:40:16 +02:00
bsongis adadbe06ad Fixes #1559 2014-07-27 17:37:39 +02:00
Andre Bernet 92f2c48de9 French translation fix 2014-07-27 17:31:06 +02:00
Bertrand Songis 1d4fa2a8b0 Update DONATIONS.txt 2014-07-26 22:27:25 +02:00
Bertrand Songis 5493776b9c Update DONATIONS.txt 2014-07-26 19:48:32 +02:00
bsongis b166b77c3e New french TTS prompts 2014-07-26 19:47:40 +02:00
Bertrand Songis 0ecb978364 Update DONATIONS.txt 2014-07-26 19:14:46 +02:00
Bertrand Songis c8d792d3d8 Merge pull request #1556 from opentx/driver33/PL_TR
TR fixes
2014-07-26 12:24:22 +02:00
Jacek Drewniak e9663e40e2 TR fixes 2014-07-26 11:51:23 +02:00
bsongis a7e906dea9 All other Off are uppercase! 2014-07-25 23:30:19 +02:00
Bertrand Songis 685ab3d101 Update DONATIONS.txt 2014-07-25 22:25:49 +02:00
Bertrand Songis 77564d74a4 Merge pull request #1554 from opentx/MicheleVilla/IT_translation_FW
Update it.h.txt
2014-07-25 19:38:14 +02:00
Bertrand Songis a0142d65be Update DONATIONS.txt 2014-07-25 19:29:08 +02:00
bsongis 662bf15562 Fixes #1555 2014-07-25 19:28:08 +02:00
Bertrand Songis 79b928af56 Update DONATIONS.txt 2014-07-25 17:10:32 +02:00
Bertrand Songis 8c28f4bc48 Update DONATIONS.txt 2014-07-25 15:06:16 +02:00
bsongis 7a4d6c89a1 2.0.9 preparation 2014-07-25 12:05:34 +02:00
bsongis 38347becca Cosmetics 2014-07-25 12:05:34 +02:00
Michele 49036dbb40 Update it.h.txt
One change in Italian translation
2014-07-25 11:58:05 +02:00
Bertrand Songis abf36de157 Update DONATIONS.txt 2014-07-25 08:41:56 +02:00
bsongis 32afbf5a5a Fixes #1552 2014-07-25 08:39:41 +02:00
bsongis cba4a02cc1 Fixes #1551 2014-07-25 07:31:58 +02:00
125 changed files with 5876 additions and 4823 deletions
+66
View File
@@ -536,3 +536,69 @@ Cyberauto Systems
John Alsbrooks
John Kearney
Christopher Borden
Marc Virgilio Ricci
Frederick Davie
Jürgen Enders
Terrence Pitts
Thomas Sandner
Marco Coltorti
Harald Wilczak
Rodney Lorimor
Richard Davis
Stephen Palmer
Michael Napolitan
Joshua Bardwell
Fred Dawson
Jim Wagner
Peter Johnson
Fredrik Lewerth
Arvin Stenersen
Daniel Morgan
Roy Nixon
Joachim Blunck
Karl-Heinz Gansel
Monrovia Mountain Enterprises
Alessandro Villa
Jan-Åke Nilsson
Matthias Rei
DVR Solutions BV
Bertrand Condevaux Lanloy
Henri Mirra
Aurélien Planiol
Kevin Caldwell
Andrew Garello
Tomasz Maziarz
Russell Flack
Fernando Rimoldi
Greg Reid
Dietmar Drees
Holger Landwehr
Arno Loehdorf
Boon Sripattha
Patrik Åkerfeldt
Alonzo Fretwell
Renjith Chandrasekharan
Ruben Gomez Hernandez
Michael Gardner
Judith Green
Timo Ruppell
John Lipscomb
Norbert Wenke
Erik Frieberg
Raimo Ruotsalainen
Brian Harris
Sebastian Blüml
Efisio Maxia
Jeff Theobald
Anthony Rizzo
Rodney Huddleston
Dietmar Drees
Jürgen Monden
David Morgan
Andrew Fernie
Michel Baily
Donald Burke
Ronald Donker
Fredie Singh
Patrizio Simoncini (monthly)
Harald Gabler
+3 -4
View File
@@ -1,8 +1,7 @@
##OpenTX Next Branch
##OpenTX Master Branch
You have found your way to the GitHub repository site for the OpenTX Next Branch. This code branch holds the source code for the ongoing development.
You have found your way to the GitHub repository site for the OpenTX Master Branch. This code branch holds the source code for the latest stable release.
The stable release code is not here, it is in the master branch.
Under no circumstances build and use software from this branch for real world application. At times you will be more or less guaranteed to crash your plane and destroy all your model settings.
The ongoing development is not done in this branch. It is performed in the branch called next.
Refer to the opentx.wiki for information about setting up the tool chains for building OpenTX and OpenTX Companion as well as other development related issues.
+19 -1
View File
@@ -1,4 +1,22 @@
<h2>Version 2.0.8</h2>
<h2>Version 2.0.12 / 2014-09-15</h2>
<ul>
<li>Typos & Translations updated</li>
</ul>
<h2>Version 2.0.11 / 2014-09-10</h2>
<ul>
<li>Limits EEPROM export was broken (all boards except Taranis)</li>
<li>Fix issue when a GVAR was used as Offset</li>
</ul>
<h2>Version 2.0.10 / 2014-09-08</h2>
<ul>
<li>Taranis is now the default board in General Settings</li>
<li>GVARS allowed in Limits min/max/offset</li>
<li>Limits displayed in us when ppmus option selected
</ul>
<h2>Version 2.0.8 / 2014-07-23</h2>
<ul>
<li>Compare dialog bugfixes</li>
<li>Curve index correctly resetted when type changed</li>
+6 -2
View File
@@ -2,7 +2,7 @@ PROJECT( companion )
SET( C9X_VERSION_MAJOR "2" )
SET( C9X_VERSION_MINOR "0" )
SET( C9X_VERSION_REVISION "8" )
SET( C9X_VERSION_REVISION "12" )
SET( C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR}.${C9X_VERSION_REVISION} )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
@@ -338,7 +338,11 @@ if(WIN32)
set(simu_SRCS ${simu_SRCS} icon.rc)
endif()
add_executable(simulator WIN32 ${simu_SRCS})
if(APPLE)
add_executable(simulator MACOSX_BUNDLE ${simu_SRCS})
else()
add_executable(simulator WIN32 ${simu_SRCS})
endif()
if(SDL_FOUND)
target_link_libraries(simulator simulation common ${QT_LIBRARIES} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS})
+2 -2
View File
@@ -156,11 +156,11 @@ void avrOutputDialog::doCopy()
dest.close();
}
else {
QMessageBox::warning(this, tr("Error"),tr("Cannot write destination") + ": " + dest.errorString());
QMessageBox::warning(this, tr("Error"),tr("Cannot write destination") + ": " + dest.fileName() + ", " + tr("reason") + ": " + dest.errorString());
}
}
else {
QMessageBox::warning(this, tr("Error"),tr("Cannot open source file") + ": " + source.errorString());
QMessageBox::warning(this, tr("Error"),tr("Cannot open source file") + ": " + source.fileName() + ", " + tr("reason") + ": " + source.errorString());
}
source.close();
+2 -4
View File
@@ -354,10 +354,8 @@ void burnConfigDialog::restFuses(bool eeProtect)
//use hfuse = 0x81 to prevent eeprom being erased with every flashing
}
else {
QString tempDir = QDir::tempPath();
QString tempFile;
QString lfuses;
tempFile = tempDir + "/ftemp.bin";
QString tempFile = generateProcessUniqueTempFileName("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);
@@ -376,7 +374,7 @@ void burnConfigDialog::restFuses(bool eeProtect)
lfuses="lfuse:w:0x3F:m";
}
file.close();
unlink(tempFile.toAscii());
qunlink(tempFile);
}
else {
lfuses="lfuse:w:0x3F:m";
+3 -5
View File
@@ -418,12 +418,11 @@ void burnDialog::on_BurnFlashButton_clicked()
image = 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";
tempFile = generateProcessUniqueTempFileName("flash.hex");
else
tempFile = tempDir + "/flash.bin";
tempFile = generateProcessUniqueTempFileName("flash.bin");
FlashInterface flash(fileName);
flash.setSplash(image);
if (flash.saveFlash(tempFile) > 0) {
@@ -556,8 +555,7 @@ void burnDialog::on_BurnFlashButton_clicked()
}
if (patch) {
QString tempDir = QDir::tempPath();
QString fileName = tempDir + "/temp.bin";
QString fileName = generateProcessUniqueTempFileName("temp.bin");
QFile file(fileName);
uint8_t *eeprom = (uint8_t*)malloc(GetEepromInterface()->getEEpromSize());
+6 -16
View File
@@ -156,16 +156,12 @@ void CompareDialog::dropEvent(QDropEvent *event)
void CompareDialog::closeEvent(QCloseEvent *event)
{
QByteArray ba = curvefile5.toLatin1();
char *name = ba.data();
unlink(name);
ba = curvefile9.toLatin1();
name = ba.data();
unlink(name);
}
CompareDialog::~CompareDialog()
{
qunlink(curvefile5);
qunlink(curvefile9);
delete ui;
}
@@ -260,13 +256,10 @@ void CompareDialog::printSetup()
str.append(fv(tr("Pulse Polarity"), g_model1->moduleData[0].polarityToString(), color));
color=getColor1(g_model1->thrTrim,g_model2->thrTrim);
str.append(fv(tr("Throttle Trim"), g_model1->thrTrim ? tr("Enabled") : tr("Disabled"), color));
color=getColor1(g_model1->thrExpo,g_model2->thrExpo);
str.append(fv(tr("Throttle Expo"), g_model1->thrExpo ? tr("Enabled") : tr("Disabled"),color));
// TODO str.append(fv(tr("Trim Switch"), getSWName(g_model->trimSw)));
color=getColor1(getTrimInc(g_model1),getTrimInc(g_model2));
str.append(fv(tr("Trim Increment"), getTrimInc(g_model1),color));
color=getColor1(getCenterBeep(g_model1),getCenterBeep(g_model2));
str.append(fv(tr("Center Beep"), getCenterBeep(g_model1),color)); // specify which channels beep
color = getColor1(getCenterBeepStr(g_model1), getCenterBeepStr(g_model2));
str.append(fv(tr("Center Beep"), getCenterBeepStr(g_model1), color)); // specify which channels beep
str.append("</table></td>");
str.append("<td><table border=0 cellspacing=0 cellpadding=3 width=\"50%\">");
color=getColor2(g_model1->name,g_model2->name);
@@ -283,13 +276,10 @@ void CompareDialog::printSetup()
str.append(fv(tr("Pulse Polarity"), g_model2->moduleData[0].polarityToString(), color));
color=getColor2(g_model1->thrTrim,g_model2->thrTrim);
str.append(fv(tr("Throttle Trim"), g_model2->thrTrim ? tr("Enabled") : tr("Disabled"), color));
color=getColor2(g_model1->thrExpo,g_model2->thrExpo);
str.append(fv(tr("Throttle Expo"), g_model2->thrExpo ? tr("Enabled") : tr("Disabled"),color));
// TODO str.append(fv(tr("Trim Switch"), getSWName(g_model->trimSw)));
color=getColor2(getTrimInc(g_model1),getTrimInc(g_model2));
str.append(fv(tr("Trim Increment"), getTrimInc(g_model2),color));
color=getColor2(getCenterBeep(g_model1),getCenterBeep(g_model2));
str.append(fv(tr("Center Beep"), getCenterBeep(g_model2),color)); // specify which channels beep
color = getColor2(getCenterBeepStr(g_model1),getCenterBeepStr(g_model2));
str.append(fv(tr("Center Beep"), getCenterBeepStr(g_model2), color)); // specify which channels beep
str.append("</td></tr></table></td></tr></table>");
te->append(str);
}
+17 -4
View File
@@ -505,7 +505,7 @@ class ConversionTable {
{
after = 0;
for (std::list<ConversionTuple>::iterator it=internalTable.begin(); it!=internalTable.end(); it++) {
for (std::list<ConversionTuple>::iterator it=exportTable.begin(); it!=exportTable.end(); it++) {
ConversionTuple tuple = *it;
if (before == tuple.a) {
after = tuple.b;
@@ -520,7 +520,7 @@ class ConversionTable {
{
after = 0;
for (std::list<ConversionTuple>::iterator it=internalTable.begin(); it!=internalTable.end(); it++) {
for (std::list<ConversionTuple>::iterator it=importTable.begin(); it!=importTable.end(); it++) {
ConversionTuple tuple = *it;
if (before == tuple.b) {
after = tuple.a;
@@ -547,10 +547,23 @@ class ConversionTable {
void addConversion(const int a, const int b)
{
internalTable.push_back(ConversionTuple(a, b));
ConversionTuple conversion(a, b);
importTable.push_back(conversion);
exportTable.push_back(conversion);
}
std::list<ConversionTuple> internalTable;
void addImportConversion(const int a, const int b)
{
importTable.push_back(ConversionTuple(a, b));
}
void addExportConversion(const int a, const int b)
{
exportTable.push_back(ConversionTuple(a, b));
}
std::list<ConversionTuple> importTable;
std::list<ConversionTuple> exportTable;
};
template<class T>
+5 -5
View File
@@ -301,7 +301,7 @@ RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSetting
break;
default:
result.max = (model.extendedLimits ? 125 : 100);
result.max = model.getChannelsMax(true);
result.min = -result.max;
break;
}
@@ -460,7 +460,7 @@ QString RawSwitch::toString()
};
static const QString timerModes[] = {
QObject::tr("OFF"), QObject::tr("ABS"),
QObject::tr("OFF"), QObject::tr("ON"),
QObject::tr("THs"), QObject::tr("TH%"), QObject::tr("THt")
};
@@ -723,7 +723,7 @@ void FuncSwData::clear()
QString FuncSwData::funcToString()
{
ModelData model;
if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32)
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32)
return QObject::tr("Override %1").arg(RawSource(SOURCE_TYPE_CH, func).toString(model));
else if (func == FuncTrainer)
return QObject::tr("Trainer");
@@ -1309,9 +1309,9 @@ ModelData ModelData::removeGlobalVars()
return result;
}
int ModelData::getChannelsMax()
int ModelData::getChannelsMax(bool forceExtendedLimits) const
{
if (extendedLimits)
if (forceExtendedLimits || extendedLimits)
return IS_TARANIS(GetCurrentFirmware()->getBoard()) ? 150 : 125;
else
return 100;
+7 -6
View File
@@ -526,6 +526,8 @@ class GeneralSettings {
int temperatureCalib;
int temperatureWarn;
unsigned int mAhWarn;
unsigned int mAhUsed;
unsigned int globalTimer;
unsigned int btBaudrate;
unsigned int sticksGain;
unsigned int rotarySteps;
@@ -725,8 +727,8 @@ class LogicalSwitchData { // Logical Switches data
};
enum AssignFunc {
FuncSafetyCh1 = 0,
FuncSafetyCh32 = FuncSafetyCh1+C9X_NUM_CHNOUT-1,
FuncOverrideCH1 = 0,
FuncOverrideCH32 = FuncOverrideCH1+C9X_NUM_CHNOUT-1,
FuncTrainer,
FuncTrainerRUD,
FuncTrainerELE,
@@ -755,7 +757,7 @@ enum AssignFunc {
class FuncSwData { // Function Switches data
public:
FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
FuncSwData(AssignFunc func=FuncOverrideCH1) { clear(); this->func = func; }
RawSwitch swtch;
AssignFunc func;
int param;
@@ -919,7 +921,6 @@ class TimerData {
RawSwitch mode;
bool minuteBeep;
unsigned int countdownBeep;
bool dir; // 0=>Count Down, 1=>Count Up
unsigned int val;
unsigned int persistent;
int pvalue;
@@ -986,7 +987,6 @@ class ModelData {
char name[12+1];
TimerData timers[2];
bool thrTrim; // Enable Throttle Trim
bool thrExpo; // Enable Throttle Expo
int trimInc; // Trim Increments
bool disableThrottleWarning;
@@ -1045,7 +1045,7 @@ class ModelData {
void clearMixes();
void clearInputs();
int getChannelsMax();
int getChannelsMax(bool forceExtendedLimits=false) const;
protected:
void removeGlobalVar(int & var);
@@ -1131,6 +1131,7 @@ enum Capability {
HasSoundMixer,
NumModules,
PPMCenter,
PPMUnitMicroseconds,
SYMLimits,
HasCurrentCalibration,
HasVolume,
+2 -4
View File
@@ -138,8 +138,8 @@ t_Er9xLimitData::t_Er9xLimitData()
t_Er9xLimitData::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.min = 10*(min-100);
c9x.max = 10*(max+100);
c9x.revert = revert;
c9x.offset = offset;
return c9x;
@@ -358,7 +358,6 @@ t_Er9xModelData::operator ModelData ()
c9x.used = true;
getEEPROMString(c9x.name, name, sizeof(name));
c9x.timers[0].mode = getEr9xTimerMode(tmrMode);
c9x.timers[0].dir = tmrDir;
c9x.timers[0].val = tmrVal;
switch(protocol) {
case 1:
@@ -377,7 +376,6 @@ t_Er9xModelData::operator ModelData ()
c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.funcSw[0].func = FuncInstantTrim;
@@ -147,8 +147,8 @@ t_Ersky9xLimitData::t_Ersky9xLimitData()
t_Ersky9xLimitData::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.min = 10*(min-100);
c9x.max = 10*(max+100);
c9x.revert = revert;
c9x.offset = offset;
return c9x;
@@ -489,7 +489,6 @@ t_Ersky9xModelData_v10::operator ModelData ()
getEEPROMString(c9x.name, name, sizeof(name));
for (int i=0; i<2; i++) {
c9x.timers[i].mode = getErSky9xTimerMode(timer[i].tmrModeA);
c9x.timers[i].dir = timer[i].tmrDir;
c9x.timers[i].val = timer[i].tmrVal;
}
switch(protocol) {
@@ -509,7 +508,6 @@ t_Ersky9xModelData_v10::operator ModelData ()
c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.funcSw[0].func = FuncInstantTrim;
@@ -607,7 +605,6 @@ t_Ersky9xModelData_v11::operator ModelData ()
getEEPROMString(c9x.name, name, sizeof(name));
for (int i=0; i<2; i++) {
c9x.timers[i].mode = getErSky9xTimerMode(timer[i].tmrModeA);
c9x.timers[i].dir = timer[i].tmrDir;
c9x.timers[i].val = timer[i].tmrVal;
}
switch(protocol) {
@@ -627,7 +624,6 @@ t_Ersky9xModelData_v11::operator ModelData ()
c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.funcSw[0].func = FuncInstantTrim;
@@ -201,8 +201,8 @@ t_Gruvin9xLimitData::t_Gruvin9xLimitData()
t_Gruvin9xLimitData::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.min = 10*(min-100);
c9x.max = 10*(max+100);
c9x.revert = revert;
c9x.offset = offset;
return c9x;
@@ -378,7 +378,6 @@ t_Gruvin9xTimerData::operator TimerData ()
TimerData c9x;
c9x.mode = getEr9xTimerMode(mode);
c9x.val = val;
c9x.dir = dir;
return c9x;
}
@@ -447,7 +446,6 @@ t_Gruvin9xModelData_v102::operator ModelData ()
}
c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH);
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.beepANACenter = beepANACenter;
@@ -518,7 +516,6 @@ t_Gruvin9xModelData_v103::operator ModelData ()
}
c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH);
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.beepANACenter = beepANACenter;
@@ -589,7 +586,6 @@ t_Gruvin9xModelData_v105::operator ModelData ()
}
c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH);
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.beepANACenter = beepANACenter;
@@ -680,7 +676,6 @@ t_Gruvin9xModelData_v106::operator ModelData ()
}
c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH);
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc-2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.beepANACenter = beepANACenter;
@@ -138,7 +138,6 @@ t_Open9xArmTimerData_v202::operator TimerData ()
*/
c9x.val = val;
c9x.persistent = false;
c9x.dir = (val == 0);
return c9x;
}
@@ -577,7 +576,7 @@ t_Open9xArmFuncSwData_v208::operator FuncSwData ()
FuncSwData c9x;
c9x.swtch = open9xArmToSwitch(swtch);
c9x.func = (AssignFunc)(func);
if (c9x.func <= FuncSafetyCh32) {
if (c9x.func <= FuncOverrideCH32) {
c9x.enabled=param & 0x01;
c9x.param = (param>>1)<<1;
}
@@ -129,8 +129,8 @@ t_Open9xExpoData_v211::operator ExpoData ()
t_Open9xLimitData_v201::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.min = 10*(min-100);
c9x.max = 10*(max+100);
c9x.revert = revert;
c9x.offset = offset;
return c9x;
@@ -139,8 +139,8 @@ t_Open9xLimitData_v201::operator LimitData ()
t_Open9xLimitData_v211::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.min = 10*(min-100);
c9x.max = 10*(max+100);
c9x.revert = revert;
c9x.offset = offset;
c9x.symetrical=symetrical;
@@ -704,7 +704,6 @@ t_Open9xTimerData_v201::operator TimerData ()
// c9x.mode = TMRMODE_OFF;
c9x.val = val;
c9x.persistent = persistent;
c9x.dir = dir;
return c9x;
}
@@ -725,7 +724,6 @@ t_Open9xTimerData_v202::operator TimerData ()
*/
c9x.val = val;
c9x.persistent = false;
c9x.dir = (val == 0);
return c9x;
}
@@ -939,7 +937,6 @@ t_Open9xModelData_v201::operator ModelData ()
}
c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH);
c9x.thrTrim = thrTrim;
c9x.thrExpo = thrExpo;
c9x.trimInc = trimInc - 2;
c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
c9x.beepANACenter = beepANACenter;
@@ -149,6 +149,7 @@ inline int geteepromsize() {
#include "radio/src/lua/src/lstate.c"
#include "radio/src/lua/src/lstring.c"
#include "radio/src/lua/src/ltable.c"
#include "radio/src/lua/src/lrotable.c"
#include "radio/src/lua/src/ltm.c"
#include "radio/src/lua/src/lundump.c"
#include "radio/src/lua/src/lvm.c"
@@ -156,6 +157,7 @@ inline int geteepromsize() {
#include "radio/src/lua/src/lbaselib.c"
#include "radio/src/lua/src/linit.c"
#include "radio/src/lua/src/lmathlib.c"
#include "radio/src/lua/src/lbitlib.c"
#include "radio/src/lua/src/loadlib.c"
#include "radio/src/lua/src/lauxlib.c"
#include "radio/src/lua/src/ltablib.c"
+96 -30
View File
@@ -40,11 +40,11 @@ inline int switchIndex(int i, BoardEnum board, unsigned int version)
class SwitchesConversionTable: public ConversionTable {
public:
SwitchesConversionTable(BoardEnum board, unsigned int version, unsigned long flags=0)
SwitchesConversionTable(BoardEnum board, unsigned int version, bool timer=false)
{
int val=0;
int offset=0;
if (flags & POPULATE_TIMER_MODES) {
if (timer) {
offset = 4;
for (int i=0; i<5; i++) {
addConversion(RawSwitch(SWITCH_TYPE_TIMER_MODE, i), val++);
@@ -56,8 +56,15 @@ class SwitchesConversionTable: public ConversionTable {
for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) {
int s = switchIndex(i, board, version);
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++);
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val);
if (IS_TARANIS(board) && s>=21/*SHup/SHdown*/) {
addImportConversion(RawSwitch(SWITCH_TYPE_SWITCH, 21+22-s), -val+offset);
addExportConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset);
}
else {
addConversion(RawSwitch(SWITCH_TYPE_SWITCH, -s), -val+offset);
}
val++;
}
if (IS_TARANIS(board) && version >= 216) {
@@ -86,17 +93,15 @@ class SwitchesConversionTable: public ConversionTable {
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++);
}
if (!(flags & POPULATE_TIMER_MODES)) {
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
if (version >= 216) {
addConversion(RawSwitch(SWITCH_TYPE_ONE, -1), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_ONE, 1), val++);
if (IS_ARM(board)) {
for (int i=1; i<=MAX_FLIGHT_MODES(board, version); i++) {
addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, -i), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i), val++);
}
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
if (version >= 216) {
addConversion(RawSwitch(SWITCH_TYPE_ONE, -1), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_ONE, 1), val++);
if (IS_ARM(board)) {
for (int i=1; i<=MAX_FLIGHT_MODES(board, version); i++) {
addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, -i), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i), val++);
}
}
}
@@ -124,6 +129,16 @@ class SwitchesConversionTable: public ConversionTable {
ConversionTable::addConversion(sw.toValue(), b);
}
void addImportConversion(const RawSwitch & sw, const int b)
{
ConversionTable::addImportConversion(sw.toValue(), b);
}
void addExportConversion(const RawSwitch & sw, const int b)
{
ConversionTable::addExportConversion(sw.toValue(), b);
}
class Cache {
public:
Cache(BoardEnum board, unsigned int version, unsigned long flags, SwitchesConversionTable * table):
@@ -1024,6 +1039,8 @@ class MixField: public TransformedField {
mix.curve = CurveReference(CurveReference::CURVE_REF_DIFF, smallGvarToC9x(_curveParam));
else if (_curveParam > 6)
mix.curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, _curveParam-6);
else if (_curveParam < 0)
mix.curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, _curveParam);
else
mix.curve = CurveReference(CurveReference::CURVE_REF_FUNC, _curveParam);
}
@@ -1083,7 +1100,7 @@ class InputField: public TransformedField {
internalField.Append(new SignedField<6>(expo.carryTrim, "CarryTrim"));
internalField.Append(new UnsignedField<2>(expo.mode, "Mode"));
internalField.Append(new ZCharField<8>(expo.name));
internalField.Append(new SignedField<8>(expo.offset, "Offset"));
internalField.Append(new SignedField<8>(_offset, "Offset"));
internalField.Append(new CurveReferenceField(expo.curve, board, version));
internalField.Append(new SpareBitsField<8>());
}
@@ -1136,7 +1153,11 @@ class InputField: public TransformedField {
virtual void beforeExport()
{
_weight = smallGvarToEEPROM(expo.weight);
_weight = smallGvarToEEPROM(expo.weight);
if (IS_TARANIS(board) && version >= 216) {
_offset = smallGvarToEEPROM(expo.offset);
}
if (!IS_TARANIS(board) || version < 216) {
if (expo.curve.type==CurveReference::CURVE_REF_FUNC && expo.curve.value) {
@@ -1169,6 +1190,10 @@ class InputField: public TransformedField {
expo.weight = smallGvarToC9x(_weight);
if (IS_TARANIS(board) && version >= 216) {
expo.offset = smallGvarToC9x(_offset);
}
if (!IS_TARANIS(board) || version < 216) {
if (!_curveMode)
expo.curve = CurveReference(CurveReference::CURVE_REF_EXPO, smallGvarToC9x(_curveParam));
@@ -1186,24 +1211,49 @@ class InputField: public TransformedField {
unsigned int version;
bool _curveMode;
int _weight;
int _offset;
int _curveParam;
};
class LimitField: public StructField {
public:
template <int shift>
static int exportLimitValue(int value)
{
if (value > 10000)
return 4095 + value - 10000;
else if (value < -10000)
return -4096 + value + 10000;
else
return value + shift;
}
template <int shift>
static int importLimitValue(int value)
{
if (value > 4095)
return 10000 + value - 4095;
else if (value < -4096)
return -10000 + value + 4096;
else
return value - shift;
}
LimitField(LimitData & limit, BoardEnum board, unsigned int version):
StructField("Limit")
{
if (IS_TARANIS(board) && version >= 216) {
Append(new ConversionField< SignedField<16> >(limit.min, +1000));
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
Append(new ConversionField< SignedField<16> >(limit.min, exportLimitValue<1000>, importLimitValue<1000>));
Append(new ConversionField< SignedField<16> >(limit.max, exportLimitValue<-1000>, importLimitValue<-1000>));
Append(new SignedField<8>(limit.ppmCenter));
Append(new ConversionField< SignedField<14> >(limit.offset, exportLimitValue<0>, importLimitValue<0>));
}
else {
Append(new ConversionField< SignedField<8> >(limit.min, +100, 10));
Append(new ConversionField< SignedField<8> >(limit.max, -100, 10));
Append(new SignedField<8>(limit.ppmCenter));
Append(new SignedField<14>(limit.offset));
}
Append(new SignedField<8>(limit.ppmCenter));
Append(new SignedField<14>(limit.offset));
Append(new BoolField<1>(limit.symetrical));
Append(new BoolField<1>(limit.revert));
if (HAS_LARGE_LCD(board)) {
@@ -1547,9 +1597,25 @@ class LogicalSwitchField: public TransformedField {
else if (csw.func >= LS_FN_EQUAL && csw.func <= LS_FN_ELESS) {
sourcesConversionTable->importValue((uint8_t)v1, csw.val1);
sourcesConversionTable->importValue((uint8_t)v2, csw.val2);
if (IS_TARANIS(board) && version < 216) {
RawSource val1(csw.val1);
if (val1.type == SOURCE_TYPE_STICK && val1.index < NUM_STICKS) {
csw.val1 = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, val1.index).toValue();
}
RawSource val2(csw.val2);
if (val2.type == SOURCE_TYPE_STICK && val2.index < NUM_STICKS) {
csw.val2 = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, val2.index).toValue();
}
}
}
else if (csw.func != LS_FN_OFF) {
sourcesConversionTable->importValue((uint8_t)v1, csw.val1);
if (IS_TARANIS(board) && version < 216) {
RawSource val1(csw.val1);
if (val1.type == SOURCE_TYPE_STICK && val1.index < NUM_STICKS) {
csw.val1 = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, val1.index).toValue();
}
}
csw.val2 = v2;
RawSource val1(csw.val1);
if (IS_ARM(board) && version < 216 && val1.type == SOURCE_TYPE_TELEMETRY) {
@@ -1802,10 +1868,10 @@ class ArmCustomFunctionField: public TransformedField {
else
_active = (fn.enabled ? 1 : 0);
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
if (version >= 216) {
*((uint16_t *)_param) = fn.param;
*((uint8_t *)(_param+3)) = fn.func - FuncSafetyCh1;
*((uint8_t *)(_param+3)) = fn.func - FuncOverrideCH1;
}
else {
*((uint32_t *)_param) = fn.param;
@@ -1884,7 +1950,7 @@ class ArmCustomFunctionField: public TransformedField {
value = *((uint32_t *)_param);
}
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
fn.func = AssignFunc(fn.func + index);
fn.param = (int8_t)value;
}
@@ -1989,9 +2055,9 @@ class AvrCustomFunctionField: public TransformedField {
_param = fn.param;
_active = (fn.enabled ? 1 : 0);
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
if (version >= 216)
_union_param = fn.func - FuncSafetyCh1;
_union_param = fn.func - FuncOverrideCH1;
else if (version >= 213)
_active += ((fn.func % 4) << 1);
}
@@ -2049,7 +2115,7 @@ class AvrCustomFunctionField: public TransformedField {
fn.enabled = (_active & 0x01);
}
if (fn.func >= FuncSafetyCh1 && fn.func <= FuncSafetyCh32) {
if (fn.func >= FuncOverrideCH1 && fn.func <= FuncOverrideCH32) {
if (version >= 216)
fn.func = AssignFunc(fn.func + _union_param);
else if (version >= 213)
@@ -2396,7 +2462,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
}
for (int i=0; i<O9X_MAX_TIMERS; i++) {
internalField.Append(new SwitchField<8>(modelData.timers[i].mode, board, version, POPULATE_TIMER_MODES));
internalField.Append(new SwitchField<8>(modelData.timers[i].mode, board, version, true));
if ((IS_ARM(board) || IS_2560(board)) && version >= 216) {
internalField.Append(new UnsignedField<16>(modelData.timers[i].val));
internalField.Append(new UnsignedField<2>(modelData.timers[i].countdownBeep));
@@ -2759,8 +2825,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
if (version >= 213) {
internalField.Append(new SignedField<8>(generalData.temperatureWarn)); // TODO
internalField.Append(new UnsignedField<8>(generalData.mAhWarn));
internalField.Append(new SpareBitsField<16>()); // mAhUsed
internalField.Append(new SpareBitsField<32>()); // globalTimer
internalField.Append(new UnsignedField<16>(generalData.mAhUsed));
internalField.Append(new UnsignedField<32>(generalData.globalTimer));
internalField.Append(new SignedField<8>(generalData.temperatureCalib)); // TODO
internalField.Append(new UnsignedField<8>(generalData.btBaudrate)); // TODO
internalField.Append(new BoolField<8>(generalData.optrexDisplay)); //TODO
@@ -663,7 +663,9 @@ int OpenTxFirmware::getCapability(const Capability capability)
case TelemetryMaxMultiplier:
return (IS_ARM(board) ? 32 : 8);
case PPMCenter:
return 1;
return (IS_TARANIS(board) || id.contains("ppmca")) ? 1 : 0;
case PPMUnitMicroseconds:
return id.contains("ppmus") ? 1 : 0;
case SYMLimits:
return 1;
case OptrexDisplay:
+2 -3
View File
@@ -124,8 +124,8 @@ t_Th9xLimitData::t_Th9xLimitData()
t_Th9xLimitData::operator LimitData ()
{
LimitData c9x;
c9x.min = min-100;
c9x.max = max+100;
c9x.min = 10*(min-100);
c9x.max = 10*(max+100);
c9x.revert = revert;
c9x.offset = offset;
return c9x;
@@ -272,7 +272,6 @@ t_Th9xModelData::operator ModelData ()
/*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;
+5 -2
View File
@@ -106,7 +106,7 @@
These will be relevant for all models in the same EEPROM.</string>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabSetup">
<attribute name="title">
@@ -275,7 +275,10 @@ These will be relevant for all models in the same EEPROM.</string>
<item>
<widget class="QSlider" name="backlightColor_SL">
<property name="maximum">
<number>100</number>
<number>20</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
+115 -47
View File
@@ -1,4 +1,11 @@
#include <QtGui>
#if defined WIN32
#include <io.h>
#include <stdio.h>
#endif
#if !defined WIN32 && defined __GNUC__
#include <unistd.h>
#endif
#include "appdata.h"
#include "helpers.h"
#include "simulatordialog.h"
@@ -140,18 +147,18 @@ void populatePhasesCB(QComboBox *b, int value)
b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes));
}
GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags):
GVarGroup::GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step, bool allowGvars):
QObject(),
weightGV(weightGV),
weightSB(weightSB),
sb(dynamic_cast<QSpinBox *>(weightSB)),
dsb(dynamic_cast<QDoubleSpinBox *>(weightSB)),
weightCB(weightCB),
weight(weight),
flags(flags),
lock(false)
step(step),
lock(true)
{
lock = true;
if (GetCurrentFirmware()->getCapability(Gvars)) {
if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) {
populateGVCB(weightCB, weight);
connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
@@ -163,21 +170,32 @@ GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightC
}
}
weightSB->setMinimum(mini);
weightSB->setMaximum(maxi);
int val;
if (weight>maxi || weight<mini) {
val = deflt;
weightGV->setChecked(true);
weightSB->hide();
weightCB->show();
}
else {
val = weight;
weightGV->setChecked(false);
weightSB->setValue(weight);
weightSB->show();
weightCB->hide();
}
if (sb) {
sb->setMinimum(mini);
sb->setMaximum(maxi);
sb->setValue(val);
}
else {
dsb->setMinimum(mini*step);
dsb->setMaximum(maxi*step);
dsb->setValue(val*step);
}
connect(weightSB, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
lock = false;
@@ -186,16 +204,23 @@ GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightC
void GVarGroup::gvarCBChanged(int state)
{
weightCB->setVisible(state);
weightSB->setVisible(!state);
if (weightSB)
weightSB->setVisible(!state);
else
weightSB->setVisible(!state);
valuesChanged();
}
void GVarGroup::valuesChanged()
{
if (weightGV->isChecked())
weight = weightCB->itemData(weightCB->currentIndex()).toInt();
else
weight = weightSB->value();
if (!lock) {
if (weightGV->isChecked())
weight = weightCB->itemData(weightCB->currentIndex()).toInt();
else if (sb)
weight = sb->value();
else
weight = dsb->value()/step;
}
}
CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags):
@@ -371,13 +396,13 @@ void populateBacklightCB(QComboBox *b, const uint8_t value)
}
}
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, unsigned long attr)
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, SwitchContext context)
{
RawSwitch item;
b->clear();
if (attr & POPULATE_ONOFF) {
if (context != MixesContext) {
// !FMx
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
for (int i=-GetCurrentFirmware()->getCapability(FlightModes); i<0; i++) {
@@ -386,14 +411,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
// !One
item = RawSwitch(SWITCH_TYPE_ONE, 1);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
// OFF
item = RawSwitch(SWITCH_TYPE_OFF);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetCurrentFirmware()->getCapability(LogicalSwitches); i<0; i++) {
@@ -428,13 +445,13 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (IS_TARANIS(GetCurrentFirmware()->getBoard())) {
//hide up and down for !SH and !SF, because they are redundant (!SFup == SFdown)
if (item.toString().contains("H") || item.toString().contains("F")) continue;
if (item.toString().contains("H") || item.toString().contains("F")) continue;
}
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (attr & POPULATE_TIMER_MODES) {
if (context == TimersContext) {
for (int i=0; i<5; i++) {
item = RawSwitch(SWITCH_TYPE_TIMER_MODE, i);
b->addItem(item.toString(), item.toValue());
@@ -481,7 +498,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (attr & POPULATE_ONOFF) {
if (context == CustomFunctionsContext) {
// ON
item = RawSwitch(SWITCH_TYPE_ON);
b->addItem(item.toString(), item.toValue());
@@ -490,7 +507,10 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
item = RawSwitch(SWITCH_TYPE_ONE, 1);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
// FMx
}
// FMx
if (context != MixesContext) {
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
for (int i=1; i<=GetCurrentFirmware()->getCapability(FlightModes); i++) {
item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i);
@@ -782,19 +802,35 @@ QString getFrSkySrc(int index)
QString getTrimInc(ModelData * g_model)
{
switch (g_model->trimInc) {
case (1): return QObject::tr("Extra Fine");
case (2): return QObject::tr("Fine");
case (3): return QObject::tr("Medium");
case (4): return QObject::tr("Coarse");
default: return QObject::tr("Exponential");
}
switch (g_model->trimInc) {
case -2:
return QObject::tr("Exponential");
case -1:
return QObject::tr("Extra Fine");
case 0:
return QObject::tr("Fine");
case 1:
return QObject::tr("Medium");
case 2:
return QObject::tr("Coarse");
default:
return QObject::tr("Unknown");
}
}
QString getTimerStr(TimerData & timer)
{
QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down"));
return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + timer.mode.toString() + str;
QString result = QObject::tr("%1:%2").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0'));
result += QString(", ") + timer.mode.toString();
if (timer.persistent)
result += QObject::tr(", Persistent");
if (timer.minuteBeep)
result += QObject::tr(", MinuteBeep");
if (timer.countdownBeep == 1)
result += QObject::tr(", CountDown(Beeps)");
else if (timer.countdownBeep == 2)
result += QObject::tr(", CountDown(Voice)");
return result;
}
QString getProtocol(ModelData * g_model)
@@ -835,18 +871,37 @@ QString getPhasesStr(unsigned int phases, ModelData & model)
}
}
QString getCenterBeep(ModelData * g_model)
QString getCenterBeepStr(ModelData * g_model)
{
//RETA123
QStringList strl;
if(g_model->beepANACenter & 0x01) strl << QObject::tr("Rudder");
if(g_model->beepANACenter & 0x02) strl << QObject::tr("Elevator");
if(g_model->beepANACenter & 0x04) strl << QObject::tr("Throttle");
if(g_model->beepANACenter & 0x08) strl << QObject::tr("Aileron");
if(g_model->beepANACenter & 0x10) strl << "P1";
if(g_model->beepANACenter & 0x20) strl << "P2";
if(g_model->beepANACenter & 0x40) strl << "P3";
if(g_model->beepANACenter & 0x80) strl << "LS";
if (g_model->beepANACenter & 0x01)
strl << QObject::tr("Rudder");
if (g_model->beepANACenter & 0x02)
strl << QObject::tr("Elevator");
if (g_model->beepANACenter & 0x04)
strl << QObject::tr("Throttle");
if (g_model->beepANACenter & 0x08)
strl << QObject::tr("Aileron");
if (IS_TARANIS(GetCurrentFirmware()->getBoard())) {
if (g_model->beepANACenter & 0x10)
strl << "S1";
if (g_model->beepANACenter & 0x20)
strl << "S2";
if (g_model->beepANACenter & 0x40)
strl << "S3";
if (g_model->beepANACenter & 0x80)
strl << "LS";
if (g_model->beepANACenter & 0x100)
strl << "RS";
}
else {
if (g_model->beepANACenter & 0x10)
strl << "P1";
if (g_model->beepANACenter & 0x20)
strl << "P2";
if (g_model->beepANACenter & 0x40)
strl << "P3";
}
return strl.join(", ");
}
@@ -964,3 +1019,16 @@ QString index2version(int index)
return QString();
}
}
int qunlink(const QString & fileName)
{
QByteArray ba = fileName.toLatin1();
return unlink(ba.constData());
}
QString generateProcessUniqueTempFileName(const QString & fileName)
{
QString sanitizedFileName = fileName;
sanitizedFileName.remove('/');
return QDir::tempPath() + QString("/%1-").arg(QCoreApplication::applicationPid()) + sanitizedFileName;
}
+21 -9
View File
@@ -6,7 +6,7 @@
extern const QColor colors[C9X_MAX_CURVES];
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetCurrentFirmware()->getCapability(LogicalSwitches)-1)
#define TMR_NUM_OPTION (TMRMODE_COUNT+2*9+2*GetCurrentFirmware()->getCapability(LogicalSwitches)-1)
//convert from mode 1 to mode generalSettings.stickMode
//NOTICE! => 1..4 -> 1..4
@@ -37,12 +37,12 @@ class CompanionIcon: public QIcon {
CompanionIcon(QString baseimage);
};
class GVarGroup : public QObject {
class GVarGroup: public QObject {
Q_OBJECT
public:
GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags=0);
GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step=1.0, bool allowGVars=true);
protected slots:
void gvarCBChanged(int);
@@ -50,10 +50,12 @@ class GVarGroup : public QObject {
protected:
QCheckBox *weightGV;
QSpinBox *weightSB;
QAbstractSpinBox *weightSB;
QSpinBox *sb;
QDoubleSpinBox *dsb;
QComboBox *weightCB;
int & weight;
const unsigned int flags;
double step;
bool lock;
};
@@ -81,9 +83,15 @@ class CurveGroup : public QObject {
int lastType;
};
#define POPULATE_ONOFF 0x01
#define POPULATE_TIMER_MODES 0x02
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, unsigned long attr=0);
enum SwitchContext
{
LogicalSwitchesContext,
CustomFunctionsContext,
TimersContext,
MixesContext
};
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, SwitchContext context);
void populatePhasesCB(QComboBox *b, int value);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
@@ -114,7 +122,7 @@ int findmult(float value, float base);
QString getTrimInc(ModelData * g_model);
QString getTimerStr(TimerData & timer);
QString getProtocol(ModelData * g_model);
QString getCenterBeep(ModelData * g_model);
QString getCenterBeepStr(ModelData * g_model);
/* FrSky helpers */
QString getFrSkyAlarmType(int alarm);
@@ -139,4 +147,8 @@ class QTimeS : public QTime
int seconds() const { return hour()*3600 + minute()*60 + second(); };
};
int qunlink(const QString & fileName);
QString generateProcessUniqueTempFileName(const QString & fileName);
#endif // HELPERS_H
+6 -6
View File
@@ -239,13 +239,13 @@ void logsDialog::on_mapsButton_clicked() {
itemSelected=n-1;
}
QString geFilename = QDir::tempPath() + "/track0.png";
if (QFile::exists(geFilename)) {
QFile::remove(geFilename);
QString geIconFilename = generateProcessUniqueTempFileName("track0.png");
if (QFile::exists(geIconFilename)) {
QFile::remove(geIconFilename);
}
QFile::copy(":/images/track0.png", geFilename);
QFile::copy(":/images/track0.png", geIconFilename);
geFilename = QDir::tempPath() + "/flight.kml";
QString geFilename = generateProcessUniqueTempFileName("flight.kml");
if (QFile::exists(geFilename)) {
QFile::remove(geFilename);
}
@@ -264,7 +264,7 @@ void logsDialog::on_mapsButton_clicked() {
QTextStream outputStream(&geFile);
outputStream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">\n";
outputStream << "\t<Document>\n\t\t<name>" << logFilename << "</name>\n";
outputStream << "\t\t<Style id=\"multiTrack_n\">\n\t\t\t<IconStyle>\n\t\t\t\t<Icon>\n\t\t\t\t\t<href>file://" << QDir::tempPath() << "/track0.png</href>\n\t\t\t\t</Icon>\n\t\t\t</IconStyle>\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
outputStream << "\t\t<Style id=\"multiTrack_n\">\n\t\t\t<IconStyle>\n\t\t\t\t<Icon>\n\t\t\t\t\t<href>file://" << geIconFilename << "</href>\n\t\t\t\t</Icon>\n\t\t\t</IconStyle>\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
outputStream << "\t\t<Style id=\"multiTrack_h\">\n\t\t\t<IconStyle>\n\t\t\t\t<scale>0</scale>\n\t\t\t\t<Icon>\n\t\t\t\t\t<href>file://" << QDir::tempPath() << "/track0.png</href>\n\t\t\t\t</Icon>\n\t\t\t</IconStyle>\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>8</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
outputStream << "\t\t<StyleMap id=\"multiTrack\">\n\t\t\t<Pair>\n\t\t\t\t<key>normal</key>\n\t\t\t\t<styleUrl>#multiTrack_n</styleUrl>\n\t\t\t</Pair>\n\t\t\t<Pair>\n\t\t\t\t<key>highlight</key>\n\t\t\t\t<styleUrl>#multiTrack_h</styleUrl>\n\t\t\t</Pair>\n\t\t</StyleMap>\n";
outputStream << "\t\t<Style id=\"lineStyle\">\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
+16 -15
View File
@@ -804,9 +804,9 @@ QStringList MainWindow::GetSambaArguments(const QString &tcl)
{
QStringList result;
QString tclFilename = QDir::tempPath() + "/temp.tcl";
QString tclFilename = generateProcessUniqueTempFileName("temp.tcl");
if (QFile::exists(tclFilename)) {
unlink(tclFilename.toAscii());
qunlink(tclFilename);
}
QFile tclFile(tclFilename);
if (!tclFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
@@ -946,21 +946,23 @@ QString MainWindow::FindMassstoragePath(QString filename)
void MainWindow::readEeprom()
{
QString tempDir = QDir::tempPath();
QString tempFile;
EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_ARM(eepromInterface->getBoard()))
tempFile = tempDir + "/temp.bin";
tempFile = generateProcessUniqueTempFileName("temp.bin");
else
tempFile = tempDir + "/temp.hex";
tempFile += generateProcessUniqueTempFileName("temp.hex");
qDebug() << "MainWindow::readEeprom(): using temp file: " << tempFile;
if (readEepromFromRadio(tempFile, tr("Read Models and Settings From Radio"))) {
MdiChild *child = createMdiChild();
child->newFile();
child->loadFile(tempFile, false);
child->show();
qunlink(tempFile);
}
}
@@ -1042,7 +1044,10 @@ bool MainWindow::readEepromFromRadio(const QString filename, const QString messa
QFile file(filename);
if (file.exists()) {
file.remove();
if (!file.remove()) {
QMessageBox::warning(this, tr("Error"), tr("Could not delete temporary file: %1").arg(filename));
return false;
}
}
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
@@ -1165,13 +1170,12 @@ void MainWindow::writeBackup()
return;
}
int oldrev = getEpromVersion(fileName);
QString tempDir = QDir::tempPath();
QString tempFlash = tempDir + "/flash.bin";
QString tempFlash = generateProcessUniqueTempFileName("flash.bin");
if (!readFirmwareFromRadio(tempFlash))
return;
QString restoreFile = tempDir + "/compat.bin";
QString restoreFile = generateProcessUniqueTempFileName("compat.bin");
if (!convertEEPROM(fileName, restoreFile, tempFlash)) {
int ret = QMessageBox::question(this, "Error", tr("Cannot check Models and Settings compatibility! Continue anyway?") ,
QMessageBox::Yes | QMessageBox::No);
@@ -1188,9 +1192,7 @@ void MainWindow::writeBackup()
}
fileName = restoreFile;
}
QByteArray ba = tempFlash.toLatin1();
char *name = ba.data();
unlink(name);
qunlink(tempFlash);
}
else {
if (backupEnable) {
@@ -1304,8 +1306,7 @@ void MainWindow::writeFlash(QString fileToFlash)
if (!fileName.isEmpty()) {
g.backupOnFlash(backup);
if (backup) {
QString tempDir = QDir::tempPath();
QString backupFile = tempDir + "/backup.bin";
QString backupFile = generateProcessUniqueTempFileName("backup.bin");
bool backupEnable=g.enableBackup();
QString backupPath=g.backupDir();
if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) {
@@ -1330,7 +1331,7 @@ void MainWindow::writeFlash(QString fileToFlash)
sleep(2);
int res = writeFirmwareToRadio(fileName);
if (res) {
QString restoreFile = tempDir + "/restore.bin";
QString restoreFile = generateProcessUniqueTempFileName("restore.bin");
if (!convertEEPROM(backupFile, restoreFile, fileName)) {
QMessageBox::warning(this, tr("Conversion failed"), tr("Cannot convert Models and Settings for use with this firmware, original data will be used"));
restoreFile = backupFile;
+4 -7
View File
@@ -531,8 +531,7 @@ void MdiChild::writeEeprom() // write to Tx
}
QString stickCal=g.profile[g.id()].stickPotCalib();
burnConfigDialog bcd;
QString tempDir = QDir::tempPath();
QString tempFile = tempDir + "/temp.bin";
QString tempFile = generateProcessUniqueTempFileName("temp.bin");
saveFile(tempFile, false);
if(!QFileInfo(tempFile).exists()) {
QMessageBox::critical(this,tr("Error"), tr("Cannot write temporary file!"));
@@ -550,12 +549,12 @@ void MdiChild::writeEeprom() // write to Tx
return;
}
int oldrev=((MainWindow *)this->parent())->getEpromVersion(tempFile);
QString tempFlash=tempDir + "/flash.bin";
QString tempFlash = generateProcessUniqueTempFileName("flash.bin");
if (!((MainWindow *)this->parent())->readFirmwareFromRadio(tempFlash))
return;
QString restoreFile = tempDir + "/compat.bin";
QString restoreFile = generateProcessUniqueTempFileName("compat.bin");
if (!((MainWindow *)this->parent())->convertEEPROM(tempFile, restoreFile, tempFlash)) {
int ret = QMessageBox::question(this, tr("Error"), tr("Cannot check eeprom compatibility! Continue anyway?"), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::No)
@@ -571,9 +570,7 @@ void MdiChild::writeEeprom() // write to Tx
}
tempFile=restoreFile;
}
QByteArray ba = tempFlash.toLatin1();
char *name = ba.data();
unlink(name);
qunlink(tempFlash);
}
else {
if (backupEnable) {
+77 -71
View File
@@ -1,4 +1,5 @@
#include "channels.h"
#include "helpers.h"
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
@@ -6,6 +7,70 @@
#include <QCheckBox>
#include <QDoubleSpinBox>
LimitsGroup::LimitsGroup(FirmwareInterface * firmware, QGridLayout *gridLayout, int row, int col, int & value, int min, int max, int deflt):
firmware(firmware),
spinbox(new QDoubleSpinBox()),
value(value),
displayStep(0.1)
{
bool allowGVars = false;
int internalStep = 1;
spinbox->setProperty("index", row);
spinbox->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
spinbox->setAccelerated(true);
if (firmware->getCapability(PPMUnitMicroseconds)) {
displayStep = 0.512;
spinbox->setDecimals(1);
spinbox->setSuffix("us");
}
else {
spinbox->setDecimals(0);
spinbox->setSuffix("%");
}
if (IS_TARANIS(firmware->getBoard()) || deflt == 0 /*it's the offset*/) {
spinbox->setDecimals(1);
allowGVars = true;
}
else {
internalStep *= 10;
}
spinbox->setSingleStep(displayStep*internalStep);
QHBoxLayout * horizontalLayout = new QHBoxLayout();
QCheckBox * gv = new QCheckBox(QObject::tr("GV"));
horizontalLayout->addWidget(gv);
QComboBox * cb = new QComboBox();
horizontalLayout->addWidget(cb);
horizontalLayout->addWidget(spinbox);
gridLayout->addLayout(horizontalLayout, row, col, 1, 1);
gvarGroup = new GVarGroup(gv, spinbox, cb, value, deflt, min, max, displayStep, allowGVars);
}
LimitsGroup::~LimitsGroup()
{
delete gvarGroup;
}
void LimitsGroup::updateMinMax(int max)
{
if (spinbox->maximum() == 0) {
spinbox->setMinimum(-max*displayStep);
if (value < -max) {
value = -max;
}
}
if (spinbox->minimum() == 0) {
spinbox->setMaximum(max*displayStep);
if (value > max) {
value = max;
}
}
}
Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
ModelPanel(parent, model, generalSettings, firmware)
{
@@ -13,8 +78,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
bool minimize = false;
int col = 1;
if (firmware->getCapability(ChannelsName))
{
if (firmware->getCapability(ChannelsName)) {
minimize=true;
addLabel(gridLayout, tr("Name"), col++);
}
@@ -52,44 +116,13 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
}
// Channel offset
QDoubleSpinBox * offset = new QDoubleSpinBox(this);
offset->setProperty("index", i);
offset->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
offset->setAccelerated(true);
offset->setDecimals(1);
offset->setMinimum(-100);
offset->setSingleStep(0.1);
offset->setValue(float(model.limitData[i].offset) / 10);
connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited()));
gridLayout->addWidget(offset, i+1, col++, 1, 1);
limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].offset, -1000, 1000, 0);
// Channel min
QDoubleSpinBox * minSB = new QDoubleSpinBox(this);
minSB->setProperty("index", i);
minSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
minSB->setAccelerated(true);
minSB->setDecimals(1);
minSB->setMinimum(-model.getChannelsMax());
minSB->setSingleStep(0.1);
minSB->setMaximum(0);
minSB->setValue(float(model.limitData[i].min) / 10);
connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited()));
gridLayout->addWidget(minSB, i+1, col++, 1, 1);
minSpins << minSB;
limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].min, -model.getChannelsMax()*10, 0, -1000);
// Channel max
QDoubleSpinBox * maxSB = new QDoubleSpinBox(this);
maxSB->setProperty("index", i);
maxSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
maxSB->setAccelerated(true);
maxSB->setDecimals(1);
maxSB->setMinimum(0);
maxSB->setSingleStep(0.1);
maxSB->setMaximum(model.getChannelsMax());
maxSB->setValue(float(model.limitData[i].max) / 10);
connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited()));
gridLayout->addWidget(maxSB, i+1, col++, 1, 1);
maxSpins << maxSB;
limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].max, 0, model.getChannelsMax()*10, 1000);
// Channel inversion
QComboBox * invCB = new QComboBox(this);
@@ -117,6 +150,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
QSpinBox * center = new QSpinBox(this);
center->setProperty("index", i);
center->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
center->setSuffix("us");
center->setMinimum(1375);
center->setMaximum(1625);
center->setValue(1500);
@@ -134,6 +168,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
gridLayout->addWidget(symlimits, i+1, col++, 1, 1);
}
}
// Push the rows up
addVSpring(gridLayout, 0,firmware->getCapability(Outputs)+1);
@@ -142,6 +177,9 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
Channels::~Channels()
{
foreach(LimitsGroup *group, limitsGroups) {
delete group;
}
}
void Channels::symlimitsEdited()
@@ -164,46 +202,14 @@ void Channels::nameEdited()
}
}
void Channels::offsetEdited()
{
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
int index = dsb->property("index").toInt();
model.limitData[index].offset = round(dsb->value() * 10);
emit modified();
}
void Channels::minEdited()
{
QDoubleSpinBox *sb = qobject_cast<QDoubleSpinBox*>(sender());
int index = sb->property("index").toInt();
model.limitData[index].min = round(sb->value() * 10);
emit modified();
}
void Channels::maxEdited()
{
QDoubleSpinBox *sb = qobject_cast<QDoubleSpinBox*>(sender());
int index = sb->property("index").toInt();
model.limitData[index].max = round(sb->value() * 10);
emit modified();
}
void Channels::refreshExtendedLimits()
{
int channelMax = model.getChannelsMax();
int channelMaxValue = channelMax * 10;
for (int i=0; i<firmware->getCapability(Outputs); i++) {
QDoubleSpinBox * minDSB = minSpins[i];
QDoubleSpinBox * maxDSB = maxSpins[i];
minDSB->setMinimum(-channelMax);
maxDSB->setMaximum(+channelMax);
//reset any limit that is bigger than current maximum (dependent on extended limits setting)
if ( model.limitData[i].min < -channelMaxValue ) model.limitData[i].min = -channelMaxValue;
if ( model.limitData[i].max > +channelMaxValue ) model.limitData[i].max = +channelMaxValue;
foreach(LimitsGroup *group, limitsGroups) {
group->updateMinMax(10*channelMax);
}
emit modified();
}
+19 -5
View File
@@ -4,6 +4,24 @@
#include "modelpanel.h"
#include <QSpinBox>
class GVarGroup;
class LimitsGroup
{
public:
LimitsGroup(FirmwareInterface * firmware, QGridLayout *gridLayout, int row, int col, int & value, int min, int max, int deflt);
~LimitsGroup();
void updateMinMax(int max);
protected:
FirmwareInterface * firmware;
QDoubleSpinBox * spinbox;
GVarGroup * gvarGroup;
int & value;
double displayStep;
};
class Channels : public ModelPanel
{
Q_OBJECT
@@ -13,8 +31,7 @@ class Channels : public ModelPanel
~Channels();
private:
QVector<QDoubleSpinBox *> minSpins;
QVector<QDoubleSpinBox *> maxSpins;
QVector<LimitsGroup *> limitsGroups;
public slots:
void refreshExtendedLimits();
@@ -22,9 +39,6 @@ class Channels : public ModelPanel
private slots:
void symlimitsEdited();
void nameEdited();
void offsetEdited();
void minEdited();
void maxEdited();
void invEdited();
void curveEdited();
void ppmcenterEdited();
+8 -7
View File
@@ -318,11 +318,12 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
int index = fswtchFunc[i]->currentIndex();
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh32) {
if (index>=FuncOverrideCH1 && index<=FuncOverrideCH32) {
int channelsMax = model.getChannelsMax(true);
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125);
fswtchParam[i]->setMaximum(125);
fswtchParam[i]->setMinimum(-channelsMax);
fswtchParam[i]->setMaximum(channelsMax);
if (modified) {
model.funcSw[i].param = fswtchParam[i]->value();
}
@@ -506,7 +507,7 @@ void CustomFunctionsPanel::update()
lock = true;
for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
if (!initialized) {
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, generalSettings, POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[i], model.funcSw[i].func);
populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode);
populateFuncParamCB(fswtchParamT[i], model, model.funcSw[i].func, model.funcSw[i].param, model.funcSw[i].adjustMode);
@@ -527,7 +528,7 @@ void CustomFunctionsPanel::fswPaste()
FuncSwData *fsw = &model.funcSw[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
populateGVmodeCB(fswtchGVmode[selectedFunction], model.funcSw[selectedFunction].adjustMode);
populateFuncParamCB(fswtchParamT[selectedFunction], model, model.funcSw[selectedFunction].func, model.funcSw[selectedFunction].param, model.funcSw[selectedFunction].adjustMode);
@@ -543,7 +544,7 @@ void CustomFunctionsPanel::fswDelete()
model.funcSw[selectedFunction].clear();
// TODO update switch and func
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
lock = false;
@@ -590,7 +591,7 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
b->clear();
for (unsigned int i=0; i<FuncCount; i++) {
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
if (((i>=FuncSafetyCh1 && i<=FuncSafetyCh32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
+1 -1
View File
@@ -33,7 +33,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve);
populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings);
populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext);
ui->sideCB->setCurrentIndex(ed->mode-1);
+3 -3
View File
@@ -30,7 +30,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// Phase switch
if (phaseIdx > 0) {
populateSwitchCB(ui->swtch, phase.swtch, generalSettings);
populateSwitchCB(ui->swtch, phase.swtch, generalSettings, MixesContext);
connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int)));
}
else {
@@ -315,10 +315,10 @@ void FlightModePanel::phaseGVUse_currentIndexChanged(int index)
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int gvar = comboBox->property("index").toInt();
if (index == 0) {
phase.gvars[gvar]=0;
phase.gvars[gvar] = 0;
}
else {
phase.gvars[gvar] = 1024+index+(index>phaseIdx?1:0);
phase.gvars[gvar] = 1024 + index;
}
update();
emit modified();
+25 -18
View File
@@ -11,6 +11,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
ModelPanel(parent, model, generalSettings, firmware),
selectedSwitch(0)
{
int channelsMax = model.getChannelsMax(true);
QGridLayout * gridLayout = new QGridLayout(this);
int col = 1;
@@ -48,8 +50,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this);
cswitchValue[i]->setMaximum(125);
cswitchValue[i]->setMinimum(-125);
cswitchValue[i]->setMaximum(channelsMax);
cswitchValue[i]->setMinimum(-channelsMax);
cswitchValue[i]->setAccelerated(true);
cswitchValue[i]->setDecimals(0);
cswitchValue[i]->setProperty("index", i);
@@ -66,8 +68,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this);
cswitchOffset[i]->setProperty("index",i);
cswitchOffset[i]->setMaximum(125);
cswitchOffset[i]->setMinimum(-125);
cswitchOffset[i]->setMaximum(channelsMax);
cswitchOffset[i]->setMinimum(-channelsMax);
cswitchOffset[i]->setAccelerated(true);
cswitchOffset[i]->setDecimals(0);
connect(cswitchOffset[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
@@ -75,8 +77,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
v2Layout->addWidget(cswitchOffset[i]);
cswitchOffset2[i] = new QDoubleSpinBox(this);
cswitchOffset2[i]->setProperty("index",i);
cswitchOffset2[i]->setMaximum(125);
cswitchOffset2[i]->setMinimum(-125);
cswitchOffset2[i]->setMaximum(channelsMax);
cswitchOffset2[i]->setMinimum(-channelsMax);
cswitchOffset2[i]->setAccelerated(true);
cswitchOffset2[i]->setDecimals(0);
connect(cswitchOffset2[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
@@ -239,6 +241,7 @@ void LogicalSwitchesPanel::edited()
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, 0.1);
break;
case LS_FAMILY_STAY:
cswitchOffset2[i]->setSpecialValueText(tr("(instant)"));
if (sender() == cswitchOffset[i]) {
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, 0.0);
@@ -246,10 +249,12 @@ void LogicalSwitchesPanel::edited()
else {
model.customSw[i].val3 = TimToVal(cswitchOffset2[i]->value()) - model.customSw[i].val2;
}
updateTimerParam(cswitchOffset2[i], model.customSw[i].val2+model.customSw[i].val3, cswitchOffset[i]->value());
updateTimerParam(cswitchOffset2[i], model.customSw[i].val2+model.customSw[i].val3, cswitchOffset[i]->value()-0.1);
if (model.customSw[i].val3 == 0) {
cswitchOffset2[i]->setSuffix(tr("(infinite)"));
cswitchOffset2[i]->clear();
cswitchOffset2[i]->setSuffix("(release)");
}
else {
cswitchOffset2[i]->setSuffix("");
}
break;
default:
@@ -274,7 +279,6 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, doubl
else
sb->setSingleStep(0.1);
sb->setValue(value);
sb->setSuffix("");
}
#define SOURCE1_VISIBLE 0x1
@@ -320,21 +324,24 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
}
break;
case LS_FAMILY_STICKY:
mask &= ~DELAY_ENABLED;
// no break
case LS_FAMILY_VBOOL:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1), generalSettings);
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2), generalSettings);
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1), generalSettings, LogicalSwitchesContext);
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2), generalSettings, LogicalSwitchesContext);
break;
case LS_FAMILY_STAY:
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1), generalSettings);
mask &= ~DELAY_ENABLED;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1), generalSettings, LogicalSwitchesContext);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, 0.0);
updateTimerParam(cswitchOffset2[i], model.customSw[i].val2+model.customSw[i].val3, cswitchOffset[i]->value());
updateTimerParam(cswitchOffset2[i], model.customSw[i].val2+model.customSw[i].val3, cswitchOffset[i]->value()-0.1);
cswitchOffset2[i]->setSpecialValueText(tr("(instant)"));
if (model.customSw[i].val3 == 0) {
cswitchOffset2[i]->setSuffix(tr("(infinite)"));
cswitchOffset2[i]->clear();
cswitchOffset2[i]->setSuffix(tr("(release)"));
}
else {
cswitchOffset2[i]->setSuffix("");
}
break;
case LS_FAMILY_VCOMP:
@@ -410,7 +417,7 @@ void LogicalSwitchesPanel::populateCSWCB(QComboBox *b, int value)
void LogicalSwitchesPanel::populateAndSwitchCB(QComboBox *b, const RawSwitch & value)
{
if (IS_ARM(firmware->getBoard())) {
populateSwitchCB(b, value, generalSettings, POPULATE_ONOFF);
populateSwitchCB(b, value, generalSettings, LogicalSwitchesContext);
}
else {
RawSwitch item;
+1 -1
View File
@@ -76,7 +76,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
}
}
populateSwitchCB(ui->switchesCB, md->swtch, generalSettings);
populateSwitchCB(ui->switchesCB, md->swtch, generalSettings, MixesContext);
ui->warningCB->setCurrentIndex(md->mixWarn);
ui->mltpxCB->setCurrentIndex(md->mltpx);
int scale=firmware->getCapability(SlowScale);
+3 -3
View File
@@ -15,7 +15,7 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
lock = true;
// Mode
populateSwitchCB(ui->mode, timer.mode, generalSettings, POPULATE_TIMER_MODES);
populateSwitchCB(ui->mode, timer.mode, generalSettings, TimersContext);
if (!firmware->getCapability(PermTimers)) {
ui->persistent->hide();
@@ -210,8 +210,8 @@ void ModulePanel::update()
ui->label_protocol->setVisible(mask & MASK_PROTOCOL);
ui->protocol->setVisible(mask & MASK_PROTOCOL);
ui->label_rxNumber->setVisible(mask & MASK_FAILSAFES);
ui->rxNumber->setVisible(mask & MASK_FAILSAFES);
ui->label_rxNumber->setVisible(mask & MASK_RX_NUMBER);
ui->rxNumber->setVisible(mask & MASK_RX_NUMBER);
ui->rxNumber->setValue(model.modelId);
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
+9 -16
View File
@@ -31,12 +31,12 @@ PrintDialog::PrintDialog(QWidget *parent, FirmwareInterface * firmware, GeneralS
te->clear();
QString modelname=g_model->name;
if (modelname.isEmpty()) {
curvefile5=QString("%1/curve5.png").arg(qd->tempPath());
curvefile9=QString("%1/curve9.png").arg(qd->tempPath());
curvefile5=generateProcessUniqueTempFileName("curve5.png");
curvefile9=generateProcessUniqueTempFileName("curve9.png");
}
else {
curvefile5=QString("%1/%2-curve5.png").arg(qd->tempPath()).arg(modelname);
curvefile9=QString("%1/%2-curve9.png").arg(qd->tempPath()).arg(modelname);
curvefile5=generateProcessUniqueTempFileName(QString("%1-curve5.png").arg(modelname));
curvefile9=generateProcessUniqueTempFileName(QString("%1-curve9.png").arg(modelname));
}
printSetup();
if (gvars) {
@@ -60,19 +60,14 @@ PrintDialog::PrintDialog(QWidget *parent, FirmwareInterface * firmware, GeneralS
void PrintDialog::closeEvent(QCloseEvent *event)
{
if (printfilename.isEmpty()) {
QByteArray ba = curvefile5.toLatin1();
char *name = ba.data();
unlink(name);
ba = curvefile9.toLatin1();
name = ba.data();
unlink(name);
}
}
PrintDialog::~PrintDialog()
{
delete ui;
// notice PrintDialog::closeEvent() is not called if user clicks on Close button
qunlink(curvefile5);
qunlink(curvefile9);
delete ui;
}
QString doTC(const QString s, const QString color="", bool bold=false)
@@ -121,10 +116,8 @@ void PrintDialog::printSetup()
str.append(fv(tr("Protocol"), getProtocol(g_model))); //proto, numch, delay,
str.append(fv(tr("Pulse Polarity"), g_model->moduleData[0].polarityToString()));
str.append(fv(tr("Throttle Trim"), g_model->thrTrim ? tr("Enabled") : tr("Disabled")));
str.append(fv(tr("Throttle Expo"), g_model->thrExpo ? tr("Enabled") : tr("Disabled")));
// TODO str.append(fv(tr("Trim Switch"), getSWName(g_model->trimSw)));
str.append(fv(tr("Trim Increment"), getTrimInc(g_model)));
str.append(fv(tr("Center Beep"), getCenterBeep(g_model))); // specify which channels beep
str.append(fv(tr("Center Beep"), getCenterBeepStr(g_model))); // specify which channels beep
str.append("</td></tr></table></td>");
if (!gvars) {
str.append("<td width=\"380\">");
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+50 -50
View File
@@ -1458,82 +1458,82 @@ Behöver inte vara samma som menyspråket</translation>
<message>
<location filename="../modeledit/templates.cpp" line="+39"/>
<source>Simple 4-CH</source>
<translation type="unfinished"></translation>
<translation>Enkel 4-Kanal</translation>
</message>
<message>
<location line="+1"/>
<source>T-Cut</source>
<translation type="unfinished"></translation>
<translation>Gas-klipp</translation>
</message>
<message>
<location line="+1"/>
<source>Sticky T-Cut</source>
<translation type="unfinished"></translation>
<translation>Sticky Gas-Klipp</translation>
</message>
<message>
<location line="+1"/>
<source>V-Tail</source>
<translation type="unfinished">V-stjärt</translation>
<translation>V-stjärt</translation>
</message>
<message>
<location line="+1"/>
<source>Elevon\Delta</source>
<translation type="unfinished"></translation>
<translation>Flygande vinge/Deltavinge</translation>
</message>
<message>
<location line="+1"/>
<source>Heli Setup</source>
<translation type="unfinished"></translation>
<translation>Helikopter</translation>
</message>
<message>
<location line="+1"/>
<source>Heli Setup with gyro gain control</source>
<translation type="unfinished"></translation>
<translation>Helikopter med gyro-gain</translation>
</message>
<message>
<location line="+1"/>
<source>Gyro gain control</source>
<translation type="unfinished"></translation>
<translation>Gyrogain-kontroll</translation>
</message>
<message>
<location line="+1"/>
<source>Heli Setup (Futaba&apos;s channel assignment style)</source>
<translation type="unfinished"></translation>
<translation>Helikopter (Futabas kanalordning)</translation>
</message>
<message>
<location line="+1"/>
<source>Heli Setup with gyro gain control (Futaba&apos;s channel assignment style)</source>
<translation type="unfinished"></translation>
<translation>Helikopter med gyro gain (Futabas kanalordning)</translation>
</message>
<message>
<location line="+1"/>
<source>Gyro gain control (Futaba&apos;s channel assignment style)</source>
<translation type="unfinished"></translation>
<translation>Gyrogain-kontroll (Futabas kanalordning)</translation>
</message>
<message>
<location line="+1"/>
<source>Servo Test</source>
<translation type="unfinished"></translation>
<translation>Servotest</translation>
</message>
<message>
<location line="+1"/>
<source>MultiCopter</source>
<translation type="unfinished"></translation>
<translation>Multikopter</translation>
</message>
<message>
<location line="+1"/>
<source>Use Model Config Wizard</source>
<translation type="unfinished"></translation>
<translation>Använd Modellguiden</translation>
</message>
<message>
<location line="+29"/>
<source>Apply Template?</source>
<translation type="unfinished"></translation>
<translation>Använd Mall?</translation>
</message>
<message>
<location line="+0"/>
<source>Apply template &quot;%1&quot;?</source>
<translation type="unfinished"></translation>
<translation>Använd Mall &quot;%1&quot;?</translation>
</message>
<message>
<location line="+88"/>
@@ -1544,7 +1544,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+2"/>
<location line="+129"/>
<source>RUD</source>
<translation type="unfinished">ROD</translation>
<translation>ROD</translation>
</message>
<message>
<location line="-316"/>
@@ -1558,14 +1558,14 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+113"/>
<location line="+1"/>
<source>ELE</source>
<translation type="unfinished">HÖJ</translation>
<translation>HJD</translation>
</message>
<message>
<location line="-298"/>
<location line="+171"/>
<location line="+122"/>
<source>THR</source>
<translation type="unfinished">GAS</translation>
<translation>GAS</translation>
</message>
<message>
<location line="-277"/>
@@ -1577,7 +1577,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+94"/>
<location line="+1"/>
<source>AIL</source>
<translation type="unfinished">SKE</translation>
<translation>SKE</translation>
</message>
<message>
<location line="-279"/>
@@ -1585,7 +1585,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+185"/>
<location line="+6"/>
<source>AIL2</source>
<translation type="unfinished"></translation>
<translation>SKE2</translation>
</message>
<message>
<location line="-184"/>
@@ -1593,7 +1593,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+185"/>
<location line="+6"/>
<source>ELE2</source>
<translation type="unfinished"></translation>
<translation>HJD2</translation>
</message>
<message>
<location line="-187"/>
@@ -1603,7 +1603,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+94"/>
<location line="+1"/>
<source>FLAPS</source>
<translation type="unfinished"></translation>
<translation>FLAPS</translation>
</message>
<message>
<location line="-272"/>
@@ -1613,7 +1613,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+89"/>
<location line="+6"/>
<source>FLAP%1</source>
<translation type="unfinished"></translation>
<translation>FLAP%1</translation>
</message>
<message>
<location line="-252"/>
@@ -1621,7 +1621,7 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+21"/>
<location line="+4"/>
<source>PITCH</source>
<translation type="unfinished"></translation>
<translation>PITCH</translation>
</message>
<message>
<location line="-16"/>
@@ -1633,41 +1633,41 @@ Behöver inte vara samma som menyspråket</translation>
<location line="+3"/>
<location line="+1"/>
<source>GYRO</source>
<translation type="unfinished"></translation>
<translation>GYRO</translation>
</message>
<message>
<location line="+118"/>
<location line="+1"/>
<source>SPOIL</source>
<translation type="unfinished"></translation>
<translation>SPOIL</translation>
</message>
<message>
<location line="+14"/>
<location line="+6"/>
<source>SPOIL%1</source>
<translation type="unfinished"></translation>
<translation>SPOIL%1</translation>
</message>
<message>
<location line="+39"/>
<location line="+6"/>
<source>RUD2</source>
<translation type="unfinished"></translation>
<translation>ROD2</translation>
</message>
<message>
<location line="+203"/>
<location line="+112"/>
<source>Clear Mixes?</source>
<translation type="unfinished">Ta bort mixarna?</translation>
<translation>Nollställ mixarna?</translation>
</message>
<message>
<location line="-112"/>
<source>Really clear existing mixes on CH6?</source>
<translation type="unfinished"></translation>
<translation>Vill du verkligen ta bort mixarna på kanal 6?</translation>
</message>
<message>
<location line="+112"/>
<source>Really clear existing mixes on CH5?</source>
<translation type="unfinished"></translation>
<translation>Vill du verkligen ta bort mixarna på kanal 5?</translation>
</message>
</context>
<context>
@@ -6480,7 +6480,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+383"/>
<source>Override %1</source>
<translation type="unfinished"></translation>
<translation>I stället för %1</translation>
</message>
<message>
<location line="+2"/>
@@ -6655,7 +6655,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+1"/>
<source>Cell</source>
<translation>Batt</translation>
<translation>Cell</translation>
</message>
<message>
<location line="+43"/>
@@ -6713,7 +6713,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+13"/>
<source>Speed+</source>
<translation type="unfinished"></translation>
<translation>Hastighet+</translation>
</message>
<message>
<location line="+0"/>
@@ -7044,7 +7044,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="-627"/>
<source>(displaying only first 10 warnings)</source>
<translation type="unfinished"></translation>
<translation>(enbart de 10 första varningarna visas)</translation>
</message>
<message>
<location line="+660"/>
@@ -8336,13 +8336,13 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+452"/>
<source>OpenTX doesn&apos;t accept this telemetry protocol</source>
<translation type="unfinished"></translation>
<translation>OpenTX accepterar inte detta telemetri-protokoll</translation>
</message>
<message>
<location line="+104"/>
<location line="+5"/>
<source>OpenTX doesn&apos;t accept this radio protocol</source>
<translation type="unfinished"></translation>
<translation>OpenTX accepterar inte detta radio-protokoll</translation>
</message>
<message>
<source>OpenTX doesn&apos;t accept this protocol</source>
@@ -8389,7 +8389,7 @@ eeprom-storleken är 4096, men enbart den första hälften används</translation
<message>
<location line="+1"/>
<source>No OverrideCH functions available</source>
<translation type="unfinished"></translation>
<translation>Inga funktioner finns för att ersätta kanaldata</translation>
</message>
<message>
<location line="+37"/>
@@ -8532,12 +8532,12 @@ OpenTX-gruppen.</translation>
<message>
<location filename="../eeprominterface.h" line="+957"/>
<source>Positive</source>
<translation type="unfinished">Positiv</translation>
<translation>Positiv</translation>
</message>
<message>
<location line="+0"/>
<source>Negative</source>
<translation type="unfinished">Negativ</translation>
<translation>Negativ</translation>
</message>
</context>
<context>
@@ -8761,7 +8761,7 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga
<location line="+23"/>
<location line="+1"/>
<source>Outputs</source>
<translation type="unfinished">Utgångar</translation>
<translation>Utgångar</translation>
</message>
<message>
<location line="+153"/>
@@ -8827,7 +8827,7 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga
<message>
<location line="+638"/>
<source>Outputs2</source>
<translation type="unfinished"></translation>
<translation>Outputs2</translation>
</message>
<message>
<location line="+13"/>
@@ -8900,7 +8900,7 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga
<message>
<location line="+219"/>
<source>Outputs2</source>
<translation type="unfinished"></translation>
<translation>Outputs2</translation>
</message>
<message>
<location line="+13"/>
@@ -9499,17 +9499,17 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga
<message>
<location line="-189"/>
<source>FrSky S.PORT</source>
<translation type="unfinished">FrSky S.PORT</translation>
<translation>FrSky S.PORT</translation>
</message>
<message>
<location line="+1"/>
<source>FrSky D</source>
<translation type="unfinished">FrSky D</translation>
<translation>FrSky D</translation>
</message>
<message>
<location line="+2"/>
<source>FrSky D (cable)</source>
<translation type="unfinished"></translation>
<translation>FrSky D (kabel)</translation>
</message>
<message>
<location line="+187"/>
@@ -9629,17 +9629,17 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga
<message>
<location line="+4"/>
<source>Not persistent</source>
<translation type="unfinished"></translation>
<translation>Ej bestående</translation>
</message>
<message>
<location line="+1"/>
<source>Persistent (flight)</source>
<translation type="unfinished"></translation>
<translation>Bestående (under flygning)</translation>
</message>
<message>
<location line="+1"/>
<source>Persistent (manual reset)</source>
<translation type="unfinished"></translation>
<translation>Bestående (återställs manuellt)</translation>
</message>
</context>
<context>
-1
View File
@@ -136,7 +136,6 @@ void saveModel(ModelData & m, model & xm)
trims xtrims;
xtrims.extended(m.extendedTrims);
xtrims.throttleTrim(m.thrTrim);
xtrims.throttleTrimExpo(m.thrExpo);
xm.trims(xtrims);
}
if (m.beepANACenter) {
+155 -108
View File
@@ -1,200 +1,247 @@
<h2>Version 2.0.12 / 2014-09-16</h2>
[Taranis]
<ul>
<li>LTR patch (modified) applied to the Lua code. Saves around 8-10k RAM</li>
<li>Lua hardening again!</li>
<li>bit32 lib added to the Lua interpreter</li>
<li>Audio tones distorsion (just after playing a wav file)</li>
<li>ABS changed to ON in Timers modes</li>
<li>S2 and S3 pots inverted on Taranis+</li>
</ul>
<h2>Version 2.0.11 / 2014-09-10</h2>
[9XR-PRO]
<ul>
<li>Audio broken (since we changed the ARM GCC compiler)</li>
</ul>
[Taranis]
<ul>
<li>Switch warning didn't allow access to SG</li>
<li>Pot warning would show S3 when the cursor wasn't on the Pot Warning line</li>
</ul>
<h2>Version 2.0.10 / 2014-09-08</h2>
[All]
<ul>
<li>Duration and AND fixed on Sticky and Edge logical switches</li>
</ul>
[Taranis]
<ul>
<li>CCPM issue on Helis when cross trims used</li>
<li>Taranis+ LCD color range and brightness adjusted</li>
<li>Taranis+ SWR removed</li>
<li>Lua small enhancements (TIMEHOUR constant, GVARS over 500)</li>
<li>Lua hardening, use of newlib-nano (optimizes RAM usage)</li>
<li>Incoming telemetry rejected if RSSI=0</li>
<li>Assign Bitmap impossible if filename length too big</li>
</ul>
[9XR-PRO]
<ul>
<li>Telemetry enabled</li>
</ul>
<h2>Version 2.0.8 / 2014-07-23</h2>
[Taranis]
<ul>
<li>Curve wrongly displayed when used in an Input with a positive offset
<li>Telemetry Channels are now accessible through Lua
<li>New string Lua fields added for accessing sources
<li>Trims now applied on Inputs when used in Logical Switches
<li>Option "nojoystick" added
<li>Curve wrongly displayed when used in an Input with a positive offset</li>
<li>Telemetry Channels are now accessible through Lua</li>
<li>New string Lua fields added for accessing sources</li>
<li>Trims now applied on Inputs when used in Logical Switches</li>
<li>Option "nojoystick" added</li>
</ul>
<h2>Version 2.0.7 / 2014-07-15</h2>
[Taranis]
<ul>
<li>Instant Trim problem when using a negative curve
<li>Instant Trim problem when using a negative curve</li>
</ul>
[All]
<ul>
<li>SafetyCH function was missing on the compilation server
<li>SafetyCH function was missing on the compilation server</li>
</ul>
<h2>Version 2.0.6 / 2014-07-13</h2>
[Taranis]
<ul>
<li>Telemetry Type field is hidden when only S.PORT is available
<li>Permanent timers may be not resetted on Flight Reset
<li>Instant Trim bugfix
<li>No sound on trim press when trim option disabled
<li>[Page] / [Page Long] allowed to change Telemetry screen
<li>XXL font added for Lua telemetry screens
<li>
<li>Telemetry Type field is hidden when only S.PORT is available</li>
<li>Permanent timers may be not resetted on Flight Reset</li>
<li>Instant Trim bugfix</li>
<li>No sound on trim press when trim option disabled</li>
<li>[Page] / [Page Long] allowed to change Telemetry screen</li>
<li>XXL font added for Lua telemetry screens</li>
</ul>
[9XR-PRO / Sky9x]
<ul>
<li>RTC time was not stored correctly
<li>PPM polarity fix
<li>RTC time was not stored correctly</li>
<li>PPM polarity fix</li>
</ul>
[Gruvin9x, 9X128, 9XR128]
<ul>
<li>12 logical switches instead of 15 (the extra ones were not accessible in custom functions)
<li>12 logical switches instead of 15 (the extra ones were not accessible in custom functions)</li>
</ul>
[All]
<ul>
<li>Logical switches were not resetted on Model load
<li>SafetyCH function can be hidden (depending on Companion options)
<li>MPH to km/h conversion improved
<li>Logical switches were not resetted on Model load</li>
<li>SafetyCH function can be hidden (depending on Companion options)</li>
<li>MPH to km/h conversion improved</li>
</ul>
<h2>Version 2.0.5 / 2014-06-26</h2>
[Taranis]
<ul>
<li>Add Flight Mode indication to the mixer/inputs screens
<li>Joystick emulation fixed
<li>Fixed float number display in Lua
<li>Fixed telemetry screens page order (Lua, custom, voltage, GPS)
<li>Fixed unability to disable switch warning for SG
<li>Lua bugfixes in getCustomFunction/setCustomFunction and getLogicalSwitch/setLogicalSwitch
<li>Add Flight Mode indication to the mixer/inputs screens</li>
<li>Joystick emulation fixed</li>
<li>Fixed float number display in Lua</li>
<li>Fixed telemetry screens page order (Lua, custom, voltage, GPS)</li>
<li>Fixed unability to disable switch warning for SG</li>
<li>Lua bugfixes in getCustomFunction/setCustomFunction and getLogicalSwitch/setLogicalSwitch</li>
</ul>
<h2>Version 2.0.4 / 2014-06-24</h2>
[Taranis]
<ul>
<li>Lua Telemetry custom screens added
<li>Lua wrong memory used indication
<li>Telemetry on the serial port in the battery bay
<li>
<li>Lua Telemetry custom screens added</li>
<li>Lua wrong memory used indication</li>
<li>Telemetry on the serial port in the battery bay</li>
</ul>
[All]
<ul>
<li>Air Speed added in Logs
<li>|d|>x bug fix
<li>Air Speed added in Logs</li>
<li>|d|>x bug fix</li>
<li>Timers played even if 00:00
</ul>
<h2>Version 2.0.3 / 2014-06-17</h2>
<ul>
<li>Bugfix on Reset Flight function (possible freeze of the menus)
<li>Imperial units bug (on altitude)
<li>FIRMWARE.BIN and EEPROM.BIN are not anymore marked as system files
<li>Bugfix on Reset Flight function (possible freeze of the menus)</li>
<li>Imperial units bug (on altitude)</li>
<li>FIRMWARE.BIN and EEPROM.BIN are not anymore marked as system files</li>
</ul>
<h2>Version 2.0.2 / 2014-06-12</h2>
<ul>
<li>RxBatt removed (merged with A1 as before)
<li>Bootloader accessible through the 2 trims (as 2.0.0)
<li>Delay on switches middle position only applied to Play functions
<li>Delay for Play functions is configurable (0-300ms)
<li>SWR, A3 and A4 now recorded in SD logs
<li>Persistent mAh was not correctly stored in EEPROM
<li>A lot of small bug fixes
<li>RxBatt removed (merged with A1 as before)</li>
<li>Bootloader accessible through the 2 trims (as 2.0.0)</li>
<li>Delay on switches middle position only applied to Play functions</li>
<li>Delay for Play functions is configurable (0-300ms)</li>
<li>SWR, A3 and A4 now recorded in SD logs</li>
<li>Persistent mAh was not correctly stored in EEPROM</li>
<li>A lot of small bug fixes</li>
</ul>
<h2>OpenTX 2.0.1 / 2014-02-05</h2>
[Taranis]
<ul>
<li>S.PORT / D protocol choice added in TELEMETRY menu
<li>Heli mixer fix (stick modes 2/3/4)
<li>Multipos switch fix
<li>Italian translations updated
<li>French translations fixes
<li>Multis Wizard added
<li>Bootloader now needs only one trim pressed
<li>S3 warning hidden (no S3 on Taranis)
<li>Persistent mAh was broken
<li>S.PORT / D protocol choice added in TELEMETRY menu</li>
<li>Heli mixer fix (stick modes 2/3/4)</li>
<li>Multipos switch fix</li>
<li>Italian translations updated</li>
<li>French translations fixes</li>
<li>Multis Wizard added</li>
<li>Bootloader now needs only one trim pressed</li>
<li>S3 warning hidden (no S3 on Taranis)</li>
<li>Persistent mAh was broken</li>
</ul>
[Stock]
<ul>
<li>Fix for LS used as source
<li>Fix for LS used as source</li>
</ul>
[All]
<ul>
<li>Fix on d>=x logical switches
<li>Fix on d>=x logical switches</li>
</ul>
<h2>OpenTX 2.0.0 / 2014-06-02</h2>
[Taranis]
<ul>
<li>Inputs layer with support for all physical inputs and telemetry
<li>Lua interpreter for runtime scripts and one-time configuration assistants
<li>GVARs useable for offsets and limits
<li>GVAR modification popup on home screen can be enabled/disabled for each GVAR
<li>Output curve assignable to each servo on the SERVOS page
<li>32 curves instead of 16, with smoothing, and any number of points between 2 and 17
<li>Pot position memory for the 4 pots, with startup warning
<li>Copy/paste/insert/delete of custom function lines
<li>Altitude can be displayed in the top bar
<li>FrSky Taranis will run at 120MHz instead of 60MHz
<li>New trim system (a mode's trims can be relative to that of another mode's)
<li>SPORT data form internal module available on the UART connector in the battery compartment in the Taranis
<li>Support for 6-position pots, with individual positions available in the switch selection list
<li>Taranis will be useable as a standard PC joystick through USB, 8 analogs and 8 buttons mapped to CH1-8 and 9-16 respectively
<li>Inputs layer with support for all physical inputs and telemetry</li>
<li>Lua interpreter for runtime scripts and one-time configuration assistants</li>
<li>GVARs useable for offsets and limits</li>
<li>GVAR modification popup on home screen can be enabled/disabled for each GVAR</li>
<li>Output curve assignable to each servo on the SERVOS page</li>
<li>32 curves instead of 16, with smoothing, and any number of points between 2 and 17</li>
<li>Pot position memory for the 4 pots, with startup warning</li>
<li>Copy/paste/insert/delete of custom function lines</li>
<li>Altitude can be displayed in the top bar</li>
<li>FrSky Taranis will run at 120MHz instead of 60MHz</li>
<li>New trim system (a mode's trims can be relative to that of another mode's)</li>
<li>SPORT data form internal module available on the UART connector in the battery compartment in the Taranis</li>
<li>Support for 6-position pots, with individual positions available in the switch selection list</li>
<li>Taranis will be useable as a standard PC joystick through USB, 8 analogs and 8 buttons mapped to CH1-8 and 9-16 respectively</li>
</ul>
[ARM Boards]
<ul>
<li>Measured consumption (mAh) can be stored on power off
<li>0.1% resolution for limits
<li>Sound repeat time settable in multiples of 1sec, call at model load can be disabled
<li>3 options for timer countdown voice output
<li>9 GVARS instead of 5 (ARM boards only)
<li>64 custom functions instead of 32
<li>Ability to read text files from the SD card. A file with the name of a model will be linked to it and easily accessible as "model notes". Can be displayed automatically at model load for use as a checklist
<li>Bootloader added, removes the need to install computer drivers to flash new firmware
<li>Radio can handle EEPROM conversion by itself (no need for companion)
<li>Improved vario sounds
<li>Default audio files can be placed on the SD card for each model for all switch positions (both for physical and logical switches).
<li>Support for up to 16 channels on trainer input
<li>Measured consumption (mAh) can be stored on power off</li>
<li>0.1% resolution for limits</li>
<li>Sound repeat time settable in multiples of 1sec, call at model load can be disabled</li>
<li>3 options for timer countdown voice output</li>
<li>9 GVARS instead of 5 (ARM boards only)</li>
<li>64 custom functions instead of 32</li>
<li>Ability to read text files from the SD card. A file with the name of a model will be linked to it and easily accessible as "model notes". Can be displayed automatically at model load for use as a checklist</li>
<li>Bootloader added, removes the need to install computer drivers to flash new firmware</li>
<li>Radio can handle EEPROM conversion by itself (no need for companion)</li>
<li>Improved vario sounds</li>
<li>Default audio files can be placed on the SD card for each model for all switch positions (both for physical and logical switches)</li>
<li>Support for up to 16 channels on trainer input</li>
</ul>
[All]
<ul>
<li>Proportional fonts
<li>Switch warnings can be disabled for switches you don't use on a given model
<li>Compensation for offset error of FrSky FAS-xx current sensors (option on m64)
<li>Companion merged into OpenTX
<li>Companion major code / graphics refactoring
<li>Sticky Logical Switches
<li>ASpd, dTE, Cel-, Vfas- added to Telemetry values
<li>Workaround for newer bogus FlySky modules that send out servo centers on powerup (9x only)
<li>Finnish language support
<li>Proportional fonts</li>
<li>Switch warnings can be disabled for switches you don't use on a given model</li>
<li>Compensation for offset error of FrSky FAS-xx current sensors (option on m64)</li>
<li>Companion merged into OpenTX</li>
<li>Companion major code / graphics refactoring</li>
<li>Sticky Logical Switches</li>
<li>ASpd, dTE, Cel-, Vfas- added to Telemetry values</li>
<li>Workaround for newer bogus FlySky modules that send out servo centers on powerup (9x only)</li>
<li>Finnish language support</li>
</ul>
<h2>2940 / 2014-02-02</h2>
[ARM Boards]
<ul>
<li>Wav files played even in silent mode
<li>GPS support had broken VFAS
<li>Wav files played even in silent mode</li>
<li>GPS support had broken VFAS</li>
</ul>
[All]
<ul>
<li>Custom function triggered by a CSW based on analog triggering erroneously at powerup
<li>Problem with mixer weight field when !GVARS
<li>PPM5 was broken
<li>Custom function triggered by a CSW based on analog triggering erroneously at powerup</li>
<li>Problem with mixer weight field when !GVARS</li>
<li>PPM5 was broken</li>
</ul>
<h2>2923 / 2014-01-08</h2>
[ARM Boards]
<ul>
<li>Audio freeze bug fixed
<li>Aurora gimbals support
<li>Audio freeze bug fixed</li>
<li>Aurora gimbals support</li>
</ul>
<h2>2834 / 2013-10-29</h2>
[ARM Boards]
<ul>
<li>Altitude played without decimal when &gt;= 10m
<li>Check to avoid too long paths when playing SD files
<li>Altitude played without decimal when &gt;= 10m</li>
<li>Check to avoid too long paths when playing SD files</li>
</ul>
[All]
<ul>
<li>Mixer bug when a MULTIPLY mix used with a slow
<li>GVAR popup removed
<li>Sticky virtual switches are reset when ResetFlight function is called
<li>Mixer bug when a MULTIPLY mix used with a slow</li>
<li>GVAR popup removed</li>
<li>Sticky virtual switches are reset when ResetFlight function is called </li>
</ul>
<h2>2768 / 2013-09-20</h2>
@@ -278,26 +325,26 @@
<ul>
<li>Flash savings</li>
<li>Vario sink tones removed</li>
<li>Audio files renumbered (see here) </li>
<li>Audio files renumbered (see here)</li>
</ul>
[Sky9x]
<ul>
<li>Audio mixer: several sounds can now be played simulataneously, and beeps won't interrupt and clear voice alerts anymore. Note that sound files now need to have sampling rates of either 8, 16 or 32kHz and may need to be replaced. </li>
<li>Audio mixer: several sounds can now be played simulataneously, and beeps won't interrupt and clear voice alerts anymore. Note that sound files now need to have sampling rates of either 8, 16 or 32kHz and may need to be replaced</li>
</ul>
<h2>2413 / 2013-05-22</h2>
[All]
<ul>
<li>Calibration screen automatically appears following an EEPROM format</li>
<li>Wraparound in popup menus </li>
<li>Wraparound in popup menus</li>
</ul>
[9X Stock]
<ul>
<li>More options supported (novario / nogps / nogauges)</li>
<li>Flash savings</li>
<li>Mavlink huge rework by Rienk! </li>
<li>Mavlink huge rework by Rienk!</li>
</ul>
[Sky9x]
@@ -309,17 +356,17 @@
<h2>2215 / 2013-04-05</h2>
[All]
<ul>
<li>New option AUTOSOURCE to automatically select the stick / pot / switch which is moved when editing a Mix source </li>
<li>New option AUTOSOURCE to automatically select the stick / pot / switch which is moved when editing a Mix source</li>
</ul>
[9X Stock]
<ul>
<li>All prompts renumbered to have the "custom" prompts starting at 0 and to be able to use PlayTrack?(GVAR) with Adjust(GVAR) to play tracks sequences </li>
<li>All prompts renumbered to have the "custom" prompts starting at 0 and to be able to use PlayTrack?(GVAR) with Adjust(GVAR) to play tracks sequences</li>
</ul>
[Gruvin9x]
<ul>
<li>Possibility to have both BEEPER and SPEAKER enable in the same time </li>
<li>Possibility to have both BEEPER and SPEAKER enable in the same time</li>
</ul>
[Sky9x]
@@ -329,5 +376,5 @@
<li>Possibility to have both BEEPER and SPEAKER enable in the same time</li>
<li>New menu in Main Views / Telemetry Views</li>
<li>Vario sounds improved!</li>
<li>SD Folders renamed. "9XSOUNDS" becomes "SOUNDS", don't forget to updateyour cards!</li>
<li>SD Folders renamed. "9XSOUNDS" becomes "SOUNDS", don't forget to update your SD card!</li>
</ul>
+1
View File
@@ -26,3 +26,4 @@
/gtests.d
/lua_exports.cpp
/lua_exports.txt
/lua_fields.txt
+33 -23
View File
@@ -69,7 +69,7 @@ FAI = NO
# the latests deliveries for Turnigy 9x transmitters (since 2 years now, 2014) do not stop sending if no pulses are generated.
# This fact totally breaks the nice throttle and switch warning concept, because even we prevent sending pulses the
# transmitter modul ignores this, and continous to send the last value or 0 at beginning. And 0 means in the middle of throttle -> 50%.
# transmitter module ignores this, and continues to send the last value or 0 at beginning. And 0 means in the middle of throttle -> 50%.
# To cope with this situation, we need a new concept how to handle throttle and switch warnings.
# if you have a 0 value (50% ) for throttle, while throttle warning is active, you should activate this switch
# Values = YES, NO
@@ -126,7 +126,7 @@ CORRECT_NEGATIVE_VALUES = YES
ARITHMETIC_OVERFLOW_CHECK = NO
# increases resolution for throttle statistics and throttle counting, in very rare cases.
# this will be only true if an output channel is used for throttle calculation, and this chanenel has changed limits, e.g. -90% to +80%
# this will be only true if an output channel is used for throttle calculation, and this channel has changed limits, e.g. -90% to +80%
# if you use standard limits for throttle or directly the throttle stick you do not need to bother about this option
# not valid for ARM based transmitters like Taranis, They do not have this rounding issue at all
# Values = YES, NO
@@ -161,7 +161,7 @@ FONT = STD
# Values = YES, NO
PPM_CENTER_ADJUSTABLE = NO
# PPM symetrical limits
# PPM symmetrical limits
# Values = YES, NO
PPM_LIMITS_SYMETRICAL = NO
@@ -247,7 +247,7 @@ EEPROM_PROGRESS_BAR = NO
# Activates the DEBUG Mode (all boards)
# On G9X V4 board, when VOICE=NO:
# PORTH:7 --> Transistion LOW to HIGH = start of setupPulses(). Transistion HIGH to LOW = end of setupPulses().
# PORTH:7 --> Transition LOW to HIGH = start of setupPulses(). Transition HIGH to LOW = end of setupPulses().
# PORTH:6 --> LOW->HIGH = start of mixer calcs. HIGH->LOW, end of mixer calcs.
# Values = YES, NO
DEBUG = NO
@@ -282,13 +282,17 @@ MENUS_LOCK = NO
# MASSSTORAGE: The TX will appear as a drive
USB = JOYSTICK
# Channel monitor display behaviour
# Channel monitor display behavior
# Values = NO, YES
# YES - hide the fact that channel is inverted in limits tab
# and show inverted channel value with oposite sign
# NO - normal behaviour, show real channel values
# and show inverted channel value with opposite sign
# NO - normal behavior, show real channel values
CHANNELS_MONITOR_INV_HIDE = NO
# Use newlib-nano
# Values = NO, YES
NANO = NO
#------- END BUILD OPTIONS ---------------------------
# Define programs and commands.
@@ -296,7 +300,7 @@ SHELL = sh
IMG2LBM = -python ../util/img2lbm.py
BIN2LBM = -python ../util/bin2lbm.py
TRANSLATE = -python ../util/translate.py
VERSION = 2.0.8
VERSION = 2.0.12
SRC =
CPPSRC =
@@ -718,6 +722,12 @@ ifeq ($(PCB), TARANIS)
EXTRABOARDSRC += targets/taranis/usbd_storage_msd.cpp
endif
ifeq ($(NANO), YES)
# use newlib-nano for linking
NEWLIB_NANO_FLAGS = --specs=nano.specs -u _printf_float
CPPDEFS += -DNANO
endif
ifneq ($(LUA), NO)
ifeq ($(LUA), YES)
CPPDEFS += -DLUA_MODEL_SCRIPTS
@@ -726,9 +736,8 @@ ifeq ($(PCB), TARANIS)
INCDIRS += lua/src
CPPSRC += lua.cpp
LUASRC = lua/src/lapi.c lua/src/lcode.c lua/src/lctype.c lua/src/ldebug.c lua/src/ldo.c lua/src/ldump.c lua/src/lfunc.c lua/src/lgc.c lua/src/llex.c lua/src/lmem.c \
lua/src/lobject.c lua/src/lopcodes.c lua/src/lparser.c lua/src/lstate.c lua/src/lstring.c lua/src/ltable.c lua/src/ltm.c lua/src/lundump.c lua/src/lvm.c lua/src/lzio.c \
lua/src/lbaselib.c lua/src/linit.c lua/src/lmathlib.c lua/src/loadlib.c lua/src/lauxlib.c lua/src/ltablib.c lua/src/lcorolib.c
# lua/src/loslib.c lua/src/lbitlib.c lua/src/lstrlib.c lua/src/liolib.c lua/src/ldblib.c
lua/src/lobject.c lua/src/lopcodes.c lua/src/lparser.c lua/src/lstate.c lua/src/lstring.c lua/src/ltable.c lua/src/lrotable.c lua/src/ltm.c lua/src/lundump.c lua/src/lvm.c lua/src/lzio.c \
lua/src/lbaselib.c lua/src/linit.c lua/src/lmathlib.c lua/src/lbitlib.c lua/src/loadlib.c lua/src/lauxlib.c lua/src/ltablib.c lua/src/lcorolib.c
SRC += $(LUASRC)
LUADEP = lua_exports.cpp
endif
@@ -1278,9 +1287,10 @@ bitmaps/sticks.lbm: bitmaps/sticks_4x1.xbm bitmaps/splash_9x.xbm bitmaps/splash_
lua_exports.cpp: myeeprom.h ../util/luaexport.py
@echo "Generating a list of Lua exported constants in lua_exports.txt"
@$(CPP) -DPCBTARANIS -DCPUARM -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports.txt
@$(CPP) -DPCBTARANIS -DCPUARM -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports.txt
@echo "Parsing and generating C Lua exports in lua_exports.cpp"
@python ../util/luaexport.py lua_exports.txt lua_exports.cpp
@python ../util/luaexport.py $(VERSION) lua_exports.txt lua_exports.cpp lua_fields.txt
@rm lua_exports.txt
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
@@ -1323,7 +1333,7 @@ FOXLIB=-L/usr/local/lib \
-Wl,-rpath,$(FOXPATH)/src/.libs
simu: $(LUADEP) stamp_header $(BOARDSRC) $(CPPSRC) Makefile simu.cpp targets/simu/simpgmspace.cpp *.h tra lbm eeprom.bin
g++ $(CPPFLAGS) $(INCFLAGS) simu.cpp $(BOARDSRC) $(CPPSRC) $(LUASRC) targets/simu/simpgmspace.cpp -MD -DSIMU -O0 -o simu $(FOXINC) $(FOXLIB) -pthread -fexceptions
g++ $(CPPFLAGS) $(INCFLAGS) simu.cpp $(BOARDSRC) $(CPPSRC) $(LUASRC) targets/simu/simpgmspace.cpp -MD -DSIMU -DLUA_USE_APICHECK -O0 -o simu $(FOXINC) $(FOXLIB) -pthread -fexceptions
eeprom.bin:
dd if=/dev/zero of=$@ bs=1 count=2048
@@ -1339,7 +1349,7 @@ else
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O ihex opentx.elf opentx.hex
$(OBJCOPY) -O ihex opentx.elf opentx.hex
endif
%.bin: %.elf
@@ -1389,7 +1399,7 @@ OBJS = $(TMP:.s=.o)
@echo
@echo $(MSG_COMPILING) $@
$(CC) $(ARMCPPFLAGS) $< -o allsrc.o
$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections -o $@
$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections $(NEWLIB_NANO_FLAGS) -o $@
endif
# Target: clean project.
@@ -1419,7 +1429,7 @@ clean_list :
$(REMOVE) stamp-opentx.h
$(REMOVE) bitmaps/*.lbm
$(REMOVE) fonts/*/*.lbm
$(REMOVE) lua_exports.txt lua_exports.cpp
$(REMOVE) lua_exports.txt lua_exports.cpp lua_fields.txt
$(MAKE) -C bootloader clean
#### Install
@@ -1429,12 +1439,12 @@ AVRCOMMAND = $(AVRDUDE) $(AVRDEVICE)
WRITE_COMMAND = $(AVRCOMMAND) -U flash:w:opentx.hex:i
ifeq ($(RESTORE_EEPROM), YES)
BACKUP_EEPROM = YES
ifeq ($(DOUBLE_WRITE_OK), YES)
WRITE_COMMAND += -U eeprom:w:$(DATA_DIR)/eeprom-$(DATE).hex:i
else
SECOND_WRITE_COMMAND = -U eeprom:w:$(DATA_DIR)/eeprom-$(DATE).hex:i
endif
BACKUP_EEPROM = YES
ifeq ($(DOUBLE_WRITE_OK), YES)
WRITE_COMMAND += -U eeprom:w:$(DATA_DIR)/eeprom-$(DATE).hex:i
else
SECOND_WRITE_COMMAND = -U eeprom:w:$(DATA_DIR)/eeprom-$(DATE).hex:i
endif
endif
ifeq ($(BACKUP_FLASH), YES)
+21 -6
View File
@@ -607,7 +607,6 @@ int WavContext::mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade)
}
}
clear();
return -result;
}
#else
@@ -719,12 +718,18 @@ void AudioQueue::wakeup()
}
// mix the normal context (tones and wavs)
if (normalContext.fragment.type == FRAGMENT_TONE)
if (normalContext.fragment.type == FRAGMENT_TONE) {
result = normalContext.tone.mixBuffer(buffer, g_eeGeneral.beepVolume, fade);
else if (normalContext.fragment.type == FRAGMENT_FILE)
}
else if (normalContext.fragment.type == FRAGMENT_FILE) {
result = normalContext.wav.mixBuffer(buffer, g_eeGeneral.wavVolume, fade);
else
if (result < 0) {
normalContext.wav.clear();
}
}
else {
result = 0;
}
if (result > 0) {
size = max(size, result);
fade += 1;
@@ -732,7 +737,7 @@ void AudioQueue::wakeup()
else {
CoEnterMutexSection(audioMutex);
if (ridx != widx) {
normalContext.fragment = fragments[ridx];
normalContext.tone.setFragment(fragments[ridx]);
if (!fragments[ridx].repeat--) {
ridx = (ridx + 1) % AUDIO_QUEUE_LENGTH;
}
@@ -799,8 +804,9 @@ void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t f
{
CoEnterMutexSection(audioMutex);
if (freq && freq < BEEP_MIN_FREQ)
if (freq && freq < BEEP_MIN_FREQ) {
freq = BEEP_MIN_FREQ;
}
if (flags & PLAY_BACKGROUND) {
AudioFragment & fragment = varioContext.fragment;
@@ -923,6 +929,15 @@ void AudioQueue::stopAll()
CoLeaveMutexSection(audioMutex);
}
void AudioQueue::flush()
{
CoEnterMutexSection(audioMutex);
widx = ridx; // clean the queue
varioContext.clear();
backgroundContext.clear();
CoLeaveMutexSection(audioMutex);
}
void audioEvent(uint8_t e, uint16_t f)
{
#if defined(HAPTIC)
+9
View File
@@ -103,6 +103,12 @@ class ToneContext {
uint16_t pause;
} state;
inline void setFragment(AudioFragment & fragment)
{
this->fragment = fragment;
memset(&state, 0, sizeof(state));
}
inline void clear()
{
memset(this, 0, sizeof(ToneContext));
@@ -163,6 +169,8 @@ class AudioQueue {
void stopAll();
void flush();
void pause(uint16_t tLen);
void stopSD();
@@ -328,6 +336,7 @@ void pushPrompt(uint16_t prompt, uint8_t id=0);
#define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id))
#define STOP_PLAY(id) audioQueue.stopPlay((id))
#define AUDIO_RESET() audioQueue.stopAll()
#define AUDIO_FLUSH() audioQueue.flush()
#if defined(SDCARD)
extern tmr10ms_t timeAutomaticPromptsSilence;
+1
View File
@@ -154,6 +154,7 @@ void audioDefevent(uint8_t e);
#define AUDIO_HEARTBEAT() audio.heartbeat()
#define IS_AUDIO_BUSY() audio.busy()
#define AUDIO_RESET()
#define AUDIO_FLUSH()
#define PLAY_PHASE_OFF(phase)
#define PLAY_PHASE_ON(phase)
+1 -1
View File
@@ -183,7 +183,7 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const xcoord_t width
f_close(&bmpFile);
return SDCARD_ERROR(result);
}
for (uint32_t j=0; j<w/2; j++) {
for (uint32_t j=0; j<(w+1)/2; j++) {
uint8_t * dst = dest + (i/2)*w + j*2;
if (i & 1) {
uint8_t val = palette[(buf[j] >> 4) & 0x0F] << 4;
+2 -1
View File
@@ -160,7 +160,8 @@ SRC = ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/
../targets/taranis/aspi.c \
../targets/taranis/usb_bsp.c \
../targets/taranis/usb_driver.c \
../targets/taranis/pwr_driver.c
../targets/taranis/pwr_driver.c \
init.c
CPPSRC = ../targets/taranis/lcd_driver.cpp \
../targets/taranis/configure_pins.cpp \
+4
View File
@@ -0,0 +1,4 @@
void _init (void)
{
}
+1
View File
@@ -99,6 +99,7 @@ void beep(uint8_t val);
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
#define AUDIO_RESET()
#define AUDIO_FLUSH()
#define PLAY_PHASE_OFF(phase)
#define PLAY_PHASE_ON(phase)
+2 -2
View File
@@ -472,8 +472,8 @@ void ConvertModel_215_to_216(ModelData &model)
memcpy(&g_model.header, &oldModel.header, sizeof(g_model.header));
for (uint8_t i=0; i<2; i++) {
TimerData & timer = g_model.timers[i];
if (oldModel.timers[i].mode >= TMRMODE_FIRST_SWITCH)
timer.mode = TMRMODE_FIRST_SWITCH + ConvertSwitch_215_to_216(oldModel.timers[i].mode - TMRMODE_FIRST_SWITCH + 1) - 1;
if (oldModel.timers[i].mode >= TMRMODE_COUNT)
timer.mode = TMRMODE_COUNT + ConvertSwitch_215_to_216(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
else
timer.mode = oldModel.timers[i].mode;
timer.start = oldModel.timers[i].start;
+1
View File
@@ -385,6 +385,7 @@ void eeLoadModel(uint8_t id)
read32_eeprom_data((File_system[id+1].block_no << 12) + sizeof(struct t_eeprom_header), (uint8_t *)&g_model, size) ;
}
AUDIO_FLUSH();
flightReset();
logicalSwitchesReset();
+7 -1
View File
@@ -964,16 +964,22 @@ void eeLoadModel(uint8_t id)
}
#endif
bool newModel = false;
if (sz < 256) {
modelDefault(id);
eeCheck(true);
newModel = true;
}
AUDIO_FLUSH();
flightReset();
logicalSwitchesReset();
if (pulsesStarted()) {
checkAll();
if (!newModel) {
checkAll();
}
resumePulses();
}
+5 -1
View File
@@ -47,6 +47,10 @@ class Fifo
{
}
bool empty() {
return (ridx == widx);
}
void push(uint8_t byte) {
uint32_t next = (widx+1) & (N-1);
if (next != ridx) {
@@ -56,7 +60,7 @@ class Fifo
}
bool pop(uint8_t & byte) {
if (ridx == widx) {
if (empty()) {
return false;
}
else {
+13 -17
View File
@@ -229,16 +229,16 @@ void menuGeneralSetup(uint8_t event)
#if defined(RTCLOCK)
case ITEM_SETUP_DATE:
lcd_putsLeft(y, STR_DATE);
lcd_putc(RADIO_SETUP_DATE_COLUMN+2, y, '-'); lcd_putc(RADIO_SETUP_DATE_COLUMN+3*FW, y, '-');
lcd_putc(RADIO_SETUP_DATE_COLUMN, y, '-'); lcd_putc(RADIO_SETUP_DATE_COLUMN+3*FW-2, y, '-');
for (uint8_t j=0; j<3; j++) {
uint8_t rowattr = (m_posHorz==j ? attr : 0);
switch (j) {
case 0:
lcd_outdezAtt(RADIO_SETUP_DATE_COLUMN+2, y, t.tm_year+1900, rowattr);
lcd_outdezAtt(RADIO_SETUP_DATE_COLUMN, y, t.tm_year+1900, rowattr);
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_year = checkIncDec(event, t.tm_year, 112, 200, 0);
break;
case 1:
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+3*FW, y, t.tm_mon+1, rowattr|LEADING0, 2);
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+3*FW-2, y, t.tm_mon+1, rowattr|LEADING0, 2);
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_mon = checkIncDec(event, t.tm_mon, 0, 11, 0);
break;
case 2:
@@ -247,7 +247,7 @@ void menuGeneralSetup(uint8_t event)
int8_t dlim = (((((year%4==0) && (year%100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0);
static const pm_uint8_t dmon[] PROGMEM = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
dlim += pgm_read_byte(&dmon[t.tm_mon]);
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+6*FW-2, y, t.tm_mday, rowattr|LEADING0, 2);
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+6*FW-4, y, t.tm_mday, rowattr|LEADING0, 2);
if (rowattr && (s_editMode>0 || p1valdiff)) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0);
break;
}
@@ -292,9 +292,9 @@ void menuGeneralSetup(uint8_t event)
#if defined(BATTGRAPH) || defined(PCBTARANIS)
case ITEM_SETUP_BATT_RANGE:
lcd_putsLeft(y, STR_BATTERY_RANGE);
lcd_putc(g_eeGeneral.vBatMin >= 10 ? RADIO_SETUP_2ND_COLUMN+2*FW+FWNUM-1 : RADIO_SETUP_2ND_COLUMN+2*FW+FWNUM-FW/2, y, '-');
putsVolts(RADIO_SETUP_2ND_COLUMN, y, 90+g_eeGeneral.vBatMin, (m_posHorz==0 ? attr : 0)|LEFT|NO_UNIT);
putsVolts(RADIO_SETUP_2ND_COLUMN+4*FW-2, y, 120+g_eeGeneral.vBatMax, (m_posHorz>0 ? attr : 0)|LEFT|NO_UNIT);
lcd_putc(lcdLastPos, y, '-');
putsVolts(lcdLastPos+FW, y, 120+g_eeGeneral.vBatMax, (m_posHorz>0 ? attr : 0)|LEFT|NO_UNIT);
#if defined(PCBTARANIS)
if (attr && m_posHorz < 0) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, LCD_W-RADIO_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
#endif
@@ -531,8 +531,8 @@ void menuGeneralSetup(uint8_t event)
#if defined(PCBTARANIS) && defined(REVPLUS)
case ITEM_SETUP_BACKLIGHT_COLOR:
lcd_putsLeft(y, STR_BLCOLOR);
displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 100, attr);
if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 100, EE_GENERAL | NO_INCDEC_MARKS);
displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr);
if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 20, EE_GENERAL | NO_INCDEC_MARKS);
break;
#endif
@@ -859,12 +859,7 @@ void onSdManagerMenu(const char *result)
#endif
#if defined(PCBTARANIS)
else if (result == STR_ASSIGN_BITMAP) {
strcpy(lfn, reusableBuffer.sdmanager.lines[index]);
// TODO duplicated code for finding extension
uint8_t len = strlen(lfn) - 4;
memset(lfn+len, 0, sizeof(g_model.header.bitmap)-len);
// TODO duplicated code
memcpy(g_model.header.bitmap, lfn, sizeof(g_model.header.bitmap));
strAppendFilename(g_model.header.bitmap, reusableBuffer.sdmanager.lines[index], sizeof(g_model.header.bitmap));
LOAD_MODEL_BITMAP();
memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap));
eeDirty(EE_MODEL);
@@ -983,7 +978,8 @@ void menuGeneralSdManager(uint8_t _event)
uint8_t index = m_posVert-1-s_pgOfs;
// TODO duplicated code for finding extension
char * ext = reusableBuffer.sdmanager.lines[index];
ext += strlen(ext) - 4;
int len = strlen(ext) - 4;
ext += len;
/* TODO if (!strcasecmp(ext, MODELS_EXT)) {
s_menu[s_menu_count++] = STR_LOAD_FILE;
}
@@ -992,7 +988,7 @@ void menuGeneralSdManager(uint8_t _event)
}
#endif
#if defined(PCBTARANIS)
else if (!strcasecmp(ext, BITMAPS_EXT) && !READ_ONLY()) {
else if (!strcasecmp(ext, BITMAPS_EXT) && !READ_ONLY() && len <= (int)sizeof(g_model.header.bitmap)) {
MENU_ADD_ITEM(STR_ASSIGN_BITMAP);
}
else if (!strcasecmp(ext, TEXT_EXT)) {
@@ -1397,7 +1393,7 @@ void menuGeneralHardware(uint8_t event)
case ITEM_SETUP_HW_UART3_MODE:
g_eeGeneral.uart3Mode = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_UART3MODE, STR_UART3MODES, g_eeGeneral.uart3Mode, 0, UART_MODE_MAX, attr, event);
if (checkIncDec_Ret) {
uart3Init(g_eeGeneral.uart3Mode, MODEL_TELEMETRY_PROTOCOL);
uart3Init(g_eeGeneral.uart3Mode, MODEL_TELEMETRY_PROTOCOL());
}
break;
}
+43 -44
View File
@@ -1120,7 +1120,7 @@ void menuModelSetup(uint8_t event)
div_t qr = div(timer->start, 60);
switch (m_posHorz) {
case 0:
CHECK_INCDEC_MODELVAR(event, timer->mode, SWSRC_FIRST, TMR_VAROFS+SWSRC_LAST-1);
CHECK_INCDEC_MODELVAR_CHECK(event, timer->mode, SWSRC_FIRST, TMRMODE_COUNT+SWSRC_LAST-1/*SWSRC_None removed*/, isSwitchAvailableInTimers);
break;
case 1:
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
@@ -1224,7 +1224,7 @@ void menuModelSetup(uint8_t event)
if (attr) {
s_editMode = 0;
if (!READ_ONLY()) {
switch(event) {
switch (event) {
CASE_EVT_ROTARY_BREAK
case EVT_KEY_BREAK(KEY_ENTER):
#if defined(CPUM64)
@@ -1320,13 +1320,13 @@ void menuModelSetup(uint8_t event)
}
}
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""Off\0""Man\0""Auto"), potMode, attr & ((m_posHorz == 0) ? attr : !INVERS));
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""OFF\0""Man\0""Auto"), potMode, attr & ((m_posHorz == 0) ? attr : !INVERS));
if (potMode) {
uint8_t x = MODEL_SETUP_2ND_COLUMN+5*FW;
for (uint8_t i=0; i<NUM_POTS ; i++) {
#if !defined(REVPLUS)
if (i == POT3-POT1) {
if (m_posHorz==i+1) REPEAT_LAST_CURSOR_MOVE();
if (attr && (m_posHorz==i+1)) REPEAT_LAST_CURSOR_MOVE();
continue;
}
#endif
@@ -1353,7 +1353,7 @@ void menuModelSetup(uint8_t event)
uint8_t x = MODEL_SETUP_2ND_COLUMN+i*FW;
#if defined(PCBTARANIS) && !defined(REVPLUS)
if (i == POT3) {
if (m_posHorz == POT3) REPEAT_LAST_CURSOR_MOVE();
if (attr && m_posHorz == POT3) REPEAT_LAST_CURSOR_MOVE();
continue;
}
else if (i > POT3) {
@@ -1621,7 +1621,7 @@ void menuModelSetup(uint8_t event)
if (IS_PPM_PROTOCOL(protocol)) {
lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, m_posHorz!=0 ? attr : 0);
}
else if (attr) {
else if (m_posHorz>0 && attr) {
MOVE_CURSOR_FROM_HERE();
}
if (attr && (editMode>0 || p1valdiff || (!IS_PPM_PROTOCOL(protocol) && !IS_DSM2_PROTOCOL(protocol)))) {
@@ -1940,7 +1940,7 @@ void menuModelFlightModesAll(uint8_t event)
case ITEM_FLIGHT_MODES_SWITCH:
putsSwitches((5+LEN_FP_NAME)*FW+FW/2, y, p->swtch, attr);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST_SHORT_LIST, SWSRC_LAST_SHORT_LIST);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
break;
case ITEM_FLIGHT_MODES_TRIM_RUD:
@@ -3097,12 +3097,13 @@ void menuModelExpoOne(uint8_t event)
if (ed->srcRaw >= MIXSRC_FIRST_TELEM) {
putsTelemetryChannel(LCD_W-8, 6*FH, ed->srcRaw - MIXSRC_FIRST_TELEM, x512, 0);
if (ed->scale > 0) x512 = (x512 * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale);
x512 = limit(-1024, x512, 1024);
}
else {
lcd_outdezAtt(LCD_W-8, 6*FH, calcRESXto1000(x512), PREC1);
}
x512 = limit(-1024, x512, 1024);
int y512 = expoFn(x512);
y512 = limit(-1024, y512, 1024);
lcd_outdezAtt(LCD_W-8-6*FW, 1*FH, calcRESXto1000(y512), PREC1);
#else
int16_t x512 = calibratedStick[ed->chn];
@@ -3111,10 +3112,11 @@ void menuModelExpoOne(uint8_t event)
lcd_outdezAtt(LCD_W-8-6*FW, 1*FH, calcRESXto100(y512), 0);
#endif
x512 = X0+x512/(RESXu/WCHART);
#if defined(CPUARM)
x512 = X0+x512/(RESX/WCHART);
y512 = (LCD_H-1) - ((y512+RESX)/2) * (LCD_H-1) / RESX;
#else
x512 = X0+x512/(RESXu/WCHART);
y512 = (LCD_H-1) - (uint16_t)((y512+RESX)/2) * (LCD_H-1) / RESX;
#endif
@@ -4359,6 +4361,22 @@ enum LogicalSwitchFields {
#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag)
#endif
#if defined(CPUARM)
void putsEdgeDelayParam(xcoord_t x, uint8_t y, LogicalSwitchData *cs, uint8_t lattr, uint8_t rattr)
{
lcd_putc(x-4, y, '[');
lcd_outdezAtt(x, y, lswTimerValue(cs->v2), LEFT|PREC1|lattr);
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 < 0)
lcd_putsAtt(lcdLastPos+3, y, "<<", rattr);
else if (cs->v3 == 0)
lcd_putsAtt(lcdLastPos+3, y, "--", rattr);
else
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|rattr);
lcd_putc(lcdLastPos, y, ']');
}
#endif
#if defined(CPUARM) && LCD_W < 212
#define CSWONE_2ND_COLUMN (11*FW)
@@ -4440,17 +4458,10 @@ void menuModelLogicalSwitchOne(uint8_t event)
v2_max = 99;
}
else if (cstate == LS_FAMILY_STAY) {
lcd_putc(CSWONE_2ND_COLUMN-4, y, '[');
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0));
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 == 0)
lcd_putsAtt(lcdLastPos+3, y, "--", (m_posHorz==1 ? attr : 0));
else
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(m_posHorz==1 ? attr : 0));
lcd_putc(lcdLastPos, y, ']');
putsEdgeDelayParam(CSWONE_2ND_COLUMN, y, cs, m_posHorz==0 ? attr : 0, m_posHorz==1 ? attr : 0);
if (s_editMode <= 0) continue;
if (attr && m_posHorz==1) {
CHECK_INCDEC_MODELVAR(event, cs->v3, 0, 222 - cs->v2);
CHECK_INCDEC_MODELVAR(event, cs->v3, -1, 222 - cs->v2);
break;
}
v2_min = -129; v2_max = 122;
@@ -4480,7 +4491,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
else
#endif
{
v2_min = -125; v2_max = 125;
v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT;
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2, LEFT|attr);
}
}
@@ -4563,14 +4574,7 @@ void menuModelLogicalSwitches(uint8_t event)
}
else if (cstate == LS_FAMILY_STAY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1);
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 == 0)
lcd_puts(lcdLastPos+3, y, "--");
else
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1);
lcd_putc(lcdLastPos-1, y, ']');
putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, 0, 0);
}
else if (cstate == LS_FAMILY_TIMER) {
lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT);
@@ -4682,7 +4686,7 @@ void menuModelLogicalSwitches(uint8_t event)
uint8_t cstate = lswFamily(cs->func);
#if defined(CPUARM)
int16_t v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
int16_t v3_min=0, v3_max=100;
int16_t v3_min=-1, v3_max=100;
#else
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
#define v1_val cs->v1
@@ -4691,28 +4695,21 @@ void menuModelLogicalSwitches(uint8_t event)
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2);
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1;
v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES;
v2_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v2_max = SWSRC_LAST_IN_LOGICAL_SWITCHES;
INCDEC_SET_FLAG(INCDEC_SWITCH);
INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches);
}
#if defined(CPUARM)
else if (cstate == LS_FAMILY_STAY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2);
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 == 0)
lcd_putsAtt(lcdLastPos+3, y, "--", (horz==LS_FIELD_V3 ? attr : 0));
else
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==LS_FIELD_V3 ? attr : 0));
lcd_putc(lcdLastPos, y, ']');
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, attr2, horz==LS_FIELD_V3 ? attr : 0);
v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES;
v2_min=-129; v2_max = 122;
v3_max = 222 - cs->v2;
if (horz == 1) {
INCDEC_SET_FLAG(INCDEC_SWITCH);
INCDEC_ENABLE_CHECK(isSwitchAvailable);
INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches);
}
else {
INCDEC_SET_FLAG(0);
@@ -4791,7 +4788,7 @@ void menuModelLogicalSwitches(uint8_t event)
else
#endif
{
v2_min = -125; v2_max = +125;
v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT;
}
}
#else
@@ -4801,7 +4798,7 @@ void menuModelLogicalSwitches(uint8_t event)
}
else {
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT|attr2);
v2_min = -125; v2_max = 125;
v2_min = -LIMIT_EXT_PERCENT; v2_max = +LIMIT_EXT_PERCENT;
}
#endif
}
@@ -5042,7 +5039,7 @@ void menuModelCustomFunctions(uint8_t event)
switch (j) {
case 0:
putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(sd), attr | ((activeFnSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0));
if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_MODELSWITCH(event, CFN_SWITCH(sd), SWSRC_FIRST, SWSRC_LAST);
if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_MODELSWITCH(event, CFN_SWITCH(sd), SWSRC_FIRST, SWSRC_LAST, isSwitchAvailableInCustomFunctions);
break;
case 1:
@@ -5122,8 +5119,10 @@ void menuModelCustomFunctions(uint8_t event)
}
#if defined(OVERRIDE_CHANNEL_FUNCTION)
else if (func == FUNC_OVERRIDE_CHANNEL) {
#if !defined(CPUARM)
val_displayed = (int8_t)CFN_PARAM(sd);
val_min = -125; val_max = 125;
#endif
val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
}
#endif
+75 -21
View File
@@ -1117,7 +1117,7 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t
{
lcd_putsColumnLeft(x, y, STR_SWITCH);
putsSwitches(x, y, value, attr);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_SHORT_LIST, SWSRC_LAST_SHORT_LIST);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
return value;
}
@@ -1433,6 +1433,12 @@ bool isTelemetrySourceAvailable(int source)
return false;
#endif
#if defined(PCBTARANIS) && defined(REVPLUS)
// on Taranis+ we also hide the SWR
if (source == TELEM_SWR)
return false;
#endif
if (source >= TELEM_A1 && source <= TELEM_A4) {
return g_model.frsky.channels[source-TELEM_A1].ratio != 0;
}
@@ -1462,6 +1468,14 @@ bool isTelemetrySourceAvailable(int source)
bool isInputSourceAvailable(int source)
{
#if defined(PCBTARANIS) && !defined(REVPLUS)
if (source == MIXSRC_POT3)
return false;
#endif
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
return true;
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
return true;
@@ -1480,17 +1494,25 @@ bool isInputSourceAvailable(int source)
return false;
}
bool isSwitchAvailableInLogicalSwitches(int swtch)
enum SwitchContext
{
LogicalSwitchesContext,
CustomFunctionsContext,
TimersContext,
MixesContext
};
bool isSwitchAvailable(int swtch, SwitchContext context)
{
if (swtch < 0) {
if (swtch <= -SWSRC_ON)
return false;
#if defined(PCBTARANIS)
else if (swtch == -SWSRC_SF0 || swtch == -SWSRC_SF2 || swtch == -SWSRC_SH0 || swtch == -SWSRC_SH2)
if (swtch == -SWSRC_SF0 || swtch == -SWSRC_SF2 || swtch == -SWSRC_SH0 || swtch == -SWSRC_SH2)
return false;
#endif
else
swtch = -swtch;
if (swtch == -SWSRC_ON || swtch == -SWSRC_One) {
return false;
}
swtch = -swtch;
}
#if defined(PCBTARANIS)
@@ -1506,27 +1528,59 @@ bool isSwitchAvailableInLogicalSwitches(int swtch)
}
#endif
return true;
}
bool isSwitchAvailable(int swtch)
{
if (!isSwitchAvailableInLogicalSwitches(swtch)) {
return false;
}
if (swtch < 0) {
swtch = -swtch;
}
if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) {
if (context != LogicalSwitchesContext && swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) {
LogicalSwitchData * cs = lswAddress(swtch-SWSRC_FIRST_LOGICAL_SWITCH);
return (cs->func != LS_FUNC_NONE);
}
if (context != CustomFunctionsContext && (swtch == SWSRC_ON || swtch == SWSRC_One)) {
return false;
}
if (swtch >= SWSRC_FIRST_FLIGHT_MODE && swtch <= SWSRC_LAST_FLIGHT_MODE) {
if (context == MixesContext) {
return false;
}
else {
swtch -= SWSRC_FIRST_FLIGHT_MODE;
if (swtch == 0) {
return true;
}
FlightModeData * fm = flightModeAddress(swtch);
return (fm->swtch != SWSRC_NONE);
}
}
return true;
}
bool isSwitchAvailableInLogicalSwitches(int swtch)
{
return isSwitchAvailable(swtch, LogicalSwitchesContext);
}
bool isSwitchAvailableInCustomFunctions(int swtch)
{
return isSwitchAvailable(swtch, CustomFunctionsContext);
}
bool isSwitchAvailableInMixes(int swtch)
{
return isSwitchAvailable(swtch, MixesContext);
}
bool isSwitchAvailableInTimers(int swtch)
{
if (swtch >= 0) {
if (swtch < TMRMODE_COUNT) {
return true;
}
swtch -= TMRMODE_COUNT-1;
}
return isSwitchAvailable(swtch, TimersContext);
}
bool isThrottleSourceAvailable(int source)
{
#if defined(PCBTARANIS)
+12 -5
View File
@@ -209,9 +209,13 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
var = checkIncDecModelZero(event,var,max)
#if defined(CPUARM)
#define CHECK_INCDEC_MODELVAR_CHECK(event, var, min, max, check) \
var = checkIncDec(event, var, min, max, EE_MODEL, check)
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
var = checkIncDec(event, var, 0, max, EE_MODEL, check)
#else
#define CHECK_INCDEC_MODELVAR_CHECK(event, var, min, max, check) \
var = checkIncDec(event, var, min, max, EE_MODEL)
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
CHECK_INCDEC_MODELVAR_ZERO(event, var, max)
#endif
@@ -220,19 +224,22 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
bool isThrottleSourceAvailable(int source);
bool isLogicalSwitchFunctionAvailable(int function);
bool isAssignableFunctionAvailable(int function);
bool isSwitchAvailable(int swtch);
bool isSwitchAvailableInLogicalSwitches(int swtch);
bool isSwitchAvailableInCustomFunctions(int swtch);
bool isSwitchAvailableInMixes(int swtch);
bool isSwitchAvailableInTimers(int swtch);
bool isModuleAvailable(int module);
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable)
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, available)
#elif defined(AUTOSWITCH)
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH)
#else
#define AUTOSWITCH_ENTER_LONG() (0)
#define CHECK_INCDEC_MODELSWITCH CHECK_INCDEC_MODELVAR
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
CHECK_INCDEC_MODELVAR(event, var, min, max)
#endif
#if defined(CPUARM)
+2 -2
View File
@@ -164,7 +164,7 @@ void displayTrims(uint8_t phase)
uint8_t att = ROUND;
int16_t val = getTrimValue(phase, i);
if (val < -125 || val > 125)
if (val < TRIM_MIN || val > TRIM_MAX)
att = BLINK|INVERS|ROUND;
if (val < -(TRIM_LEN+1)*4)
@@ -306,7 +306,7 @@ void displayTopBar()
}
/* Audio volume */
if (requiredSpeakerVolume == 0)
if (requiredSpeakerVolume == 0 || g_eeGeneral.beepMode == e_mode_quiet)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER0);
else if (requiredSpeakerVolume < 10)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER1);
+64 -42
View File
@@ -92,9 +92,20 @@ void menuStatisticsView(uint8_t event)
#if defined(PCBTARANIS)
#define MENU_DEBUG_COL1_OFS (11*FW-2)
#define MENU_DEBUG_Y_MIXMAX (2*FH-3)
#define MENU_DEBUG_Y_LUA (3*FH-2)
#define MENU_DEBUG_Y_FREE_RAM (4*FH-1)
#define MENU_DEBUG_Y_STACK (5*FH)
#define MENU_DEBUG_Y_RTOS (6*FH)
#elif defined(PCBSKY9X)
#define MENU_DEBUG_COL1_OFS (11*FW-3)
#define MENU_DEBUG_COL2_OFS (17*FW)
#define MENU_DEBUG_Y_CURRENT (1*FH)
#define MENU_DEBUG_Y_MAH (2*FH)
#define MENU_DEBUG_Y_CPU_TEMP (3*FH)
#define MENU_DEBUG_Y_COPROC (4*FH)
#define MENU_DEBUG_Y_MIXMAX (5*FH)
#define MENU_DEBUG_Y_RTOS (6*FH)
#else
#define MENU_DEBUG_COL1_OFS (14*FW)
#endif
@@ -149,76 +160,87 @@ void menuStatisticsDebug(uint8_t event)
#if defined(PCBSKY9X) && !defined(REVA)
// current
lcd_putsLeft(1*FH, STR_CPU_CURRENT);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 1*FH, getCurrent(), UNIT_MILLIAMPS, LEFT);
lcd_putsLeft(MENU_DEBUG_Y_CURRENT, STR_CPU_CURRENT);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CURRENT, getCurrent(), UNIT_MILLIAMPS, LEFT);
uint32_t current_scale = 488 + g_eeGeneral.currentCalib;
lcd_putc(MENU_DEBUG_COL2_OFS, 1*FH, '>');
putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, 1*FH, Current_max*10*current_scale/8192, UNIT_RAW, LEFT);
lcd_putc(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CURRENT, '>');
putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CURRENT, Current_max*10*current_scale/8192, UNIT_RAW, LEFT);
// consumption
lcd_putsLeft(2*FH, STR_CPU_MAH);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 2*FH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1);
lcd_putsLeft(MENU_DEBUG_Y_MAH, STR_CPU_MAH);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MAH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1);
#endif
#if defined(PCBSKY9X)
lcd_putsLeft(3*FH, STR_CPU_TEMP);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 3*FH, getTemperature(), UNIT_TEMPERATURE, LEFT);
lcd_putc(MENU_DEBUG_COL2_OFS, 3*FH, '>');
putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, 3*FH, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT);
lcd_putsLeft(MENU_DEBUG_Y_CPU_TEMP, STR_CPU_TEMP);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CPU_TEMP, getTemperature(), UNIT_TEMPERATURE, LEFT);
lcd_putc(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CPU_TEMP, '>');
putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CPU_TEMP, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT);
#endif
#if defined(COPROCESSOR)
lcd_putsLeft(4*FH, STR_COPROC_TEMP);
lcd_putsLeft(MENU_DEBUG_Y_COPROC, STR_COPROC_TEMP);
if (Coproc_read==0) {
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Co Proc NACK"),INVERS);
lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS);
}
else if (Coproc_read==0x81) {
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Inst.TinyApp"),INVERS);
lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS);
}
else if (Coproc_read<3) {
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Upgr.TinyApp"),INVERS);
lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS);
}
else {
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 4*FH, Coproc_temp, UNIT_TEMPERATURE, LEFT);
putsTelemetryValue(MENU_DEBUG_COL2_OFS, 4*FH, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, Coproc_temp, UNIT_TEMPERATURE, LEFT);
putsTelemetryValue(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_COPROC, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT);
}
#endif
#if defined(PCBTARANIS) && !defined(SIMU)
lcd_putsLeft(3*FH, "Free Mem");
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 3*FH, getAvailableMemory(), LEFT);
lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem");
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, getAvailableMemory(), LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_FREE_RAM, "b");
#endif
#if defined(LUA)
lcd_putsLeft(4*FH, "Lua scripts");
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH+1, "[Duration]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaDuration, LEFT);
lcd_putsAtt(lcdLastPos+2, 4*FH+1, "[Interval]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaInterval, LEFT);
lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts");
lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT);
lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT);
#endif
#if defined(CPUARM)
lcd_putsLeft(5*FH, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 5*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
lcd_puts(lcdLastPos, 5*FH, "ms");
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
#if LCD_W >= 212
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 6*FH+1, "[Main]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(0), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Mix]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Audio]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT);
#else
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 6*FH, stack_free(0), UNSIGN|LEFT);
lcd_puts(lcdLastPos, 6*FH, "/");
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT);
lcd_puts(lcdLastPos, 6*FH, "/");
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT);
lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms");
#endif
#else
#if 0
lcd_putsLeft(MENU_DEBUG_Y_STACK, STR_FREESTACKMINB);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_STACK, stack_free(255), UNSIGN|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_STACK, "b");
#endif
#if defined(PCBTARANIS)
lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB);
lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[Main]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[Mix]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[Audio]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT);
#endif
#if defined(PCBSKY9X)
lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_RTOS, "/");
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_RTOS, "/");
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT);
#endif
#if !defined(CPUARM)
lcd_putsLeft(1*FH, STR_TMR1LATMAXUS);
lcd_outdez8(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 );
lcd_putsLeft(2*FH, STR_TMR1LATMINUS);
+1
View File
@@ -299,5 +299,6 @@ void lcdSetContrast();
char * strAppend(char * dest, const char * source);
char * strAppendDate(char * str, bool time=false);
char * strAppendFilename(char * dest, const char * filename, const int size);
#endif
+16 -12
View File
@@ -134,11 +134,7 @@ void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
{
#if !defined(BOOT)
const pm_uchar *q = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
#else
const pm_uchar *q = &font_5x7[(c-0x20)*5];
#endif
const pm_uchar * q;
lcdNextPos = x-1;
@@ -158,14 +154,17 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
c_remapped = 4;
else if (c!=' ')
flags &= ~BOLD;
if ((c>= 128) && (flags & DBLSIZE))
c_remapped = c - 60;
}
if (flags & DBLSIZE) {
/* each letter consists of ten top bytes followed by
* by ten bottom bytes (20 bytes per * char) */
q = &font_10x14[((uint16_t)c_remapped)*20];
if (c >= 0xC0) {
q = &font_10x14_extra[((uint16_t)(c-0xC0))*20];
}
else {
if (c >= 128)
c_remapped = c - 60;
q = &font_10x14[((uint16_t)c_remapped)*20];
}
lcdPutPattern(x, y, q, 10, 16, flags);
}
else if (flags & XXLSIZE) {
@@ -193,6 +192,11 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
else
#endif
{
#if !defined(BOOT)
q = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
#else
q = &font_5x7[(c-0x20)*5];
#endif
lcdPutPattern(x, y, q, 5, 7, flags);
}
}
@@ -839,10 +843,10 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att)
{
if (mode >= 0) {
if (mode < TMR_VAROFS)
if (mode < TMRMODE_COUNT)
return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att);
else
mode -= (TMR_VAROFS-1);
mode -= (TMRMODE_COUNT-1);
}
putsSwitches(x, y, mode, att);
}
+6 -1
View File
@@ -145,7 +145,12 @@ void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t offset, uint8_
{
const pm_uchar *q = img;
uint8_t w = pgm_read_byte(q++);
if (!width) width = w;
if (!width || width > w) {
width = w;
}
if (x+width > LCD_W) {
width = LCD_W-x;
}
uint8_t rows = (pgm_read_byte(q++) + 1) / 2;
for (uint8_t row=0; row<rows; row++) {
+13 -4
View File
@@ -115,7 +115,9 @@ const pm_char * openLogs()
f_puts("Time,", &g_oLogFile);
#endif
#if defined(CPUARM) && defined(FRSKY)
#if defined(PCBTARANIS) && defined(REVPLUS)
f_puts("RSSI,A1,A2,A3,A4,", &g_oLogFile);
#elif defined(CPUARM) && defined(FRSKY)
f_puts("SWR,RSSI,A1,A2,A3,A4,", &g_oLogFile);
#elif defined(FRSKY)
f_puts("Buffer,RX,TX,A1,A2,", &g_oLogFile);
@@ -155,7 +157,10 @@ tmr10ms_t lastLogTime = 0;
void closeLogs()
{
f_close(&g_oLogFile);
if (f_close(&g_oLogFile) != FR_OK) {
// close failed, forget file
g_oLogFile.fs = 0;
}
lastLogTime = 0;
}
@@ -195,7 +200,9 @@ void writeLogs()
#endif
#if defined(FRSKY)
#if defined(CPUARM)
#if defined(PCBTARANIS) && defined(REVPLUS)
f_printf(&g_oLogFile, "%d,", RAW_FRSKY_MINMAX(frskyData.rssi[0]));
#elif defined(CPUARM)
f_printf(&g_oLogFile, "%d,%d,", RAW_FRSKY_MINMAX(frskyData.swr), RAW_FRSKY_MINMAX(frskyData.rssi[0]));
#else
f_printf(&g_oLogFile, "%d,%d,%d,", frskyStreaming, RAW_FRSKY_MINMAX(frskyData.rssi[0]), RAW_FRSKY_MINMAX(frskyData.rssi[1]));
@@ -279,13 +286,15 @@ void writeLogs()
if (result<0 && !error_displayed) {
error_displayed = STR_SDCARD_ERROR;
POPUP_WARNING(STR_SDCARD_ERROR);
closeLogs();
}
}
}
else {
error_displayed = NULL;
if (g_oLogFile.fs)
if (g_oLogFile.fs) {
closeLogs();
}
}
}
+479 -283
View File
@@ -45,6 +45,7 @@ extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <lrotable.h>
#if !defined(SIMU)
}
#endif
@@ -73,9 +74,21 @@ uint16_t maxLuaDuration = 0;
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (10000/100)
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100)
#define SCRIPTS_MAX_HEAP 50
#define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x))
struct our_longjmp * global_lj = 0;
/* custom panic handler */
static int custom_lua_atpanic(lua_State *lua)
{
TRACE("PANIC: unprotected error in call to Lua API (%s)\n", lua_tostring(L, -1));
if (global_lj) {
longjmp(global_lj->b, 1);
/* will never return */
}
return 0;
}
static int instructionsPercent = 0;
void hook(lua_State* L, lua_Debug *ar)
{
@@ -514,6 +527,7 @@ static int luaModelGetInfo(lua_State *L)
{
lua_newtable(L);
lua_pushtablezstring(L, "name", g_model.header.name);
lua_pushtablenzstring(L, "bitmap", g_model.header.bitmap);
lua_pushtableinteger(L, "id", g_model.header.modelId);
return 1;
}
@@ -529,6 +543,10 @@ static int luaModelSetInfo(lua_State *L)
str2zchar(g_model.header.name, name, sizeof(g_model.header.name));
memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name));
}
else if (!strcmp(key, "bitmap")) {
const char * name = luaL_checkstring(L, -1);
strncpy(g_model.header.bitmap, name, sizeof(g_model.header.bitmap));
}
else if (!strcmp(key, "id")) {
g_model.header.modelId = luaL_checkinteger(L, -1);
modelHeaders[g_eeGeneral.currModel].modelId = g_model.header.modelId;
@@ -768,6 +786,8 @@ static int luaModelGetMix(lua_State *L)
lua_pushtableinteger(L, "weight", mix->weight);
lua_pushtableinteger(L, "offset", mix->offset);
lua_pushtableinteger(L, "switch", mix->swtch);
lua_pushtableinteger(L, "curveType", mix->curve.type);
lua_pushtableinteger(L, "curveValue", mix->curve.value);
lua_pushtableinteger(L, "multiplex", mix->mltpx);
}
else {
@@ -809,6 +829,12 @@ static int luaModelInsertMix(lua_State *L)
else if (!strcmp(key, "switch")) {
mix->swtch = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "curveType")) {
mix->curve.type = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "curveValue")) {
mix->curve.value = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "multiplex")) {
mix->mltpx = luaL_checkinteger(L, -1);
}
@@ -897,6 +923,48 @@ static int luaModelSetLogicalSwitch(lua_State *L)
return 0;
}
static int luaModelGetCurve(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
if (idx < MAX_CURVES) {
CurveInfo & curveInfo = g_model.curves[idx];
lua_newtable(L);
lua_pushtablezstring(L, "name", g_model.curveNames[idx]);
lua_pushtableinteger(L, "type", curveInfo.type);
lua_pushtableboolean(L, "smooth", curveInfo.smooth);
lua_pushtableinteger(L, "points", curveInfo.points+5);
lua_pushstring(L, "y");
lua_newtable(L);
int8_t * point = curveAddress(idx);
for (int i=0; i<curveInfo.points+5; i++) {
lua_pushinteger(L, i);
lua_pushinteger(L, *point++);
lua_settable(L, -3);
}
lua_settable(L, -3);
if (curveInfo.type == CURVE_TYPE_CUSTOM) {
lua_pushstring(L, "x");
lua_newtable(L);
lua_pushinteger(L, 0);
lua_pushinteger(L, 0);
lua_settable(L, -3);
for (int i=0; i<curveInfo.points+3; i++) {
lua_pushinteger(L, i+1);
lua_pushinteger(L, *point++);
lua_settable(L, -3);
}
lua_pushinteger(L, curveInfo.points+4);
lua_pushinteger(L, 100);
lua_settable(L, -3);
lua_settable(L, -3);
}
}
else {
lua_pushnil(L);
}
return 1;
}
static int luaModelGetCustomFunction(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
@@ -1044,7 +1112,7 @@ static int luaModelSetGlobalVariable(lua_State *L)
int idx = luaL_checkunsigned(L, 1);
int phase = luaL_checkunsigned(L, 2);
int value = luaL_checkinteger(L, 3);
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_LIMIT && value <= GVAR_LIMIT) {
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_MAX && value <= GVAR_MAX) {
g_model.flightModeData[phase].gvars[idx] = value;
eeDirty(EE_MODEL);
}
@@ -1280,7 +1348,77 @@ int luaGetOutputs(ScriptInputsOutputs & sid)
return 0;
}
static const luaL_Reg modelLib[] = {
const luaL_Reg opentxLib[] = {
{ "getTime", luaGetTime },
{ "getVersion", luaGetVersion },
{ "getGeneralSettings", luaGetGeneralSettings },
{ "getValue", luaGetValue },
{ "getFieldInfo", luaGetFieldInfo },
{ "playFile", luaPlayFile },
{ "playNumber", luaPlayNumber },
// { "playDuration", luaPlayDuration },
// { "playTone", luaPlayTone },
{ "popupInput", luaPopupInput },
{ "defaultStick", luaDefaultStick },
{ "defaultChannel", luaDefaultChannel },
{ "killEvents", luaKillEvents },
{ NULL, NULL } /* sentinel */
};
const luaR_value_entry opentxConstants[] = {
{ "FULLSCALE", RESX },
{ "XXLSIZE", XXLSIZE },
{ "DBLSIZE", DBLSIZE },
{ "MIDSIZE", MIDSIZE },
{ "SMLSIZE", SMLSIZE },
{ "INVERS", INVERS },
{ "LEFT", LEFT },
{ "PREC1", PREC1 },
{ "PREC2", PREC2 },
{ "BLINK", BLINK },
{ "VALUE", 0 },
{ "SOURCE", 1 },
{ "REPLACE", MLTPX_REP },
{ "MIXSRC_FIRST_INPUT", MIXSRC_FIRST_INPUT },
{ "MIXSRC_Rud", MIXSRC_Rud },
{ "MIXSRC_Ele", MIXSRC_Ele },
{ "MIXSRC_Thr", MIXSRC_Thr },
{ "MIXSRC_Ail", MIXSRC_Ail },
{ "MIXSRC_SA", MIXSRC_SA },
{ "MIXSRC_SB", MIXSRC_SB },
{ "MIXSRC_SC", MIXSRC_SC },
{ "MIXSRC_SD", MIXSRC_SD },
{ "MIXSRC_SE", MIXSRC_SE },
{ "MIXSRC_SF", MIXSRC_SF },
{ "MIXSRC_SG", MIXSRC_SG },
{ "MIXSRC_SH", MIXSRC_SH },
{ "MIXSRC_CH1", MIXSRC_CH1 },
{ "SWSRC_LAST", SWSRC_LAST_LOGICAL_SWITCH },
{ "EVT_MENU_BREAK", EVT_KEY_BREAK(KEY_MENU) },
{ "EVT_PAGE_BREAK", EVT_KEY_BREAK(KEY_PAGE) },
{ "EVT_PAGE_LONG", EVT_KEY_LONG(KEY_PAGE) },
{ "EVT_ENTER_BREAK", EVT_KEY_BREAK(KEY_ENTER) },
{ "EVT_ENTER_LONG", EVT_KEY_LONG(KEY_ENTER) },
{ "EVT_EXIT_BREAK", EVT_KEY_BREAK(KEY_EXIT) },
{ "EVT_PLUS_BREAK", EVT_KEY_BREAK(KEY_PLUS) },
{ "EVT_MINUS_BREAK", EVT_KEY_BREAK(KEY_MINUS) },
{ "EVT_PLUS_FIRST", EVT_KEY_FIRST(KEY_PLUS) },
{ "EVT_MINUS_FIRST", EVT_KEY_FIRST(KEY_MINUS) },
{ "EVT_PLUS_REPT", EVT_KEY_REPT(KEY_PLUS) },
{ "EVT_MINUS_REPT", EVT_KEY_REPT(KEY_MINUS) },
{ "FILL_WHITE", FILL_WHITE },
{ "GREY_DEFAULT", GREY_DEFAULT },
{ "SOLID", SOLID },
{ "DOTTED", DOTTED },
{ "LCD_W", LCD_W },
{ "LCD_H", LCD_H },
{ "PLAY_NOW", PLAY_NOW },
{ "PLAY_BACKGROUND", PLAY_BACKGROUND },
{ "TIMEHOUR", TIMEHOUR },
{ NULL, 0 } /* sentinel */
};
const luaL_Reg modelLib[] = {
{ "getInfo", luaModelGetInfo },
{ "setInfo", luaModelSetInfo },
{ "getTimer", luaModelGetTimer },
@@ -1300,6 +1438,7 @@ static const luaL_Reg modelLib[] = {
{ "setLogicalSwitch", luaModelSetLogicalSwitch },
{ "getCustomFunction", luaModelGetCustomFunction },
{ "setCustomFunction", luaModelSetCustomFunction },
{ "getCurve", luaModelGetCurve },
{ "getOutput", luaModelGetOutput },
{ "setOutput", luaModelSetOutput },
{ "getGlobalVariable", luaModelGetGlobalVariable },
@@ -1309,7 +1448,7 @@ static const luaL_Reg modelLib[] = {
{ NULL, NULL } /* sentinel */
};
static const luaL_Reg lcdLib[] = {
const luaL_Reg lcdLib[] = {
{ "lock", luaLcdLock },
{ "clear", luaLcdClear },
{ "getLastPos", luaLcdGetLastPos },
@@ -1330,91 +1469,77 @@ static const luaL_Reg lcdLib[] = {
{ NULL, NULL } /* sentinel */
};
void luaInit()
void luaDisable()
{
POPUP_WARNING("Lua disabled!");
luaState = INTERPRETER_PANIC;
}
void luaClose()
{
if (L) {
lua_close(L);
PROTECT_LUA() {
lua_close(L); // this should not panic, but we make sure anyway
}
else {
// we can only disable Lua for the rest of the session
luaDisable();
}
UNPROTECT_LUA();
L = NULL;
}
}
L = luaL_newstate();
void luaRegisterAll()
{
// Init lua
luaL_openlibs(L);
}
// Push OpenTX libs
lua_registerlib(L, "model", modelLib);
lua_registerlib(L, "lcd", lcdLib);
void luaInit()
{
luaClose();
if (luaState != INTERPRETER_PANIC) {
L = luaL_newstate();
if (L) {
// install our panic handler
lua_atpanic(L, &custom_lua_atpanic);
// Push OpenTX functions
lua_register(L, "getTime", luaGetTime);
lua_register(L, "getVersion", luaGetVersion);
lua_register(L, "getGeneralSettings", luaGetGeneralSettings);
lua_register(L, "getValue", luaGetValue);
lua_register(L, "getFieldInfo", luaGetFieldInfo);
lua_register(L, "playFile", luaPlayFile);
lua_register(L, "playNumber", luaPlayNumber);
lua_register(L, "popupInput", luaPopupInput);
lua_register(L, "defaultStick", luaDefaultStick);
lua_register(L, "defaultChannel", luaDefaultChannel);
lua_register(L, "killEvents", luaKillEvents);
// Push OpenTX constants
lua_registerint(L, "FULLSCALE", RESX);
lua_registerint(L, "XXLSIZE", XXLSIZE);
lua_registerint(L, "DBLSIZE", DBLSIZE);
lua_registerint(L, "MIDSIZE", MIDSIZE);
lua_registerint(L, "SMLSIZE", SMLSIZE);
lua_registerint(L, "INVERS", INVERS);
lua_registerint(L, "LEFT", LEFT);
lua_registerint(L, "PREC1", PREC1);
lua_registerint(L, "PREC2", PREC2);
lua_registerint(L, "BLINK", BLINK);
lua_registerint(L, "VALUE", 0);
lua_registerint(L, "SOURCE", 1);
lua_registerint(L, "REPLACE", MLTPX_REP);
lua_registerint(L, "MIXSRC_FIRST_INPUT", MIXSRC_FIRST_INPUT);
lua_registerint(L, "MIXSRC_Rud", MIXSRC_Rud);
lua_registerint(L, "MIXSRC_Ele", MIXSRC_Ele);
lua_registerint(L, "MIXSRC_Thr", MIXSRC_Thr);
lua_registerint(L, "MIXSRC_Ail", MIXSRC_Ail);
lua_registerint(L, "MIXSRC_SA", MIXSRC_SA);
lua_registerint(L, "MIXSRC_SB", MIXSRC_SB);
lua_registerint(L, "MIXSRC_SC", MIXSRC_SC);
lua_registerint(L, "MIXSRC_SD", MIXSRC_SD);
lua_registerint(L, "MIXSRC_SE", MIXSRC_SE);
lua_registerint(L, "MIXSRC_SF", MIXSRC_SF);
lua_registerint(L, "MIXSRC_SG", MIXSRC_SG);
lua_registerint(L, "MIXSRC_SH", MIXSRC_SH);
lua_registerint(L, "MIXSRC_CH1", MIXSRC_CH1);
lua_registerint(L, "SWSRC_LAST", SWSRC_LAST_LOGICAL_SWITCH);
lua_registerint(L, "EVT_MENU_BREAK", EVT_KEY_BREAK(KEY_MENU));
lua_registerint(L, "EVT_PAGE_BREAK", EVT_KEY_BREAK(KEY_PAGE));
lua_registerint(L, "EVT_PAGE_LONG", EVT_KEY_LONG(KEY_PAGE));
lua_registerint(L, "EVT_ENTER_BREAK", EVT_KEY_BREAK(KEY_ENTER));
lua_registerint(L, "EVT_ENTER_LONG", EVT_KEY_LONG(KEY_ENTER));
lua_registerint(L, "EVT_EXIT_BREAK", EVT_KEY_BREAK(KEY_EXIT));
lua_registerint(L, "EVT_PLUS_BREAK", EVT_KEY_BREAK(KEY_PLUS));
lua_registerint(L, "EVT_MINUS_BREAK", EVT_KEY_BREAK(KEY_MINUS));
lua_registerint(L, "EVT_PLUS_FIRST", EVT_KEY_FIRST(KEY_PLUS));
lua_registerint(L, "EVT_MINUS_FIRST", EVT_KEY_FIRST(KEY_MINUS));
lua_registerint(L, "EVT_PLUS_REPT", EVT_KEY_REPT(KEY_PLUS));
lua_registerint(L, "EVT_MINUS_REPT", EVT_KEY_REPT(KEY_MINUS));
lua_registerint(L, "FILL_WHITE", FILL_WHITE);
lua_registerint(L, "GREY_DEFAULT", GREY_DEFAULT);
lua_registerint(L, "SOLID", SOLID);
lua_registerint(L, "DOTTED", DOTTED);
lua_registerint(L, "LCD_W", LCD_W);
lua_registerint(L, "LCD_H", LCD_H);
// protect libs and constants registration
PROTECT_LUA() {
luaRegisterAll();
}
else {
// if we got panic during registration
// we disable Lua for this session
luaDisable();
}
UNPROTECT_LUA();
}
else {
/* log error and return */
luaDisable();
}
}
}
void luaFree(ScriptInternalData & sid)
{
if (sid.run) {
luaL_unref(L, LUA_REGISTRYINDEX, sid.run);
sid.run = 0;
PROTECT_LUA() {
if (sid.run) {
luaL_unref(L, LUA_REGISTRYINDEX, sid.run);
sid.run = 0;
}
if (sid.background) {
luaL_unref(L, LUA_REGISTRYINDEX, sid.background);
sid.background = 0;
}
lua_gc(L, LUA_GCCOLLECT, 0);
}
else {
luaDisable();
}
UNPROTECT_LUA();
}
int luaLoad(const char *filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=NULL)
@@ -1424,51 +1549,66 @@ int luaLoad(const char *filename, ScriptInternalData & sid, ScriptInputsOutputs
sid.instructions = 0;
sid.state = SCRIPT_OK;
#if 0
// not needed, we just called luaInit
luaFree(sid);
#endif
if (luaState == INTERPRETER_PANIC) {
return SCRIPT_PANIC;
}
SET_LUA_INSTRUCTIONS_COUNT(MANUAL_SCRIPTS_MAX_INSTRUCTIONS);
if (luaL_loadfile(L, filename) == 0 &&
lua_pcall(L, 0, 1, 0) == 0 &&
lua_istable(L, -1)) {
PROTECT_LUA() {
if (luaL_loadfile(L, filename) == 0 &&
lua_pcall(L, 0, 1, 0) == 0 &&
lua_istable(L, -1)) {
luaL_checktype(L, -1, LUA_TTABLE);
luaL_checktype(L, -1, LUA_TTABLE);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
const char *key = lua_tostring(L, -2);
if (!strcmp(key, "init")) {
init = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
const char *key = lua_tostring(L, -2);
if (!strcmp(key, "init")) {
init = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (!strcmp(key, "run")) {
sid.run = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (!strcmp(key, "background")) {
sid.background = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (sio && !strcmp(key, "input")) {
luaGetInputs(*sio);
}
else if (sio && !strcmp(key, "output")) {
luaGetOutputs(*sio);
}
}
else if (!strcmp(key, "run")) {
sid.run = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (!strcmp(key, "background")) {
sid.background = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushnil(L);
}
else if (sio && !strcmp(key, "input")) {
luaGetInputs(*sio);
}
else if (sio && !strcmp(key, "output")) {
luaGetOutputs(*sio);
if (init) {
lua_rawgeti(L, LUA_REGISTRYINDEX, init);
if (lua_pcall(L, 0, 0, 0) != 0) {
TRACE("Error in script %s init: %s", filename, lua_tostring(L, -1));
sid.state = SCRIPT_SYNTAX_ERROR;
}
luaL_unref(L, LUA_REGISTRYINDEX, init);
lua_gc(L, LUA_GCCOLLECT, 0);
}
}
if (init) {
lua_rawgeti(L, LUA_REGISTRYINDEX, init);
luaL_unref(L, LUA_REGISTRYINDEX, init);
if (lua_pcall(L, 0, 0, 0) != 0) {
TRACE("Error in script %s init: %s", filename, lua_tostring(L, -1));
sid.state = SCRIPT_SYNTAX_ERROR;
}
else {
TRACE("Error in script %s: %s", filename, lua_tostring(L, -1));
sid.state = SCRIPT_SYNTAX_ERROR;
}
}
else {
TRACE("Error in script %s: %s", filename, lua_tostring(L, -1));
sid.state = SCRIPT_SYNTAX_ERROR;
luaDisable();
return SCRIPT_PANIC;
}
UNPROTECT_LUA();
if (sid.state != SCRIPT_OK) {
luaFree(sid);
@@ -1477,7 +1617,7 @@ int luaLoad(const char *filename, ScriptInternalData & sid, ScriptInputsOutputs
return sid.state;
}
void luaLoadMixScript(uint8_t index)
bool luaLoadMixScript(uint8_t index)
{
ScriptData & sd = g_model.scriptsData[index];
@@ -1490,8 +1630,11 @@ void luaLoadMixScript(uint8_t index)
strncpy(filename+sizeof(SCRIPTS_MIXES_PATH), sd.file, sizeof(sd.file));
filename[sizeof(SCRIPTS_MIXES_PATH)+sizeof(sd.file)] = '\0';
strcat(filename+sizeof(SCRIPTS_MIXES_PATH), SCRIPTS_EXT);
luaLoad(filename, sid, sio);
if (luaLoad(filename, sid, sio) == SCRIPT_PANIC) {
return false;
}
}
return true;
}
bool luaLoadFunctionScript(uint8_t index)
@@ -1507,13 +1650,15 @@ bool luaLoadFunctionScript(uint8_t index)
strncpy(filename+sizeof(SCRIPTS_FUNCS_PATH), fn.play.name, sizeof(fn.play.name));
filename[sizeof(SCRIPTS_FUNCS_PATH)+sizeof(fn.play.name)] = '\0';
strcat(filename+sizeof(SCRIPTS_FUNCS_PATH), SCRIPTS_EXT);
luaLoad(filename, sid);
if (luaLoad(filename, sid) == SCRIPT_PANIC) {
return false;
}
}
else {
POPUP_WARNING(STR_TOO_MANY_LUA_SCRIPTS);
return false;
}
}
return true;
}
@@ -1542,9 +1687,12 @@ bool luaLoadTelemetryScript(uint8_t index)
ScriptInternalData & sid = scriptInternalData[luaScriptsCount++];
sid.reference = SCRIPT_TELEMETRY_FIRST+index;
sid.state = SCRIPT_NOFILE;
luaLoad(path, sid);
if (luaLoad(path, sid) == SCRIPT_PANIC) {
return false;
}
}
else {
POPUP_WARNING(STR_TOO_MANY_LUA_SCRIPTS);
return false;
}
}
@@ -1570,13 +1718,14 @@ void luaLoadPermanentScripts()
// Load model scripts
for (int i=0; i<MAX_SCRIPTS; i++) {
luaLoadMixScript(i);
if (!luaLoadMixScript(i)) {
return;
}
}
// Load custom function scripts
for (int i=0; i<NUM_CFN; i++) {
if (!luaLoadFunctionScript(i)) {
POPUP_WARNING(STR_TOO_MANY_LUA_SCRIPTS);
return;
}
}
@@ -1584,16 +1733,13 @@ void luaLoadPermanentScripts()
// Load custom telemetry scripts
for (int i=0; i<MAX_SCRIPTS; i++) {
if (!luaLoadTelemetryScript(i)) {
POPUP_WARNING(STR_TOO_MANY_LUA_SCRIPTS);
return;
}
}
if (!luaLoadTelemetryScript(TELEMETRY_VOLTAGES_SCREEN)) {
POPUP_WARNING(STR_TOO_MANY_LUA_SCRIPTS);
return;
}
if (!luaLoadTelemetryScript(TELEMETRY_AFTER_FLIGHT_SCREEN)) {
POPUP_WARNING(STR_TOO_MANY_LUA_SCRIPTS);
return;
}
}
@@ -1630,6 +1776,9 @@ void luaError(uint8_t error)
case SCRIPT_KILLED:
msg = "Script killed";
break;
case SCRIPT_PANIC:
msg = "Script panic";
break;
}
POPUP_WARNING(msg);
}
@@ -1637,22 +1786,202 @@ void luaError(uint8_t error)
void luaExec(const char *filename)
{
LUA_RESET();
standaloneScript.state = SCRIPT_NOFILE;
int result = luaLoad(filename, standaloneScript);
// TODO the same with run ...
if (result == SCRIPT_OK) {
luaState = LUASTATE_STANDALONE_SCRIPT_RUNNING;
luaInit();
if (luaState != INTERPRETER_PANIC) {
standaloneScript.state = SCRIPT_NOFILE;
int result = luaLoad(filename, standaloneScript);
// TODO the same with run ...
if (result == SCRIPT_OK) {
luaState = INTERPRETER_RUNNING_STANDALONE_SCRIPT;
}
else {
luaError(result);
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
}
}
else {
luaError(result);
}
void luaDoOneRunStandalone(uint8_t evt)
{
static uint8_t luaDisplayStatistics = false;
if (standaloneScript.state == SCRIPT_OK && standaloneScript.run) {
SET_LUA_INSTRUCTIONS_COUNT(MANUAL_SCRIPTS_MAX_INSTRUCTIONS);
lua_rawgeti(L, LUA_REGISTRYINDEX, standaloneScript.run);
lua_pushinteger(L, evt);
if (lua_pcall(L, 1, 1, 0) == 0) {
if (!lua_isnumber(L, -1)) {
if (instructionsPercent > 100) {
TRACE("Script killed");
standaloneScript.state = SCRIPT_KILLED;
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
}
else if (lua_isstring(L, -1)) {
char nextScript[_MAX_LFN+1];
strncpy(nextScript, lua_tostring(L, -1), _MAX_LFN);
nextScript[_MAX_LFN] = '\0';
luaExec(nextScript);
}
else {
TRACE("Script error");
standaloneScript.state = SCRIPT_SYNTAX_ERROR;
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
}
}
else {
int scriptResult = lua_tointeger(L, -1);
lua_pop(L, 1); /* pop returned value */
if (scriptResult != 0) {
TRACE("Script finished with status %d", scriptResult);
standaloneScript.state = SCRIPT_NOFILE;
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
return;
}
else if (luaDisplayStatistics) {
lcd_hline(0, 7*FH-1, lcdLastPos+FW, ERASE);
lcd_puts(0, 7*FH, "GV Use: ");
lcd_outdezAtt(lcdLastPos, 7*FH, luaGetMemUsed(), LEFT);
lcd_putc(lcdLastPos, 7*FH, 'b');
lcd_hline(0, 7*FH-2, lcdLastPos+FW, FORCE);
lcd_vlineStip(lcdLastPos+FW, 7*FH-2, FH+2, SOLID, FORCE);
}
}
}
else {
TRACE("Script error: %s", lua_tostring(L, -1));
standaloneScript.state = (instructionsPercent > 100 ? SCRIPT_KILLED : SCRIPT_SYNTAX_ERROR);
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
}
if (standaloneScript.state != SCRIPT_OK) {
luaError(standaloneScript.state);
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
}
if (evt == EVT_KEY_LONG(KEY_EXIT)) {
TRACE("Script force exit");
killEvents(evt);
standaloneScript.state = SCRIPT_NOFILE;
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
}
else if (evt == EVT_KEY_LONG(KEY_MENU)) {
killEvents(evt);
luaDisplayStatistics = !luaDisplayStatistics;
}
}
}
void luaDoOneRunPermanentScript(uint8_t evt, int i)
{
ScriptInternalData & sid = scriptInternalData[i];
if (sid.state == SCRIPT_OK) {
SET_LUA_INSTRUCTIONS_COUNT(PERMANENT_SCRIPTS_MAX_INSTRUCTIONS);
int inputsCount = 0;
#if defined(SIMU) || defined(DEBUG)
const char *filename;
#endif
ScriptInputsOutputs * sio = NULL;
if (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST) {
ScriptData & sd = g_model.scriptsData[sid.reference-SCRIPT_MIX_FIRST];
sio = &scriptInputsOutputs[sid.reference-SCRIPT_MIX_FIRST];
inputsCount = sio->inputsCount;
#if defined(SIMU) || defined(DEBUG)
filename = sd.file;
#endif
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
for (int j=0; j<sio->inputsCount; j++) {
if (sio->inputs[j].type == 1)
luaGetValueAndPush((uint8_t)sd.inputs[j]);
else
lua_pushinteger(L, sd.inputs[j] + sio->inputs[j].def);
}
}
else if (sid.reference >= SCRIPT_FUNC_FIRST && sid.reference <= SCRIPT_FUNC_LAST) {
CustomFnData & fn = g_model.funcSw[sid.reference-SCRIPT_FUNC_FIRST];
if (!getSwitch(fn.swtch)) {
return;
}
#if defined(SIMU) || defined(DEBUG)
filename = fn.play.name;
#endif
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
}
else {
#if defined(SIMU) || defined(DEBUG)
filename = "[telem]";
#endif
if (g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view) {
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
lua_pushinteger(L, evt);
inputsCount = 1;
}
else if (sid.background) {
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.background);
}
else {
return;
}
}
if (lua_pcall(L, inputsCount, sio ? sio->outputsCount : 0, 0) == 0) {
if (sio) {
for (int j=sio->outputsCount-1; j>=0; j--) {
if (!lua_isnumber(L, -1)) {
sid.state = (instructionsPercent > 100 ? SCRIPT_KILLED : SCRIPT_SYNTAX_ERROR);
TRACE("Script %8s disabled", filename);
break;
}
sio->outputs[j].value = lua_tointeger(L, -1);
lua_pop(L, 1);
}
}
}
else {
if (instructionsPercent > 100) {
TRACE("Script %8s killed", filename);
sid.state = SCRIPT_KILLED;
}
else {
TRACE("Script %8s error: %s", filename, lua_tostring(L, -1));
sid.state = SCRIPT_SYNTAX_ERROR;
}
}
if (sid.state != SCRIPT_OK) {
luaFree(sid);
}
else {
if (instructionsPercent > sid.instructions) {
sid.instructions = instructionsPercent;
}
}
}
}
void luaDoGc()
{
if (L) {
PROTECT_LUA() {
lua_gc(L, LUA_GCCOLLECT, 0);
#if defined(SIMU) || defined(DEBUG)
static int lastgc = 0;
int gc = luaGetMemUsed();
if (gc != lastgc) {
lastgc = gc;
TRACE("GC Use: %dbytes", gc);
}
#endif
}
else {
// we disable Lua for the rest of the session
luaDisable();
}
UNPROTECT_LUA();
}
}
void luaTask(uint8_t evt)
{
lcd_locked = false;
static uint8_t luaDisplayStatistics = false;
uint32_t t0 = get_tmr10ms();
static uint32_t lastLuaTime = 0;
@@ -1662,176 +1991,43 @@ void luaTask(uint8_t evt)
maxLuaInterval = interval;
}
if (luaState & LUASTATE_STANDALONE_SCRIPT_RUNNING) {
// standalone script
if (standaloneScript.state == SCRIPT_OK && standaloneScript.run) {
SET_LUA_INSTRUCTIONS_COUNT(MANUAL_SCRIPTS_MAX_INSTRUCTIONS);
lua_rawgeti(L, LUA_REGISTRYINDEX, standaloneScript.run);
lua_pushinteger(L, evt);
if (lua_pcall(L, 1, 1, 0) == 0) {
if (!lua_isnumber(L, -1)) {
if (instructionsPercent > 100) {
TRACE("Script killed");
standaloneScript.state = SCRIPT_KILLED;
luaState = LUASTATE_RELOAD_MODEL_SCRIPTS;
}
else if (lua_isstring(L, -1)) {
char nextScript[_MAX_LFN+1];
strncpy(nextScript, lua_tostring(L, -1), _MAX_LFN);
nextScript[_MAX_LFN] = '\0';
luaExec(nextScript);
}
else {
TRACE("Script error");
standaloneScript.state = SCRIPT_SYNTAX_ERROR;
luaState = LUASTATE_RELOAD_MODEL_SCRIPTS;
}
}
else {
int scriptResult = lua_tointeger(L, -1);
lua_pop(L, 1); /* pop returned value */
if (scriptResult != 0) {
TRACE("Script finished with status %d", scriptResult);
standaloneScript.state = SCRIPT_NOFILE;
luaState = LUASTATE_RELOAD_MODEL_SCRIPTS;
}
else if (luaDisplayStatistics) {
int gc = 1000*lua_gc(L, LUA_GCCOUNT, 0) + lua_gc(L, LUA_GCCOUNTB, 0);
lcd_hline(0, 7*FH-1, lcdLastPos+FW, ERASE);
lcd_puts(0, 7*FH, "GV Use: ");
lcd_outdezAtt(lcdLastPos, 7*FH, gc, LEFT);
lcd_putc(lcdLastPos, 7*FH, 'b');
lcd_hline(0, 7*FH-2, lcdLastPos+FW, FORCE);
lcd_vlineStip(lcdLastPos+FW, 7*FH-2, FH+2, SOLID, FORCE);
}
}
}
else {
TRACE("Script error: %s", lua_tostring(L, -1));
standaloneScript.state = (instructionsPercent > 100 ? SCRIPT_KILLED : SCRIPT_SYNTAX_ERROR);
luaState = LUASTATE_RELOAD_MODEL_SCRIPTS;
}
if (luaState == INTERPRETER_PANIC) {
return;
}
if (standaloneScript.state != SCRIPT_OK) {
luaError(standaloneScript.state);
}
if (evt == EVT_KEY_LONG(KEY_EXIT)) {
TRACE("Script force exit");
killEvents(evt);
standaloneScript.state = SCRIPT_NOFILE;
luaState = LUASTATE_RELOAD_MODEL_SCRIPTS;
}
else if (evt == EVT_KEY_LONG(KEY_MENU)) {
killEvents(evt);
luaDisplayStatistics = !luaDisplayStatistics;
}
if (luaState & INTERPRETER_RUNNING_STANDALONE_SCRIPT) {
PROTECT_LUA() {
luaDoOneRunStandalone(evt);
}
else {
luaDisable();
return;
}
UNPROTECT_LUA();
}
else {
// model scripts
if (luaState & LUASTATE_RELOAD_MODEL_SCRIPTS) {
if (luaState & INTERPRETER_RELOAD_PERMANENT_SCRIPTS) {
luaState = 0;
LUA_RESET();
luaInit();
if (luaState == INTERPRETER_PANIC) return;
luaLoadPermanentScripts();
if (luaState == INTERPRETER_PANIC) return;
}
for (int i=0; i<luaScriptsCount; i++) {
ScriptInternalData & sid = scriptInternalData[i];
if (sid.state == SCRIPT_OK) {
SET_LUA_INSTRUCTIONS_COUNT(PERMANENT_SCRIPTS_MAX_INSTRUCTIONS);
int inputsCount = 0;
#if defined(SIMU) || defined(DEBUG)
const char *filename;
#endif
ScriptInputsOutputs * sio = NULL;
if (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST) {
ScriptData & sd = g_model.scriptsData[sid.reference-SCRIPT_MIX_FIRST];
sio = &scriptInputsOutputs[sid.reference-SCRIPT_MIX_FIRST];
inputsCount = sio->inputsCount;
#if defined(SIMU) || defined(DEBUG)
filename = sd.file;
#endif
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
for (int j=0; j<sio->inputsCount; j++) {
if (sio->inputs[j].type == 1)
luaGetValueAndPush((uint8_t)sd.inputs[j]);
else
lua_pushinteger(L, sd.inputs[j] + sio->inputs[j].def);
}
}
else if (sid.reference >= SCRIPT_FUNC_FIRST && sid.reference <= SCRIPT_FUNC_LAST) {
CustomFnData & fn = g_model.funcSw[sid.reference-SCRIPT_FUNC_FIRST];
if (!getSwitch(fn.swtch)) {
continue;
}
#if defined(SIMU) || defined(DEBUG)
filename = fn.play.name;
#endif
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
}
else {
#if defined(SIMU) || defined(DEBUG)
filename = "[telem]";
#endif
if (g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view) {
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run);
lua_pushinteger(L, evt);
inputsCount = 1;
}
else if (sid.background) {
lua_rawgeti(L, LUA_REGISTRYINDEX, sid.background);
}
else {
continue;
}
}
if (lua_pcall(L, inputsCount, sio ? sio->outputsCount : 0, 0) == 0) {
if (sio) {
for (int j=sio->outputsCount-1; j>=0; j--) {
if (!lua_isnumber(L, -1)) {
sid.state = (instructionsPercent > 100 ? SCRIPT_KILLED : SCRIPT_SYNTAX_ERROR);
TRACE("Script %8s disabled", filename);
break;
}
sio->outputs[j].value = lua_tointeger(L, -1);
lua_pop(L, 1);
}
}
}
else {
if (instructionsPercent > 100) {
TRACE("Script %8s killed", filename);
sid.state = SCRIPT_KILLED;
}
else {
TRACE("Script %8s error: %s", filename, lua_tostring(L, -1));
sid.state = SCRIPT_SYNTAX_ERROR;
}
}
if (sid.state != SCRIPT_OK) {
luaFree(sid);
}
else {
if (instructionsPercent > sid.instructions) {
sid.instructions = instructionsPercent;
}
}
PROTECT_LUA() {
luaDoOneRunPermanentScript(evt, i);
}
else {
luaDisable();
return;
}
UNPROTECT_LUA();
}
}
lua_gc(L, LUA_GCCOLLECT, 0);
#if defined(SIMU) || defined(DEBUG)
static int lastgc = 0;
int gc = luaGetMemUsed();
if (gc != lastgc) {
lastgc = gc;
TRACE("GC Use: %dbytes", gc);
}
#endif
luaDoGc();
t0 = get_tmr10ms() - t0;
if (t0 > maxLuaDuration) {
@@ -1841,5 +2037,5 @@ void luaTask(uint8_t evt)
int luaGetMemUsed()
{
return 1000*lua_gc(L, LUA_GCCOUNT, 0) + lua_gc(L, LUA_GCCOUNTB, 0);
return (lua_gc(L, LUA_GCCOUNT, 0) << 10) + lua_gc(L, LUA_GCCOUNTB, 0);
}
+34 -12
View File
@@ -23,6 +23,7 @@
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "lrotable.h"
#include "ltm.h"
#include "lundump.h"
#include "lvm.h"
@@ -260,7 +261,7 @@ LUA_API const char *lua_typename (lua_State *L, int t) {
LUA_API int lua_iscfunction (lua_State *L, int idx) {
StkId o = index2addr(L, idx);
return (ttislcf(o) || (ttisCclosure(o)));
return (ttislcf(o) || ttislightfunction(o) || (ttisCclosure(o)));
}
@@ -417,7 +418,7 @@ LUA_API size_t lua_rawlen (lua_State *L, int idx) {
LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
StkId o = index2addr(L, idx);
if (ttislcf(o)) return fvalue(o);
if (ttislcf(o)) return lcfvalue(o);
else if (ttisCclosure(o))
return clCvalue(o)->f;
else return NULL; /* not a C function */
@@ -446,11 +447,14 @@ LUA_API const void *lua_topointer (lua_State *L, int idx) {
case LUA_TTABLE: return hvalue(o);
case LUA_TLCL: return clLvalue(o);
case LUA_TCCL: return clCvalue(o);
case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o)));
case LUA_TLCF: return cast(void *, cast(size_t, lcfvalue(o)));
case LUA_TTHREAD: return thvalue(o);
case LUA_TUSERDATA:
case LUA_TLIGHTUSERDATA:
return lua_touserdata(L, idx);
case LUA_TROTABLE:
case LUA_TLIGHTFUNCTION:
return pvalue(o);
default: return NULL;
}
}
@@ -551,11 +555,10 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
return ret;
}
LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
lua_lock(L);
if (n == 0) {
setfvalue(L->top, fn);
setlcfvalue(L->top, fn);
}
else {
Closure *cl;
@@ -573,7 +576,6 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
lua_unlock(L);
}
LUA_API void lua_pushboolean (lua_State *L, int b) {
lua_lock(L);
setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
@@ -589,6 +591,19 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
lua_unlock(L);
}
LUA_API void lua_pushrotable (lua_State *L, void *p) {
lua_lock(L);
setrvalue(L->top, p);
api_incr_top(L);
lua_unlock(L);
}
LUA_API void lua_pushlightfunction(lua_State *L, void *p) {
lua_lock(L);
setlfvalue(L->top, p);
api_incr_top(L);
lua_unlock(L);
}
LUA_API int lua_pushthread (lua_State *L) {
lua_lock(L);
@@ -598,8 +613,6 @@ LUA_API int lua_pushthread (lua_State *L) {
return (G(L)->mainthread == L);
}
/*
** get functions (Lua -> stack)
*/
@@ -609,9 +622,19 @@ LUA_API void lua_getglobal (lua_State *L, const char *var) {
Table *reg = hvalue(&G(L)->l_registry);
const TValue *gt; /* global table */
lua_lock(L);
gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
setsvalue2s(L, L->top++, luaS_new(L, var));
luaV_gettable(L, gt, L->top - 1, L->top - 1);
lu_byte keytype;
luaR_result res = luaR_findglobal(var, &keytype);
if (res != 0) {
setsvalue2s(L, L->top++, luaS_new(L, var));
setlfvalue(L->top - 1, (void*)(size_t)res)
}
else {
gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
setsvalue2s(L, L->top++, luaS_new(L, var));
luaV_gettable(L, gt, L->top - 1, L->top - 1);
}
lua_unlock(L);
}
@@ -1008,7 +1031,6 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
return status;
}
LUA_API int lua_status (lua_State *L) {
return L->status;
}
+6
View File
@@ -24,6 +24,12 @@ typedef struct luaL_Reg {
lua_CFunction func;
} luaL_Reg;
extern const luaL_Reg baselib[];
extern const luaL_Reg mathlib[];
extern const luaL_Reg opentxLib[];
extern const luaL_Reg bitlib[];
extern const luaL_Reg lcdLib[];
extern const luaL_Reg modelLib[];
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM)
+9 -16
View File
@@ -16,7 +16,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
static int luaB_print (lua_State *L) {
int n = lua_gettop(L); /* number of arguments */
@@ -411,8 +411,7 @@ static int luaB_tostring (lua_State *L) {
return 1;
}
static const luaL_Reg base_funcs[] = {
const luaL_Reg baselib[] = {
{"assert", luaB_assert},
{"collectgarbage", luaB_collectgarbage},
{"dofile", luaB_dofile},
@@ -441,16 +440,10 @@ static const luaL_Reg base_funcs[] = {
{NULL, NULL}
};
LUAMOD_API int luaopen_base (lua_State *L) {
/* set global _G */
lua_pushglobaltable(L);
lua_pushglobaltable(L);
lua_setfield(L, -2, "_G");
/* open lib into global table */
luaL_setfuncs(L, base_funcs, 0);
lua_pushliteral(L, LUA_VERSION);
lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */
return 1;
}
#if 0
// TODO
const luaR_value_entry baselib_vals[] = {
{"_VERSION", LUA_VERSION},
{NULL, 0}
};
#endif
+6 -4
View File
@@ -11,6 +11,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
/* number of bits to consider in a number */
#if !defined(LUA_NBITS)
@@ -185,7 +186,7 @@ static int b_replace (lua_State *L) {
}
static const luaL_Reg bitlib[] = {
const luaL_Reg bitlib[] = {
{"arshift", b_arshift},
{"band", b_and},
{"bnot", b_not},
@@ -201,10 +202,11 @@ static const luaL_Reg bitlib[] = {
{NULL, NULL}
};
const luaR_value_entry bitlib_vals[] = {
{NULL, 0}
};
LUAMOD_API int luaopen_bit32 (lua_State *L) {
luaL_newlib(L, bitlib);
return 1;
return 0;
}
+4 -1
View File
@@ -299,7 +299,10 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
ptrdiff_t funcr = savestack(L, func);
switch (ttype(func)) {
case LUA_TLCF: /* light C function */
f = fvalue(func);
f = lcfvalue(func);
goto Cfunc;
case LUA_TLIGHTFUNCTION:
f = check_exp(ttislightfunction(func), val_(func).f);
goto Cfunc;
case LUA_TCCL: { /* C closure */
f = clCvalue(func)->f;
+14 -2
View File
@@ -20,13 +20,14 @@
#include "lualib.h"
#include "lauxlib.h"
#include "lrotable.h"
/*
** these libs are loaded by lua.c and are readily available to any Lua
** program
*/
static const luaL_Reg loadedlibs[] = {
{"_G", luaopen_base},
// {"_G", luaopen_base},
// {LUA_LOADLIBNAME, luaopen_package},
// {LUA_COLIBNAME, luaopen_coroutine},
// {LUA_TABLIBNAME, luaopen_table},
@@ -34,11 +35,22 @@ static const luaL_Reg loadedlibs[] = {
// {LUA_OSLIBNAME, luaopen_os},
// {LUA_STRLIBNAME, luaopen_string},
// {LUA_BITLIBNAME, luaopen_bit32},
{LUA_MATHLIBNAME, luaopen_math},
// {LUA_MATHLIBNAME, luaopen_math},
// {LUA_DBLIBNAME, luaopen_debug},
{NULL, NULL}
};
/* The read-only tables are defined here */
const luaR_table lua_rotable[] =
{
{LUA_MATHLIBNAME, mathlib, mathlib_vals},
{LUA_BITLIBNAME, bitlib, NULL},
{"lcd", lcdLib, NULL},
{"model", modelLib, NULL},
{"__baselib", baselib, NULL},
{"__opentx", opentxLib, opentxConstants},
{NULL, NULL, NULL}
};
/*
** these libs are preloaded and must be required before used
+10 -10
View File
@@ -15,6 +15,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
#undef PI
#define PI ((lua_Number)(3.1415926535897932384626433832795))
@@ -228,20 +229,19 @@ static int math_randomseed (lua_State *L) {
return 0;
}
static const luaL_Reg mathlib[] = {
const luaL_Reg mathlib[] = {
{"abs", math_abs},
{"acos", math_acos},
{"asin", math_asin},
{"atan2", math_atan2},
{"atan", math_atan},
{"ceil", math_ceil},
{"cosh", math_cosh},
{"cosh", math_cosh},
{"cos", math_cos},
{"deg", math_deg},
{"exp", math_exp},
{"floor", math_floor},
{"fmod", math_fmod},
{"fmod", math_fmod},
{"frexp", math_frexp},
{"ldexp", math_ldexp},
#if defined(LUA_COMPAT_LOG10)
@@ -263,16 +263,16 @@ static const luaL_Reg mathlib[] = {
{NULL, NULL}
};
const luaR_value_entry mathlib_vals[] = {
{"pi", PI},
{"huge", HUGE_VAL},
{NULL, 0}
};
/*
** Open math library
*/
LUAMOD_API int luaopen_math (lua_State *L) {
luaL_newlib(L, mathlib);
lua_pushnumber(L, PI);
lua_setfield(L, -2, "pi");
lua_pushnumber(L, HUGE_VAL);
lua_setfield(L, -2, "huge");
return 1;
return 0;
}
+12 -2
View File
@@ -137,6 +137,8 @@ typedef union Value Value;
#define ttisnil(o) checktag((o), LUA_TNIL)
#define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
#define ttisrotable(o) checktag((o), LUA_TROTABLE)
#define ttislightfunction(o) checktag((o), LUA_TLIGHTFUNCTION)
#define ttisstring(o) checktype((o), LUA_TSTRING)
#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
@@ -156,6 +158,8 @@ typedef union Value Value;
#define nvalue(o) check_exp(ttisnumber(o), num_(o))
#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
#define rvalue(o) check_exp(ttisrotable(o), val_(o).p)
#define lfvalue(o) check_exp(ttislightfunction(o), val_(o).p)
#define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts)
#define tsvalue(o) (&rawtsvalue(o)->tsv)
#define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u)
@@ -163,7 +167,7 @@ typedef union Value Value;
#define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl)
#define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
#define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
#define fvalue(o) check_exp(ttislcf(o), val_(o).f)
#define lcfvalue(o) check_exp(ttislcf(o), val_(o).f)
#define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h)
#define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
#define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th)
@@ -192,12 +196,18 @@ typedef union Value Value;
#define setnilvalue(obj) settt_(obj, LUA_TNIL)
#define setfvalue(obj,x) \
#define setlcfvalue(obj,x) \
{ TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
#define setpvalue(obj,x) \
{ TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
#define setrvalue(obj,x) \
{ TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TROTABLE); }
#define setlfvalue(obj,x) \
{ TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTFUNCTION); }
#define setbvalue(obj,x) \
{ TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
+86
View File
@@ -0,0 +1,86 @@
/* Read-only tables for Lua */
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lrotable.h"
/* Local defines */
#define LUAR_FINDFUNCTION 0
#define LUAR_FINDVALUE 1
/* Utility function: find a key in a given table (of functions or constants) */
static luaR_result luaR_findkey(const void *where, const char *key, int type, int *found) {
const char *pname;
const luaL_Reg *pf = (luaL_Reg*)where;
const luaR_value_entry *pv = (luaR_value_entry*)where;
int isfunction = type == LUAR_FINDFUNCTION;
*found = 0;
if(!where)
return 0;
while(1) {
if (!(pname = isfunction ? pf->name : pv->name))
break;
if (!strcmp(pname, key)) {
*found = 1;
return isfunction ? (luaR_result)(size_t)pf->func : (luaR_result)pv->value;
}
pf ++; pv ++;
}
return 0;
}
/* Find a global "read only table" in the constant lua_rotable array */
luaR_result luaR_findglobal(const char *name, lu_byte *ptype) {
unsigned i;
*ptype = LUA_TNIL;
if (strlen(name) > LUA_MAX_ROTABLE_NAME)
return 0;
for (i=0; lua_rotable[i].name; i++) {
if (!strcmp(lua_rotable[i].name, name)) {
*ptype = LUA_TROTABLE;
return i+1;
}
if (!strncmp(lua_rotable[i].name, "__", 2)) {
int result = luaR_findentry((void *)(size_t)(i+1), name, ptype);
if (result != 0) {
return result;
}
}
}
return 0;
}
int luaR_findfunction(lua_State *L, const luaL_Reg *ptable) {
int found;
const char *key = luaL_checkstring(L, 2);
luaR_result res = luaR_findkey(ptable, key, LUAR_FINDFUNCTION, &found);
if (found)
lua_pushlightfunction(L, (void*)(size_t)res);
else
lua_pushnil(L);
return 1;
}
luaR_result luaR_findentry(void *data, const char *key, lu_byte *ptype) {
int found;
unsigned idx = (unsigned)(size_t)data - 1;
luaR_result res;
*ptype = LUA_TNIL;
/* First look at the functions */
res = luaR_findkey(lua_rotable[idx].pfuncs, key, LUAR_FINDFUNCTION, &found);
if (found) {
*ptype = LUA_TLIGHTFUNCTION;
return res;
}
else {
/* Then at the values */
res = luaR_findkey(lua_rotable[idx].pvalues, key, LUAR_FINDVALUE, &found);
if(found) {
*ptype = LUA_TNUMBER;
return res;
}
}
return 0;
}
+37
View File
@@ -0,0 +1,37 @@
// Read-only tables for Lua
#ifndef lrotable_h
#define lrotable_h
#include "lua.h"
#include "llimits.h"
#include "lauxlib.h"
typedef lua_Number luaR_result;
// A number entry in the read only table
typedef struct
{
const char *name;
lua_Number value;
} luaR_value_entry;
extern const luaR_value_entry baselib_vals[];
extern const luaR_value_entry mathlib_vals[];
extern const luaR_value_entry opentxConstants[];
// A mapping between table name and its entries
typedef struct
{
const char *name;
const luaL_Reg *pfuncs;
const luaR_value_entry *pvalues;
} luaR_table;
extern const luaR_table lua_rotable[];
luaR_result luaR_findglobal(const char *key, lu_byte *ptype);
int luaR_findfunction(lua_State *L, const luaL_Reg *ptable);
luaR_result luaR_findentry(void *data, const char *key, lu_byte *ptype);
#endif
+1 -1
View File
@@ -113,7 +113,7 @@ static Node *mainposition (const Table *t, const TValue *key) {
case LUA_TLIGHTUSERDATA:
return hashpointer(t, pvalue(key));
case LUA_TLCF:
return hashpointer(t, fvalue(key));
return hashpointer(t, lcfvalue(key));
default:
return hashpointer(t, gcvalue(key));
}
+1 -2
View File
@@ -23,12 +23,11 @@ static const char udatatypename[] = "userdata";
LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = {
"no value",
"nil", "boolean", udatatypename, "number",
"nil", "boolean", "rotable", "lightfunction", udatatypename, "number",
"string", "table", "function", udatatypename, "thread",
"proto", "upval" /* these last two cases are used for tests only */
};
void luaT_init (lua_State *L) {
static const char *const luaT_eventname[] = { /* ORDER TM */
"__index", "__newindex",
+12 -8
View File
@@ -77,15 +77,17 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
#define LUA_TNIL 0
#define LUA_TBOOLEAN 1
#define LUA_TLIGHTUSERDATA 2
#define LUA_TNUMBER 3
#define LUA_TSTRING 4
#define LUA_TTABLE 5
#define LUA_TFUNCTION 6
#define LUA_TUSERDATA 7
#define LUA_TTHREAD 8
#define LUA_TROTABLE 2
#define LUA_TLIGHTFUNCTION 3
#define LUA_TLIGHTUSERDATA 4
#define LUA_TNUMBER 5
#define LUA_TSTRING 6
#define LUA_TTABLE 7
#define LUA_TFUNCTION 8
#define LUA_TUSERDATA 9
#define LUA_TTHREAD 10
#define LUA_NUMTAGS 9
#define LUA_NUMTAGS 11
@@ -214,6 +216,8 @@ LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
LUA_API void (lua_pushboolean) (lua_State *L, int b);
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
LUA_API void (lua_pushlightfunction) (lua_State *L, void *p);
LUA_API void (lua_pushrotable) (lua_State *L, void *p);
LUA_API int (lua_pushthread) (lua_State *L);
+1 -1
View File
@@ -558,7 +558,7 @@
** without modifying the main part of the file.
*/
#define LUA_MAX_ROTABLE_NAME 20
#endif
+149 -51
View File
@@ -25,7 +25,7 @@
#include "ltable.h"
#include "ltm.h"
#include "lvm.h"
#include "lrotable.h"
/* limit for table tag-method chains (to avoid loops) */
@@ -106,9 +106,31 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1,
}
}
static void lua_getcstr(char *dest, const TString *src, size_t maxsize) {
if (src->tsv.len+1 > maxsize)
dest[0] = '\0';
else {
memcpy(dest, getstr(src), src->tsv.len);
dest[src->tsv.len] = '\0';
}
}
void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
int loop;
if (ttisrotable(t)) {
setnilvalue(val);
if (ttisstring(key)) {
char keyname[LUA_MAX_ROTABLE_NAME + 1];
lu_byte keytype;
lua_getcstr(keyname, rawtsvalue(key), LUA_MAX_ROTABLE_NAME);
luaR_result res = luaR_findentry(rvalue(t), keyname, &keytype);
if (keytype == LUA_TLIGHTFUNCTION)
setlfvalue(val, (void*)(size_t)res)
else if (keytype == LUA_TNUMBER)
setnvalue(val, (lua_Number)res)
}
return;
}
for (loop = 0; loop < MAXTAGLOOP; loop++) {
const TValue *tm;
if (ttistable(t)) { /* `t' is a table? */
@@ -123,7 +145,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
}
else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
luaG_typeerror(L, t, "index");
if (ttisfunction(tm)) {
if (ttisfunction(tm) || ttislightfunction(tm)) {
callTM(L, tm, t, key, val, 1);
return;
}
@@ -264,8 +286,11 @@ int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) {
case LUA_TNIL: return 1;
case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
case LUA_TLCF: return fvalue(t1) == fvalue(t2);
case LUA_TLIGHTUSERDATA:
case LUA_TROTABLE:
case LUA_TLIGHTFUNCTION:
return pvalue(t1) == pvalue(t2);
case LUA_TLCF: return lcfvalue(t1) == lcfvalue(t2);
case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));
case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2));
case LUA_TUSERDATA: {
@@ -554,53 +579,97 @@ void luaV_execute (lua_State *L) {
lua_assert(base == ci->u.l.base);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE,
case OP_MOVE:
setobjs2s(L, ra, RB(i));
)
vmcase(OP_LOADK,
break;
case OP_LOADK:
{
TValue *rb = k + GETARG_Bx(i);
setobj2s(L, ra, rb);
)
vmcase(OP_LOADKX,
}
break;
case OP_LOADKX:
{
TValue *rb;
lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
rb = k + GETARG_Ax(*ci->u.l.savedpc++);
setobj2s(L, ra, rb);
)
vmcase(OP_LOADBOOL,
}
break;
case OP_LOADBOOL:
setbvalue(ra, GETARG_B(i));
if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */
)
vmcase(OP_LOADNIL,
break;
case OP_LOADNIL:
{
int b = GETARG_B(i);
do {
setnilvalue(ra++);
} while (b--);
)
vmcase(OP_GETUPVAL,
}
break;
case OP_GETUPVAL:
{
int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v);
)
vmcase(OP_GETTABUP,
}
break;
case OP_GETTABUP:
{
int b = GETARG_B(i);
Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra));
)
vmcase(OP_GETTABLE,
if (ttisstring(RKC(i))) {
char keyname[LUA_MAX_ROTABLE_NAME + 1];
lu_byte keytype;
lua_getcstr(keyname, rawtsvalue(RKC(i)), LUA_MAX_ROTABLE_NAME);
luaR_result res = luaR_findglobal(keyname, &keytype);
if (keytype == LUA_TROTABLE) {
setrvalue(ra, (void*)(size_t)res)
}
else if (keytype == LUA_TLIGHTFUNCTION)
setlfvalue(ra, (void*)(size_t)res)
else if (keytype == LUA_TNUMBER)
setnvalue(ra, (lua_Number)res)
else
Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra));
}
else {
Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra));
}
}
break;
case OP_GETTABLE:
/* First try to look for a rotable with this name */
Protect(luaV_gettable(L, RB(i), RKC(i), ra));
)
vmcase(OP_SETTABUP,
break;
case OP_SETTABUP:
{
int a = GETARG_A(i);
Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i)));
)
vmcase(OP_SETUPVAL,
}
break;
case OP_SETUPVAL:
{
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, ra);
luaC_barrier(L, uv, ra);
)
vmcase(OP_SETTABLE,
}
break;
case OP_SETTABLE:
Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
)
vmcase(OP_NEWTABLE,
break;
case OP_NEWTABLE:
{
int b = GETARG_B(i);
int c = GETARG_C(i);
Table *t = luaH_new(L);
@@ -608,31 +677,43 @@ void luaV_execute (lua_State *L) {
if (b != 0 || c != 0)
luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
checkGC(L, ra + 1);
)
vmcase(OP_SELF,
}
break;
case OP_SELF:
{
StkId rb = RB(i);
setobjs2s(L, ra+1, rb);
Protect(luaV_gettable(L, rb, RKC(i), ra));
)
vmcase(OP_ADD,
}
break;
case OP_ADD:
arith_op(luai_numadd, TM_ADD);
)
vmcase(OP_SUB,
break;
case OP_SUB:
arith_op(luai_numsub, TM_SUB);
)
vmcase(OP_MUL,
break;
case OP_MUL:
arith_op(luai_nummul, TM_MUL);
)
vmcase(OP_DIV,
break;
case OP_DIV:
arith_op(luai_numdiv, TM_DIV);
)
vmcase(OP_MOD,
break;
case OP_MOD:
arith_op(luai_nummod, TM_MOD);
)
vmcase(OP_POW,
break;
case OP_POW:
arith_op(luai_numpow, TM_POW);
)
vmcase(OP_UNM,
break;
case OP_UNM:
{
TValue *rb = RB(i);
if (ttisnumber(rb)) {
lua_Number nb = nvalue(rb);
@@ -641,15 +722,19 @@ void luaV_execute (lua_State *L) {
else {
Protect(luaV_arith(L, ra, rb, rb, TM_UNM));
}
)
}
break;
vmcase(OP_NOT,
TValue *rb = RB(i);
int res = l_isfalse(rb); /* next assignment may change this value */
setbvalue(ra, res);
)
vmcase(OP_LEN,
Protect(luaV_objlen(L, ra, RB(i)));
)
vmcase(OP_CONCAT,
int b = GETARG_B(i);
int c = GETARG_C(i);
@@ -662,9 +747,11 @@ void luaV_execute (lua_State *L) {
checkGC(L, (ra >= rb ? ra + 1 : rb));
L->top = ci->top; /* restore top */
)
vmcase(OP_JMP,
dojump(ci, i, 0);
)
vmcase(OP_EQ,
TValue *rb = RKB(i);
TValue *rc = RKC(i);
@@ -675,6 +762,7 @@ void luaV_execute (lua_State *L) {
donextjump(ci);
)
)
vmcase(OP_LT,
Protect(
if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i))
@@ -706,7 +794,9 @@ void luaV_execute (lua_State *L) {
donextjump(ci);
}
)
vmcase(OP_CALL,
case OP_CALL:
{
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
if (b != 0) L->top = ra+b; /* else previous instruction set top */
@@ -719,8 +809,11 @@ void luaV_execute (lua_State *L) {
ci->callstatus |= CIST_REENTRY;
goto newframe; /* restart luaV_execute over new Lua function */
}
)
vmcase(OP_TAILCALL,
}
break;
case OP_TAILCALL:
{
int b = GETARG_B(i);
if (b != 0) L->top = ra+b; /* else previous instruction set top */
lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
@@ -748,7 +841,8 @@ void luaV_execute (lua_State *L) {
lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize);
goto newframe; /* restart luaV_execute over new Lua function */
}
)
}
vmcasenb(OP_RETURN,
int b = GETARG_B(i);
if (b != 0) L->top = ra+b-1;
@@ -764,7 +858,9 @@ void luaV_execute (lua_State *L) {
goto newframe; /* restart luaV_execute over new Lua function */
}
)
vmcase(OP_FORLOOP,
case OP_FORLOOP:
{
lua_Number step = nvalue(ra+2);
lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */
lua_Number limit = nvalue(ra+1);
@@ -774,7 +870,9 @@ void luaV_execute (lua_State *L) {
setnvalue(ra, idx); /* update internal index... */
setnvalue(ra+3, idx); /* ...and external index */
}
)
}
break;
vmcase(OP_FORPREP,
const TValue *init = ra;
const TValue *plimit = ra+1;
+37 -21
View File
@@ -64,6 +64,7 @@ int16_t ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMa
int16_t cyc_anas[3] = {0};
#if defined(PCBTARANIS)
int16_t heliAnas[4] = {0};
uint8_t heliTrims[4] = {0};
#endif
#endif
@@ -105,8 +106,9 @@ void applyExpos(int16_t *anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
else {
v = getValue(ed->srcRaw);
if (ed->srcRaw >= MIXSRC_FIRST_TELEM && ed->scale > 0) {
v = limit(-1024, int((v * 1024) / convertTelemValue(ed->srcRaw-MIXSRC_FIRST_TELEM+1, ed->scale)), 1024);
v = (v * 1024) / convertTelemValue(ed->srcRaw-MIXSRC_FIRST_TELEM+1, ed->scale);
}
v = limit(-1024, v, 1024);
}
#else
int16_t v = anas2[ed->chn];
@@ -151,10 +153,14 @@ void applyExpos(int16_t *anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
virtualInputsTrims[cur_chn] = -1;
#if defined(HELI)
if (ed->srcRaw == MIXSRC_Ele)
if (ed->srcRaw == MIXSRC_Ele) {
heliAnas[ELE_STICK] = v;
else if (ed->srcRaw == MIXSRC_Ail)
heliTrims[ELE_STICK] = virtualInputsTrims[cur_chn];
}
else if (ed->srcRaw == MIXSRC_Ail) {
heliAnas[AIL_STICK] = v;
heliTrims[AIL_STICK] = virtualInputsTrims[cur_chn];
}
#endif
#endif
@@ -246,8 +252,10 @@ int16_t applyLimits(uint8_t channel, int32_t value)
if (lim->revert) ofs = -ofs; // finally do the reverse.
#if defined(OVERRIDE_CHANNEL_FUNCTION)
if (safetyCh[channel] != -128) // if safety channel available for channel check
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) {
// safety channel available for channel check
ofs = calc100toRESX(safetyCh[channel]);
}
#endif
return ofs;
@@ -504,17 +512,17 @@ void evalInputs(uint8_t mode)
#if !defined(PCBTARANIS)
rawAnas[ch] = v;
anas[ch] = v; //set values for mixer
anas[ch] = v; // set values for mixer
#endif
}
}
/* TRIMs */
evalTrims();
/* EXPOs */
applyExpos(anas, mode);
/* TRIMs */
evalTrims(); // when no virtual inputs, the trims need the anas array calculated above (when throttle trim enabled)
if (mode == e_perout_mode_normal) {
#if !defined(CPUARM)
anaCenter &= g_model.beepANACenter;
@@ -525,9 +533,11 @@ void evalInputs(uint8_t mode)
}
#if defined(PCBTARANIS)
#define HELI_ANAS_ARRAY heliAnas
#define HELI_ANAS_ARRAY(x) heliAnas[x]
#define HELI_TRIMS_ARRAY(x) trims[heliTrims[x]]
#else
#define HELI_ANAS_ARRAY anas
#define HELI_ANAS_ARRAY(x) anas[x]
#define HELI_TRIMS_ARRAY(x) trims[x]
#endif
uint8_t mixerCurrentFlightMode;
@@ -543,14 +553,14 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
#if defined(HELI)
if (g_model.swashR.value) {
uint32_t v = ((int32_t)HELI_ANAS_ARRAY[ELE_STICK]*HELI_ANAS_ARRAY[ELE_STICK] + (int32_t)HELI_ANAS_ARRAY[AIL_STICK]*HELI_ANAS_ARRAY[AIL_STICK]);
uint32_t v = ((int32_t)HELI_ANAS_ARRAY(ELE_STICK)*HELI_ANAS_ARRAY(ELE_STICK) + (int32_t)HELI_ANAS_ARRAY(AIL_STICK)*HELI_ANAS_ARRAY(AIL_STICK));
uint32_t q = calc100toRESX(g_model.swashR.value);
q *= q;
if (v>q) {
uint16_t d = isqrt32(v);
int16_t tmp = calc100toRESX(g_model.swashR.value);
HELI_ANAS_ARRAY[ELE_STICK] = (int32_t) HELI_ANAS_ARRAY[ELE_STICK]*tmp/d;
HELI_ANAS_ARRAY[AIL_STICK] = (int32_t) HELI_ANAS_ARRAY[AIL_STICK]*tmp/d;
HELI_ANAS_ARRAY(ELE_STICK) = (int32_t) HELI_ANAS_ARRAY(ELE_STICK)*tmp/d;
HELI_ANAS_ARRAY(AIL_STICK) = (int32_t) HELI_ANAS_ARRAY(AIL_STICK)*tmp/d;
}
}
@@ -558,8 +568,8 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
#define REZ_SWASH_Y(x) ((x)) // 1024 => 1024
if (g_model.swashR.type) {
getvalue_t vp = HELI_ANAS_ARRAY[ELE_STICK]+trims[ELE_STICK];
getvalue_t vr = HELI_ANAS_ARRAY[AIL_STICK]+trims[AIL_STICK];
getvalue_t vp = HELI_ANAS_ARRAY(ELE_STICK) + HELI_TRIMS_ARRAY(ELE_STICK);
getvalue_t vr = HELI_ANAS_ARRAY(AIL_STICK) + HELI_TRIMS_ARRAY(AIL_STICK);
getvalue_t vc = 0;
if (g_model.swashR.collectiveSource)
vc = getValue(g_model.swashR.collectiveSource);
@@ -637,7 +647,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
//========== PHASE && SWITCH =====
bool mixCondition = (md->flightModes != 0 || md->swtch);
delayval_t mixEnabled = !(md->flightModes & (1 << mixerCurrentFlightMode)) && getSwitch(md->swtch);
delayval_t mixEnabled = (!(md->flightModes & (1 << mixerCurrentFlightMode)) && getSwitch(md->swtch)) ? DELAY_POS_MARGIN+1 : 0;
if (mixEnabled && md->srcRaw >= MIXSRC_FIRST_TRAINER && md->srcRaw <= MIXSRC_LAST_TRAINER && !ppmInValid) {
mixEnabled = 0;
@@ -742,11 +752,17 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
else
mix_trim = -1;
if (mix_trim >= 0) {
int16_t trim = trims[mix_trim];
if (mix_trim == THR_STICK && g_model.throttleReversed)
v -= trim;
else
v += trim;
int32_t trim = trims[mix_trim];
if (mix_trim == THR_STICK) {
if (g_model.thrTrim) {
int16_t trimMin = g_model.extendedTrims ? 2*TRIM_EXTENDED_MIN : 2*TRIM_MIN;
trim = (((g_model.throttleReversed)?(trim+trimMin):(trim-trimMin)) * (RESX-v)) >> (RESX_SHIFT+1);
}
if (g_model.throttleReversed) {
trim = -trim;
}
}
v += trim;
}
}
#else
+17 -8
View File
@@ -165,7 +165,7 @@
CURVE_TYPE_CUSTOM,
CURVE_TYPE_LAST = CURVE_TYPE_CUSTOM
};
PACK(typedef struct t_CurveInfo {
PACK(typedef struct {
uint8_t type:3;
uint8_t smooth:1;
uint8_t spare:4;
@@ -473,7 +473,7 @@ enum CurveRefType {
CURVE_REF_FUNC,
CURVE_REF_CUSTOM
};
PACK(typedef struct t_CurveRef {
PACK(typedef struct {
uint8_t type;
int8_t value;
}) CurveRef;
@@ -1451,8 +1451,15 @@ enum SwitchSources {
SWSRC_LAST = SWSRC_COUNT-1,
SWSRC_FIRST = -SWSRC_LAST,
SWSRC_LAST_SHORT_LIST = SWSRC_LAST_LOGICAL_SWITCH,
SWSRC_FIRST_SHORT_LIST = -SWSRC_LAST_SHORT_LIST,
#if defined(CPUARM)
SWSRC_LAST_IN_LOGICAL_SWITCHES = SWSRC_LAST_FLIGHT_MODE,
SWSRC_LAST_IN_MIXES = SWSRC_LAST_FLIGHT_MODE,
#else
SWSRC_LAST_IN_LOGICAL_SWITCHES = SWSRC_LAST_LOGICAL_SWITCH,
SWSRC_LAST_IN_MIXES = SWSRC_LAST_LOGICAL_SWITCH,
#endif
SWSRC_FIRST_IN_LOGICAL_SWITCHES = -SWSRC_LAST_IN_LOGICAL_SWITCHES,
SWSRC_FIRST_IN_MIXES = -SWSRC_LAST_IN_MIXES,
};
enum MixSources {
@@ -1610,12 +1617,14 @@ enum TimerModes {
TMRMODE_THR,
TMRMODE_THR_REL,
TMRMODE_THR_TRG,
TMRMODE_FIRST_SWITCH
TMRMODE_COUNT
};
#define COUNTDOWN_SILENT 0
#define COUNTDOWN_BEEPS 1
#define COUNTDOWN_VOICE 2
enum CountDownModes {
COUNTDOWN_SILENT,
COUNTDOWN_BEEPS,
COUNTDOWN_VOICE
};
#if defined(CPUARM) || defined(CPUM2560)
PACK(typedef struct t_TimerData {
+62 -16
View File
@@ -148,7 +148,7 @@ uint8_t heartbeat;
uint8_t stickMode;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
int8_t safetyCh[NUM_CHNOUT];
safetych_t safetyCh[NUM_CHNOUT];
#endif
union ReusableBuffer reusableBuffer;
@@ -441,11 +441,23 @@ void modelDefault(uint8_t id)
}
#endif
#if defined(CPUARM) && !defined(PCBTARANIS)
g_model.externalModule = MODULE_TYPE_PPM;
#endif
#if defined(PXX) && defined(CPUARM)
modelHeaders[id].modelId = g_model.header.modelId = id+1;
checkModelIdUnique(id);
#endif
#if defined(CPUARM) && defined(FLIGHT_MODES) && defined(GVARS)
for (int p=1; p<MAX_FLIGHT_MODES; p++) {
for (int i=0; i<MAX_GVARS; i++) {
g_model.flightModeData[p].gvars[i] = GVAR_MAX+1;
}
}
#endif
#if defined(PCBTARANIS)
g_model.frsky.channels[0].ratio = 132;
#endif
@@ -455,6 +467,23 @@ void modelDefault(uint8_t id)
g_model.mavlink.pc_rssi_en = 1;
#endif
}
#if defined(PCBTARANIS)
bool isInputRecursive(int index)
{
ExpoData * line = expoAddress(0);
for (int i=0; i<MAX_EXPOS; i++, line++) {
if (line->chn > index)
break;
else if (line->chn < index)
continue;
else if (line->srcRaw >= MIXSRC_FIRST_LOGICAL_SWITCH)
return true;
}
return false;
}
#endif
#if defined(AUTOSOURCE)
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
{
@@ -466,8 +495,10 @@ int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS)
if (min <= MIXSRC_FIRST_INPUT) {
for (uint8_t i=0; i<MAX_INPUTS; i++) {
if (abs(anas[i] - inputsStates[i]) > 512) {
result = MIXSRC_FIRST_INPUT+i;
break;
if (!isInputRecursive(i)) {
result = MIXSRC_FIRST_INPUT+i;
break;
}
}
}
}
@@ -1047,10 +1078,16 @@ void doSplash()
getADC();
#if defined(FSPLASH)
if (!(g_eeGeneral.splashMode & 0x04))
// Splash is forced, we can't skip it
if (!(g_eeGeneral.splashMode & 0x04)) {
#endif
if (keyDown() || inputsMoved()) return;
#if defined(FSPLASH)
}
#endif
if (pwrCheck()==e_power_off) return;
#if !defined(PCBTARANIS) && !defined(PCBSTD)
@@ -1611,11 +1648,8 @@ void timerReset(uint8_t idx)
void flightReset()
{
static bool firstReset = true;
if (firstReset)
firstReset = false;
else
AUDIO_RESET();
// we don't reset the whole audio here (the tada.wav would be cut, if a prompt is queued before FlightReset, it should be played)
// TODO check if the vario / background music are stopped correctly if switching to a model which doesn't have these functions enabled
if (!IS_MANUAL_RESET_TIMER(0)) {
timerReset(0);
@@ -1653,10 +1687,13 @@ FORCEINLINE void evalTrims()
for (uint8_t i=0; i<NUM_STICKS; i++) {
// do trim -> throttle trim if applicable
int16_t trim = getTrimValue(phase, i);
#if !defined(PCBTARANIS)
if (i==THR_STICK && g_model.thrTrim) {
trim = (((g_model.throttleReversed)?(int32_t)(trim+TRIM_MIN):(int32_t)(trim-TRIM_MIN)) * (RESX-getValue(MIXSRC_Thr))) >> (RESX_SHIFT+1);
int16_t trimMin = g_model.extendedTrims ? TRIM_EXTENDED_MIN : TRIM_MIN;
trim = (((g_model.throttleReversed)?(int32_t)(trim+trimMin):(int32_t)(trim-trimMin)) * (RESX-anas[i])) >> (RESX_SHIFT+1);
}
else if (trimsCheckTimer > 0) {
#endif
if (trimsCheckTimer > 0) {
trim = 0;
}
@@ -1867,7 +1904,7 @@ void evalFunctions()
#if defined(OVERRIDE_CHANNEL_FUNCTION)
for (uint8_t i=0; i<NUM_CHNOUT; i++) {
safetyCh[i] = -128; // not defined
safetyCh[i] = OVERRIDE_CHANNEL_UNDEFINED;
}
#endif
@@ -2308,7 +2345,7 @@ void doMixerCalculations()
}
}
else {
if (tm > 0) tm -= (TMR_VAROFS-1);
if (tm > 0) tm -= (TMRMODE_COUNT-1);
if (getSwitch(tm))
newTimerVal++;
}
@@ -2497,6 +2534,10 @@ void opentxClose()
// TODO needed? telemetryEnd();
#endif
#if defined(LUA)
luaClose();
#endif
#if defined(SDCARD)
closeLogs();
sdDone();
@@ -3286,6 +3327,13 @@ uint16_t stack_free(uint8_t tid)
stack = audioStack;
size = AUDIO_STACK_SIZE;
break;
#if 0 // defined(PCBTARANIS)
case 255:
// main stack
stack = (OS_STK *)&_main_stack_start;
size = ((unsigned char *)&_estack - (unsigned char *)&_main_stack_start) / 4;
break;
#endif
default:
return 0;
}
@@ -3378,8 +3426,6 @@ inline void opentxInit(OPENTX_INIT_ARGS)
rtcInit();
#endif
LUA_INIT();
if (g_eeGeneral.backlightMode != e_backlight_mode_off) backlightOn(); // on Tx start turn the light on
if (UNEXPECTED_SHUTDOWN()) {
@@ -3406,7 +3452,7 @@ inline void opentxInit(OPENTX_INIT_ARGS)
backlightOn();
#if defined(PCBTARANIS)
uart3Init(g_eeGeneral.uart3Mode, MODEL_TELEMETRY_PROTOCOL);
uart3Init(g_eeGeneral.uart3Mode, MODEL_TELEMETRY_PROTOCOL());
#endif
#if defined(CPUARM)
+42 -16
View File
@@ -354,10 +354,14 @@ enum PotType {
POT_TYPE_MAX=POT_TYPE_NO_DETENT
};
#if defined(PCBTARANIS)
#if defined(PCBTARANIS) && defined(REVPLUS)
#define IS_POT_AVAILABLE(x) ((x)!=POT3 || (g_eeGeneral.potsType & (0x03 << (2*((x)-POT1))))!=POT_TYPE_NONE)
#define IS_POT_MULTIPOS(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsType>>(2*((x)-POT1)))&0x03)==POT_TYPE_MULTIPOS)
#define IS_POT_WITHOUT_DETENT(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsType>>(2*((x)-POT1)))&0x03)==POT_TYPE_NO_DETENT)
#elif defined(PCBTARANIS)
#define IS_POT_AVAILABLE(x) ((x)!=POT3)
#define IS_POT_MULTIPOS(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsType>>(2*((x)-POT1)))&0x03)==POT_TYPE_MULTIPOS)
#define IS_POT_WITHOUT_DETENT(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsType>>(2*((x)-POT1)))&0x03)==POT_TYPE_NO_DETENT)
#else
#define IS_POT_AVAILABLE(x) (true)
#define IS_POT_MULTIPOS(x) (false)
@@ -617,7 +621,12 @@ extern uint8_t pxxFlag[NUM_MODULES];
#define PXX_SEND_RANGECHECK (1 << 5)
#define LEN_STD_CHARS 40
#if defined(TRANSLATIONS_CZ)
#define ZCHAR_MAX (LEN_STD_CHARS)
#else
#define ZCHAR_MAX (LEN_STD_CHARS + LEN_SPECIAL_CHARS)
#endif
char idx2char(int8_t idx);
#if defined(CPUARM) || defined(SIMU)
@@ -689,7 +698,8 @@ extern uint8_t flightModeTransitionLast;
#if defined(CPUARM) && !defined(SIMU)
extern unsigned char *heap;
extern int _end;
extern unsigned char *_estack;
extern int _estack;
extern int _main_stack_start;
#define getAvailableMemory() ((unsigned int)((unsigned char *)&_estack - heap))
#endif
@@ -847,7 +857,14 @@ struct TimerState {
extern TimerState timersStates[MAX_TIMERS];
#if defined(OVERRIDE_CHANNEL_FUNCTION)
extern int8_t safetyCh[NUM_CHNOUT];
#if defined(CPUARM)
typedef int16_t safetych_t;
#define OVERRIDE_CHANNEL_UNDEFINED -4096
#else
typedef int8_t safetych_t;
#define OVERRIDE_CHANNEL_UNDEFINED -128
#endif
extern safetych_t safetyCh[NUM_CHNOUT];
#endif
extern uint8_t trimsCheckTimer;
@@ -1081,8 +1098,6 @@ extern int16_t calcRESXto1000(int16_t x);
extern int8_t calcRESXto100(int16_t x);
#endif
#define TMR_VAROFS 5
extern const char vers_stamp[];
extern uint8_t g_vbat100mV;
@@ -1463,13 +1478,14 @@ enum AUDIO_SOUNDS {
SCRIPT_OK,
SCRIPT_NOFILE,
SCRIPT_SYNTAX_ERROR,
SCRIPT_PANIC,
SCRIPT_KILLED
};
enum ScriptReference {
SCRIPT_MIX_FIRST,
SCRIPT_MIX_LAST=SCRIPT_MIX_FIRST+MAX_SCRIPTS-1,
SCRIPT_FUNC_FIRST,
SCRIPT_FUNC_LAST=SCRIPT_FUNC_FIRST+MAX_SCRIPTS-1,
SCRIPT_FUNC_LAST=SCRIPT_FUNC_FIRST+NUM_CFN-1,
SCRIPT_TELEMETRY_FIRST,
SCRIPT_TELEMETRY_LAST=SCRIPT_TELEMETRY_FIRST+MAX_SCRIPTS, // telem0 and telem1 .. telem7
};
@@ -1486,28 +1502,38 @@ enum AUDIO_SOUNDS {
uint8_t outputsCount;
ScriptOutput outputs[MAX_SCRIPT_OUTPUTS];
};
#define LUASTATE_STANDALONE_SCRIPT_RUNNING 1
#define LUASTATE_RELOAD_MODEL_SCRIPTS 2
#define INTERPRETER_RUNNING_STANDALONE_SCRIPT 1
#define INTERPRETER_RELOAD_PERMANENT_SCRIPTS 2
#define INTERPRETER_PANIC 255
extern uint8_t luaState;
extern uint8_t luaScriptsCount;
extern ScriptInternalData standaloneScript;
extern ScriptInternalData scriptInternalData[MAX_SCRIPTS];
extern ScriptInputsOutputs scriptInputsOutputs[MAX_SCRIPTS];
void luaClose();
void luaInit();
void luaTask(uint8_t evt);
void luaExec(const char *filename);
void luaLoadMixScript(uint8_t index);
void luaLoadMixScripts();
int luaGetMemUsed();
#define luaGetCpuUsed(idx) scriptInternalData[idx].instructions
bool isTelemetryScriptAvailable(uint8_t index);
#define LUA_INIT()
#define LUA_RESET() luaInit()
#define LUA_LOAD_MODEL_SCRIPTS() luaState |= LUASTATE_RELOAD_MODEL_SCRIPTS
#define LUA_LOAD_MODEL_SCRIPT(idx) luaState |= LUASTATE_RELOAD_MODEL_SCRIPTS
#define LUA_LOAD_MODEL_SCRIPTS() luaState |= INTERPRETER_RELOAD_PERMANENT_SCRIPTS
#define LUA_LOAD_MODEL_SCRIPT(idx) luaState |= INTERPRETER_RELOAD_PERMANENT_SCRIPTS
// Lua PROTECT/UNPROTECT
#include <setjmp.h>
struct our_longjmp {
struct our_longjmp *previous;
jmp_buf b;
volatile int status; /* error code */
};
extern struct our_longjmp * global_lj;
#define PROTECT_LUA() { struct our_longjmp lj; \
lj.previous = global_lj; /* chain new error handler */ \
global_lj = &lj; \
if (setjmp(lj.b) == 0)
#define UNPROTECT_LUA() global_lj = lj.previous; } /* restore old error handler */
#else
#define LUA_INIT()
#define LUA_RESET()
#define LUA_LOAD_MODEL_SCRIPTS()
#define LUA_LOAD_MODEL_SCRIPT(idx)
#endif
+3 -2
View File
@@ -308,9 +308,10 @@ void putPcmHead()
putPcmPart( 0xC0 ) ;
}
uint16_t scaleForPXX(uint8_t i)
uint16_t scaleForPXX( uint8_t i )
{
return channelOutputs[i] * 3 / 4 + 2250 ;
int16_t value = ( ( i < 16 ) ? channelOutputs[i] * 3 / 4 : 0 ) + 1024;
return limit<uint16_t>(1, value, 2046);
}
void setupPulsesPXX()
+1 -1
View File
@@ -357,7 +357,7 @@ int main(int argc,char **argv)
// We pass the "name" of the application, and its "vendor", the name
// and vendor are used to search the registry database (which stores
// persistent information e.g. fonts and colors).
FXApp application("Open9xSim", "thus");
FXApp application("OpenTX Simu", "OpenTX");
// Here we initialize the application. We pass the command line arguments
// because FOX may sometimes need to filter out some of the arguments.
+13 -1
View File
@@ -49,7 +49,7 @@ char idx2char(int8_t idx)
if (idx < 37) return '0' + idx - 27;
if (idx <= 40) return pgm_read_byte(s_charTab+idx-37);
#if LEN_SPECIAL_CHARS > 0
if (idx <= ZCHAR_MAX) return 'z' + 5 + idx - 40;
if (idx <= (LEN_STD_CHARS + LEN_SPECIAL_CHARS)) return 'z' + 5 + idx - 40;
#endif
return ' ';
}
@@ -151,6 +151,18 @@ char * strAppend(char * dest, const char * source)
return dest - 1;
}
char * strAppendFilename(char * dest, const char * filename, const int size)
{
memset(dest, 0, size);
for (int i=0; i<size; i++) {
char c = *filename++;
if (c == '\0' || c == '.')
break;
*dest++ = c;
}
return dest;
}
#if defined(RTCLOCK)
#include "rtc.h"
+19 -12
View File
@@ -191,6 +191,16 @@ getvalue_t getValueForLogicalSwitch(uint8_t i)
#define getValueForLogicalSwitch(i) getValue(i)
#endif
PACK(typedef struct {
uint8_t state;
uint8_t last;
}) ls_sticky_struct;
PACK(typedef struct {
uint16_t state:1;
uint16_t duration:15;
}) ls_stay_struct;
bool getLogicalSwitch(uint8_t idx)
{
LogicalSwitchData * ls = lswAddress(idx);
@@ -206,7 +216,9 @@ bool getLogicalSwitch(uint8_t idx)
#endif
if (ls->func == LS_FUNC_NONE || (s && !getSwitch(s))) {
LS_LAST_VALUE(mixerCurrentFlightMode, idx) = CS_LAST_VALUE_INIT;
if (ls->func != LS_FUNC_STICKY) {
LS_LAST_VALUE(mixerCurrentFlightMode, idx) = CS_LAST_VALUE_INIT;
}
result = false;
}
else if ((s=lswFamily(ls->func)) == LS_FAMILY_BOOL) {
@@ -379,6 +391,10 @@ DurationAndDelayProcessing:
if (context.timerState == SWITCH_ENABLE) {
result = (ls->duration==0 || context.timer>0); // return false after duration timer runs out
if (!result && ls->func == LS_FUNC_STICKY) {
ls_sticky_struct & lastValue = (ls_sticky_struct &)context.lastValue;
lastValue.state = 0;
}
}
}
else if (context.timerState == SWITCH_ENABLE && ls->duration > 0 && context.timer > 0) {
@@ -733,10 +749,6 @@ void logicalSwitchesTimerTick()
}
}
else if (ls->func == LS_FUNC_STICKY) {
PACK(typedef struct {
uint8_t state;
uint8_t last;
}) ls_sticky_struct;
ls_sticky_struct & lastValue = (ls_sticky_struct &)LS_LAST_VALUE(fm, i);
bool before = lastValue.last & 0x01;
if (lastValue.state) {
@@ -760,22 +772,17 @@ void logicalSwitchesTimerTick()
}
#if defined(CPUARM)
else if (ls->func == LS_FUNC_STAY) {
PACK(typedef struct {
uint16_t state:1;
uint16_t duration:15;
}) ls_stay_struct;
ls_stay_struct & lastValue = (ls_stay_struct &)LS_LAST_VALUE(fm, i);
lastValue.state = false;
bool state = getSwitch(ls->v1);
if (state) {
if (ls->v3 == 0 && lastValue.duration == lswTimerValue(ls->v2))
if (ls->v3 == -1 && lastValue.duration == lswTimerValue(ls->v2))
lastValue.state = true;
if (lastValue.duration < 1000)
lastValue.duration++;
}
else {
if (lastValue.duration > lswTimerValue(ls->v2) && lastValue.duration <= lswTimerValue(ls->v2+ls->v3))
if (lastValue.duration > lswTimerValue(ls->v2) && (ls->v3 == 0 || lastValue.duration <= lswTimerValue(ls->v2+ls->v3)))
lastValue.state = true;
lastValue.duration = 0;
}
@@ -301,7 +301,6 @@ FORCEINLINE void readKeysAndTrims()
#endif
}
#if ROTARY_ENCODERS <= 2
ISR(INT2_vect)
{
uint8_t input = (PIND & 0x0C);
@@ -313,7 +312,6 @@ ISR(INT3_vect)
uint8_t input = (PIND & 0x0C);
if (input == 0 || input == 0x0C) incRotaryEncoder(0, +1);
}
#endif
ISR(INT5_vect)
{
+3 -10
View File
@@ -82,14 +82,12 @@
#define JACK_PPM_OUT() PORTG |= (1<<OUT_G_SIM_CTL)
#define JACK_PPM_IN() PORTG &= ~(1<<OUT_G_SIM_CTL)
#define sdDone()
// SD driver
#define sdDone()
#if !defined(SIMU)
bool sdMounted();
void sdMountPoll();
void sdPoll10ms();
#define SD_IS_HC() (0)
#define SD_GET_BLOCKNR() (0)
#define SD_GET_SIZE_MB() (0)
@@ -193,13 +191,8 @@ void pwrOff();
#define HAPTIC_OFF() PORTD |= (1 << OUT_D_HAPTIC)
// Rotary encoder driver
#if ROTARY_ENCODERS <= 2
#define REA_DOWN() (~PIND & 0x20)
#define REB_DOWN() (~PIND & 0x10)
#else
#define REA_DOWN() (0)
#define REB_DOWN() (0)
#endif
#define REA_DOWN() (~PIND & 0x20)
#define REB_DOWN() (~PIND & 0x10)
#define ROTENC_DOWN() (REA_DOWN() || REB_DOWN())
#endif
+24 -24
View File
@@ -116,12 +116,6 @@ void pwrOff()
#endif
}
#if ROTARY_ENCODERS <= 2
#define ROTENC_DOWN() ((~PIND & 0x20) || (~PIND & 0x10))
#else
#define ROTENC_DOWN() (0)
#endif
FORCEINLINE uint8_t keyDown()
{
return ((~PINL) & 0x3F) || ROTENC_DOWN();
@@ -196,6 +190,24 @@ bool switchState(EnumKeys enuk)
return result;
}
// Trim switches ...
static const pm_uchar crossTrim[] PROGMEM ={
1<<INP_F_TRM_LH_DWN,
1<<INP_F_TRM_LH_UP,
1<<INP_F_TRM_LV_DWN,
1<<INP_F_TRM_LV_UP,
1<<INP_F_TRM_RV_DWN,
1<<INP_F_TRM_RV_UP,
1<<INP_F_TRM_RH_DWN,
1<<INP_F_TRM_RH_UP
};
uint8_t trimDown(uint8_t idx)
{
uint8_t in = ~PIND;
return (in & pgm_read_byte(crossTrim+idx));
}
FORCEINLINE void readKeysAndTrims()
{
/* Original keys were connected to PORTB as follows:
@@ -213,40 +225,28 @@ FORCEINLINE void readKeysAndTrims()
uint8_t enuk = KEY_MENU;
keys[BTN_REa].input(~PIND & 0x20, BTN_REa);
keys[BTN_REb].input(~PIND & 0x10, BTN_REb);
// User buttons ...
uint8_t tin = ~PINL;
uint8_t in;
in = (tin & 0x0f) << 3;
in |= (tin & 0x30) >> 3;
for (int i=1; i<7; i++)
{
for (int i=1; i<7; i++) {
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
++enuk;
}
// Trim switches ...
static const pm_uchar crossTrim[] PROGMEM ={
1<<INP_F_TRM_LH_DWN,
1<<INP_F_TRM_LH_UP,
1<<INP_F_TRM_LV_DWN,
1<<INP_F_TRM_LV_UP,
1<<INP_F_TRM_RV_DWN,
1<<INP_F_TRM_RV_UP,
1<<INP_F_TRM_RH_DWN,
1<<INP_F_TRM_RH_UP
};
// Trims ...
in = ~PINF;
for (int i=0; i<8; i++) {
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
keys[enuk].input(in & pgm_read_byte(crossTrim+i),(EnumKeys)enuk);
++enuk;
}
keys[BTN_REa].input(REA_DOWN(), BTN_REa);
keys[BTN_REb].input(REB_DOWN(), BTN_REb);
}
ISR(INT2_vect)
+7 -4
View File
@@ -83,12 +83,11 @@
#define JACK_PPM_IN() PORTG &= ~(1<<OUT_G_SIM_CTL)
// SD driver
#define sdDone()
#if !defined(SIMU)
bool sdMounted();
void sdMountPoll();
void sdPoll10ms();
#define sdDone()
#define SD_IS_HC() (0)
#define SD_GET_BLOCKNR() (0)
#define SD_GET_SIZE_MB() (0)
@@ -143,6 +142,7 @@ void sdPoll10ms();
# define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
# define INP_C_ID1 0
# define INP_C_ID2 1
# define INP_G_RF_POW 1
# define INP_G_RuddDR 0
@@ -155,8 +155,6 @@ void sdPoll10ms();
# define OUT_B_PPM 6
# define INP_B_Trainer 5
# define INP_C_ID2 1
#if defined(VOICE)
# define OUT_H_14DRESET 3
# define OUT_H_14DCLK 4
@@ -194,4 +192,9 @@ void pwrOff();
#define HAPTIC_ON() PORTD &= ~(1 << OUT_D_HAPTIC)
#define HAPTIC_OFF() PORTD |= (1 << OUT_D_HAPTIC)
// Rotary encoder driver
#define REA_DOWN() (~PIND & 0x20)
#define REB_DOWN() (~PIND & 0x10)
#define ROTENC_DOWN() (REA_DOWN() || REB_DOWN())
#endif
+11 -5
View File
@@ -47,7 +47,7 @@
#include <direct.h>
#endif
volatile uint8_t pina=0xff, pinb=0xff, pinc=0xff, pind, pine=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0;
volatile uint8_t pina=0xff, pinb=0xff, pinc=0xff, pind, pine=0xff, pinf=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0;
uint8_t portb, portc, porth=0, dummyport;
uint16_t dummyport16;
const char *eepromFile = NULL;
@@ -158,7 +158,7 @@ void simuSetKey(uint8_t key, bool state)
#endif
#if defined(PCBSKY9X) && !defined(REVX)
KEY_CASE(BTN_REa, PIOB->PIO_PDSR, 0x40)
#elif defined(PCBGRUVIN9X)
#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560)
KEY_CASE(BTN_REa, pind, 0x20)
#elif defined(ROTARY_ENCODER_NAVIGATION)
KEY_CASE(BTN_REa, RotEncoder, 0x20)
@@ -212,7 +212,15 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
SWITCH_CASE(4, pinc, 1<<INP_C_AileDR)
SWITCH_CASE(5, ping, 1<<INP_G_Gear)
SWITCH_CASE(6, pinb, 1<<INP_B_Trainer)
#else // STOCK
#elif defined(PCBMEGA2560)
SWITCH_CASE(0, ping, 1<<INP_G_ThrCt)
SWITCH_CASE(1, ping, 1<<INP_G_RuddDR)
SWITCH_CASE(2, pinc, 1<<INP_C_ElevDR)
SWITCH_3_CASE(3, pinc, pinc, (1<<INP_C_ID1), (1<<INP_C_ID2))
SWITCH_CASE(4, pinc, 1<<INP_C_AileDR)
SWITCH_CASE(5, ping, 1<<INP_G_Gear)
SWITCH_CASE(6, pinb, 1<<INP_B_Trainer)
#else // PCB9X
#if defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT)
SWITCH_CASE(0, pinc, 1<<INP_C_ThrCt)
SWITCH_CASE(4, pinc, 1<<INP_C_AileDR)
@@ -309,8 +317,6 @@ void *main_thread(void *)
if (g_eeGeneral.backlightMode != e_backlight_mode_off) backlightOn(); // on Tx start turn the light on
LUA_INIT();
if (main_thread_running == 1) {
opentxStart();
}
+2 -1
View File
@@ -225,6 +225,7 @@ extern void rxPdcUsart( void (*pChProcess)(uint8_t x) );
#define PINC ~pinc
#define PIND ~pind
#define PINE ~pine
#define PINF ~pinf
#define PING ~ping
#define PINH ~pinh
#define PINJ ~pinj
@@ -334,7 +335,7 @@ extern uint32_t Master_frequency;
#define __enable_irq()
#endif
extern volatile unsigned char pina, pinb, pinc, pind, pine, ping, pinh, pinj, pinl;
extern volatile unsigned char pina, pinb, pinc, pind, pine, pinf, ping, pinh, pinj, pinl;
extern uint8_t portb, portc, porth, dummyport;
extern uint16_t dummyport16;
extern uint8_t main_thread_running;
+2
View File
@@ -107,6 +107,7 @@ bool dacQueue(AudioBuffer *buffer)
return false;
}
#pragma GCC optimize ("O1")
extern "C" void DAC_IRQHandler()
{
AudioBuffer *nextBuffer = audioQueue.getNextFilledBuffer();
@@ -118,6 +119,7 @@ extern "C" void DAC_IRQHandler()
dacStop();
}
}
#pragma GCC optimize ("O2")
// Sound routines
void audioInit()
+1 -1
View File
@@ -293,6 +293,6 @@ void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size);
// Second UART driver
void telemetrySecondPortInit(unsigned int protocol);
uint16_t telemetrySecondPortReceive();
bool telemetrySecondPortReceive(uint8_t & data);
#endif
@@ -44,10 +44,9 @@
/** Pins description corresponding to Rxd,Txd, (UART pins) */
#define SECOND_SERIAL_PINS {PINS_UART}
Fifo<512> serial2RxFifo;
#if !defined(SIMU)
extern Fifo<512> debugRxFifo;
/*
* Outputs a character on the UART line.
*
@@ -99,10 +98,8 @@ void SECOND_UART_Configure(uint32_t baudrate, uint32_t masterClock)
/* Enable receiver and transmitter */
pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
#if defined(DEBUG)
pUart->UART_IER = UART_IER_RXRDY;
NVIC_EnableIRQ(UART0_IRQn);
#endif
}
void SECOND_UART_Stop()
@@ -113,9 +110,7 @@ void SECOND_UART_Stop()
extern "C" void UART0_IRQHandler()
{
#if defined(DEBUG)
debugRxFifo.push(SECOND_SERIAL_UART->UART_RHR);
#endif
serial2RxFifo.push(SECOND_SERIAL_UART->UART_RHR);
}
#else
#define SECOND_UART_Configure(...)
@@ -125,17 +120,11 @@ extern "C" void UART0_IRQHandler()
void telemetrySecondPortInit(unsigned int /*protocol*/)
{
SECOND_UART_Configure(FRSKY_D_BAUDRATE, Master_frequency);
startPdcUsartReceive();
// startPdcUsartReceive();
}
uint16_t telemetrySecondPortReceive()
bool telemetrySecondPortReceive(uint8_t & data)
{
Uart *pUart = SECOND_SERIAL_UART;
if (pUart->UART_SR & UART_SR_RXRDY) {
return pUart->UART_RHR ;
}
return 0xFFFF ;
return serial2RxFifo.pop(data);
}
#endif
+7 -1
View File
@@ -142,8 +142,9 @@ extern int _write( int file, char *ptr, int len )
extern void _exit( int status )
{
#if defined(SIMU)
printf( "Exiting with status %d.\n", status ) ;
#endif
for ( ; ; ) ;
}
@@ -156,3 +157,8 @@ extern int _getpid ( void )
{
return -1 ;
}
void _init (void)
{
}
+19 -29
View File
@@ -36,7 +36,7 @@
#include "../../opentx.h"
#define RX_UART_BUFFER_SIZE 32
#define RX_UART_BUFFER_SIZE 128
struct t_rxUartBuffer
{
@@ -44,8 +44,7 @@ struct t_rxUartBuffer
uint8_t *outPtr ;
};
struct t_rxUartBuffer TelemetryInBuffer[2] ;
uint32_t TelemetryActiveBuffer;
struct t_rxUartBuffer TelemetryInBuffer ;
uint16_t DsmRxTimeout;
// USART0 configuration
@@ -106,18 +105,14 @@ extern "C" void USART0_IRQHandler()
void startPdcUsartReceive()
{
register Usart *pUsart = SECOND_USART;
TelemetryInBuffer[0].outPtr = TelemetryInBuffer[0].fifo ;
TelemetryInBuffer[1].outPtr = TelemetryInBuffer[1].fifo ;
TelemetryInBuffer.outPtr = TelemetryInBuffer.fifo ;
#ifndef SIMU
// TODO because of the 64bits cast ...
pUsart->US_RPR = (uint32_t)TelemetryInBuffer[0].fifo ;
pUsart->US_RNPR = (uint32_t)TelemetryInBuffer[1].fifo ;
pUsart->US_RPR = (uint32_t)TelemetryInBuffer.fifo ;
pUsart->US_RNPR = (uint32_t)TelemetryInBuffer.fifo ;
#endif
pUsart->US_RCR = RX_UART_BUFFER_SIZE ;
pUsart->US_RNCR = RX_UART_BUFFER_SIZE ;
pUsart->US_PTCR = US_PTCR_RXTEN ;
TelemetryActiveBuffer = 0;
}
void rxPdcUsart( void (*pChProcess)(uint8_t x) )
@@ -126,34 +121,29 @@ void rxPdcUsart( void (*pChProcess)(uint8_t x) )
register Usart *pUsart = SECOND_USART;
uint8_t *ptr ;
uint8_t *endPtr ;
uint32_t j ;
// Find out where the DMA has got to
__disable_irq() ;
pUsart->US_PTCR = US_PTCR_RXTDIS ; // Freeze DMA
ptr = (uint8_t *)pUsart->US_RPR ;
j = pUsart->US_RNCR ;
pUsart->US_PTCR = US_PTCR_RXTEN ; // DMA active again
__enable_irq() ;
endPtr = ptr - 1 ;
ptr = TelemetryInBuffer[TelemetryActiveBuffer].outPtr ;
if ( j == 0 ) // First buf is full
endPtr = (uint8_t *)pUsart->US_RPR ;
// Check for DMA passed end of buffer
if ( endPtr > &TelemetryInBuffer.fifo[RX_UART_BUFFER_SIZE-1] )
{
endPtr = &TelemetryInBuffer[TelemetryActiveBuffer].fifo[RX_UART_BUFFER_SIZE-1] ; // last byte
endPtr = TelemetryInBuffer.fifo ;
}
while ( ptr <= endPtr )
ptr = TelemetryInBuffer.outPtr ;
while ( ptr != endPtr )
{
(*pChProcess)(*ptr++) ;
if ( ptr > &TelemetryInBuffer.fifo[RX_UART_BUFFER_SIZE-1] ) // last byte
{
ptr = TelemetryInBuffer.fifo ;
}
}
TelemetryInBuffer[TelemetryActiveBuffer].outPtr = ptr ;
if ( j == 0 ) // First buf is full
TelemetryInBuffer.outPtr = ptr ;
if ( pUsart->US_RNCR == 0 )
{
TelemetryInBuffer[TelemetryActiveBuffer].outPtr = TelemetryInBuffer[TelemetryActiveBuffer].fifo ;
pUsart->US_RNPR = (uint32_t)TelemetryInBuffer[TelemetryActiveBuffer].fifo ;
pUsart->US_RNPR = (uint32_t)TelemetryInBuffer.fifo ;
pUsart->US_RNCR = RX_UART_BUFFER_SIZE ;
TelemetryActiveBuffer ^= 1 ; // Other buffer is active
rxPdcUsart( pChProcess ) ; // Get any chars from second buffer
}
#endif
}
+10 -3
View File
@@ -61,10 +61,12 @@
volatile uint16_t Analog_values[NUMBER_ANALOG];
#if defined(REV4a)
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,1,-1,1, 1};
#if defined(REVPLUS)
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,-1,-1,1, 1};
#elif defined(REV4a)
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,0,-1,1, 1};
#elif !defined(REV3)
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,1,-1,1, 1};
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,0,-1,1, 1};
#endif
void adcInit()
@@ -129,6 +131,11 @@ void adcRead()
if (ana_direction[i] < 0) {
Analog_values[i] = 4096-Analog_values[i];
}
#if !defined(REVPLUS)
else if (ana_direction[i] == 0) {
Analog_values[i] = 0;
}
#endif
}
#endif
}

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