Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4062555605 | |||
| 9cb38ce839 | |||
| 905090ef09 | |||
| 62e5820082 | |||
| 2d21e16201 | |||
| 07303f4301 | |||
| 91228f803c | |||
| e5d7e1f7c2 | |||
| 81573537eb | |||
| 7a85328b86 | |||
| fd84c62ff4 | |||
| 13e0b21656 | |||
| 5949be30fa | |||
| 0117c2da68 | |||
| 943f70c599 | |||
| 52a48fc4b1 | |||
| 2712ffabb0 | |||
| fa8c8a7094 | |||
| 5907193571 | |||
| 45abfb872f | |||
| 4d5962b15b | |||
| eea1c3a84c | |||
| deed7fc20f | |||
| 62fca3f8b6 | |||
| 9377e58407 | |||
| 9b53f69038 | |||
| 3680149b52 | |||
| 93faeeafbe | |||
| 2d5d1cb357 | |||
| 2a5364dc8c | |||
| 7f47a4fe10 | |||
| a0cc428228 | |||
| 61985f7d6a | |||
| 3baf64f123 | |||
| 4fd40c154e | |||
| 3c360618b9 | |||
| 1d96731ad5 | |||
| 9d1d31d26a | |||
| 0b52ccfaf1 | |||
| 484566083e | |||
| 0f33dc6113 | |||
| 7f3778fc3c | |||
| 0a9dcc5ce6 | |||
| 2f01f139cc | |||
| fb3e615008 | |||
| ce6d0807fa | |||
| cab8f3db71 | |||
| 399a8b2e35 | |||
| 3d4a791940 | |||
| 7373ce2cae | |||
| 5da1e35efe | |||
| fe5b7bee8c | |||
| 2da1134796 | |||
| 83e47d9e35 | |||
| f0c76efaf7 | |||
| 2fe7d856c3 | |||
| a7c1f22b36 | |||
| d92620919b | |||
| 94bb21886b | |||
| 5db98a3fef | |||
| 763c7fbb7d | |||
| b2d1a4ed22 | |||
| e7211065ab | |||
| 68b8b0e38f | |||
| 644c833311 | |||
| 30b1f62e99 | |||
| 03aa787c8e | |||
| 79592d3b00 | |||
| 7ed527a328 | |||
| 3e0766f2bf | |||
| 71e7926045 | |||
| 8c3d47deac | |||
| 197f31d5a1 | |||
| 1a198c35ad | |||
| 2934fc4d23 | |||
| 4ae9585080 | |||
| 161016a02a | |||
| 559bb83864 | |||
| 9a37c3027e | |||
| 6548afcad3 | |||
| ee31c51275 | |||
| 63aadad10c | |||
| 30958a9a65 | |||
| 995183bf22 |
@@ -518,3 +518,21 @@ Jens Lochmüller
|
||||
Anthony Witham
|
||||
Peter Hauke
|
||||
Arizona Action Photos
|
||||
Francis F Dale
|
||||
Willie Swanepoel
|
||||
Edward Hauser
|
||||
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
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
<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>
|
||||
<li>EEPROM export warning when exporting logical switches > L12 on 9X128</li>
|
||||
<li>FAS offset was not exported on 9X/9XR boards</li>
|
||||
<li>Trims modes bugfix on non Taranis boards</li>
|
||||
<li>It was impossible to open a backuped model from the Tx</li>
|
||||
</ul>
|
||||
|
||||
<h2>Version 2.0.6</h2>
|
||||
<ul>
|
||||
<li>Fix Mix curves bug on Sky9x boards</li>
|
||||
|
||||
@@ -2,7 +2,7 @@ PROJECT( companion )
|
||||
|
||||
SET( C9X_VERSION_MAJOR "2" )
|
||||
SET( C9X_VERSION_MINOR "0" )
|
||||
SET( C9X_VERSION_REVISION "6" )
|
||||
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")
|
||||
|
||||
@@ -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("<", "<").replace(">", ">");
|
||||
if (md->curve.value) str += " " + md->curve.toString().replace("<", "<").replace(">", ">");
|
||||
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("<", "<").replace(">", ">"));
|
||||
if (md->curve.value) str += " " + md->curve.toString().replace("<", "<").replace(">", ">");
|
||||
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);
|
||||
|
||||
@@ -648,7 +648,7 @@ class ConversionField: public TransformedField {
|
||||
if (table->exportValue(_field, _field))
|
||||
return;
|
||||
if (!error.isEmpty())
|
||||
EEPROMWarnings += error + "\n";
|
||||
EEPROMWarnings.push_back(error);
|
||||
}
|
||||
|
||||
if (shift) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "helpers.h"
|
||||
#include "wizarddata.h"
|
||||
|
||||
QString EEPROMWarnings;
|
||||
std::list<QString> EEPROMWarnings;
|
||||
|
||||
const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" };
|
||||
const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" };
|
||||
@@ -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));
|
||||
|
||||
@@ -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 {
|
||||
@@ -1198,7 +1201,7 @@ class EEPROMInterface
|
||||
|
||||
};
|
||||
|
||||
extern QString EEPROMWarnings;
|
||||
extern std::list<QString> EEPROMWarnings;
|
||||
|
||||
/* EEPROM string conversion functions */
|
||||
void setEEPROMString(char *dst, const char *src, int size);
|
||||
|
||||
@@ -344,6 +344,57 @@ unsigned int RleFile::readRlc12(uint8_t *buf, unsigned int i_len, bool rlc2)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int importRlc(QByteArray & dst, QByteArray & src, unsigned int rlcVersion)
|
||||
{
|
||||
uint8_t *buf = (uint8_t *)src.data();
|
||||
unsigned int len = src.size();
|
||||
uint8_t zeroes = 0;
|
||||
uint8_t bRlc = 0;
|
||||
|
||||
dst.resize(0);
|
||||
|
||||
for( ; 1; ) {
|
||||
for (int i=0; i<zeroes; i++)
|
||||
dst.append((char)0);
|
||||
zeroes = 0;
|
||||
|
||||
if (len == 0)
|
||||
return dst.size();
|
||||
|
||||
for (int i=0; i<bRlc; i++) {
|
||||
dst.append(*buf++);
|
||||
if (--len == 0)
|
||||
return dst.size();
|
||||
}
|
||||
|
||||
bRlc = *buf++;
|
||||
--len;
|
||||
|
||||
if (!(bRlc & 0x7f)) {
|
||||
qDebug() << "RLC decoding error!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rlcVersion == 2) {
|
||||
if (bRlc&0x80){ // if contains high byte
|
||||
zeroes = (bRlc>>4) & 0x07;
|
||||
bRlc = bRlc & 0x0f;
|
||||
}
|
||||
else if (bRlc&0x40){
|
||||
zeroes = bRlc & 0x3f;
|
||||
bRlc = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (bRlc&0x80){ // if contains high byte
|
||||
zeroes = bRlc & 0x7f;
|
||||
bRlc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dst.size();
|
||||
}
|
||||
|
||||
unsigned int RleFile::write1(uint8_t b)
|
||||
{
|
||||
return write(&b, 1);
|
||||
|
||||
@@ -146,4 +146,6 @@ public:
|
||||
unsigned int get_current_block_number(unsigned int block_no, uint16_t *p_size);
|
||||
};
|
||||
|
||||
unsigned int importRlc(QByteArray & dst, QByteArray & src, unsigned int rlcVersion=2);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -149,7 +149,7 @@ t_Open9xArmExpoData_v208::operator ExpoData ()
|
||||
c9x.chn = chn;
|
||||
|
||||
if (expo!=0 && curve!=0) {
|
||||
EEPROMWarnings += ::QObject::tr("Simultaneous usage of expo and curves is no longer supported") + "\n";
|
||||
EEPROMWarnings.push_back(::QObject::tr("Simultaneous usage of expo and curves is no longer supported"));
|
||||
}
|
||||
else {
|
||||
if (curve == 0) {
|
||||
@@ -179,7 +179,7 @@ t_Open9xArmExpoData_v210::operator ExpoData ()
|
||||
c9x.chn = chn;
|
||||
|
||||
if (expo!=0 && curve!=0) {
|
||||
EEPROMWarnings += ::QObject::tr("Simultaneous usage of expo and curves is no longer supported") + "\n";
|
||||
EEPROMWarnings.push_back(::QObject::tr("Simultaneous usage of expo and curves is no longer supported"));
|
||||
}
|
||||
else {
|
||||
if (curve == 0) {
|
||||
|
||||
@@ -89,7 +89,7 @@ t_Open9xExpoData_v201::operator ExpoData ()
|
||||
c9x.mode = mode;
|
||||
c9x.chn = chn;
|
||||
if (expo!=0 && curve!=0) {
|
||||
EEPROMWarnings += ::QObject::tr("Simultaneous usage of expo and curves is no longer supported in OpenTX") + "\n";
|
||||
EEPROMWarnings.push_back(::QObject::tr("Simultaneous usage of expo and curves is no longer supported in OpenTX"));
|
||||
}
|
||||
else {
|
||||
if (curve == 0) {
|
||||
@@ -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,6 +48,7 @@
|
||||
#define GPS
|
||||
#define FAI_CHOICE
|
||||
#define FRSKY_STICKS
|
||||
#define OVERRIDE_CHANNEL_FUNCTION
|
||||
|
||||
#define EEPROM_VARIANT 3
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#define FRSKY_STICKS
|
||||
#define DSM2
|
||||
#define DSM2_PPM
|
||||
#define OVERRIDE_CHANNEL_FUNCTION
|
||||
|
||||
#define EEPROM_VARIANT SIMU_M128_VARIANTS
|
||||
#define GAUGES
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#define GPS
|
||||
#define FAI_CHOICE
|
||||
#define FRSKY_STICKS
|
||||
#define OVERRIDE_CHANNEL_FUNCTION
|
||||
#define FAS_OFFSET
|
||||
|
||||
#define EEPROM_VARIANT SIMU_STOCK_VARIANTS
|
||||
#define GAUGES
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#define GPS
|
||||
#define FAI_CHOICE
|
||||
#define FRSKY_STICKS
|
||||
#define OVERRIDE_CHANNEL_FUNCTION
|
||||
|
||||
#define NUM_POTS 3
|
||||
#define EEPROM_VARIANT 3
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#define EEPROM_VARIANT 3
|
||||
#define HAPTIC
|
||||
#define REVPLUS
|
||||
#define OVERRIDE_CHANNEL_FUNCTION
|
||||
|
||||
#define NUM_POTS 5
|
||||
|
||||
|
||||
@@ -235,8 +235,9 @@ class SourcesConversionTable: public ConversionTable {
|
||||
addConversion(RawSource(SOURCE_TYPE_SWITCH, i), val++);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<MAX_CUSTOM_SWITCHES(board, version); i++)
|
||||
for (int i=0; i<MAX_CUSTOM_SWITCHES(board, version); i++) {
|
||||
addConversion(RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i), val++);
|
||||
}
|
||||
}
|
||||
|
||||
if (!afterrelease21March2013) {
|
||||
@@ -369,7 +370,8 @@ template <int N>
|
||||
class SwitchField: public ConversionField< SignedField<N> > {
|
||||
public:
|
||||
SwitchField(RawSwitch & sw, BoardEnum board, unsigned int version, unsigned long flags=0):
|
||||
ConversionField< SignedField<N> >(_switch, SwitchesConversionTable::getInstance(board, version, flags), "Switch"),
|
||||
ConversionField< SignedField<N> >(_switch, SwitchesConversionTable::getInstance(board, version, flags), "Switch",
|
||||
"Switch "+ sw.toString()+" cannot be exported on this board!"),
|
||||
sw(sw),
|
||||
_switch(0)
|
||||
{
|
||||
@@ -503,7 +505,8 @@ template <int N>
|
||||
class SourceField: public ConversionField< UnsignedField<N> > {
|
||||
public:
|
||||
SourceField(RawSource & source, BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0):
|
||||
ConversionField< UnsignedField<N> >(_source, SourcesConversionTable::getInstance(board, version, variant, flags), "Source"),
|
||||
ConversionField< UnsignedField<N> >(_source, SourcesConversionTable::getInstance(board, version, variant, flags),
|
||||
"Source", "Source "+ source.toString(ModelData())+" cannot be exported on this board!"),
|
||||
source(source),
|
||||
_source(0)
|
||||
{
|
||||
@@ -1255,14 +1258,14 @@ class CurvesField: public TransformedField {
|
||||
if (IS_TARANIS(board) && version >= 216) {
|
||||
offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count);
|
||||
if (offset > maxPoints) {
|
||||
EEPROMWarnings += ::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints) + "\n";
|
||||
EEPROMWarnings.push_back(::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count) - 5;
|
||||
if (offset > maxPoints - 5 * maxCurves) {
|
||||
EEPROMWarnings += ::QObject::tr("OpenTx only accepts %1 points in all curves").arg(maxPoints) + "\n";
|
||||
EEPROMWarnings.push_back(::QObject::tr("OpenTx only accepts %1 points in all curves").arg(maxPoints));
|
||||
break;
|
||||
}
|
||||
_curves[i] = offset;
|
||||
@@ -2335,10 +2338,9 @@ class FrskyField: public StructField {
|
||||
Append(new UnsignedField<3>(frsky.varioSource));
|
||||
Append(new SignedField<5>(frsky.varioCenterMin));
|
||||
Append(new ConversionField< UnsignedField<3> >(frsky.currentSource, &telemetryCurrentSourceConversionTable, "Current Source"));
|
||||
Append(new SignedField<8>(frsky.varioCenterMax));
|
||||
Append(new SignedField<5>(frsky.varioCenterMax));
|
||||
if (version >= 216) {
|
||||
// TODO int8_t fasOffset;
|
||||
Append(new SpareBitsField<8>());
|
||||
Append(new SignedField<8>(frsky.fasOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2428,7 +2430,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
|
||||
if (IS_ARM(board))
|
||||
internalField.Append(new UnsignedField<3>(modelData.telemetryProtocol));
|
||||
else
|
||||
internalField.Append(new ConversionField< UnsignedField<3> >((unsigned int &)modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol")));
|
||||
internalField.Append(new ConversionField< UnsignedField<3> >((unsigned int &)modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this telemetry protocol")));
|
||||
|
||||
internalField.Append(new BoolField<1>(modelData.thrTrim));
|
||||
|
||||
@@ -2532,12 +2534,12 @@ 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 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) {
|
||||
modulesCount = 3;
|
||||
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol")));
|
||||
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this radio protocol")));
|
||||
}
|
||||
|
||||
if (IS_ARM(board) && version >= 215) {
|
||||
|
||||
@@ -163,8 +163,20 @@ bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData &mode
|
||||
}
|
||||
else {
|
||||
// load from SD Backup, size is stored in index
|
||||
QByteArray eepromData((char *)data, index);
|
||||
open9xModel.Import(eepromData);
|
||||
QByteArray backupData((char *)data, index);
|
||||
QByteArray modelData;
|
||||
if (IS_SKY9X(board))
|
||||
modelData = backupData;
|
||||
else
|
||||
importRlc(modelData, backupData);
|
||||
if (modelData.size()) {
|
||||
open9xModel.Import(modelData);
|
||||
// open9xModel.Dump();
|
||||
model.used = true;
|
||||
}
|
||||
else {
|
||||
model.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -402,10 +414,21 @@ int OpenTxEepromInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
if (!EEPROMWarnings.isEmpty())
|
||||
if (!EEPROMWarnings.empty()) {
|
||||
QString msg;
|
||||
int noErrorsToDisplay = std::min((int)EEPROMWarnings.size(),10);
|
||||
for (int n = 0; n < noErrorsToDisplay; n++) {
|
||||
msg += "-" + EEPROMWarnings.front() + "\n";
|
||||
EEPROMWarnings.pop_front();
|
||||
}
|
||||
if (!EEPROMWarnings.empty()) {
|
||||
msg = QObject::tr("(displaying only first 10 warnings)") + "\n" + msg;
|
||||
}
|
||||
EEPROMWarnings.clear();
|
||||
QMessageBox::warning(NULL,
|
||||
QObject::tr("Warning"),
|
||||
QObject::tr("EEPROM saved with these warnings:") + "\n- " + EEPROMWarnings.remove(EEPROMWarnings.length()-1, 1).replace("\n", "\n- "));
|
||||
QObject::tr("EEPROM saved with these warnings:") + "\n" + msg);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -557,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;
|
||||
@@ -621,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;
|
||||
@@ -910,11 +933,32 @@ bool OpenTxEepromInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, in
|
||||
{
|
||||
std::cout << "trying " << getName() << " backup import...";
|
||||
|
||||
if (esize < 8 || memcmp(eeprom, "o9x", 3) != 0 || eeprom[3] != 0x30+board) {
|
||||
if (esize < 8 || memcmp(eeprom, "o9x", 3) != 0) {
|
||||
std::cout << " no\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
BoardEnum backupBoard = (BoardEnum)-1;
|
||||
switch (eeprom[3]) {
|
||||
case 0x33:
|
||||
backupBoard = BOARD_TARANIS;
|
||||
break;
|
||||
case 0x32:
|
||||
backupBoard = BOARD_SKY9X;
|
||||
break;
|
||||
case 0x31:
|
||||
backupBoard = BOARD_GRUVIN9X;
|
||||
break;
|
||||
default:
|
||||
std::cout << " unknown board\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (backupBoard != board) {
|
||||
std::cout << " not right board\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t version = eeprom[4];
|
||||
uint8_t bcktype = eeprom[5];
|
||||
uint16_t size = ((uint16_t)eeprom[7] << 8) + eeprom[6];
|
||||
@@ -1007,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);
|
||||
}
|
||||
|
||||
@@ -1051,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);
|
||||
@@ -1219,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);
|
||||
|
||||
@@ -1227,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ int8_t t_Th9xLogicalSwitchData::fromSource(RawSource source)
|
||||
if (source.type == SOURCE_TYPE_STICK)
|
||||
v1 = 1+source.index;
|
||||
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
|
||||
EEPROMWarnings += ::QObject::tr("th9x on this board doesn't have Rotary Encoders") + "\n";
|
||||
EEPROMWarnings.push_back(::QObject::tr("th9x on this board doesn't have Rotary Encoders"));
|
||||
v1 = 5+source.index;
|
||||
}
|
||||
else if (source.type == SOURCE_TYPE_MAX)
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -67,6 +67,7 @@ class CurveGroup : public QObject {
|
||||
|
||||
protected slots:
|
||||
void gvarCBChanged(int);
|
||||
void typeChanged(int);
|
||||
void valuesChanged();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1596,7 +1596,7 @@ void MainWindow::createActions()
|
||||
writeEepromAct = addAct("write_eeprom.png", tr("Write Models and Settings To Radio"), tr("Write Models and Settings to Radio"), SLOT(writeEeprom()));
|
||||
readEepromAct = addAct("read_eeprom.png", tr("Read Models and Settings From Radio"), tr("Read Models and Settings from Radio"), SLOT(readEeprom()));
|
||||
burnConfigAct = addAct("configure.png", tr("Configure Communications..."), tr("Configure software for communicating with the Radio"), SLOT(burnConfig()));
|
||||
writeBackupToRadioAct = addAct("write_eeprom_file.png", tr("Write Backup to Radio"), tr("Write Backup from file to to Radio"), SLOT(writeBackup()));
|
||||
writeBackupToRadioAct = addAct("write_eeprom_file.png", tr("Write Backup to Radio"), tr("Write Backup from file to Radio"), SLOT(writeBackup()));
|
||||
readBackupToFileAct = addAct("read_eeprom_file.png", tr("Backup Radio to File"), tr("Save a complete backup file of all settings and model data in the Radio"), SLOT(readBackup()));
|
||||
contributorsAct = addAct("contributors.png", tr("Contributors..."), tr("A tribute to those who have contributed to OpenTX and Companion"), SLOT(contributors()));
|
||||
|
||||
|
||||
@@ -63,19 +63,25 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
|
||||
trimsValue << ui->trim1Value << ui->trim2Value << ui->trim3Value << ui->trim4Value;
|
||||
trimsSlider << ui->trim1Slider << ui->trim2Slider << ui->trim3Slider << ui->trim4Slider;
|
||||
|
||||
BoardEnum board = firmware->getBoard();
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]);
|
||||
|
||||
QComboBox * cb = trimsUse[i];
|
||||
cb->setProperty("index", i);
|
||||
cb->addItem(QObject::tr("Trim disabled"), -1);
|
||||
if (IS_TARANIS(board)) {
|
||||
cb->addItem(QObject::tr("Trim disabled"), -1);
|
||||
}
|
||||
for (int m=0; m<modesCount; m++) {
|
||||
if (m == phaseIdx) {
|
||||
cb->addItem(QObject::tr("Own Trim"), m*2);
|
||||
}
|
||||
else if (phaseIdx > 0) {
|
||||
cb->addItem(QObject::tr("Use Trim from Flight mode %1").arg(m), m*2);
|
||||
cb->addItem(QObject::tr("Use Trim from Flight mode %1 + Own Trim as an offset").arg(m), m*2+1);
|
||||
if (IS_TARANIS(board)) {
|
||||
cb->addItem(QObject::tr("Use Trim from Flight mode %1 + Own Trim as an offset").arg(m), m*2+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int)));
|
||||
@@ -157,7 +163,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
|
||||
gvLayout->addWidget(gvValues[i], i, col++, 1, 1);
|
||||
|
||||
// Popups
|
||||
if (IS_TARANIS(GetEepromInterface()->getBoard()) && (phaseIdx == 0)) {
|
||||
if (IS_TARANIS(board) && phaseIdx == 0) {
|
||||
gvPopups[i] = new QCheckBox(ui->gvGB);
|
||||
gvPopups[i]->setProperty("index", i);
|
||||
gvPopups[i]->setText(tr("Popup enabled"));
|
||||
@@ -270,7 +276,11 @@ void FlightModePanel::trimUpdate(unsigned int trim)
|
||||
trimsSlider[trim]->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
trimsUse[trim]->setCurrentIndex(1 + 2*phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0));
|
||||
BoardEnum board = firmware->getBoard();
|
||||
if (IS_TARANIS(board))
|
||||
trimsUse[trim]->setCurrentIndex(1 + 2*phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0));
|
||||
else
|
||||
trimsUse[trim]->setCurrentIndex(phase.trimRef[chn]);
|
||||
trimsValue[trim]->setEnabled(true);
|
||||
trimsSlider[trim]->setEnabled(true);
|
||||
}
|
||||
@@ -364,8 +374,15 @@ void FlightModePanel::phaseTrimUse_currentIndexChanged(int index)
|
||||
phase.trim[chn] = 0;
|
||||
}
|
||||
else {
|
||||
phase.trimMode[chn] = data % 2;
|
||||
phase.trimRef[chn] = data / 2;
|
||||
BoardEnum board = firmware->getBoard();
|
||||
if (IS_TARANIS(board)) {
|
||||
phase.trimMode[chn] = data % 2;
|
||||
phase.trimRef[chn] = data / 2;
|
||||
}
|
||||
else {
|
||||
phase.trimMode[chn] = 0;
|
||||
phase.trimRef[chn] = data / 2;
|
||||
}
|
||||
phase.trim[chn] = 0;
|
||||
}
|
||||
trimUpdate(trim);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -658,10 +658,10 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-1.500000000000000</double>
|
||||
<double>-12.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.500000000000000</double>
|
||||
<double>12.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
|
||||
@@ -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>");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -24,5 +24,6 @@
|
||||
#define round(x) floor(x+0.5)
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _tcsnicmp
|
||||
#define snprintf _snprintf
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
<h2>Version 2.0.6 / 2014-07-08</h2>
|
||||
<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>
|
||||
<li>Instant Trim problem when using a negative curve
|
||||
|
||||
[All]
|
||||
<ul>
|
||||
<li>SafetyCH function was missing on the compilation server
|
||||
|
||||
<h2>Version 2.0.6 / 2014-07-13</h2>
|
||||
[Taranis]
|
||||
<ul>
|
||||
<li>Telemetry Type field is hidden when only S.PORT is available
|
||||
|
||||
@@ -24,3 +24,5 @@
|
||||
/gtests
|
||||
/gtest_main.a
|
||||
/gtests.d
|
||||
/lua_exports.cpp
|
||||
/lua_exports.txt
|
||||
|
||||
@@ -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.6
|
||||
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:
|
||||
@@ -1408,7 +1417,9 @@ clean_list :
|
||||
$(REMOVE) *.lst
|
||||
$(REMOVE) allsrc.cpp
|
||||
$(REMOVE) stamp-opentx.h
|
||||
$(REMOVE) `find . -name "*.lbm"`
|
||||
$(REMOVE) bitmaps/*.lbm
|
||||
$(REMOVE) fonts/*/*.lbm
|
||||
$(REMOVE) lua_exports.txt lua_exports.cpp
|
||||
$(MAKE) -C bootloader clean
|
||||
|
||||
#### Install
|
||||
@@ -1490,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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -340,8 +340,8 @@ void displayTimers()
|
||||
// Main timer
|
||||
if (g_model.timers[0].mode) {
|
||||
TimerState & timerState = timersStates[0];
|
||||
putsTimer(TIMERS_X, TIMER1_Y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT);
|
||||
putsTimerMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SMLSIZE);
|
||||
putsTimer(TIMERS_X, TIMER1_Y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT);
|
||||
if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE);
|
||||
if (timerState.val < 0) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
@@ -353,8 +353,8 @@ void displayTimers()
|
||||
// Second timer
|
||||
if (g_model.timers[1].mode) {
|
||||
TimerState & timerState = timersStates[1];
|
||||
putsTimer(TIMERS_X, TIMER2_Y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT);
|
||||
putsTimerMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SMLSIZE);
|
||||
putsTimer(TIMERS_X, TIMER2_Y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT);
|
||||
if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE);
|
||||
if (timerState.val < 0) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
|
||||
@@ -310,7 +310,7 @@ bool displayGaugesTelemetryScreen(FrSkyScreenData & screen)
|
||||
else {
|
||||
#if defined(CPUARM)
|
||||
threshold = barsThresholds[source-TELEM_ALT];
|
||||
#else
|
||||
#elif defined(GAUGES)
|
||||
threshold = convertBarTelemValue(source, barsThresholds[source-TELEM_ALT]);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -51,7 +51,87 @@ uint8_t lcdLastPos;
|
||||
uint8_t lcdNextPos;
|
||||
|
||||
#if defined(CPUARM)
|
||||
void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width, uint8_t height, LcdFlags flags);
|
||||
void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width, uint8_t height, LcdFlags flags)
|
||||
{
|
||||
bool blink = false;
|
||||
bool inv = false;
|
||||
if (flags & BLINK) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
if (flags & INVERS)
|
||||
inv = true;
|
||||
else {
|
||||
blink = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & INVERS) {
|
||||
inv = true;
|
||||
}
|
||||
|
||||
uint8_t lines = (height+7)/8;
|
||||
assert(lines <= 5);
|
||||
|
||||
for (int8_t i=0; i<width+2; i++) {
|
||||
if (x<LCD_W) {
|
||||
uint8_t b[5] = { 0 };
|
||||
if (i==0) {
|
||||
if (x==0 || !inv) {
|
||||
lcdNextPos++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
// we need to work on the previous x when INVERS
|
||||
x--;
|
||||
}
|
||||
}
|
||||
else if (i<=width) {
|
||||
uint8_t skip = true;
|
||||
for (uint8_t j=0; j<lines; j++) {
|
||||
b[j] = pgm_read_byte(pattern++); /*top byte*/
|
||||
if (b[j] != 0xff) {
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
if (flags & FIXEDWIDTH) {
|
||||
for (uint8_t j=0; j<lines; j++) {
|
||||
b[j] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((flags & CONDENSED) && i==2) {
|
||||
/*condense the letter by skipping column 3 */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (int8_t j=-1; j<=height; j++) {
|
||||
bool plot;
|
||||
if (j < 0 || j == height) {
|
||||
plot = false;
|
||||
if (height >= 12) continue;
|
||||
if (j<0 && !inv) continue;
|
||||
}
|
||||
else {
|
||||
uint8_t line = (j / 8);
|
||||
uint8_t pixel = (j % 8);
|
||||
plot = b[line] & (1 << pixel);
|
||||
}
|
||||
if (inv) plot = !plot;
|
||||
if (!blink) {
|
||||
lcd_plot(x, y+j, plot ? FORCE : ERASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
lcdNextPos++;
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
{
|
||||
#if !defined(BOOT)
|
||||
@@ -94,20 +174,22 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
}
|
||||
else if (flags & MIDSIZE) {
|
||||
q = &font_8x10[((uint16_t)c-0x20)*16];
|
||||
lcdPutPattern(x, y, q, 8, 11, flags);
|
||||
lcdPutPattern(x, y, q, 8, 12, flags);
|
||||
}
|
||||
else if (flags & SMLSIZE) {
|
||||
q = (c < 0xc0 ? &font_4x6[(c-0x20)*5] : &font_4x6_extra[(c-0xc0)*5]);
|
||||
lcdPutPattern(x, y, q, 5, 6, flags);
|
||||
lcdPutPattern(x, y, q, 5, 7, flags);
|
||||
}
|
||||
else if (flags & TINSIZE) {
|
||||
q = &font_3x5[((uint16_t)c-0x2d)*3];
|
||||
lcdPutPattern(x, y, q, 3, 5, flags);
|
||||
}
|
||||
#if defined(BOLD_FONT)
|
||||
else if (flags & BOLD) {
|
||||
q = &font_5x7_B[c_remapped*5];
|
||||
lcdPutPattern(x, y, q, 5, 7, flags);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
@@ -38,110 +38,7 @@
|
||||
|
||||
#define LCD_BYTE_FILTER(p, keep, add) *(p) = (*(p) & (keep)) | (add)
|
||||
|
||||
#if defined(CPUARM)
|
||||
void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width, uint8_t height, LcdFlags flags)
|
||||
{
|
||||
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
|
||||
uint8_t *end = &displayBuf[ y / 8 * LCD_W + LCD_W ];
|
||||
|
||||
bool blink = false;
|
||||
bool inv = false;
|
||||
if (flags & BLINK) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
if (flags & INVERS)
|
||||
inv = true;
|
||||
else {
|
||||
blink = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & INVERS) {
|
||||
inv = true;
|
||||
}
|
||||
|
||||
uint8_t lines = (height+7)/8;
|
||||
assert(lines <= 5);
|
||||
|
||||
for (int8_t i=0; i<width+2; i++) {
|
||||
if (p<end) {
|
||||
uint8_t b[5] = { 0 };
|
||||
if (i==0) {
|
||||
if (x==0 || !inv) {
|
||||
lcdNextPos++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
// we need to work on the previous byte when INVERS
|
||||
p--;
|
||||
}
|
||||
}
|
||||
else if (i<=width) {
|
||||
uint8_t skip = true;
|
||||
for (uint8_t j=0; j<lines; j++) {
|
||||
b[j] = pgm_read_byte(pattern++); /*top byte*/
|
||||
if (b[j] != 0xff) {
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
if (flags & FIXEDWIDTH) {
|
||||
for (uint8_t j=0; j<lines; j++) {
|
||||
b[j] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((flags & CONDENSED) && i==2) {
|
||||
/*condense the letter by skipping column 3 */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const uint8_t ym8 = (y & 0x07);
|
||||
const uint8_t keepref = (1 << ((height&0x07)+1)) - 1;
|
||||
uint8_t * dest = p;
|
||||
for (uint8_t j=0; j<lines+1; j++) {
|
||||
if (dest < DISPLAY_END) {
|
||||
uint8_t b1=0, b2=0, keep=0;
|
||||
if (j>0) {
|
||||
b1 = b[j-1] >> (8-ym8);
|
||||
}
|
||||
else {
|
||||
keep = ~(keepref << ym8);
|
||||
}
|
||||
if (j<lines) {
|
||||
if (inv) {
|
||||
b[j] = ~b[j];
|
||||
}
|
||||
b2 = b[j] << ym8;
|
||||
}
|
||||
else {
|
||||
keep = ~(keepref >> (8-ym8));
|
||||
}
|
||||
if (!blink) {
|
||||
LCD_BYTE_FILTER(dest, keep, b1|b2);
|
||||
}
|
||||
dest += LCD_W;
|
||||
}
|
||||
}
|
||||
|
||||
if (inv && height<8) {
|
||||
if (ym8) {
|
||||
lcd_mask(p, 0x01 << (ym8-1), FORCE);
|
||||
}
|
||||
else if (y) {
|
||||
ASSERT_IN_DISPLAY(p - LCD_W);
|
||||
lcd_mask(p - LCD_W, 0x80, FORCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p++;
|
||||
lcdNextPos++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if !defined(CPUARM)
|
||||
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
{
|
||||
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
|
||||
|
||||
@@ -36,86 +36,6 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width, uint8_t height, LcdFlags flags)
|
||||
{
|
||||
bool blink = false;
|
||||
bool inv = false;
|
||||
if (flags & BLINK) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
if (flags & INVERS)
|
||||
inv = true;
|
||||
else {
|
||||
blink = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & INVERS) {
|
||||
inv = true;
|
||||
}
|
||||
|
||||
uint8_t lines = (height+7)/8;
|
||||
assert(lines <= 5);
|
||||
|
||||
for (int8_t i=0; i<width+2; i++) {
|
||||
if (x<LCD_W) {
|
||||
uint8_t b[5] = { 0 };
|
||||
if (i==0) {
|
||||
if (x==0 || !inv) {
|
||||
lcdNextPos++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
// we need to work on the previous x when INVERS
|
||||
x--;
|
||||
}
|
||||
}
|
||||
else if (i<=width) {
|
||||
uint8_t skip = true;
|
||||
for (uint8_t j=0; j<lines; j++) {
|
||||
b[j] = pgm_read_byte(pattern++); /*top byte*/
|
||||
if (b[j] != 0xff) {
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
if (flags & FIXEDWIDTH) {
|
||||
for (uint8_t j=0; j<lines; j++) {
|
||||
b[j] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((flags & CONDENSED) && i==2) {
|
||||
/*condense the letter by skipping column 3 */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (int8_t j=-1; j<=height; j++) {
|
||||
bool plot;
|
||||
if (j < 0 || j == height) {
|
||||
plot = false;
|
||||
if (j<0 && !inv) continue;
|
||||
}
|
||||
else {
|
||||
uint8_t line = (j / 8);
|
||||
uint8_t pixel = (j % 8);
|
||||
plot = b[line] & (1 << pixel);
|
||||
}
|
||||
if (inv) plot = !plot;
|
||||
if (!blink) {
|
||||
lcd_plot(x, y+j, plot ? FORCE : ERASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
lcdNextPos++;
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att)
|
||||
{
|
||||
ASSERT_IN_DISPLAY(p);
|
||||
@@ -172,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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -3095,6 +3093,12 @@ ISR(USART0_UDRE_vect)
|
||||
|
||||
void instantTrim()
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
int16_t anas_0[NUM_INPUTS];
|
||||
evalInputs(e_perout_mode_notrainer | e_perout_mode_nosticks);
|
||||
memcpy(anas_0, anas, sizeof(anas_0));
|
||||
#endif
|
||||
|
||||
evalInputs(e_perout_mode_notrainer);
|
||||
|
||||
for (uint8_t stick=0; stick<NUM_STICKS; stick++) {
|
||||
@@ -3107,7 +3111,7 @@ void instantTrim()
|
||||
ExpoData * ed = expoAddress(e);
|
||||
if (!EXPO_VALID(ed)) break; // end of list
|
||||
if (ed->srcRaw-MIXSRC_Rud == stick) {
|
||||
delta = anas[ed->chn];
|
||||
delta = anas[ed->chn] - anas_0[ed->chn];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 513 B |
|
After Width: | Height: | Size: 558 B |
@@ -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>
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -191,3 +191,56 @@ 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)
|
||||
{
|
||||
lcd_clear();
|
||||
lcd_putsAtt(0, 0, "TESTgy,", SMLSIZE);
|
||||
lcd_putsAtt(10, 22, "TESTgy,", SMLSIZE|INVERS);
|
||||
lcd_filled_rect(8, 40, 100, 20);
|
||||
lcd_putsAtt(10, 42, "TESTgy,", SMLSIZE);
|
||||
EXPECT_TRUE(checkScreenshot("smlsize"));
|
||||
}
|
||||
|
||||
TEST(Lcd, Stdsize)
|
||||
{
|
||||
lcd_clear();
|
||||
lcd_putsAtt(0, 0, "TEST", 0);
|
||||
lcd_putsAtt(10, 22, "TEST", INVERS);
|
||||
lcd_filled_rect(8, 40, 100, 20);
|
||||
lcd_putsAtt(10, 42, "TEST", 0);
|
||||
EXPECT_TRUE(checkScreenshot("stdsize"));
|
||||
}
|
||||
|
||||
TEST(Lcd, Midsize)
|
||||
{
|
||||
lcd_clear();
|
||||
lcd_putsAtt(0, 0, "TEST", MIDSIZE);
|
||||
lcd_putsAtt(10, 22, "TEST", MIDSIZE|INVERS);
|
||||
lcd_filled_rect(8, 40, 100, 20);
|
||||
lcd_putsAtt(10, 42, "TEST", MIDSIZE);
|
||||
EXPECT_TRUE(checkScreenshot("midsize"));
|
||||
}
|
||||
|
||||
TEST(Lcd, Dblsize)
|
||||
{
|
||||
lcd_clear();
|
||||
lcd_putsAtt(2, 10, "TST", DBLSIZE);
|
||||
lcd_putsAtt(42, 10, "TST", DBLSIZE|INVERS);
|
||||
lcd_filled_rect(80, 8, 46, 24);
|
||||
lcd_putsAtt(82, 10, "TST", DBLSIZE);
|
||||
EXPECT_TRUE(checkScreenshot("dblsize"));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
|
After Width: | Height: | Size: 503 B |
|
After Width: | Height: | Size: 532 B |
@@ -34,10 +34,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QPainter>
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -50,6 +46,7 @@ void doMixerCalculations();
|
||||
|
||||
#define MODEL_RESET() \
|
||||
memset(&g_model, 0, sizeof(g_model)); \
|
||||
memset(&anaInValues, 0, sizeof(anaInValues)); \
|
||||
extern uint8_t s_mixer_first_run_done; \
|
||||
s_mixer_first_run_done = false; \
|
||||
lastFlightMode = 255;
|
||||
@@ -133,6 +130,33 @@ TEST(Trims, CopySticksToOffset)
|
||||
EXPECT_EQ(g_model.limitData[1].offset, -97);
|
||||
}
|
||||
|
||||
TEST(Trims, InstantTrim)
|
||||
{
|
||||
MODEL_RESET();
|
||||
modelDefault(0);
|
||||
anaInValues[AIL_STICK] = 50;
|
||||
instantTrim();
|
||||
EXPECT_EQ(25, getTrimValue(0, AIL_STICK));
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(Trims, InstantTrimNegativeCurve)
|
||||
{
|
||||
MODEL_RESET();
|
||||
modelDefault(0);
|
||||
ExpoData *expo = expoAddress(AIL_STICK);
|
||||
expo->curve.type = CURVE_REF_CUSTOM;
|
||||
expo->curve.value = 1;
|
||||
g_model.points[0] = -100;
|
||||
g_model.points[1] = -75;
|
||||
g_model.points[2] = -50;
|
||||
g_model.points[3] = -25;
|
||||
g_model.points[4] = 0;
|
||||
anaInValues[AIL_STICK] = 512;
|
||||
instantTrim();
|
||||
EXPECT_EQ(128, getTrimValue(0, AIL_STICK));
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Curves, LinearIntpol)
|
||||
{
|
||||
|
||||
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 389 B |
|
After Width: | Height: | Size: 559 B |
|
After Width: | Height: | Size: 596 B |
|
After Width: | Height: | Size: 483 B |
|
After Width: | Height: | Size: 507 B |
@@ -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
|
||||
|
||||
|
After Width: | Height: | Size: 272 B |
|
After Width: | Height: | Size: 294 B |
@@ -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 "
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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)
|
||||