Compare commits

..

48 Commits

Author SHA1 Message Date
bsongis 4062555605 FAI option tooltip updated (too many users select it without knowing
what it means)
2014-07-24 21:02:15 +02:00
bsongis 9cb38ce839 Companion default firmware is now OpenTX for Taranis 2014-07-24 20:51:31 +02:00
Bertrand Songis 905090ef09 Update DONATIONS.txt 2014-07-24 14:44:59 +02:00
Bertrand Songis 62e5820082 Update DONATIONS.txt 2014-07-24 12:07:18 +02:00
bsongis 2d21e16201 In Companion Wizard, Delta Wing has now 50% weight on elevons (as in
OpenTX Wizard)
2014-07-23 19:19:10 +02:00
bsongis 07303f4301 Taranis calibration better fix 2014-07-23 18:23:24 +02:00
bsongis 91228f803c snprintf undefined on VC++ 2014-07-23 18:02:46 +02:00
bsongis e5d7e1f7c2 Taranis calibration bug 2014-07-23 17:55:02 +02:00
bsongis 81573537eb Fixes #1549 2014-07-23 17:09:55 +02:00
bsongis 7a85328b86 #1549 (Firmware part) 2014-07-23 17:05:14 +02:00
bsongis fd84c62ff4 Dead code removed 2014-07-23 16:31:20 +02:00
bsongis 13e0b21656 The firmware should compile correctly on Windows now 2014-07-23 15:55:27 +02:00
bsongis 5949be30fa Fixes #1547 2014-07-23 15:46:51 +02:00
bsongis 0117c2da68 Fixes #1259 2014-07-23 15:15:26 +02:00
bsongis 943f70c599 OpenTX 2.0.8 preparation 2014-07-22 17:27:33 +02:00
Bertrand Songis 52a48fc4b1 Update DONATIONS.txt 2014-07-22 17:04:17 +02:00
Damjan Adamic 2712ffabb0 Re #1486: gtest improvements in Lua section 2014-07-22 11:39:36 +02:00
Bertrand Songis fa8c8a7094 Update DONATIONS.txt 2014-07-22 07:44:49 +02:00
bsongis 5907193571 Fixes #1543 2014-07-21 23:21:35 +02:00
bsongis 45abfb872f Fixes #1486 2014-07-21 22:25:55 +02:00
bsongis 4d5962b15b Fixes #1533 2014-07-21 20:41:57 +02:00
bsongis eea1c3a84c SAFETY renamed to OVERRIDE 2014-07-21 20:38:44 +02:00
bsongis deed7fc20f Curve index is correctly resetted when its type is changed 2014-07-21 20:23:56 +02:00
bsongis 62fca3f8b6 Fixes #1534 2014-07-21 20:09:39 +02:00
bsongis 9377e58407 Change Lua field name from vario-speed to vertical-speed 2014-07-21 19:22:40 +02:00
bsongis 9b53f69038 Fixes #1535 2014-07-21 19:15:24 +02:00
Bertrand Songis 3680149b52 Merge pull request #1529 from opentx/projectkk2glider/lua_constants_issue_1480
Projectkk2glider/lua constants issue 1480
2014-07-21 19:12:06 +02:00
Bertrand Songis 93faeeafbe Update DONATIONS.txt 2014-07-21 18:34:39 +02:00
Damjan Adamic 2d5d1cb357 Re #1480: couple corrections of field names 2014-07-21 12:04:08 +02:00
Damjan Adamic 2a5364dc8c Re #1480: wrong field.id for multiple fields 2014-07-21 11:51:30 +02:00
bsongis 7f47a4fe10 Fixes #1542 2014-07-20 18:51:24 +02:00
Bertrand Songis a0cc428228 Update DONATIONS.txt 2014-07-19 13:15:16 +02:00
Andre Bernet 61985f7d6a All companion translation files updated 2014-07-19 12:26:49 +02:00
Andre Bernet 3baf64f123 French translations 2014-07-19 12:26:10 +02:00
Andre Bernet 4fd40c154e Rename of "SafetyCH" to "OverrideCH" was not done in companion - UPDATE SERVER SCRIPT! 2014-07-19 12:22:32 +02:00
Andre Bernet 3c360618b9 nosafetych option was duplicated for 9x 2014-07-19 12:19:07 +02:00
Andre Bernet 1d96731ad5 Typo 2014-07-19 12:09:34 +02:00
Andre Bernet 9d1d31d26a lupdate-qt4 is just lupdate on Win 2014-07-19 12:09:04 +02:00
Bertrand Songis 0b52ccfaf1 Update DONATIONS.txt 2014-07-19 07:41:55 +02:00
bsongis 484566083e A little refactoring to avoid all the sprintf and too many string
comparaisons. Completely untested
2014-07-18 22:13:02 +02:00
Bertrand Songis 0f33dc6113 Update DONATIONS.txt 2014-07-18 18:49:59 +02:00
Damjan Adamic 7f3778fc3c Re #1480: units updated 2014-07-18 10:41:16 +02:00
Damjan Adamic 0a9dcc5ce6 Re #1480: added TELEM_MAX_ASPEED conversion in luaGetValueAndPush() 2014-07-18 10:41:16 +02:00
Damjan Adamic 2f01f139cc Re #1480: Cosmetics 2014-07-18 09:07:36 +02:00
Damjan Adamic fb3e615008 Fixes #1480: How to handle the increasing number of Lua constants 2014-07-18 08:59:38 +02:00
Bertrand Songis ce6d0807fa Update DONATIONS.txt 2014-07-17 23:14:29 +02:00
Bertrand Songis cab8f3db71 Update DONATIONS.txt 2014-07-17 08:53:18 +02:00
bsongis 399a8b2e35 Fixes #1517 2014-07-16 20:27:05 +02:00
67 changed files with 21385 additions and 17274 deletions
+11
View File
@@ -525,3 +525,14 @@ Adilson Oliveira
Joseph Ordille
Michael Shellim
Teddie Holmes
Alexandre Rault
Eric Albin
Lukas Kliment
Bernard Philippe
Bernard Delpy
Didier Klein
Arnaldo Guedes
Cyberauto Systems
John Alsbrooks
John Kearney
Christopher Borden
+6
View File
@@ -1,3 +1,9 @@
<h2>Version 2.0.8</h2>
<ul>
<li>Compare dialog bugfixes</li>
<li>Curve index correctly resetted when type changed</li>
</ul>
<h2>Version 2.0.7</h2>
<ul>
<li>SafetyCH function was missing in simulator</li>
+17 -2
View File
@@ -2,7 +2,7 @@ PROJECT( companion )
SET( C9X_VERSION_MAJOR "2" )
SET( C9X_VERSION_MINOR "0" )
SET( C9X_VERSION_REVISION "7" )
SET( C9X_VERSION_REVISION "8" )
SET( C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR}.${C9X_VERSION_REVISION} )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
@@ -87,6 +87,13 @@ add_custom_command(
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
)
add_custom_command(
OUTPUT ${RADIO_SRC_DIRECTORY}/lua_exports.inc
COMMAND make lua_exports.cpp
DEPENDS ${RADIO_SRC_DIRECTORY}/myeeprom.h
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/../..
@@ -112,6 +119,7 @@ set(common_SRCS
firmwares/ersky9x/ersky9xinterface.cpp
${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm
${RADIO_SRC_DIRECTORY}/translations/en.h
${RADIO_SRC_DIRECTORY}/lua_exports.inc
firmwares/opentx/opentxeeprom.cpp
firmwares/opentx/open9xStockeeprom.cpp
firmwares/opentx/open9xGruvin9xeeprom.cpp
@@ -312,6 +320,7 @@ set(simu_SRCS
${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp
${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm
${RADIO_SRC_DIRECTORY}/translations/en.h
${RADIO_SRC_DIRECTORY}/lua_exports.inc
modeledit/node.cpp
modeledit/edge.cpp # TODO not needed
simulator.cpp
@@ -418,9 +427,15 @@ ADD_CUSTOM_TARGET( stamp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/version.h ${CMAKE_SOURCE_DIR}/../companion.stamp
DEPENDS ${CMAKE_BINARY_DIR}/version.h )
ADD_CUSTOM_TARGET( translations
IF(WIN32)
ADD_CUSTOM_TARGET( translations
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND lupdate ${CMAKE_SOURCE_DIR} -ts ${companion_TS} )
ELSE( )
ADD_CUSTOM_TARGET( translations
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND lupdate-qt4 ${CMAKE_SOURCE_DIR} -ts ${companion_TS} )
ENDIF( )
SET(CPACK_PACKAGE_NAME "COMPANION")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Models and settings editor for the OpenTx open source firmware")
+8 -9
View File
@@ -506,11 +506,11 @@ void CompareDialog::printLimits()
str.append(doTC(tr("CH")+QString(" %1").arg(i+1,2,10,QChar('0')),"",true));
}
color=getColor1(g_model1->limitData[i].offset,g_model2->limitData[i].offset);
str.append(doTR(QString::number((qreal)g_model1->limitData[i].offset/10, 'f', 1),color));
str.append(doTR(g_model1->limitData[i].offsetToString(), color));
color=getColor1(g_model1->limitData[i].min,g_model2->limitData[i].min);
str.append(doTR(QString::number(g_model1->limitData[i].min),color));
str.append(doTR(g_model1->limitData[i].minToString(), color));
color=getColor1(g_model1->limitData[i].max,g_model2->limitData[i].max);
str.append(doTR(QString::number(g_model1->limitData[i].max),color));
str.append(doTR(g_model1->limitData[i].maxToString(), color));
color=getColor1(g_model1->limitData[i].revert,g_model2->limitData[i].revert);
str.append(doTR(QString(g_model1->limitData[i].revert ? tr("INV") : tr("NOR")),color));
str.append("</tr>");
@@ -533,11 +533,11 @@ void CompareDialog::printLimits()
str.append(doTC(tr("CH")+QString(" %1").arg(i+1,2,10,QChar('0')),"",true));
}
color=getColor2(g_model1->limitData[i].offset,g_model2->limitData[i].offset);
str.append(doTR(QString::number((qreal)g_model2->limitData[i].offset/10, 'f', 1),color));
str.append(doTR(g_model2->limitData[i].offsetToString(), color));
color=getColor2(g_model1->limitData[i].min,g_model2->limitData[i].min);
str.append(doTR(QString::number(g_model2->limitData[i].min),color));
str.append(doTR(g_model2->limitData[i].minToString(), color));
color=getColor2(g_model1->limitData[i].max,g_model2->limitData[i].max);
str.append(doTR(QString::number(g_model2->limitData[i].max),color));
str.append(doTR(g_model2->limitData[i].maxToString(), color));
color=getColor2(g_model1->limitData[i].revert,g_model2->limitData[i].revert);
str.append(doTR(QString(g_model2->limitData[i].revert ? tr("INV") : tr("NOR")),color));
str.append("</tr>");
@@ -807,7 +807,7 @@ void CompareDialog::printMixers()
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
str += md->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (md->curve.value) str += " " + md->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
if (md->mixWarn) str += " "+tr("Warn")+QString("(%1)").arg(md->mixWarn);
@@ -885,8 +885,7 @@ void CompareDialog::printMixers()
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
// TODO if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
// TODO if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
if (md->curve.value) str += " " + md->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
if (md->mixWarn) str += " "+tr("Warn")+QString("(%1)").arg(md->mixWarn);
+23 -1
View File
@@ -724,7 +724,7 @@ QString FuncSwData::funcToString()
{
ModelData model;
if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32)
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString(model));
return QObject::tr("Override %1").arg(RawSource(SOURCE_TYPE_CH, func).toString(model));
else if (func == FuncTrainer)
return QObject::tr("Trainer");
else if (func == FuncTrainerRUD)
@@ -851,6 +851,28 @@ QString FuncSwData::repeatToString()
}
}
QString LimitData::minToString()
{
return QString::number((qreal)min/10);
}
QString LimitData::maxToString()
{
return QString::number((qreal)max/10);
}
QString LimitData::offsetToString()
{
return QString::number((qreal)offset/10, 'f', 1);
}
void LimitData::clear()
{
memset(this, 0, sizeof(LimitData));
min = -1000;
max = +1000;
}
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
+4 -1
View File
@@ -631,7 +631,10 @@ class LimitData {
bool symetrical;
char name[6+1];
CurveReference curve;
void clear() { memset(this, 0, sizeof(LimitData)); min = -1000; max = +1000; }
QString minToString();
QString maxToString();
QString offsetToString();
void clear();
};
enum MltpxValue {
@@ -573,8 +573,8 @@ t_Open9xFuncSwData_v201::operator FuncSwData ()
}
enum Functions {
FUNC_SAFETY_CH1,
FUNC_SAFETY_CH16=FUNC_SAFETY_CH1+15,
FUNC_OVERRIDE_CH1,
FUNC_OVERRIDE_CH16=FUNC_OVERRIDE_CH1+15,
FUNC_TRAINER,
FUNC_TRAINER_RUD,
FUNC_TRAINER_ELE,
@@ -48,7 +48,7 @@
#define GPS
#define FAI_CHOICE
#define FRSKY_STICKS
#define SAFETY_CHANNEL_FUNCTION
#define OVERRIDE_CHANNEL_FUNCTION
#define EEPROM_VARIANT 3
@@ -48,7 +48,7 @@
#define FRSKY_STICKS
#define DSM2
#define DSM2_PPM
#define SAFETY_CHANNEL_FUNCTION
#define OVERRIDE_CHANNEL_FUNCTION
#define EEPROM_VARIANT SIMU_M128_VARIANTS
#define GAUGES
@@ -50,7 +50,7 @@
#define GPS
#define FAI_CHOICE
#define FRSKY_STICKS
#define SAFETY_CHANNEL_FUNCTION
#define OVERRIDE_CHANNEL_FUNCTION
#define FAS_OFFSET
#define EEPROM_VARIANT SIMU_STOCK_VARIANTS
@@ -54,7 +54,7 @@
#define GPS
#define FAI_CHOICE
#define FRSKY_STICKS
#define SAFETY_CHANNEL_FUNCTION
#define OVERRIDE_CHANNEL_FUNCTION
#define NUM_POTS 3
#define EEPROM_VARIANT 3
@@ -54,7 +54,7 @@
#define EEPROM_VARIANT 3
#define HAPTIC
#define REVPLUS
#define SAFETY_CHANNEL_FUNCTION
#define OVERRIDE_CHANNEL_FUNCTION
#define NUM_POTS 5
@@ -2534,7 +2534,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
if (IS_TARANIS(board)) {
modulesCount = 3;
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this rado protocol")));
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[1].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol")));
internalField.Append(new UnsignedField<8>(modelData.trainerMode));
}
else if (IS_ARM(board) && version >= 216) {
@@ -580,7 +580,7 @@ int OpenTxFirmware::getCapability(const Capability capability)
else
return 16;
case SafetyChannelCustomFunction:
return id.contains("nosafetych") ? 0 : 1;
return id.contains("noovveridech") ? 0 : 1;
case LogicalSwitches:
if (IS_ARM(board))
return 32;
@@ -644,7 +644,7 @@ int OpenTxFirmware::getCapability(const Capability capability)
case HasCvNames:
return (IS_TARANIS(board) ? 1 : 0);
case Telemetry:
if (board == BOARD_GRUVIN9X || IS_ARM(board) || id.contains("frsky"))
if (board == BOARD_GRUVIN9X || IS_ARM(board) || id.contains("frsky") || id.contains("telemetrez"))
return TM_HASTELEMETRY|TM_HASOFFSET|TM_HASWSHH;
else
return 0;
@@ -1051,8 +1051,8 @@ void addOpenTxCommonOptions(OpenTxFirmware * firmware)
{
firmware->addOption("ppmus", QObject::tr("Channel values displayed in us"));
firmware->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
firmware->addOption("nosafetych", QObject::tr("No SafetyCH functions available"));
Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };
firmware->addOption("nooverridech", QObject::tr("No OverrideCH functions available"));
Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE (no telemetry) at field") }, { "faimode", QObject::tr("FAI MODE (no telemetry) always enabled") }, { NULL } };
firmware->addOptions(fai_options);
}
@@ -1095,7 +1095,6 @@ void registerOpenTxFirmwares()
openTx->addOption("novario", QObject::tr("No vario support"));
openTx->addOption("nogps", QObject::tr("No GPS support"));
openTx->addOption("nogauges", QObject::tr("No gauges in the custom telemetry screen"));
openTx->addOption("nosafetych", QObject::tr("No SafetyCH functions available"));
openTx->addOption("fasoffset", QObject::tr("Allow compensating for offset errors in FrSky FAS current sensors"));
openTx->addOption("stickrev", QObject::tr("Add support for reversing stick inputs (e.g. needed for FrSky gimbals)"));
addOpenTxCommonOptions(openTx);
@@ -1263,6 +1262,7 @@ void registerOpenTxFirmwares()
openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
openTx->addOption("haptic", QObject::tr("Haptic module installed"));
openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
openTx->addOption("nojoystick", QObject::tr("No Joystick emulation inside the FW (only Mass Storage as in the Bootloader)"));
addOpenTxCommonOptions(openTx);
firmwares.push_back(openTx);
@@ -1271,10 +1271,11 @@ void registerOpenTxFirmwares()
openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
openTx->addOption("nojoystick", QObject::tr("No Joystick emulation inside the FW (only Mass Storage as in the Bootloader)"));
addOpenTxCommonOptions(openTx);
firmwares.push_back(openTx);
default_firmware_variant = GetFirmware("opentx-9x-heli-templates-en");
default_firmware_variant = GetFirmware("opentx-taranis-en");
current_firmware_variant = default_firmware_variant;
}
+19 -4
View File
@@ -106,7 +106,7 @@
These will be relevant for all models in the same EEPROM.</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tabSetup">
<attribute name="title">
@@ -3195,7 +3195,7 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<property name="text">
<string>Pot (normal)</string>
<string>Pot with detent (normal)</string>
</property>
</item>
<item>
@@ -3203,6 +3203,11 @@ p, li { white-space: pre-wrap; }
<string>Multipos Switch</string>
</property>
</item>
<item>
<property name="text">
<string>Pot without detent</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
@@ -3236,7 +3241,7 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<property name="text">
<string>Pot (normal)</string>
<string>Pot with detent (normal)</string>
</property>
</item>
<item>
@@ -3244,6 +3249,11 @@ p, li { white-space: pre-wrap; }
<string>Multipos Switch</string>
</property>
</item>
<item>
<property name="text">
<string>Pot without detent</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
@@ -3284,7 +3294,7 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<property name="text">
<string>Pot (normal)</string>
<string>Pot with detent (normal)</string>
</property>
</item>
<item>
@@ -3292,6 +3302,11 @@ p, li { white-space: pre-wrap; }
<string>Multipos Switch</string>
</property>
</item>
<item>
<property name="text">
<string>Pot without detent</string>
</property>
</item>
</widget>
</item>
<item row="6" column="3">
+23 -1
View File
@@ -216,7 +216,7 @@ CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox
curveValueCB->setMaxVisibleItems(10);
connect(curveTypeCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
connect(curveTypeCB, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged(int)));
connect(curveGVarCB, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
connect(curveValueCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
connect(curveValueSB, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
@@ -300,6 +300,28 @@ void CurveGroup::gvarCBChanged(int state)
}
}
void CurveGroup::typeChanged(int value)
{
if (!lock) {
switch (value) {
case 0:
curve = CurveReference(CurveReference::CURVE_REF_DIFF, 0);
break;
case 1:
curve = CurveReference(CurveReference::CURVE_REF_EXPO, 0);
break;
case 2:
curve = CurveReference(CurveReference::CURVE_REF_FUNC, 0);
break;
case 3:
curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, 0);
break;
}
update();
}
}
void CurveGroup::valuesChanged()
{
if (!lock) {
+1
View File
@@ -67,6 +67,7 @@ class CurveGroup : public QObject {
protected slots:
void gvarCBChanged(int);
void typeChanged(int);
void valuesChanged();
protected:
+33 -19
View File
@@ -167,16 +167,20 @@ void LogicalSwitchesPanel::andEdited(int value)
void LogicalSwitchesPanel::durationEdited(double duration)
{
int index = sender()->property("index").toInt();
model.customSw[index].duration = (uint8_t)round(duration*10);
emit modified();
if (!lock) {
int index = sender()->property("index").toInt();
model.customSw[index].duration = (uint8_t)round(duration*10);
emit modified();
}
}
void LogicalSwitchesPanel::delayEdited(double delay)
{
int index = sender()->property("index").toInt();
model.customSw[index].delay = (uint8_t)round(delay*10);
emit modified();
if (!lock) {
int index = sender()->property("index").toInt();
model.customSw[index].delay = (uint8_t)round(delay*10);
emit modified();
}
}
void LogicalSwitchesPanel::edited()
@@ -184,19 +188,25 @@ void LogicalSwitchesPanel::edited()
if (!lock) {
lock = true;
int i = sender()->property("index").toInt();
int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt();
bool chAr = (model.customSw[i].getFunctionFamily() != LogicalSwitchData(newFunc).getFunctionFamily());
model.customSw[i].func = newFunc;
if (chAr) {
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_TIMER) {
CSFunctionFamily oldFuncFamily = model.customSw[i].getFunctionFamily();
model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
CSFunctionFamily newFuncFamily = model.customSw[i].getFunctionFamily();
if (oldFuncFamily != newFuncFamily) {
if (newFuncFamily == LS_FAMILY_TIMER) {
model.customSw[i].val1 = -119;
model.customSw[i].val2 = -119;
}
else if (model.customSw[i].getFunctionFamily() == LS_FAMILY_STAY) {
else if (newFuncFamily == LS_FAMILY_STAY) {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = -129;
model.customSw[i].val3 = 0;
}
else if (newFuncFamily == LS_FAMILY_STICKY) {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = 0;
model.customSw[i].delay = 0;
}
else {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = 0;
@@ -207,7 +217,7 @@ void LogicalSwitchesPanel::edited()
RawSource source;
switch (model.customSw[i].getFunctionFamily())
switch (newFuncFamily)
{
case LS_FAMILY_VOFS:
{
@@ -273,12 +283,13 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, doubl
#define VALUE2_VISIBLE 0x8
#define VALUE3_VISIBLE 0x10
#define VALUE_TO_VISIBLE 0x20
#define DELAY_ENABLED 0x40
void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
{
lock = true;
unsigned int mask = 0;
unsigned int mask = DELAY_ENABLED;
RawSource source = RawSource(model.customSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model.customSw[i].getRangeFlags());
@@ -308,8 +319,10 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
case LS_FAMILY_VBOOL:
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);
@@ -342,6 +355,11 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchOffset[i]->setVisible(mask & VALUE2_VISIBLE);
cswitchOffset2[i]->setVisible(mask & VALUE3_VISIBLE);
cswitchTOffset[i]->setVisible(mask & VALUE_TO_VISIBLE);
if (firmware->getCapability(LogicalSwitchesExt)) {
cswitchDelay[i]->setEnabled(mask & DELAY_ENABLED);
cswitchDuration[i]->setValue(model.customSw[i].duration/10.0);
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
}
lock = false;
}
@@ -425,10 +443,6 @@ void LogicalSwitchesPanel::updateLine(int i)
setSwitchWidgetVisibility(i);
lock = true;
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
if (firmware->getCapability(LogicalSwitchesExt)) {
cswitchDuration[i]->setValue(model.customSw[i].duration/10.0);
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
}
lock = false;
}
+4 -2
View File
@@ -198,12 +198,14 @@ void TelemetryAnalog::on_CalibSB_editingFinished()
}
if (alarm2value<calib) {
alarm2value=calib;
} else if (alarm2value>(ratio+calib)) {
}
else if (alarm2value>(ratio+calib)) {
alarm2value=ratio+calib;
}
analog.alarms[0].value=round(((alarm1value-calib)*255)/ratio);
analog.alarms[1].value=round(((alarm2value-calib)*255)/ratio);
} else {
}
else {
analog.offset=0;
analog.alarms[0].value=0;
analog.alarms[1].value=0;
+4 -5
View File
@@ -340,7 +340,6 @@ void PrintDialog::printMixes()
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
int scale = firmware->getCapability(SlowScale);
if (scale == 0)
@@ -379,22 +378,22 @@ void PrintDialog::printLimits()
if (firmware->getCapability(HasChNames)) {
str.append("<tr><td><b>"+tr("Name")+"</b></td>");
for(int i=0; i<firmware->getCapability(Outputs); i++) {
str.append(doTR(g_model->limitData[i].name,"green"));
str.append(doTR(g_model->limitData[i].name, "green"));
}
}
str.append("<tr><td><b>"+tr("Offset")+"</b></td>");
for(int i=0; i<firmware->getCapability(Outputs); i++) {
str.append(doTR(QString::number((qreal)g_model->limitData[i].offset/10, 'f', 1),"green"));
str.append(doTR(g_model->limitData[i].offsetToString(), "green"));
}
str.append("</tr>");
str.append("<tr><td><b>"+tr("Min")+"</b></td>");
for(int i=0; i<firmware->getCapability(Outputs); i++) {
str.append(doTR(QString::number((qreal)g_model->limitData[i].min/10),"green"));
str.append(doTR(g_model->limitData[i].minToString(), "green"));
}
str.append("</tr>");
str.append("<tr><td><b>"+tr("Max")+"</b></td>");
for(int i=0; i<firmware->getCapability(Outputs); i++) {
str.append(doTR(QString::number((qreal)g_model->limitData[i].max/10),"green"));
str.append(doTR(g_model->limitData[i].maxToString(), "green"));
}
str.append("</tr>");
str.append("<tr><td><b>"+tr("Invert")+"</b></td>");
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
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
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
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -628,8 +628,8 @@ void ElevonsPage::initializePage()
bool ElevonsPage::validatePage()
{
releaseBookings();
return (bookChannel(elevon1CB, AILERONS_INPUT, 100, ELEVATOR_INPUT, 100) &&
bookChannel(elevon2CB, AILERONS_INPUT, -100, ELEVATOR_INPUT, 100));
return (bookChannel(elevon1CB, AILERONS_INPUT, 50, ELEVATOR_INPUT, 50) &&
bookChannel(elevon2CB, AILERONS_INPUT, -50, ELEVATOR_INPUT, 50));
}
RudderPage::RudderPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage):
@@ -1002,7 +1002,7 @@ WizardPrinter::WizardPrinter(WizMix *wizMix)
mix = wizMix;
}
QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, int weight2 )
QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, int weight2 )
{
QString str;
str = QString("[%1, %2]").arg(inputName(input1)).arg(weight1);
+1
View File
@@ -24,5 +24,6 @@
#define round(x) floor(x+0.5)
#define strcasecmp _stricmp
#define strncasecmp _tcsnicmp
#define snprintf _snprintf
#endif
+9
View File
@@ -1,3 +1,12 @@
<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
<h2>Version 2.0.7 / 2014-07-15</h2>
[Taranis]
<ul>
+2
View File
@@ -24,3 +24,5 @@
/gtests
/gtest_main.a
/gtests.d
/lua_exports.cpp
/lua_exports.txt
+19 -8
View File
@@ -169,9 +169,9 @@ PPM_LIMITS_SYMETRICAL = NO
# Values = PERCENT_PREC1, PERCENT_PREC0, US
PPM_UNIT = PERCENT_PREC1
# SafetyCHxx functions enable
# OverrideCHxx functions enable
# Values = YES, NO
SAFETY_CHANNEL_FUNCTION = YES
OVERRIDE_CHANNEL_FUNCTION = YES
# FrSky Hub
# Values = YES, NO
@@ -296,12 +296,13 @@ SHELL = sh
IMG2LBM = -python ../util/img2lbm.py
BIN2LBM = -python ../util/bin2lbm.py
TRANSLATE = -python ../util/translate.py
VERSION = 2.0.7
VERSION = 2.0.8
SRC =
CPPSRC =
INCDIRS = . translations
EXTRAINCDIRS =
LUADEP =
# MCU name
ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X 9XRPRO TARANIS))
@@ -729,6 +730,7 @@ ifeq ($(PCB), TARANIS)
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
SRC += $(LUASRC)
LUADEP = lua_exports.cpp
endif
ifeq ($(SDCARD), YES)
@@ -769,6 +771,7 @@ ifeq ($(PCB), TARANIS)
endif
CC = $(TRGT)gcc
CPP = $(TRGT)cpp
AS = $(TRGT)as
OBJCOPY = $(TRGT)objcopy
OBJDUMP = $(TRGT)objdump
@@ -1022,8 +1025,8 @@ ifeq ($(PPM_LIMITS_SYMETRICAL), YES)
CPPDEFS += -DPPM_LIMITS_SYMETRICAL
endif
ifeq ($(SAFETY_CHANNEL_FUNCTION), YES)
CPPDEFS += -DSAFETY_CHANNEL_FUNCTION
ifeq ($(OVERRIDE_CHANNEL_FUNCTION), YES)
CPPDEFS += -DOVERRIDE_CHANNEL_FUNCTION
endif
ifeq ($(PPM_UNIT), US)
@@ -1156,7 +1159,7 @@ all: begin gccversion sizebefore build sizeafter end
ifeq ($(ARCH), AVR)
build: stamp_header tra lbm allsrc.cpp elf remallsrc hex
else ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO TARANIS))
build: stamp_header tra lbm bootloader.lbm allsrc.cpp elf remallsrc bin
build: stamp_header tra lbm bootloader.lbm $(LUADEP) allsrc.cpp elf remallsrc bin
else
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
endif
@@ -1272,6 +1275,12 @@ bitmaps/sticks.lbm: bitmaps/sticks_4x1.xbm bitmaps/splash_9x.xbm bitmaps/splash_
$(IMG2LBM) bitmaps/about_taranis.png bitmaps/about_taranis.lbm bmp
$(IMG2LBM) bitmaps/about_9x.png bitmaps/about_9x.lbm img
$(IMG2LBM) bitmaps/asterisk_4bits.png bitmaps/asterisk_4bits.lbm bmp
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
@echo "Parsing and generating C Lua exports in lua_exports.cpp"
@python ../util/luaexport.py lua_exports.txt lua_exports.cpp
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
@@ -1313,7 +1322,7 @@ FOXLIB=-L/usr/local/lib \
-lFOX-1.6 \
-Wl,-rpath,$(FOXPATH)/src/.libs
simu: stamp_header $(BOARDSRC) $(CPPSRC) Makefile simu.cpp targets/simu/simpgmspace.cpp *.h tra lbm eeprom.bin
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
eeprom.bin:
@@ -1410,6 +1419,7 @@ clean_list :
$(REMOVE) stamp-opentx.h
$(REMOVE) bitmaps/*.lbm
$(REMOVE) fonts/*/*.lbm
$(REMOVE) lua_exports.txt lua_exports.cpp
$(MAKE) -C bootloader clean
#### Install
@@ -1491,4 +1501,5 @@ gtest_main.a : gtest-all.o gtest_main.o
GTEST_TESTS_SRCS = $(shell find tests/ -type f -name '*.cpp')
gtests: $(BOARDSRC) $(CPPSRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp *.h gtest_main.a
g++ -std=gnu++0x $(CPPFLAGS) $(BOARDSRC) $(CPPSRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp -I$(GTEST_DIR) ${INCFLAGS} -I$(GTEST_DIR)/include -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest_main.a
g++ -std=gnu++0x $(CPPFLAGS) $(BOARDSRC) $(CPPSRC) $(LUASRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp -I$(GTEST_DIR) ${INCFLAGS} -I$(GTEST_DIR)/include -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest_main.a -fexceptions
+1 -1
View File
@@ -730,7 +730,7 @@ void ConvertModel_215_to_216(ModelData &model)
fn.func = oldModel.funcSw[i].func;
if (fn.func <= 15) {
fn.all.param = fn.func;
fn.func = FUNC_SAFETY_CHANNEL;
fn.func = FUNC_OVERRIDE_CHANNEL;
}
else if (fn.func <= 20) {
fn.all.param = fn.func - 16;
+19 -15
View File
@@ -1386,9 +1386,9 @@ void menuGeneralHardware(uint8_t event)
putsMixerSource(sizeof(TR_TYPE)*FW, y, MIXSRC_FIRST_POT+idx);
uint8_t potType = (g_eeGeneral.potsType & mask) >> shift;
if (potType == POT_TYPE_NONE && i < 2)
potType = POT_TYPE_POT;
potType = POT_TYPE_DETENT;
potType = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_TYPE, STR_POTTYPES, potType, 0, POT_TYPE_MAX, attr, event);
if (potType == POT_TYPE_POT && i < 2)
if (potType == POT_TYPE_DETENT && i < 2)
potType = POT_TYPE_NONE;
g_eeGeneral.potsType &= ~mask;
g_eeGeneral.potsType |= (potType << shift);
@@ -1490,7 +1490,9 @@ void menuCommonCalib(uint8_t event)
reusableBuffer.calib.loVals[i] = min(vt, reusableBuffer.calib.loVals[i]);
reusableBuffer.calib.hiVals[i] = max(vt, reusableBuffer.calib.hiVals[i]);
if (i >= POT1 && i <= POT_LAST) {
reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2;
if (IS_POT_WITHOUT_DETENT(i)) {
reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2;
}
#if defined(PCBTARANIS)
uint8_t idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
@@ -1585,23 +1587,25 @@ void menuCommonCalib(uint8_t event)
for (uint8_t i=POT1; i<=POT_LAST; i++) {
int idx = i - POT1;
int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount;
if (IS_POT_MULTIPOS(i) && count > 1 && count <= XPOTS_MULTIPOS_COUNT) {
for (int j=0; j<count; j++) {
for (int k=j+1; k<count; k++) {
if (reusableBuffer.calib.xpotsCalib[idx].steps[k] < reusableBuffer.calib.xpotsCalib[idx].steps[j]) {
swap(reusableBuffer.calib.xpotsCalib[idx].steps[j], reusableBuffer.calib.xpotsCalib[idx].steps[k]);
if (IS_POT_MULTIPOS(i)) {
if (count > 1 && count <= XPOTS_MULTIPOS_COUNT) {
for (int j=0; j<count; j++) {
for (int k=j+1; k<count; k++) {
if (reusableBuffer.calib.xpotsCalib[idx].steps[k] < reusableBuffer.calib.xpotsCalib[idx].steps[j]) {
swap(reusableBuffer.calib.xpotsCalib[idx].steps[j], reusableBuffer.calib.xpotsCalib[idx].steps[k]);
}
}
}
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
calib->count = count - 1;
for (int j=0; j<calib->count; j++) {
calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5;
}
}
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i];
calib->count = count - 1;
for (int j=0; j<calib->count; j++) {
calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5;
else {
g_eeGeneral.potsType &= ~(0x03<<(2*idx));
}
}
else {
g_eeGeneral.potsType &= ~(1<<idx);
}
}
#endif
g_eeGeneral.chkSum = evalChkSum();
+4 -4
View File
@@ -5068,8 +5068,8 @@ void menuModelCustomFunctions(uint8_t event)
case 2:
{
int8_t maxParam = NUM_CHNOUT-1;
#if defined(SAFETY_CHANNEL_FUNCTION)
if (func == FUNC_SAFETY_CHANNEL) {
#if defined(OVERRIDE_CHANNEL_FUNCTION)
if (func == FUNC_OVERRIDE_CHANNEL) {
putsChn(lcdNextPos, y, CFN_CH_INDEX(sd)+1, attr);
}
else
@@ -5120,8 +5120,8 @@ void menuModelCustomFunctions(uint8_t event)
val_max = FUNC_RESET_PARAM_LAST;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(sd), attr);
}
#if defined(SAFETY_CHANNEL_FUNCTION)
else if (func == FUNC_SAFETY_CHANNEL) {
#if defined(OVERRIDE_CHANNEL_FUNCTION)
else if (func == FUNC_OVERRIDE_CHANNEL) {
val_displayed = (int8_t)CFN_PARAM(sd);
val_min = -125; val_max = 125;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
+2 -2
View File
@@ -1544,8 +1544,8 @@ bool isLogicalSwitchFunctionAvailable(int function)
bool isAssignableFunctionAvailable(int function)
{
switch (function) {
#if !defined(SAFETY_CHANNEL_FUNCTION)
case FUNC_SAFETY_CHANNEL:
#if !defined(OVERRIDE_CHANNEL_FUNCTION)
case FUNC_OVERRIDE_CHANNEL:
#endif
#if !defined(HAPTIC)
case FUNC_HAPTIC:
+1 -1
View File
@@ -92,7 +92,7 @@ void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att)
if (x >= LCD_W) return;
if (y >= LCD_H) return;
if (h<0) { y+=h; h=-h; }
if (y<0) { h+=y; y=0; }
if (y<0) { h+=y; y=0; if (h<=0) return; }
if (y+h > LCD_H) { h = LCD_H - y; }
if (pat==DOTTED && !(y%2)) {
+241 -71
View File
@@ -34,6 +34,8 @@
*
*/
#include <ctype.h>
#include <stdio.h>
#include "opentx.h"
#include "stamp-opentx.h"
@@ -47,13 +49,16 @@ extern "C" {
}
#endif
#include "lua_exports.cpp" // this line must be after lua headers
#define lua_registernumber(L, n, i) (lua_pushnumber(L, (i)), lua_setglobal(L, (n)))
#define lua_registerint(L, n, i) (lua_pushinteger(L, (i)), lua_setglobal(L, (n)))
#define lua_pushtablenil(L, k) (lua_pushstring(L, (k)), lua_pushnil(L), lua_settable(L, -3))
#define lua_pushtableboolean(L, k, v) (lua_pushstring(L, (k)), lua_pushboolean(L, (v)), lua_settable(L, -3))
#define lua_pushtableinteger(L, k, v) (lua_pushstring(L, (k)), lua_pushinteger(L, (v)), lua_settable(L, -3))
#define lua_pushtablenumber(L, k, v) (lua_pushstring(L, (k)), lua_pushnumber(L, (v)), lua_settable(L, -3))
#define lua_pushtablestring(L, k, v) { char tmp[sizeof(v)+1]; strncpy(tmp, (v), sizeof(v)); tmp[sizeof(v)] = '\0'; lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); }
#define lua_pushtablestring(L, k, v) (lua_pushstring(L, (k)), lua_pushstring(L, (v)), lua_settable(L, -3))
#define lua_pushtablenzstring(L, k, v) { char tmp[sizeof(v)+1]; strncpy(tmp, (v), sizeof(v)); tmp[sizeof(v)] = '\0'; lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); }
#define lua_pushtablezstring(L, k, v) { char tmp[sizeof(v)+1]; zchar2str(tmp, (v), sizeof(v)); lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); }
#define lua_registerlib(L, name, tab) (luaL_newmetatable(L, name), luaL_setfuncs(L, tab, 0), lua_setglobal(L, name))
@@ -97,14 +102,17 @@ static int luaGetTime(lua_State *L)
static void luaGetValueAndPush(int src)
{
/*
Hint about dividers are taken from putsTelemetryChannel()
*/
if (!TELEMETRY_STREAMING() && src>=MIXSRC_FIRST_TELEM && src<=MIXSRC_LAST_TELEM) {
//telemetry not working, return zero for telemetry sources
lua_pushinteger(L, (int)0);
return;
if (src >= MIXSRC_FIRST_TELEM && src <= MIXSRC_LAST_TELEM) {
// telemetry values
if ((src != MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE) && !TELEMETRY_STREAMING()) {
// telemetry not working, return zero for telemetry sources
// except for "tx voltage"
lua_pushinteger(L, (int)0);
return;
}
}
int idx = src;
switch (src) {
case MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE:
case MIXSRC_FIRST_TELEM-1+TELEM_VFAS:
@@ -113,21 +121,25 @@ static void luaGetValueAndPush(int src)
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_CELLS_SUM:
case MIXSRC_FIRST_TELEM-1+TELEM_CURRENT:
case MIXSRC_FIRST_TELEM-1+TELEM_MAX_CURRENT:
case MIXSRC_FIRST_TELEM-1+TELEM_VSPEED:
//theese need to be divided by 10
case MIXSRC_FIRST_TELEM-1+TELEM_ASPEED:
case MIXSRC_FIRST_TELEM-1+TELEM_MAX_ASPEED:
// these need to be divided by 10
lua_pushnumber(L, getValue(src)/10.0);
break;
case MIXSRC_FIRST_TELEM-1+TELEM_A1:
case MIXSRC_FIRST_TELEM-1+TELEM_A2:
//convert raw A1/2 values to calibrated values
lua_pushnumber(L, applyChannelRatio(src-(MIXSRC_FIRST_TELEM-1+TELEM_A1), getValue(src))/100.0);
break;
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1:
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_A2:
//convert raw A1/2 values to calibrated values
lua_pushnumber(L, applyChannelRatio(src-(MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1), getValue(src))/100.0);
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_A3:
case MIXSRC_FIRST_TELEM-1+TELEM_MIN_A4:
idx -= TELEM_MIN_A1-TELEM_A1;
// no break
case MIXSRC_FIRST_TELEM-1+TELEM_A1:
case MIXSRC_FIRST_TELEM-1+TELEM_A2:
case MIXSRC_FIRST_TELEM-1+TELEM_A3:
case MIXSRC_FIRST_TELEM-1+TELEM_A4:
// convert raw Ax values to calibrated values
idx -= (MIXSRC_FIRST_TELEM+TELEM_A1-1);
lua_pushnumber(L, applyChannelRatio(idx, getValue(src))/100.0);
break;
case MIXSRC_FIRST_TELEM-1+TELEM_CELL:
@@ -136,7 +148,8 @@ static void luaGetValueAndPush(int src)
case MIXSRC_FIRST_TELEM-1+TELEM_ACCx:
case MIXSRC_FIRST_TELEM-1+TELEM_ACCy:
case MIXSRC_FIRST_TELEM-1+TELEM_ACCz:
//theese need to be divided by 100
case MIXSRC_FIRST_TELEM-1+TELEM_VSPEED:
// these need to be divided by 100
lua_pushnumber(L, getValue(src)/100.0);
break;
@@ -148,61 +161,101 @@ static void luaGetValueAndPush(int src)
}
struct LuaField {
const char * name;
const uint8_t id;
const uint8_t attr;
uint16_t id;
char desc[50];
};
const LuaField luaFields[] = {
{ "altitude-max", MIXSRC_FIRST_TELEM+TELEM_MAX_ALT-1, 0 },
{ "altitude", MIXSRC_FIRST_TELEM+TELEM_ALT-1, PREC2 },
{ "vario", MIXSRC_FIRST_TELEM+TELEM_VSPEED-1, PREC2 },
{ "tx-voltage", MIXSRC_FIRST_TELEM+TELEM_TX_VOLTAGE-1, PREC1 },
{ "rpm", MIXSRC_FIRST_TELEM+TELEM_RPM-1, 0 },
{ NULL, 0, 0 },
};
#define FIND_FIELD_DESC 0x01
/**
Return field data for a given field name
*/
bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags=0)
{
// TODO better search method (binary lookup)
for (unsigned int n=0; n<DIM(luaSingleFields); ++n) {
if (!strcmp(name, luaSingleFields[n].name)) {
field.id = luaSingleFields[n].id;
if (flags & FIND_FIELD_DESC) {
strncpy(field.desc, luaSingleFields[n].desc, sizeof(field.desc)-1);
field.desc[sizeof(field.desc)-1] = '\0';
}
else {
field.desc[0] = '\0';
}
return true;
}
}
// search in multiples
unsigned int len = strlen(name);
for (unsigned int n=0; n<DIM(luaMultipleFields); ++n) {
const char * fieldName = luaMultipleFields[n].name;
unsigned int fieldLen = strlen(fieldName);
if (!strncmp(name, fieldName, fieldLen)) {
unsigned int index;
if (len == fieldLen+1 && isdigit(name[fieldLen])) {
index = name[fieldLen] - '1';
}
else if (len == fieldLen+2 && isdigit(name[fieldLen]) && isdigit(name[fieldLen+1])) {
index = 10 * (name[fieldLen] - '0') + (name[fieldLen+1] - '1');
}
else {
continue;
}
if (index < luaMultipleFields[n].count) {
field.id = luaMultipleFields[n].id + index;
if (flags & FIND_FIELD_DESC) {
snprintf(field.desc, sizeof(field.desc)-1, luaMultipleFields[n].desc, index+1);
field.desc[sizeof(field.desc)-1] = '\0';
}
else {
field.desc[0] = '\0';
}
return true;
}
}
}
return false; // not found
}
// get a detailed info about particular field
static int luaGetFieldInfo(lua_State *L)
{
const char * what = luaL_checkstring(L, 1);
LuaField field;
bool found = luaFindFieldByName(what, field, FIND_FIELD_DESC);
if (found) {
lua_newtable(L);
lua_pushtableinteger(L, "id", field.id);
lua_pushtablestring(L, "name", what);
lua_pushtablestring(L, "desc", field.desc);
return 1;
}
return 0;
}
static int luaGetValue(lua_State *L)
{
int src = 0;
if (lua_isnumber(L, 1)) {
int src = luaL_checkinteger(L, 1);
luaGetValueAndPush(src);
return 1;
src = luaL_checkinteger(L, 1);
}
else {
const char *what = luaL_checkstring(L, 1);
for (const LuaField * field = &luaFields[0]; field->name; field++) {
if (!strcmp(what, field->name)) {
getvalue_t value = getValue(field->id);
if (field->attr == PREC1)
lua_pushnumber(L, double(value)/10);
else if (field->attr == PREC2)
lua_pushnumber(L, double(value)/100);
else
lua_pushnumber(L, value);
return 1;
}
}
if (frskyData.hub.gpsFix) {
if (!strcmp(what, "latitude")) {
lua_pushnumber(L, gpsToDouble(frskyData.hub.gpsLatitudeNS=='S', frskyData.hub.gpsLatitude_bp, frskyData.hub.gpsLatitude_ap));
return 1;
}
else if (!strcmp(what, "longitude")) {
lua_pushnumber(L, gpsToDouble(frskyData.hub.gpsLongitudeEW=='W', frskyData.hub.gpsLongitude_bp, frskyData.hub.gpsLongitude_ap));
return 1;
}
else if (!strcmp(what, "pilot-latitude")) {
lua_pushnumber(L, pilotLatitude);
return 1;
}
else if (!strcmp(what, "pilot-longitude")) {
lua_pushnumber(L, pilotLongitude);
return 1;
}
// convert from field name to its id
const char *name = luaL_checkstring(L, 1);
LuaField field;
bool found = luaFindFieldByName(name, field);
if (found) {
src = field.id;
}
}
return 0;
if (src >= EXTRA_FIRST ) {
// one of the extra fields
return luaGetExtraValue(src);
}
luaGetValueAndPush(src);
return 1;
}
static int luaPlayFile(lua_State *L)
@@ -313,12 +366,11 @@ static int luaLcdDrawChannel(lua_State *L)
channel = luaL_checkinteger(L, 3);
}
else {
const char *what = luaL_checkstring(L, 3);
for (const LuaField * field = &luaFields[0]; field->name; field++) {
if (!strcmp(what, field->name)) {
channel = field->id;
break;
}
const char * what = luaL_checkstring(L, 3);
LuaField field;
bool found = luaFindFieldByName(what, field);
if (found) {
channel = field.id;
}
}
int att = luaL_checkinteger(L, 4);
@@ -854,7 +906,7 @@ static int luaModelGetCustomFunction(lua_State *L)
lua_pushtableinteger(L, "switch", CFN_SWITCH(cfn));
lua_pushtableinteger(L, "func", CFN_FUNC(cfn));
if (CFN_FUNC(cfn) == FUNC_PLAY_TRACK || CFN_FUNC(cfn) == FUNC_BACKGND_MUSIC || CFN_FUNC(cfn) == FUNC_PLAY_SCRIPT) {
lua_pushtablestring(L, "name", cfn->play.name);
lua_pushtablenzstring(L, "name", cfn->play.name);
}
else {
lua_pushtableinteger(L, "value", cfn->all.val);
@@ -999,6 +1051,120 @@ static int luaModelSetGlobalVariable(lua_State *L)
return 0;
}
static int luaModelGetTelemetryChannel(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
if (idx < MAX_FRSKY_A_CHANNELS) {
FrSkyChannelData & channel = g_model.frsky.channels[idx];
lua_newtable(L);
double range = applyChannelRatio(idx, 255-channel.offset);
double offset = applyChannelRatio(idx, 0);
double alarm1 = applyChannelRatio(idx, channel.alarms_value[0]);
double alarm2 = applyChannelRatio(idx, channel.alarms_value[1]);
if (ANA_CHANNEL_UNIT(idx) >= UNIT_RAW) {
range /= 10;
offset /= 10;
alarm1 /= 10;
alarm2 /= 10;
}
else {
range /= 100;
offset /= 100;
alarm1 /= 100;
alarm2 /= 100;
}
lua_pushtablenumber(L, "range", range);
lua_pushtablenumber(L, "offset", offset);
lua_pushtablenumber(L, "alarm1", alarm1);
lua_pushtablenumber(L, "alarm2", alarm2);
lua_pushtableinteger(L, "unit", channel.type);
}
else {
lua_pushnil(L);
}
return 1;
}
int findmult(float value, float base)
{
int vvalue = value*10;
int vbase = base*10;
vvalue--;
int mult = 0;
for (int i=8; i>=0; i--) {
if (vvalue/vbase >= (1<<i)) {
mult = i+1;
break;
}
}
return mult;
}
static int luaModelSetTelemetryChannel(lua_State *L)
{
int idx = luaL_checkunsigned(L, 1);
if (idx < MAX_FRSKY_A_CHANNELS) {
FrSkyChannelData & channel = g_model.frsky.channels[idx];
double range = applyChannelRatio(idx, 255-channel.offset);
double offset = applyChannelRatio(idx, 0);
double alarm1 = applyChannelRatio(idx, channel.alarms_value[0]);
double alarm2 = applyChannelRatio(idx, channel.alarms_value[1]);
if (ANA_CHANNEL_UNIT(idx) >= UNIT_RAW) {
range /= 10;
offset /= 10;
alarm1 /= 10;
alarm2 /= 10;
}
else {
range /= 100;
offset /= 100;
alarm1 /= 100;
alarm2 /= 100;
}
luaL_checktype(L, -1, LUA_TTABLE);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
luaL_checktype(L, -2, LUA_TSTRING); // key is string
const char * key = luaL_checkstring(L, -2);
if (!strcmp(key, "unit")) {
channel.type = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "range")) {
range = luaL_checknumber(L, -1);
double value = range;
if (ANA_CHANNEL_UNIT(idx) < UNIT_RAW) {
value *= 10;
}
channel.multiplier = findmult(value, 255);
channel.ratio = (int)(round(value)) / (1<<channel.multiplier);
}
else if (!strcmp(key, "offset")) {
offset = luaL_checknumber(L, -1);
}
else if (!strcmp(key, "alarm1")) {
alarm1 = luaL_checknumber(L, -1);
}
else if (!strcmp(key, "alarm2")) {
alarm2 = luaL_checknumber(L, -1);
}
}
if (range > 0) {
channel.offset = round((offset * 255) / range);
channel.alarms_value[0] = limit<int>(0, round((alarm1-offset)*255/range), 255);
channel.alarms_value[1] = limit<int>(0, round((alarm2-offset)*255/range), 255);
}
else {
channel.offset = 0;;
channel.alarms_value[0] = 0;
channel.alarms_value[1] = 0;
}
eeDirty(EE_MODEL);
}
return 0;
}
static int luaPopupInput(lua_State *L)
{
uint8_t event = luaL_checkinteger(L, 2);
@@ -1138,6 +1304,8 @@ static const luaL_Reg modelLib[] = {
{ "setOutput", luaModelSetOutput },
{ "getGlobalVariable", luaModelGetGlobalVariable },
{ "setGlobalVariable", luaModelSetGlobalVariable },
{ "getTelemetryChannel", luaModelGetTelemetryChannel },
{ "setTelemetryChannel", luaModelSetTelemetryChannel },
{ NULL, NULL } /* sentinel */
};
@@ -1182,6 +1350,8 @@ void luaInit()
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);
+1 -1
View File
@@ -245,7 +245,7 @@ int16_t applyLimits(uint8_t channel, int32_t value)
if (lim->revert) ofs = -ofs; // finally do the reverse.
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
if (safetyCh[channel] != -128) // if safety channel available for channel check
ofs = calc100toRESX(safetyCh[channel]);
#endif
+125 -92
View File
@@ -39,6 +39,18 @@
#include <inttypes.h>
#if defined(EXPORT)
#define LUA_EXPORT(...) LEXP(__VA_ARGS__)
#define LUA_EXPORT_TELEMETRY(...) LEXP_TELEMETRY(__VA_ARGS__)
#define LUA_EXPORT_MULTIPLE(...) LEXP_MULTIPLE(__VA_ARGS__)
#define LUA_EXPORT_EXTRA(...) LEXP_EXTRA(__VA_ARGS__)
#else
#define LUA_EXPORT(...)
#define LUA_EXPORT_TELEMETRY(...)
#define LUA_EXPORT_MULTIPLE(...)
#define LUA_EXPORT_EXTRA(...)
#endif
#define WARN_THR_BIT 0x01
#define WARN_BEP_BIT 0x80
#define WARN_SW_BIT 0x02
@@ -795,7 +807,7 @@ PACK(typedef struct t_LogicalSwitchData { // Logical Switches data
enum Functions {
// first the functions which need a checkbox
FUNC_SAFETY_CHANNEL,
FUNC_OVERRIDE_CHANNEL,
FUNC_TRAINER,
FUNC_INSTANT_TRIM,
FUNC_RESET,
@@ -837,10 +849,10 @@ enum Functions {
FUNC_MAX
};
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define HAS_ENABLE_PARAM(func) ((func) < FUNC_FIRST_WITHOUT_ENABLE)
#else
#define HAS_ENABLE_PARAM(func) ((func) < FUNC_FIRST_WITHOUT_ENABLE && (func) != FUNC_SAFETY_CHANNEL)
#define HAS_ENABLE_PARAM(func) ((func) < FUNC_FIRST_WITHOUT_ENABLE && (func) != FUNC_OVERRIDE_CHANNEL)
#endif
#if defined(VOICE)
@@ -1023,56 +1035,56 @@ PACK(typedef struct {
enum TelemetrySource {
TELEM_NONE,
TELEM_TX_VOLTAGE,
TELEM_TX_VOLTAGE, LUA_EXPORT_TELEMETRY("tx-voltage", "Transmitter battery voltage [volts]")
#if defined(CPUARM)
TELEM_TX_TIME,
TELEM_TX_TIME, LUA_EXPORT_TELEMETRY("clock", "RTC clock [minutes from midnight]")
TELEM_RESERVE1,
TELEM_RESERVE2,
TELEM_RESERVE3,
TELEM_RESERVE4,
TELEM_RESERVE5,
#endif
TELEM_TIMER1,
TELEM_TIMER2,
#if defined(CPUARM)
TELEM_SWR,
#endif
TELEM_RSSI_TX,
TELEM_RSSI_RX,
#if defined(CPUARM)
TELEM_RESERVE0,
#endif
TELEM_A_FIRST,
TELEM_A1=TELEM_A_FIRST,
TELEM_A2,
#if !defined(CPUARM)
TELEM_A_LAST=TELEM_A2,
#else
TELEM_A3,
TELEM_A4,
TELEM_A_LAST=TELEM_A4,
#endif
TELEM_ALT,
TELEM_RPM,
TELEM_FUEL,
TELEM_T1,
TELEM_T2,
TELEM_SPEED,
TELEM_DIST,
TELEM_GPSALT,
TELEM_CELL,
TELEM_CELLS_SUM,
TELEM_VFAS,
TELEM_CURRENT,
TELEM_CONSUMPTION,
TELEM_POWER,
TELEM_ACCx,
TELEM_ACCy,
TELEM_ACCz,
TELEM_HDG,
TELEM_VSPEED,
TELEM_ASPEED,
TELEM_DTE,
TELEM_TIMER1, LUA_EXPORT_TELEMETRY("timer1", "Timer 1 value [seconds]")
TELEM_TIMER2, LUA_EXPORT_TELEMETRY("timer2", "Timer 2 value [seconds]")
#if defined(CPUARM)
TELEM_SWR, LUA_EXPORT_TELEMETRY("swr", "Transmitter antenna quality [less is better]")
#endif
TELEM_RSSI_TX,
TELEM_RSSI_RX, LUA_EXPORT_TELEMETRY("rssi", "RSSI [more is better]")
#if defined(CPUARM)
TELEM_RESERVE0,
#endif
TELEM_A_FIRST,
TELEM_A1=TELEM_A_FIRST, LUA_EXPORT_TELEMETRY("a1", "A1 analogue value [units as configured]")
TELEM_A2, LUA_EXPORT_TELEMETRY("a2", "A2 analogue value [units as configured]")
#if !defined(CPUARM)
TELEM_A_LAST=TELEM_A2,
#else
TELEM_A3, LUA_EXPORT_TELEMETRY("a3", "A3 analogue value [units as configured]")
TELEM_A4, LUA_EXPORT_TELEMETRY("a4", "A4 analogue value [units as configured]")
TELEM_A_LAST=TELEM_A4,
#endif
TELEM_ALT, LUA_EXPORT_TELEMETRY("altitude", "Variometer altitude [meters]")
TELEM_RPM, LUA_EXPORT_TELEMETRY("rpm", "Rotational speed [revolutions per minute]")
TELEM_FUEL, LUA_EXPORT_TELEMETRY("fuel", "Fuel level [percent]")
TELEM_T1, LUA_EXPORT_TELEMETRY("temp1", "Temperature 1 [degrees celsius]")
TELEM_T2, LUA_EXPORT_TELEMETRY("temp2", "Temperature 2 [degrees celsius]")
TELEM_SPEED, LUA_EXPORT_TELEMETRY("gps-speed", "GPS speed [knots]")
TELEM_DIST, LUA_EXPORT_TELEMETRY("distance", "GPS distance [meters]")
TELEM_GPSALT, LUA_EXPORT_TELEMETRY("gps-altitude", "GPS altitude [meters]")
TELEM_CELL, LUA_EXPORT_TELEMETRY("cell-min", "LiPo sensor - lowest current cell voltage [volts]")
TELEM_CELLS_SUM, LUA_EXPORT_TELEMETRY("cell-sum", "LiPo sensor - current summ of all cell voltages [volts]")
TELEM_VFAS, LUA_EXPORT_TELEMETRY("vfas", "Current sensor - voltage [volts]")
TELEM_CURRENT, LUA_EXPORT_TELEMETRY("current", "Current sensor - current [ampers]")
TELEM_CONSUMPTION, LUA_EXPORT_TELEMETRY("consumption", "Current sensor - consumption [mili amper hours]")
TELEM_POWER, LUA_EXPORT_TELEMETRY("power", "Current sensor - power [wats]")
TELEM_ACCx, LUA_EXPORT_TELEMETRY("accx", "G sensor - acceleration in X axis [g]")
TELEM_ACCy, LUA_EXPORT_TELEMETRY("accy", "G sensor - acceleration in Y axis [g]")
TELEM_ACCz, LUA_EXPORT_TELEMETRY("accz", "G sensor - acceleration in Z axis [g]")
TELEM_HDG, LUA_EXPORT_TELEMETRY("heading", "GPS heading [degrees]")
TELEM_VSPEED, LUA_EXPORT_TELEMETRY("vertical-speed", "Variometer vertical speed [m/s]")
TELEM_ASPEED, LUA_EXPORT_TELEMETRY("air-speed", "Air speed [knots]")
TELEM_DTE, LUA_EXPORT_TELEMETRY("dte", "Total energy [???]")
#if defined(CPUARM)
TELEM_RESERVE6,
TELEM_RESERVE7,
@@ -1081,28 +1093,29 @@ enum TelemetrySource {
TELEM_RESERVE10,
#endif
TELEM_MIN_A_FIRST,
TELEM_MIN_A1=TELEM_MIN_A_FIRST,
TELEM_MIN_A2,
TELEM_MIN_A1=TELEM_MIN_A_FIRST, LUA_EXPORT_TELEMETRY("a1-min", "A1 analogue value minimum [units as configured]")
TELEM_MIN_A2, LUA_EXPORT_TELEMETRY("a2-min", "A2 analogue value minimum [units as configured]")
#if !defined(CPUARM)
TELEM_MIN_A_LAST=TELEM_MIN_A2,
#else
TELEM_MIN_A3,
TELEM_MIN_A4,
TELEM_MIN_A3, LUA_EXPORT_TELEMETRY("a3-min", "A3 analogue value minimum [units as configured]")
TELEM_MIN_A4, LUA_EXPORT_TELEMETRY("a4-min", "A4 analogue value minimum [units as configured]")
TELEM_MIN_A_LAST=TELEM_MIN_A4,
#endif
TELEM_MIN_ALT,
TELEM_MAX_ALT,
TELEM_MAX_RPM,
TELEM_MAX_T1,
TELEM_MAX_T2,
TELEM_MAX_SPEED,
TELEM_MAX_DIST,
TELEM_MAX_ASPEED,
TELEM_MIN_CELL,
TELEM_MIN_CELLS_SUM,
TELEM_MIN_VFAS,
TELEM_MAX_CURRENT,
TELEM_MAX_POWER,
// TODO: add A1-4 MAX
TELEM_MIN_ALT, LUA_EXPORT_TELEMETRY("altitude-min", "Lowest altitude [meters]")
TELEM_MAX_ALT, LUA_EXPORT_TELEMETRY("altitude-max", "Highest altitude [meters]")
TELEM_MAX_RPM, LUA_EXPORT_TELEMETRY("rpm-max", "Highest rotational speed [revolutions per minute] [meters]")
TELEM_MAX_T1, LUA_EXPORT_TELEMETRY("temp1-max", "Highest temperature 1 [degrees celsius]")
TELEM_MAX_T2, LUA_EXPORT_TELEMETRY("temp2-max", "Highest temperature 2 [degrees celsius]")
TELEM_MAX_SPEED, LUA_EXPORT_TELEMETRY("gps-speed-max", "Highest GPS speed [knots]")
TELEM_MAX_DIST, LUA_EXPORT_TELEMETRY("distance-max", "Biggest GPS distance [meters]")
TELEM_MAX_ASPEED, LUA_EXPORT_TELEMETRY("air-speed-max", "Highest air speed [knots]")
TELEM_MIN_CELL, LUA_EXPORT_TELEMETRY("cell-min-min", "LiPo sensor - all time lowest cell voltage [volts]")
TELEM_MIN_CELLS_SUM, LUA_EXPORT_TELEMETRY("cell-sum-min", "LiPo sensor - all time lowest summ of all cell voltages [volts]")
TELEM_MIN_VFAS, LUA_EXPORT_TELEMETRY("vfas-min", "Current sensor - lowest voltage [volts]")
TELEM_MAX_CURRENT, LUA_EXPORT_TELEMETRY("current-max", "Current sensor - highest current [ampers]")
TELEM_MAX_POWER, LUA_EXPORT_TELEMETRY("power-max", "Current sensor - highest power [wats]")
#if defined(CPUARM)
TELEM_RESERVE11,
TELEM_RESERVE12,
@@ -1446,25 +1459,25 @@ enum MixSources {
MIXSRC_NONE,
#if defined(PCBTARANIS)
MIXSRC_FIRST_INPUT,
MIXSRC_FIRST_INPUT, LUA_EXPORT_MULTIPLE("input", "Input [I%d]", MAX_INPUTS)
MIXSRC_LAST_INPUT = MIXSRC_FIRST_INPUT+MAX_INPUTS-1,
MIXSRC_FIRST_LUA,
MIXSRC_LAST_LUA = MIXSRC_FIRST_LUA+(MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS)-1,
#endif
MIXSRC_Rud,
MIXSRC_Ele,
MIXSRC_Thr,
MIXSRC_Ail,
MIXSRC_Rud, LUA_EXPORT("rud", "Rudder")
MIXSRC_Ele, LUA_EXPORT("ele", "Elevator")
MIXSRC_Thr, LUA_EXPORT("thr", "Throttle")
MIXSRC_Ail, LUA_EXPORT("ail", "Aileron")
MIXSRC_FIRST_POT,
#if defined(PCBTARANIS)
MIXSRC_POT1 = MIXSRC_FIRST_POT,
MIXSRC_POT2,
MIXSRC_POT3,
MIXSRC_SLIDER1,
MIXSRC_SLIDER2,
MIXSRC_POT1 = MIXSRC_FIRST_POT, LUA_EXPORT("s1", "Potentiometer 1")
MIXSRC_POT2, LUA_EXPORT("s2", "Potentiometer 2")
MIXSRC_POT3, LUA_EXPORT("s3", "Potentiometer 3")
MIXSRC_SLIDER1, LUA_EXPORT("ls", "Left slider")
MIXSRC_SLIDER2, LUA_EXPORT("rs", "Right slider")
MIXSRC_LAST_POT = MIXSRC_SLIDER2,
#else
MIXSRC_P1 = MIXSRC_FIRST_POT,
@@ -1494,26 +1507,26 @@ enum MixSources {
MIXSRC_MAX,
MIXSRC_CYC1,
MIXSRC_CYC2,
MIXSRC_CYC3,
MIXSRC_CYC1, LUA_EXPORT("cyc1", "Cyclic 1")
MIXSRC_CYC2, LUA_EXPORT("cyc2", "Cyclic 2")
MIXSRC_CYC3, LUA_EXPORT("cyc3", "Cyclic 3")
MIXSRC_TrimRud,
MIXSRC_TrimEle,
MIXSRC_TrimThr,
MIXSRC_TrimAil,
MIXSRC_TrimRud, LUA_EXPORT("trim-rud", "Rudder trim")
MIXSRC_TrimEle, LUA_EXPORT("trim-ele", "Elevator trim")
MIXSRC_TrimThr, LUA_EXPORT("trim-thr", "Throttle trim")
MIXSRC_TrimAil, LUA_EXPORT("trim-ail", "Aileron trim")
MIXSRC_FIRST_SWITCH,
#if defined(PCBTARANIS)
MIXSRC_SA = MIXSRC_FIRST_SWITCH,
MIXSRC_SB,
MIXSRC_SC,
MIXSRC_SD,
MIXSRC_SE,
MIXSRC_SF,
MIXSRC_SG,
MIXSRC_SH,
MIXSRC_SA = MIXSRC_FIRST_SWITCH, LUA_EXPORT("sa", "Switch A")
MIXSRC_SB, LUA_EXPORT("sb", "Switch B")
MIXSRC_SC, LUA_EXPORT("sc", "Switch C")
MIXSRC_SD, LUA_EXPORT("sd", "Switch D")
MIXSRC_SE, LUA_EXPORT("se", "Switch E")
MIXSRC_SF, LUA_EXPORT("sf", "Switch F")
MIXSRC_SG, LUA_EXPORT("sg", "Switch G")
MIXSRC_SH, LUA_EXPORT("sh", "Switch H")
#else
MIXSRC_3POS = MIXSRC_FIRST_SWITCH,
#if defined(EXTRA_3POS)
@@ -1527,18 +1540,18 @@ enum MixSources {
MIXSRC_TRN,
#endif
MIXSRC_FIRST_LOGICAL_SWITCH,
MIXSRC_SW1 = MIXSRC_FIRST_LOGICAL_SWITCH,
MIXSRC_SW1 = MIXSRC_FIRST_LOGICAL_SWITCH, LUA_EXPORT_MULTIPLE("ls", "Logical switch L%d", NUM_LOGICAL_SWITCH)
MIXSRC_SW9 = MIXSRC_SW1 + 8,
MIXSRC_SWA,
MIXSRC_SWB,
MIXSRC_SWC,
MIXSRC_LAST_LOGICAL_SWITCH = MIXSRC_FIRST_LOGICAL_SWITCH+NUM_LOGICAL_SWITCH-1,
MIXSRC_FIRST_TRAINER,
MIXSRC_FIRST_TRAINER, LUA_EXPORT_MULTIPLE("trn", "Trainer input %d", NUM_TRAINER)
MIXSRC_LAST_TRAINER = MIXSRC_FIRST_TRAINER+NUM_TRAINER-1,
MIXSRC_FIRST_CH,
MIXSRC_CH1 = MIXSRC_FIRST_CH,
MIXSRC_CH1 = MIXSRC_FIRST_CH, LUA_EXPORT_MULTIPLE("ch", "Channel CH%d", NUM_CHNOUT)
MIXSRC_CH2,
MIXSRC_CH3,
MIXSRC_CH4,
@@ -1556,13 +1569,33 @@ enum MixSources {
MIXSRC_CH16,
MIXSRC_LAST_CH = MIXSRC_CH1+NUM_CHNOUT-1,
MIXSRC_GVAR1,
MIXSRC_GVAR1, LUA_EXPORT_MULTIPLE("gvar", "Global variable %d", MAX_GVARS)
MIXSRC_LAST_GVAR = MIXSRC_GVAR1+MAX_GVARS-1,
MIXSRC_FIRST_TELEM,
MIXSRC_LAST_TELEM = MIXSRC_FIRST_TELEM+NUM_TELEMETRY-1
};
#if defined(LUA)
#define EXTRA_FIRST 1000
enum LuaExtraFields {
EXTRA_LATITUDE = EXTRA_FIRST, LUA_EXPORT_EXTRA("latitude", "GPS latitude [degrees, North is positive]", \
"gpsToDouble(frskyData.hub.gpsLatitudeNS=='S', frskyData.hub.gpsLatitude_bp, frskyData.hub.gpsLatitude_ap)", \
"frskyData.hub.gpsFix")
EXTRA_LONGITUDE, LUA_EXPORT_EXTRA("longitude", "GPS longitude [degrees, East is positive]", \
"gpsToDouble(frskyData.hub.gpsLongitudeEW=='W', frskyData.hub.gpsLongitude_bp, frskyData.hub.gpsLongitude_ap)", \
"frskyData.hub.gpsFix")
EXTRA_PILOT_LATITUDE, LUA_EXPORT_EXTRA("pilot-latitude", "Latitude of frist GPS position [degrees, North is positive]", \
"pilotLatitude", "frskyData.hub.gpsFix")
EXTRA_PILOT_LONGITUDE, LUA_EXPORT_EXTRA("pilot-longitude", "Longitude of frist GPS position [degrees, East is positive]", \
"pilotLongitude", "frskyData.hub.gpsFix")
EXTRA_GPS_CLOCK, LUA_EXPORT_EXTRA("gps-clock", "GPS clock [seconds from midnight]", \
"(int)(frskyData.hub.hour)*3600 + frskyData.hub.min*60 + frskyData.hub.sec", "frskyData.hub.gpsFix")
EXTRA_FLIGHT_MODE LUA_EXPORT_EXTRA("flight-mode", "Current flight mode number [number]", \
"getFlightMode()", "true")
};
#endif // #if defined(LUA)
#define MIXSRC_FIRST (MIXSRC_NONE+1)
#define MIXSRC_LAST MIXSRC_LAST_CH
#define INPUTSRC_FIRST MIXSRC_Rud
+4 -6
View File
@@ -147,7 +147,7 @@ uint8_t heartbeat;
uint8_t stickMode;
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
int8_t safetyCh[NUM_CHNOUT];
#endif
@@ -1405,8 +1405,6 @@ uint16_t BandGap ;
uint16_t anaIn(uint8_t chan)
{
#if defined(PCBTARANIS)
// crossAna[]={LH,LV,RH,RV,S1,S2,LS,RS,BAT
// s_anaFilt[]={LH,LV,RH,RV,S1,S2,LS,RS,_BAT
return s_anaFilt[chan];
#elif defined(PCBSKY9X) && !defined(REVA)
static const uint8_t crossAna[]={1,5,7,0,4,6,2,3};
@@ -1867,7 +1865,7 @@ void evalFunctions()
static rotenc_t rePreviousValues[ROTARY_ENCODERS];
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
for (uint8_t i=0; i<NUM_CHNOUT; i++) {
safetyCh[i] = -128; // not defined
}
@@ -1900,8 +1898,8 @@ void evalFunctions()
switch (CFN_FUNC(sd)) {
#if defined(SAFETY_CHANNEL_FUNCTION)
case FUNC_SAFETY_CHANNEL:
#if defined(OVERRIDE_CHANNEL_FUNCTION)
case FUNC_OVERRIDE_CHANNEL:
safetyCh[CFN_CH_INDEX(sd)] = CFN_PARAM(sd);
break;
#endif
+10 -7
View File
@@ -348,17 +348,20 @@ extern void boardInit();
enum PotType {
POT_TYPE_NONE,
POT_TYPE_POT,
POT_TYPE_DETENT,
POT_TYPE_MULTIPOS,
POT_TYPE_MAX=POT_TYPE_MULTIPOS
POT_TYPE_NO_DETENT,
POT_TYPE_MAX=POT_TYPE_NO_DETENT
};
#if defined(PCBTARANIS)
#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_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)
#else
#define IS_POT_AVAILABLE(x) (true)
#define IS_POT_MULTIPOS(x) (false)
#define IS_POT_AVAILABLE(x) (true)
#define IS_POT_MULTIPOS(x) (false)
#define IS_POT_WITHOUT_DETENT(x) (true)
#endif
#define GET_LOWRES_POT_POSITION(i) (getValue(MIXSRC_FIRST_POT+(i)) >> 4)
@@ -843,7 +846,7 @@ struct TimerState {
extern TimerState timersStates[MAX_TIMERS];
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
extern int8_t safetyCh[NUM_CHNOUT];
#endif
+20 -2
View File
@@ -171,6 +171,24 @@ void getSwitchesPosition(bool startup)
}
#define SWITCH_POSITION(sw) (switchesPos & (1<<(sw)))
#define POT_POSITION(sw) ((potsPos[(sw)/XPOTS_MULTIPOS_COUNT] & 0x0f) == ((sw) % XPOTS_MULTIPOS_COUNT))
getvalue_t getValueForLogicalSwitch(uint8_t i)
{
getvalue_t result = getValue(i);
if (i>=MIXSRC_FIRST_INPUT && i<=MIXSRC_LAST_INPUT) {
int8_t trimIdx = virtualInputsTrims[i-MIXSRC_FIRST_INPUT];
if (trimIdx >= 0) {
int16_t trim = trims[trimIdx];
if (trimIdx == THR_STICK && g_model.throttleReversed)
result -= trim;
else
result += trim;
}
}
return result;
}
#else
#define getValueForLogicalSwitch(i) getValue(i)
#endif
bool getLogicalSwitch(uint8_t idx)
@@ -219,10 +237,10 @@ bool getLogicalSwitch(uint8_t idx)
}
#endif
else {
getvalue_t x = getValue(ls->v1);
getvalue_t x = getValueForLogicalSwitch(ls->v1);
getvalue_t y;
if (s == LS_FAMILY_COMP) {
y = getValue(ls->v2);
y = getValueForLogicalSwitch(ls->v2);
switch (ls->func) {
case LS_FUNC_EQUAL:
+24 -24
View File
@@ -51,9 +51,10 @@
#else
#define POT_R 8
#endif
#define SLIDE_L 14
#define SLIDE_R 15
#define BATTERY 10
#define POT_XTRA 9
#define SLIDE_L 14
#define SLIDE_R 15
#define BATTERY 10
// Sample time should exceed 1uS
#define SAMPTIME 2 // sample time = 15 cycles
@@ -61,40 +62,40 @@
volatile uint16_t Analog_values[NUMBER_ANALOG];
#if defined(REV4a)
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,0,-1,1, 1};
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,-1,1,-1,1, 1};
#elif !defined(REV3)
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,0,-1,1, 1};
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,1,-1,1, 1};
#endif
void adcInit()
{
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN ; // Enable clock
RCC->AHB1ENR |= RCC_AHB1Periph_GPIOADC ; // Enable ports A&C clocks
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; // Enable clock
RCC->AHB1ENR |= RCC_AHB1Periph_GPIOADC; // Enable ports A&C clocks
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; // Enable DMA2 clock
#if defined(REV3)
configure_pins(PIN_STK_J1 | PIN_STK_J2 | PIN_STK_J3 | PIN_STK_J4 |
PIN_FLP_J1 | PIN_FLP_J2, PIN_ANALOG | PIN_PORTA) ;
PIN_FLP_J1 | PIN_FLP_J2, PIN_ANALOG | PIN_PORTA);
#else
configure_pins(PIN_STK_J1 | PIN_STK_J2 | PIN_STK_J3 | PIN_STK_J4 |
PIN_FLP_J1, PIN_ANALOG | PIN_PORTA) ;
PIN_FLP_J1, PIN_ANALOG | PIN_PORTA);
#endif
#if !defined(REV3)
#if defined(REVPLUS)
configure_pins(PIN_FLP_J2 | PIN_FLP_J3, PIN_ANALOG|PIN_PORTB);
#elif !defined(REV3)
configure_pins(PIN_FLP_J2, PIN_ANALOG|PIN_PORTB);
#endif
configure_pins(PIN_SLD_J1 | PIN_SLD_J2 | PIN_MVOLT, PIN_ANALOG | PIN_PORTC) ;
configure_pins(PIN_SLD_J1 | PIN_SLD_J2 | PIN_MVOLT, PIN_ANALOG | PIN_PORTC);
ADC1->CR1 = ADC_CR1_SCAN ;
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS ;
ADC1->SQR1 = (NUMBER_ANALOG-1) << 20 ; // NUMBER_ANALOG Channels
ADC1->SQR2 = (SLIDE_L<<5) + (SLIDE_R<<10) + (BATTERY<<15) ;
ADC1->SQR3 = STICK_LH + (STICK_LV<<5) + (STICK_RV<<10) + (STICK_RH<<15) + (POT_L<<20) + (POT_R<<25) ;
ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) ;
ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27) ;
ADC1->CR1 = ADC_CR1_SCAN;
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
ADC1->SQR1 = (NUMBER_ANALOG-1) << 20 ; // bits 23:20 = number of conversions
ADC1->SQR2 = (POT_XTRA<<0) + (SLIDE_L<<5) + (SLIDE_R<<10) + (BATTERY<<15); // conversions 7 and more
ADC1->SQR3 = (STICK_LH<<0) + (STICK_LV<<5) + (STICK_RV<<10) + (STICK_RH<<15) + (POT_L<<20) + (POT_R<<25); // conversions 1 to 6
ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24);
ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27) ;
ADC->CCR = 0 ; //ADC_CCR_ADCPRE_0 ; // Clock div 2
@@ -125,10 +126,9 @@ void adcRead()
#if !defined(REV3)
// adc direction correct
for (i=0; i<NUMBER_ANALOG; i++) {
if (ana_direction[i] == -1)
if (ana_direction[i] < 0) {
Analog_values[i] = 4096-Analog_values[i];
else if (ana_direction[i] == 0)
Analog_values[i] = 0;
}
}
#endif
}
+1 -4
View File
@@ -34,10 +34,7 @@
*
*/
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <QtCore/QString>
#include <math.h>
#include <gtest/gtest.h>
+11 -4
View File
@@ -34,16 +34,22 @@
*
*/
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <math.h>
#include <gtest/gtest.h>
#define SWAP_DEFINED
#include "opentx.h"
static char _zchar2stringResult[200];
const char * zchar2string(const char * zstring, int size)
{
if (size > (int)sizeof(_zchar2stringResult) ) {
return 0;
}
zchar2str(_zchar2stringResult, zstring, size);
return _zchar2stringResult;
}
#if !defined(PCBSKY9X)
TEST(EEPROM, 100_random_writes)
{
@@ -177,6 +183,7 @@ int main(int argc, char **argv)
StartEepromThread(NULL);
g_menuStackPtr = 0;
g_menuStack[0] = menuMainView;
LUA_RESET();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
+10
View File
@@ -192,6 +192,16 @@ TEST(Lcd, vline)
EXPECT_TRUE(checkScreenshot("vline"));
}
#if defined(CPUARM)
TEST(Lcd, vline_x_lt0)
{
lcd_clear();
lcd_vline(50, -10, 12);
lcd_vline(100, -10, 1);
EXPECT_TRUE(checkScreenshot("vline_lt0"));
}
#endif
#if defined(CPUARM)
TEST(Lcd, Smlsize)
{
+101
View File
@@ -0,0 +1,101 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* opentx is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <math.h>
#include <gtest/gtest.h>
#if defined(LUA)
#define SWAP_DEFINED
#include "opentx.h"
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
extern const char * zchar2string(const char * zstring, int size);
#define EXPECT_ZSTREQ(c_string, z_string) EXPECT_STREQ(c_string, zchar2string(z_string, sizeof(z_string)))
void luaExecStr(const char * str)
{
extern lua_State * L;
if (luaL_dostring(L, str)) {
FAIL() << "lua error: " << lua_tostring(L, -1);
}
}
TEST(Lua, testSetModelInfo)
{
luaExecStr("info = model.getInfo()");
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
luaExecStr("info.id = 2; info.name = 'modelA'");
luaExecStr("model.setInfo(info)");
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
EXPECT_EQ(g_model.header.modelId, 2);
EXPECT_ZSTREQ("modelA", g_model.header.name);
luaExecStr("info.id = 4; info.name = 'Model 1'");
luaExecStr("model.setInfo(info)");
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
EXPECT_EQ(g_model.header.modelId, 4);
EXPECT_ZSTREQ("Model 1", g_model.header.name);
}
TEST(Lua, testSetTelemetryChannel)
{
// set
luaExecStr("channel = model.getTelemetryChannel(0)");
luaExecStr("channel.range = 100.0");
luaExecStr("channel.offset = -10.0");
luaExecStr("channel.alarm1 = 60");
luaExecStr("channel.alarm2 = 50");
luaExecStr("model.setTelemetryChannel(0, channel)");
EXPECT_EQ(g_model.frsky.channels[0].multiplier, 2);
EXPECT_EQ(g_model.frsky.channels[0].ratio, 250);
EXPECT_EQ(g_model.frsky.channels[0].offset, -26);
EXPECT_EQ(g_model.frsky.channels[0].alarms_value[0], 179);
EXPECT_EQ(g_model.frsky.channels[0].alarms_value[1], 153);
//verify in Lua
luaExecStr("channel = model.getTelemetryChannel(0)");
luaExecStr("if math.abs(channel.range - 100) > 0.5 then error('channel.range is: '..channel.range) end");
luaExecStr("if math.abs(channel.offset + 10) > 0.5 then error('channel.offset is: '..channel.offset) end");
luaExecStr("if math.abs(channel.alarm1 - 60) > 0.5 then error('channel.alarm1 is: '..channel.alarm1) end");
luaExecStr("if math.abs(channel.alarm2 - 50) > 0.5 then error('channel.alarm2 is: '..channel.alarm2) end");
}
#endif
-4
View File
@@ -34,10 +34,6 @@
*
*/
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <math.h>
#include <gtest/gtest.h>
+22 -5
View File
@@ -34,10 +34,6 @@
*
*/
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QPainter>
#include <math.h>
#include <gtest/gtest.h>
@@ -61,6 +57,7 @@ TEST(getSwitch, undefCSW)
}
#endif
#if !defined(CPUARM)
TEST(getSwitch, circularCSW)
{
MODEL_RESET();
@@ -74,6 +71,7 @@ TEST(getSwitch, circularCSW)
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
EXPECT_EQ(getSwitch(-SWSRC_SW2), true);
}
#endif
#if defined(PCBTARANIS)
TEST(getSwitch, OldTypeStickyCSW)
@@ -113,7 +111,6 @@ TEST(getSwitch, nullSW)
EXPECT_EQ(getSwitch(0), true);
}
#if defined(PCBTARANIS) && defined(FRSKY)
TEST(getSwitch, VfasWithDelay)
{
@@ -344,3 +341,23 @@ TEST(getSwitch, recursiveSW)
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
}
#endif // #if !defined(CPUARM)
#if defined(PCBTARANIS)
TEST(getSwitch, inputWithTrim)
{
MODEL_RESET();
modelDefault(0);
MIXER_RESET();
g_model.logicalSw[0] = { MIXSRC_FIRST_INPUT, 0, 0, LS_FUNC_VPOS };
doMixerCalculations();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
setTrimValue(0, 0, 32);
doMixerCalculations();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
}
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "VYP\0 ""S-Port Mirror\0 ""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "Není\0 ""Potenciometr\0 ""Vícepol. přep.\0"
#define TR_POTTYPES "Není\0 ""Pot with detent""Vícepol. přep.\0""Potenciometr\0"
#define LEN_DATETIME "\006"
#define TR_DATETIME "DATUM:""ČAS: "
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Zámek \0 "
#else
#define TR_CFN_SAFETY "---\0 "
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "AUS\0 ""S-Port Data Out\0""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "Kein\0 ""Poti\0 ""Stufen-Schalter "
#define TR_POTTYPES "Kein\0 ""Pot with detent""Stufen-Schalter ""Poti\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATE:""ZEIT:"
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Sicher\0 "
#else
#define TR_CFN_SAFETY "---\0 "
+4 -4
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "OFF\0 ""S-Port Mirror\0 ""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "None\0 ""Pot\0 ""Multipos Switch"
#define TR_POTTYPES "None\0 ""Pot with detent""Multipos Switch""Pot\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATE:""TIME:"
@@ -264,10 +264,10 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION) && LCD_W >= 212
#if defined(OVERRIDE_CHANNEL_FUNCTION) && LCD_W >= 212
#define TR_CFN_SAFETY "Override\0 "
#elif defined(SAFETY_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Safety\0 "
#elif defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Overr.\0 "
#else
#define TR_CFN_SAFETY "---\0 "
#endif
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "OFF\0 ""S-Port Mirror\0 ""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "None\0 ""Pot\0 ""Multipos Switch"
#define TR_POTTYPES "None\0 ""Pot with detent""Multipos Switch""Pot\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATA:""HORA:"
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Seguro\0 "
#else
#define TR_CFN_SAFETY "---\0 "
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "POIS\0 ""S-Port Pelik\0 ""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "None\0 ""Potikka\0 ""Monias. Kytkin\0"
#define TR_POTTYPES "None\0 ""Pot with detent""Monias. Kytkin\0""Potikka\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "PÄIV:""AIKA:"
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Safety\0 "
#else
#define TR_CFN_SAFETY "---\0 "
+3 -3
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "OFF\0 ""Recopie S-Port\0""Telemetrie\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "Rien\0 ""Potentiomètre\0 ""Inter multi-pos"
#define TR_POTTYPES "Rien\0 ""Pot avec centre""Inter multi-pos""Potentiomètre\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATE:""HEURE"
@@ -264,8 +264,8 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Sécur.\0 "
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Rempl.\0 "
#else
#define TR_CFN_SAFETY "---\0 "
#endif
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "OFF\0 ""Replica Porta-S""Telemetria\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "None\0 ""Potenziometro\0 ""Inter. Multipos"
#define TR_POTTYPES "None\0 ""Pot with detent""Inter. Multipos""Potenziometro\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATA:""ORA :"
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Blocco\0 "
#else
#define TR_CFN_SAFETY "---\0 "
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "Wyłącz\0 ""S-Port Mirror\0 ""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "Brak\0 ""Potencjometr\0 ""Przeł.Wielopoz."
#define TR_POTTYPES "Brak\0 ""Pot with detent""Przeł.Wielopoz.""Potencjometr\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATA:""CZAS:"
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Bezp.\0 "
#else
#define TR_CFN_SAFETY "---\0 "
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "OFF\0 ""S-Port Mirror\0 ""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\017"
#define TR_POTTYPES "None\0 ""Pot\0 ""Multipos Switch"
#define TR_POTTYPES "None\0 ""Pot with detent""Multipos Switch""Pot\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DATA:""HORA:"
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Seguro\0 "
#else
#define TR_CFN_SAFETY "---\0 "
+2 -2
View File
@@ -83,7 +83,7 @@
#define TR_UART3MODES "Av\0 ""Spegling av S-Port""Telemetry\0 ""Debug\0 "
#define LEN_POTTYPES "\020"
#define TR_POTTYPES "Ingen\0 ""Potentiometer\0 ""Flerlägesväljare"
#define TR_POTTYPES "Ingen\0 ""Pot with detent""Flerlägesväljare""Potentiometer\0"
#define LEN_DATETIME "\005"
#define TR_DATETIME "DAG: ""TID: "
@@ -264,7 +264,7 @@
#define TR_CFN_TEST
#endif
#if defined(SAFETY_CHANNEL_FUNCTION)
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define TR_CFN_SAFETY "Säkra \0 "
#else
#define TR_CFN_SAFETY "---\0 "
+178
View File
@@ -0,0 +1,178 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import traceback
import time
PREC1 = 10
PREC2 = 100
CONSTANT_VALUE = ""
dups_cnst = []
dups_name = []
exports = []
exports_multiple = []
exports_script_outputs = []
exports_extra = []
warning = None
error = None
def checkName(name):
global warning
if name in dups_name:
print "WARNING: Duplicate name %s found for constant %s" % (name, CONSTANT_VALUE)
warning = True
dups_name.append(name)
if name != name.lower():
print "WARNING:Name not in lower case %s found for constant %s" % (name, CONSTANT_VALUE)
warning = True
def LEXP(name, description):
# print "LEXP %s, %s" % (name, description)
checkName(name)
exports.append( (CONSTANT_VALUE, name, description) )
def LEXP_TELEMETRY(name, description):
# print "LEXP %s, %s" % (name, description)
checkName(name)
exports.append( ("MIXSRC_FIRST_TELEM-1+"+CONSTANT_VALUE, name, description) )
def LEXP_MULTIPLE(nameFormat, descriptionFormat, valuesCount):
# print "LEXP_MULTIPLE %s, %s, %s" % (nameFormat, descriptionFormat, valuesCount)
for v in range(valuesCount):
name = nameFormat + str(v)
# print name
checkName(name)
exports_multiple.append( (CONSTANT_VALUE, nameFormat, descriptionFormat, valuesCount) )
def LEXP_EXTRA(name, description, value, condition = "true"):
# print "LEXP_EXTRA %s, %s, %s, %s" % (name, description, value, condition)
checkName(name)
exports_extra.append( (CONSTANT_VALUE, name, description, value, condition) )
# extra also added to normal items to enable searching
exports.append( (CONSTANT_VALUE, name, description) )
inputFile = sys.argv[1]
outputFile = sys.argv[2]
print "Input file %s" % inputFile
print "Output file %s" % outputFile
inp = open(inputFile, "r")
while True:
line = inp.readline()
if len(line) == 0:
break
line = line.strip('\r\n')
line = line.strip()
#print "line: %s" % line
parts = line.split('LEXP')
#print parts
if len(parts) != 2:
print "Wrong line: %s" % line
continue
cmd = 'LEXP' + parts[1]
cnst = parts[0].rstrip(', ')
if cnst.find('=') != -1:
# constant contains =
cnst = cnst.split('=')[0].strip()
#print "Found constant %s with command: %s" % (cnst, cmd)
try:
CONSTANT_VALUE = cnst
# if CONSTANT_VALUE in dups_cnst:
# print "WARNING: Duplicate CONSTANT_VALUE found: %s" % CONSTANT_VALUE
# warning = True
# continue
# dups_cnst.append(CONSTANT_VALUE)
# print cmd
eval(cmd)
except:
print "ERROR: problem with the definition: %s" % line
traceback.print_exc()
error = True
inp.close()
out = open(outputFile, "w")
out.write("//This file was generated by luaexport.py script on %s\n\n\n" % time.asctime())
header = """
struct LuaSingleField {
uint16_t id;
const char * name;
const char * desc;
};
struct LuaMultipleField {
uint16_t id;
const char * name;
const char * desc;
uint8_t count;
};
"""
out.write(header)
out.write("""
// The list of Lua fields
// this aray is alphabetically sorted by the second field (name)
const LuaSingleField luaSingleFields[] = {
""")
exports.sort(key = lambda x: x[1]) #sort by name
data = [" {%s, \"%s\", \"%s\"}" % export for export in exports]
out.write(",\n".join(data))
out.write("\n};\n\n")
print "Generated %d items in luaFields[]" % len(exports)
out.write("""
// The list of Lua fields that have a range of values
const LuaMultipleField luaMultipleFields[] = {
""")
data = [" {%s, \"%s\", \"%s\", %d}" % export for export in exports_multiple]
out.write(",\n".join(data))
out.write("\n};\n\n")
print "Generated %d items in luaMultipleFields[]" % len(exports_multiple)
#code generation for extra fields
case = """ case %s:
if (%s) {
lua_pushnumber(L, %s);
return 1;
}
break;"""
case_clauses = [case % (cnst, condition, value) for (cnst, name, description, value, condition) in exports_extra]
case_body = "\n".join(case_clauses)
func_body = """
extern lua_State *L;
// The handling of extra Lua fileds that are not
// accesible by the getValue()
static int luaGetExtraValue(int src)
{
switch (src) {
%s
}
return 0;
}
""" % case_body
out.write(func_body)
print "Generated %d condtions in luaGetExtraValue()" % len(exports_extra)
out.close()
if warning:
sys.exit(1)
elif error:
os.remove(outputFile)
sys.exit(2)
sys.exit(0)