Compare commits
105 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b359aa12ba | |||
| 5f81444ccb | |||
| e8aba51edb | |||
| 6393f10ae4 | |||
| 8a16b63b31 | |||
| a5d334b11d | |||
| b51060f8f8 | |||
| 0db8fc5ab2 | |||
| 1c696c28fd | |||
| f29d2074c1 | |||
| c12bc7326c | |||
| 6365292bfe | |||
| d74bdef2ea | |||
| 884698c7f7 | |||
| 1454764987 | |||
| fb35ff098d | |||
| 681064b11c | |||
| 87ebf0b90a | |||
| 1f63108753 | |||
| 649fffa439 | |||
| e3d08e9bab | |||
| b4cc92b3f0 | |||
| 9691d9f648 | |||
| f02b9699d5 | |||
| b78556275b | |||
| 1effa17204 | |||
| ff69164400 | |||
| 86e8687d32 | |||
| 85755312e4 | |||
| f826d77f18 | |||
| 9dc4756789 | |||
| afd04e0c44 | |||
| d718ca03db | |||
| ca4028cc7e | |||
| 9c0b13eb6b | |||
| 5a10d85ee0 | |||
| 2d80327ffd | |||
| 2a5ff5244f | |||
| 2ce1ec16fb | |||
| 607a93b604 | |||
| 75b7a0517b | |||
| cf54d28f35 | |||
| ffe8ee5a29 | |||
| 552e3d468a | |||
| 949369d6a8 | |||
| 3b2cf5d738 | |||
| 5468bacad7 | |||
| b8fea4d652 | |||
| 734480cc56 | |||
| 30e0d441e4 | |||
| 784238252a | |||
| 403a62478a | |||
| c73ab26bc4 | |||
| c0783948e6 | |||
| dc3ca96a2f | |||
| 5664b4a141 | |||
| 7e18f53cbe | |||
| 611e26d0bf | |||
| ae7a36deeb | |||
| 7c37277364 | |||
| 2230fbaa94 | |||
| 97bb1a4b4d | |||
| 82d385bcef | |||
| 34f9367e25 | |||
| 205e510468 | |||
| 414a482ce4 | |||
| b24d071493 | |||
| a50e2472e9 | |||
| 29c95fd2a3 | |||
| c9875525a4 | |||
| 6df7575ad8 | |||
| 86c8d4a878 | |||
| 6abc26c36a | |||
| 966398426a | |||
| d43a48f088 | |||
| 56b4698655 | |||
| 57f0c1b6f6 | |||
| b89e16e627 | |||
| 9e4e990d33 | |||
| a7c893607a | |||
| e477183026 | |||
| a4698287f8 | |||
| b035a8df64 | |||
| 223be49c5d | |||
| ac8312de36 | |||
| 46a9151bcf | |||
| 0e9536fea9 | |||
| 64d86c4c74 | |||
| 151a09149d | |||
| fd53eba65f | |||
| 393f599ecf | |||
| 1fbb4effed | |||
| fe95488a83 | |||
| c9b9de2c99 | |||
| 3adc4c20a6 | |||
| 227a886122 | |||
| de625fde01 | |||
| daad477250 | |||
| 334a718a8a | |||
| 5baaec1868 | |||
| c2ad82eb35 | |||
| c61c417f13 | |||
| 98f156301a | |||
| ef6fe0006e | |||
| 23358c254c |
@@ -602,3 +602,41 @@ Ronald Donker
|
||||
Fredie Singh
|
||||
Patrizio Simoncini (monthly)
|
||||
Harald Gabler
|
||||
Michael Brown
|
||||
Julien Gérard
|
||||
Alexandre d'Alton
|
||||
Peter Mergaerts
|
||||
Jan Houwers
|
||||
Gordon Stahl
|
||||
Christian Grandjean
|
||||
Roger Bergevin
|
||||
NorthSide
|
||||
Sigmund Martinsen
|
||||
Lionel Lafraise
|
||||
Gisli Ofeigsson
|
||||
The Gruvin9x Project
|
||||
Manuel McLure
|
||||
Fernando Rimoldi
|
||||
Hiltenkamp Stephan
|
||||
Sandeep Kishore Jain
|
||||
Sebastien Charpentier
|
||||
Greg Parker
|
||||
Norman Maaß
|
||||
Adriano Del Ben
|
||||
Justin Poole
|
||||
Kenneth Harrison
|
||||
Eugene LaFaille
|
||||
John O'Shaughnessy
|
||||
Uwe Jordt
|
||||
Stuart Olson
|
||||
Frédéric Devillard
|
||||
Cheung Leo
|
||||
Peter Webster
|
||||
Jean-Claude Bachetta
|
||||
Delfin Perena
|
||||
Sae-wook Yoon
|
||||
Focus on Excellence
|
||||
Jeffery Golias
|
||||
Nick Milton
|
||||
Paul Zasso
|
||||
Reidar Johannes Lillebotn
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
<h2>Version 2.0.13 / 2014-11-20</h2>
|
||||
<ul>
|
||||
<li>Too many curves shown on non ARM boards</li>
|
||||
<li>Fixed vario limits</li>
|
||||
<li>Fixes in compare dialog</li>
|
||||
<li>Fixed receiver number range</li>
|
||||
<li>Virtual inputs not selectable in SF Volume and heli Collective Source</li>
|
||||
<li>Joystick calibration crash after channel assignment</li>
|
||||
<li>Gvar import error for limits</li>
|
||||
<li>Companion shows too many curve types in input/mixer for 9x</li>
|
||||
<li>NOT curves removed from inputs (for non ARM platforms)</li>
|
||||
<li>Companion again builds on OS X (Mac)</li>
|
||||
<li>Companion simulator Lua crash on OS X 64bit (Mac)</li>
|
||||
<li>Companion didn't take care of PlayScript functions</li>
|
||||
</ul>
|
||||
|
||||
<h2>Version 2.0.12 / 2014-09-15</h2>
|
||||
<ul>
|
||||
<li>Typos & Translations updated</li>
|
||||
|
||||
@@ -2,7 +2,7 @@ PROJECT( companion )
|
||||
|
||||
SET( C9X_VERSION_MAJOR "2" )
|
||||
SET( C9X_VERSION_MINOR "0" )
|
||||
SET( C9X_VERSION_REVISION "12" )
|
||||
SET( C9X_VERSION_REVISION "13" )
|
||||
SET( C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR}.${C9X_VERSION_REVISION} )
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
|
||||
@@ -89,7 +89,7 @@ add_custom_command(
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${RADIO_SRC_DIRECTORY}/lua_exports.inc
|
||||
COMMAND make lua_exports.cpp
|
||||
COMMAND make PCB=TARANIS lua_exports.cpp
|
||||
DEPENDS ${RADIO_SRC_DIRECTORY}/myeeprom.h
|
||||
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
|
||||
)
|
||||
|
||||
@@ -797,7 +797,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));
|
||||
if (md->curve.value) str += " " + md->curve.toString().replace("<", "<").replace(">", ">");
|
||||
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
|
||||
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);
|
||||
@@ -875,7 +875,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));
|
||||
if (md->curve.value) str += " " + md->curve.toString().replace("<", "<").replace(">", ">");
|
||||
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
|
||||
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);
|
||||
@@ -1021,11 +1021,7 @@ void CompareDialog::printSwitches()
|
||||
str.append("<tr>");
|
||||
color=getColor1(sw1,sw2);
|
||||
str.append(QString("<td width=\"45%\"><font color=%1>").arg(color)+sw1+"</font></td>");
|
||||
if (i<9) {
|
||||
str.append("<td align=\"center\" width=\"10%\"><b>"+tr("LS")+QString("%1</b></td>").arg(i+1));
|
||||
} else {
|
||||
str.append("<td align=\"center\" width=\"10%\"><b>"+tr("LS")+('A'+(i-9))+"</b></td>");
|
||||
}
|
||||
str.append("<td align=\"center\" width=\"10%\"><b>"+tr("L%1").arg(i+1)+QString("</b></td>"));
|
||||
color=getColor2(sw1,sw2);
|
||||
str.append(QString("<td width=\"45%\"><font color=%1>").arg(color)+sw2+"</font></td>");
|
||||
str.append("</tr>");
|
||||
|
||||
@@ -753,6 +753,8 @@ QString FuncSwData::funcToString()
|
||||
return QObject::tr("Play Both");
|
||||
else if (func == FuncPlayValue)
|
||||
return QObject::tr("Play Value");
|
||||
else if (func == FuncPlayScript)
|
||||
return QObject::tr("Play Script");
|
||||
else if (func == FuncLogs)
|
||||
return QObject::tr("Start Logs");
|
||||
else if (func == FuncVolume)
|
||||
|
||||
@@ -744,6 +744,7 @@ enum AssignFunc {
|
||||
FuncPlayPrompt,
|
||||
FuncPlayBoth,
|
||||
FuncPlayValue,
|
||||
FuncPlayScript,
|
||||
FuncLogs,
|
||||
FuncVolume,
|
||||
FuncBacklight,
|
||||
@@ -1158,6 +1159,8 @@ enum Capability {
|
||||
MultiposPotsPositions,
|
||||
SimulatorVariant,
|
||||
MavlinkTelemetry,
|
||||
HasInputDiff,
|
||||
HasMixerExpo,
|
||||
};
|
||||
|
||||
class SimulatorInterface;
|
||||
|
||||
@@ -202,8 +202,8 @@ class SourcesConversionTable: public ConversionTable {
|
||||
if (IS_TARANIS(board) && version >= 216) {
|
||||
for (int i=0; i<32; i++)
|
||||
addConversion(RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i), val++);
|
||||
for (int i=0; i<GetCurrentFirmware()->getCapability(LuaScripts); i++) {
|
||||
for (int j=0; j<GetCurrentFirmware()->getCapability(LuaOutputsPerScript); j++) {
|
||||
for (int i=0; i<7; i++) {
|
||||
for (int j=0; j<6; j++) {
|
||||
addConversion(RawSource(SOURCE_TYPE_LUA_OUTPUT, i*16+j), val++);
|
||||
}
|
||||
}
|
||||
@@ -991,7 +991,12 @@ class MixField: public TransformedField {
|
||||
_destCh = mix.destCh - 1;
|
||||
if (mix.curve.type == CurveReference::CURVE_REF_CUSTOM) {
|
||||
_curveMode = true;
|
||||
_curveParam = 6 + mix.curve.value;
|
||||
if (mix.curve.value > 0) {
|
||||
_curveParam = 6 + mix.curve.value;
|
||||
}
|
||||
else {
|
||||
_curveParam = mix.curve.value;
|
||||
}
|
||||
}
|
||||
else if (mix.curve.type == CurveReference::CURVE_REF_FUNC) {
|
||||
_curveMode = true;
|
||||
@@ -1220,23 +1225,39 @@ class LimitField: public StructField {
|
||||
template <int shift>
|
||||
static int exportLimitValue(int value)
|
||||
{
|
||||
if (value > 10000)
|
||||
return 4095 + value - 10000;
|
||||
else if (value < -10000)
|
||||
return -4096 + value + 10000;
|
||||
else
|
||||
return value + shift;
|
||||
const int GV1 = 4096;
|
||||
if (value > 10000) {
|
||||
return -GV1 + value - 10001;
|
||||
}
|
||||
if (value < -10000) {
|
||||
return GV1 + value + 10000;
|
||||
}
|
||||
return value + shift;
|
||||
}
|
||||
|
||||
template <int shift>
|
||||
static int importLimitValue(int value)
|
||||
{
|
||||
if (value > 4095)
|
||||
return 10000 + value - 4095;
|
||||
else if (value < -4096)
|
||||
return -10000 + value + 4096;
|
||||
else
|
||||
return value - shift;
|
||||
/* GVARS mapping on radio:
|
||||
GV1 = -4096
|
||||
GV9 = -4088
|
||||
-GV1 = 4095
|
||||
-GV9 = 4087
|
||||
*/
|
||||
const int GV1 = 4096;
|
||||
if (value >= GV1) {
|
||||
return 10001 + value - GV1;
|
||||
}
|
||||
if (value >= GV1-9) {
|
||||
return -10000 + value - GV1;
|
||||
}
|
||||
if (value < -GV1) {
|
||||
return -10000 + value + GV1 + 1;
|
||||
}
|
||||
if (value < -GV1+9) {
|
||||
return 10000 + value + GV1 + 1;
|
||||
}
|
||||
return value - shift;
|
||||
}
|
||||
|
||||
LimitField(LimitData & limit, BoardEnum board, unsigned int version):
|
||||
@@ -1746,7 +1767,10 @@ class CustomFunctionsConversionTable: public ConversionTable {
|
||||
addConversion(FuncPlayValue, val++);
|
||||
if (IS_ARM(board)) {
|
||||
addConversion(FuncReserve, val++);
|
||||
addConversion(FuncReserve, val++);
|
||||
if (IS_TARANIS(board))
|
||||
addConversion(FuncPlayScript, val++);
|
||||
else
|
||||
addConversion(FuncReserve, val++);
|
||||
addConversion(FuncReserve, val++);
|
||||
addConversion(FuncBackgroundMusic, val++);
|
||||
addConversion(FuncBackgroundMusicPause, val++);
|
||||
@@ -1887,7 +1911,7 @@ class ArmCustomFunctionField: public TransformedField {
|
||||
*((uint8_t *)(_param+3)) = fn.func - FuncSetTimer1;
|
||||
}
|
||||
}
|
||||
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) {
|
||||
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic || fn.func == FuncPlayScript) {
|
||||
memcpy(_param, fn.paramarm, sizeof(_param));
|
||||
}
|
||||
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
|
||||
@@ -1962,7 +1986,7 @@ class ArmCustomFunctionField: public TransformedField {
|
||||
fn.func = AssignFunc(fn.func + index);
|
||||
fn.param = value;
|
||||
}
|
||||
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) {
|
||||
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic || fn.func == FuncPlayScript) {
|
||||
memcpy(fn.paramarm, _param, sizeof(fn.paramarm));
|
||||
}
|
||||
else if (fn.func == FuncVolume) {
|
||||
|
||||
@@ -732,6 +732,9 @@ int OpenTxFirmware::getCapability(const Capability capability)
|
||||
return 0;
|
||||
case MavlinkTelemetry:
|
||||
return id.contains("mavlink") ? 1 : 0;
|
||||
case HasInputDiff:
|
||||
case HasMixerExpo:
|
||||
return (IS_ARM(board) ? true : false);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -234,10 +234,10 @@ CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox
|
||||
lock(false),
|
||||
lastType(-1)
|
||||
{
|
||||
curveTypeCB->addItem(tr("Diff"));
|
||||
curveTypeCB->addItem(tr("Expo"));
|
||||
curveTypeCB->addItem(tr("Func"));
|
||||
curveTypeCB->addItem(tr("Curve"));
|
||||
if (!(flags & HIDE_DIFF)) curveTypeCB->addItem(tr("Diff"), 0);
|
||||
if (!(flags & HIDE_EXPO)) curveTypeCB->addItem(tr("Expo"), 1);
|
||||
curveTypeCB->addItem(tr("Func"), 2);
|
||||
curveTypeCB->addItem(tr("Curve"), 3);
|
||||
|
||||
curveValueCB->setMaxVisibleItems(10);
|
||||
|
||||
@@ -253,10 +253,12 @@ void CurveGroup::update()
|
||||
{
|
||||
lock = true;
|
||||
|
||||
curveTypeCB->setCurrentIndex(curve.type);
|
||||
int found = curveTypeCB->findData(curve.type);
|
||||
if (found < 0) found = 0;
|
||||
curveTypeCB->setCurrentIndex(found);
|
||||
|
||||
if (curve.type == CurveReference::CURVE_REF_DIFF || curve.type == CurveReference::CURVE_REF_EXPO) {
|
||||
curveGVarCB->show();
|
||||
curveGVarCB->setVisible(GetCurrentFirmware()->getCapability(Gvars));
|
||||
if (curve.value > 100 || curve.value < -100) {
|
||||
curveGVarCB->setChecked(true);
|
||||
if (lastType != CurveReference::CURVE_REF_DIFF && lastType != CurveReference::CURVE_REF_EXPO) {
|
||||
@@ -296,11 +298,13 @@ void CurveGroup::update()
|
||||
if (lastType != curve.type) {
|
||||
lastType = curve.type;
|
||||
curveValueCB->clear();
|
||||
for (int i=-numcurves; i<=numcurves; i++) {
|
||||
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, i).toString());
|
||||
for (int i= ((flags & HIDE_NEGATIVE_CURVES) ? 0 : -numcurves); i<=numcurves; i++) {
|
||||
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, i).toString(), i);
|
||||
if (i == curve.value) {
|
||||
curveValueCB->setCurrentIndex(curveValueCB->count() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
curveValueCB->setCurrentIndex(curve.value+numcurves);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -328,7 +332,8 @@ void CurveGroup::gvarCBChanged(int state)
|
||||
void CurveGroup::typeChanged(int value)
|
||||
{
|
||||
if (!lock) {
|
||||
switch (value) {
|
||||
int type = curveTypeCB->itemData(curveTypeCB->currentIndex()).toInt();
|
||||
switch (type) {
|
||||
case 0:
|
||||
curve = CurveReference(CurveReference::CURVE_REF_DIFF, 0);
|
||||
break;
|
||||
@@ -350,7 +355,7 @@ void CurveGroup::typeChanged(int value)
|
||||
void CurveGroup::valuesChanged()
|
||||
{
|
||||
if (!lock) {
|
||||
switch (curveTypeCB->currentIndex()) {
|
||||
switch (curveTypeCB->itemData(curveTypeCB->currentIndex()).toInt()) {
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
@@ -359,14 +364,14 @@ void CurveGroup::valuesChanged()
|
||||
value = curveValueCB->itemData(curveValueCB->currentIndex()).toInt();
|
||||
else
|
||||
value = curveValueSB->value();
|
||||
curve = CurveReference(curveTypeCB->currentIndex() == 0 ? CurveReference::CURVE_REF_DIFF : CurveReference::CURVE_REF_EXPO, value);
|
||||
curve = CurveReference(curveTypeCB->itemData(curveTypeCB->currentIndex()).toInt() == 0 ? CurveReference::CURVE_REF_DIFF : CurveReference::CURVE_REF_EXPO, value);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
curve = CurveReference(CurveReference::CURVE_REF_FUNC, curveValueCB->currentIndex());
|
||||
break;
|
||||
case 3:
|
||||
curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, curveValueCB->currentIndex() - GetCurrentFirmware()->getCapability(NumCurves));
|
||||
curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, curveValueCB->itemData(curveValueCB->currentIndex()).toInt());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ class GVarGroup: public QObject {
|
||||
bool lock;
|
||||
};
|
||||
|
||||
#define HIDE_DIFF 0x01
|
||||
#define HIDE_EXPO 0x02
|
||||
#define HIDE_NEGATIVE_CURVES 0x04
|
||||
|
||||
class CurveGroup : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
@@ -470,6 +470,18 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||
}
|
||||
}
|
||||
else if (index==FuncPlayScript) {
|
||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
||||
if (modified) {
|
||||
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
|
||||
int vml = 8/*TODO*/;
|
||||
if (fswtchParamArmT[i]->currentText() != "----") {
|
||||
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) {
|
||||
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (index==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) {
|
||||
if (modified) model.funcSw[i].param = (uint8_t)fswtchBLcolor[i]->value();
|
||||
fswtchBLcolor[i]->setValue(model.funcSw[i].param);
|
||||
@@ -593,6 +605,7 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
|
||||
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
|
||||
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
|
||||
((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
|
||||
((i==FuncPlayScript && !IS_TARANIS(firmware->getBoard()))) ||
|
||||
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
|
||||
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
|
||||
((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
|
||||
@@ -670,7 +683,7 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & m
|
||||
b->setCurrentIndex(value);
|
||||
}
|
||||
else if (function==FuncVolume) {
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS);
|
||||
}
|
||||
else if (function==FuncPlayValue) {
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
|
||||
|
||||
@@ -31,7 +31,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
ui->offsetCB->hide();
|
||||
}
|
||||
|
||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve);
|
||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES));
|
||||
|
||||
populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ void HeliPanel::update()
|
||||
lock = true;
|
||||
|
||||
ui->swashTypeCB->setCurrentIndex(model.swashRingData.type);
|
||||
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
ui->swashRingValSB->setValue(model.swashRingData.value);
|
||||
ui->swashInvertELE->setChecked(model.swashRingData.invertELE);
|
||||
ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL);
|
||||
|
||||
@@ -174,7 +174,7 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
||||
}
|
||||
}
|
||||
|
||||
if (md->curve.value) str += " " + Qt::escape(md->curve.toString());
|
||||
if (md->curve.value) str += " " + md->curve.toString();
|
||||
|
||||
QString phasesStr = getPhasesStr(md->phases, model);
|
||||
if (!phasesStr.isEmpty()) str += " " + phasesStr;
|
||||
|
||||
@@ -26,7 +26,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
|
||||
|
||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, md->weight, 100, -limit, limit);
|
||||
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, md->sOffset, 0, -limit, limit);
|
||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve);
|
||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, firmware->getCapability(HasMixerExpo) ? 0 : HIDE_EXPO);
|
||||
|
||||
ui->MixDR_CB->setChecked(md->noExpo==0);
|
||||
|
||||
|
||||
@@ -122,6 +122,15 @@ qreal Node::getX()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::setX(qreal newX)
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
QGraphicsObject::setX(rect.left() + (newX+1) * rect.width()/2);
|
||||
}
|
||||
}
|
||||
|
||||
qreal Node::getY()
|
||||
{
|
||||
if(scene())
|
||||
@@ -132,6 +141,15 @@ qreal Node::getY()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::setY(qreal newY)
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
QGraphicsObject::setY(rect.top() + (newY+1) * rect.height()/2);
|
||||
}
|
||||
}
|
||||
|
||||
QList<Edge *> Node::edges() const
|
||||
{
|
||||
return edgeList;
|
||||
|
||||
@@ -72,6 +72,8 @@ class Node : public QGraphicsObject
|
||||
int getBallSize() {return ballSize;}
|
||||
qreal getX();
|
||||
qreal getY();
|
||||
void setX(qreal newX);
|
||||
void setY(qreal newX);
|
||||
|
||||
void setCenteringX(bool val) {centerX = val;}
|
||||
void setCenteringY(bool val) {centerY = val;}
|
||||
|
||||
@@ -179,6 +179,7 @@ void ModulePanel::update()
|
||||
{
|
||||
unsigned int mask = 0;
|
||||
Protocol protocol = (Protocol)module.protocol;
|
||||
unsigned int max_rx_num = 63;
|
||||
|
||||
if (moduleIdx >= 0) {
|
||||
mask |= MASK_PROTOCOL;
|
||||
@@ -195,6 +196,7 @@ void ModulePanel::update()
|
||||
case DSMX:
|
||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
|
||||
module.channelsCount = 6;
|
||||
max_rx_num = 20;
|
||||
break;
|
||||
case PPM:
|
||||
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT;
|
||||
@@ -212,6 +214,7 @@ void ModulePanel::update()
|
||||
ui->protocol->setVisible(mask & MASK_PROTOCOL);
|
||||
ui->label_rxNumber->setVisible(mask & MASK_RX_NUMBER);
|
||||
ui->rxNumber->setVisible(mask & MASK_RX_NUMBER);
|
||||
ui->rxNumber->setMaximum(max_rx_num);
|
||||
ui->rxNumber->setValue(model.modelId);
|
||||
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
|
||||
ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
|
||||
|
||||
@@ -507,16 +507,16 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>125</number>
|
||||
<number>63</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -593,7 +593,6 @@ void TelemetryPanel::setup()
|
||||
int varioCap = firmware->getCapability(HasVario);
|
||||
if (!varioCap) {
|
||||
ui->varioLimitMax_DSB->hide();
|
||||
ui->varioLimitMinOff_ChkB->hide();
|
||||
ui->varioLimitMin_DSB->hide();
|
||||
ui->varioLimitCenterMin_DSB->hide();
|
||||
ui->varioLimitCenterMax_DSB->hide();
|
||||
@@ -607,7 +606,6 @@ void TelemetryPanel::setup()
|
||||
}
|
||||
else {
|
||||
if (!firmware->getCapability(HasVarioSink)) {
|
||||
ui->varioLimitMinOff_ChkB->hide();
|
||||
ui->varioLimitMin_DSB->hide();
|
||||
ui->varioLimitCenterMin_DSB->hide();
|
||||
ui->VarioLabel_1->hide();
|
||||
@@ -616,15 +614,7 @@ void TelemetryPanel::setup()
|
||||
ui->varioLimitMin_DSB->setValue(model.frsky.varioMin-10);
|
||||
ui->varioLimitMax_DSB->setValue(model.frsky.varioMax+10);
|
||||
ui->varioLimitCenterMax_DSB->setValue((model.frsky.varioCenterMax/10.0)+0.5);
|
||||
if (model.frsky.varioCenterMin==-16) {
|
||||
ui->varioLimitMinOff_ChkB->setChecked(true);
|
||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||
ui->varioLimitCenterMin_DSB->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
ui->varioLimitMinOff_ChkB->setChecked(false);
|
||||
ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5);
|
||||
}
|
||||
ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5);
|
||||
}
|
||||
|
||||
ui->altimetryGB->setVisible(firmware->getCapability(HasAltitudeSel) || firmware->getCapability(HasVario)),
|
||||
@@ -801,24 +791,6 @@ void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
|
||||
{
|
||||
if (!lock) {
|
||||
model.frsky.varioCenterMin = -16;
|
||||
if (!checked) {
|
||||
lock=true;
|
||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||
ui->varioLimitCenterMin_DSB->setEnabled(true);
|
||||
lock=false;
|
||||
}
|
||||
else {
|
||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||
ui->varioLimitCenterMin_DSB->setDisabled(true);
|
||||
}
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
|
||||
@@ -97,7 +97,6 @@ class TelemetryPanel : public ModelPanel
|
||||
void on_varioLimitMin_DSB_editingFinished();
|
||||
void on_varioLimitMax_DSB_editingFinished();
|
||||
void on_varioLimitCenterMin_DSB_editingFinished();
|
||||
void on_varioLimitMinOff_ChkB_toggled(bool checked);
|
||||
void on_varioLimitCenterMax_DSB_editingFinished();
|
||||
void on_fasOffset_DSB_editingFinished();
|
||||
void on_mahCount_SB_editingFinished();
|
||||
|
||||
@@ -281,10 +281,10 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2.000000000000000</double>
|
||||
<double>-2.100000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>0.000000000000000</double>
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
@@ -363,19 +363,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="varioLimitMinOff_ChkB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="VarioLabel_2">
|
||||
<property name="sizePolicy">
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>No Radio was found!</p><p>Make sure that you hold the lower trim buttons towards the center while you turn it on.</p><p>Then connect the USB wire.</p></body></html></string>
|
||||
<string><html><head/><body><p>No Radio was found!</p><p>Make sure that you hold the lower trim buttons towards the center while you turn it on.</p><p>Then connect the USB wire.</p><p><span style=" font-family:'arial,sans-serif'; font-size:13px; font-style:italic; color:#222222; background-color:#ffffff;">Note: if you have a Taranis that has not had the firmware upgraded to 2.0 then this version of Companion will not work.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
|
||||
@@ -137,8 +137,9 @@ void joystickDialog::on_okButton_clicked() {
|
||||
QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8};
|
||||
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
||||
int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1;
|
||||
int stick=cb->currentIndex();
|
||||
if (stick > 0) {
|
||||
int stick=cb->currentIndex() - 1;
|
||||
qDebug() << "joystick mapping " << cb->objectName() <<"axe:" << axe << "stick:" << stick;
|
||||
if (stick >= 0) {
|
||||
g.joystick[stick].stick_axe( axe );
|
||||
g.joystick[stick].stick_max( jscal[axe][2] );
|
||||
g.joystick[stick].stick_med( jscal[axe][1] );
|
||||
|
||||
@@ -298,7 +298,7 @@ void SimulatorDialog::initUi(T * ui)
|
||||
for (int j=0; j<8; j++){
|
||||
int axe = g.joystick[j].stick_axe();
|
||||
if (axe>=0 && axe<8) {
|
||||
jsmap[axe]=j;
|
||||
jsmap[axe]=j+1;
|
||||
jscal[axe][0] = g.joystick[j].stick_min();
|
||||
jscal[axe][1] = g.joystick[j].stick_med();
|
||||
jscal[axe][2] = g.joystick[j].stick_max();
|
||||
@@ -987,37 +987,28 @@ void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value)
|
||||
if (jscal[axis][3]==1) {
|
||||
stickval*=-1;
|
||||
}
|
||||
if (stick==1 || stick==2) {
|
||||
float currX=nodeRight->getX();
|
||||
float currY=nodeRight->getY();
|
||||
if (stick==1 ) {
|
||||
nodeRight->setPos(currX*100-10,-stickval*100/1024-10);
|
||||
}
|
||||
if (stick==2) {
|
||||
nodeRight->setPos(stickval*100/1024-10,currY*100-10);
|
||||
}
|
||||
}
|
||||
else if (stick==3 || stick==4) {
|
||||
float currX=nodeLeft->getX();
|
||||
float currY=nodeLeft->getY();
|
||||
if (stick==3) {
|
||||
nodeLeft->setPos(currX*100-10,-stickval*100/1024-10);
|
||||
}
|
||||
if (stick==4) {
|
||||
nodeLeft->setPos(stickval*100/1024-10,currY*100-10);
|
||||
}
|
||||
}
|
||||
|
||||
if (stick==5) {
|
||||
if (stick==1 ) {
|
||||
nodeRight->setY(-stickval/1024.0);
|
||||
}
|
||||
else if (stick==2) {
|
||||
nodeRight->setX(stickval/1024.0);
|
||||
}
|
||||
else if (stick==3) {
|
||||
nodeLeft->setY(-stickval/1024.0);
|
||||
}
|
||||
else if (stick==4) {
|
||||
nodeLeft->setX(stickval/1024.0);
|
||||
}
|
||||
else if (stick==5) {
|
||||
dialP_1->setValue(stickval);
|
||||
}
|
||||
if (stick==6) {
|
||||
else if (stick==6) {
|
||||
dialP_2->setValue(stickval);
|
||||
}
|
||||
if (stick==7) {
|
||||
else if (stick==7) {
|
||||
dialP_3->setValue(stickval);
|
||||
}
|
||||
if (stick==8 && dialP_4) {
|
||||
else if (stick==8 && dialP_4) {
|
||||
dialP_4->setValue(stickval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,34 @@
|
||||
<h2>Version 2.0.13 / 2014-11-20</h2>
|
||||
[Taranis]
|
||||
<ul>
|
||||
<li>Compilation with -Os instead of -O2 because of a strange bug on LS1 (AND condition changed by itself on SD error)</li>
|
||||
<li>Lua getTimer and setTimer parameters fixed (persistent and minuteBeep)</li>
|
||||
<li>Lua resetTimer function added</li>
|
||||
<li>SWR shown on newer Taranis+</li>
|
||||
<li>BOLD, CONDENSED, FIXED constants exported to Lua</li>
|
||||
<li>Disable mixer line that uses a Lua source if the Lua script is not running</li>
|
||||
<li>Additional parameters for Lua model.getMix/insertMix</li>
|
||||
<li>Fixed occasional SD card error</li>
|
||||
<li>Fixed bitmap loading</li>
|
||||
</ul>
|
||||
|
||||
[9XR-PRO]
|
||||
<ul>
|
||||
<li>Coprocessor interface bugfix</li>
|
||||
</ul>
|
||||
|
||||
[Stock]
|
||||
<ul>
|
||||
<li>Fixed never ending haptic repeat</li>
|
||||
<li>Fixed curves display</li>
|
||||
</ul>
|
||||
|
||||
[All]
|
||||
<ul>
|
||||
<li>Stick icons missing next to trim key states on switch diag page</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Version 2.0.12 / 2014-09-16</h2>
|
||||
[Taranis]
|
||||
<ul>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <CoOS.h>
|
||||
|
||||
|
||||
#define OsSchedLock() OSSchedLock++; /*!< Lock schedule */
|
||||
#define OsSchedLock() { OSSchedLock++; asm volatile ("" : : : "memory"); } /*!< Lock schedule */
|
||||
extern void OsSchedUnlock(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FatFs Module Source Files R0.09b (C)ChaN, 2013
|
||||
FatFs Module Source Files R0.10c (C)ChaN, 2014
|
||||
|
||||
|
||||
FILES
|
||||
@@ -24,7 +24,7 @@ AGREEMENTS
|
||||
small embedded systems. This is a free software and is opened for education,
|
||||
research and commercial developments under license policy of following trems.
|
||||
|
||||
Copyright (C) 2012, ChaN, all right reserved.
|
||||
Copyright (C) 2014, ChaN, all right reserved.
|
||||
|
||||
* The FatFs module is a free software and there is NO WARRANTY.
|
||||
* No restriction on use. You can use, modify and redistribute it for
|
||||
@@ -134,5 +134,30 @@ REVISION HISTORY
|
||||
Changed f_open() and f_opendir() reject null object pointer to avoid crash.
|
||||
Changed option name _FS_SHARE to _FS_LOCK.
|
||||
|
||||
Jan 23,'13 R0.09b Added f_getlabel() and f_setlabel(). (_USE_LABEL == 1)
|
||||
Jan 23,'13 R0.09b Added f_getlabel() and f_setlabel(). (_USE_LABEL)
|
||||
|
||||
Oct 02,'13 R0.10 Added selection of character encoding on the file. (_STRF_ENCODE)
|
||||
Added f_closedir().
|
||||
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
|
||||
Added forced mount feature with changes of f_mount().
|
||||
Improved behavior of volume auto detection.
|
||||
Improved write throughput of f_puts() and f_printf().
|
||||
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code.
|
||||
|
||||
Jan 15,'14 R0.10a Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||
Added a configuration option of minimum sector size. (_MIN_SS)
|
||||
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||
Fixed f_mount() with forced mount fails when drive number is >= 1.
|
||||
Fixed f_close() invalidates the file object without volume lock.
|
||||
Fixed f_closedir() returns but the volume lock is left acquired.
|
||||
Fixed creation of an entry with LFN fails on too many SFN collisions.
|
||||
|
||||
Mar 19,'14 R0.10b Fixed a hard error in the disk I/O layer can collapse the directory entry.
|
||||
Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN.
|
||||
|
||||
Nov 09,'14 R0.10c Added a configuration option for the platforms without RTC. (_FS_NORTC)
|
||||
Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel().
|
||||
Fixed a potential problem of FAT access that can appear on disk error.
|
||||
Fixed null pointer dereference on attempting to delete the root direcotry.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------------------------------------
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2013
|
||||
/*-----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2014 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
@@ -34,12 +34,13 @@ typedef enum {
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
@@ -47,14 +48,14 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
|
||||
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
|
||||
|
||||
/* Generic command (not used by FatFs) */
|
||||
/* Generic command (Not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7 /* Eject media */
|
||||
@@ -72,15 +73,6 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
#define ATA_GET_MODEL 21 /* Get model name */
|
||||
#define ATA_GET_SN 22 /* Get serial number */
|
||||
|
||||
|
||||
/* MMC card type flags (MMC_GET_TYPE) */
|
||||
#define CT_MMC 0x01 /* MMC ver 3 */
|
||||
#define CT_SD1 0x02 /* SD ver 1 */
|
||||
#define CT_SD2 0x04 /* SD ver 2 */
|
||||
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
|
||||
#define CT_BLOCK 0x08 /* Block addressing */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.09b (C)ChaN, 2013
|
||||
/ FatFs - FAT file system module include file R0.10c (C)ChaN, 2014
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||
/ This is a free software that opened for education, research and commercial
|
||||
/ developments under license policy of following terms.
|
||||
/
|
||||
/ Copyright (C) 2013, ChaN, all right reserved.
|
||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
@@ -15,7 +15,7 @@
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FATFS
|
||||
#define _FATFS 82786 /* Revision ID */
|
||||
#define _FATFS 80376 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -23,7 +23,6 @@ extern "C" {
|
||||
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if _FATFS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
@@ -43,7 +42,7 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
|
||||
#else /* Single partition configuration */
|
||||
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
|
||||
#define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */
|
||||
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,7 +52,7 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
|
||||
#if _LFN_UNICODE /* Unicode string */
|
||||
#if !_USE_LFN
|
||||
#error _LFN_UNICODE must be 0 in non-LFN cfg.
|
||||
#error _LFN_UNICODE must be 0 at non-LFN cfg.
|
||||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
typedef WCHAR TCHAR;
|
||||
@@ -78,12 +77,12 @@ typedef struct {
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
BYTE n_fats; /* Number of FAT copies (1,2) */
|
||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||
BYTE n_fats; /* Number of FAT copies (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
#if _MAX_SS != 512
|
||||
#if _MAX_SS != _MIN_SS
|
||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if _FS_REENTRANT
|
||||
@@ -92,19 +91,18 @@ typedef struct {
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
DWORD fsi_sector; /* fsinfo sector (FAT32) */
|
||||
#endif
|
||||
#if _FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
|
||||
DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
|
||||
DWORD fsize; /* Sectors per FAT */
|
||||
DWORD volbase; /* Volume start sector */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
@@ -114,25 +112,25 @@ typedef struct {
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE pad1;
|
||||
DWORD fptr; /* File read/write pointer (0ed on file open) */
|
||||
BYTE flag; /* Status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter */
|
||||
DWORD dsect; /* Current data sector of fpter */
|
||||
DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
|
||||
DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
|
||||
DWORD dir_sect; /* Sector number containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File data read/write buffer */
|
||||
BYTE buf[_MAX_SS]; /* File private data read/write window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
@@ -149,6 +147,9 @@ typedef struct {
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
@@ -203,38 +204,39 @@ typedef enum {
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_mount (BYTE vol, FATFS* fs); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_opendir (DIR* dj, const TCHAR* path); /* Open an existing directory */
|
||||
FRESULT f_readdir (DIR* dj, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a new directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_chdrive (BYTE drv); /* Change current drive */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_mkfs (BYTE vol, BYTE sfd, UINT au); /* Create a file system on the drive */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
|
||||
@@ -249,7 +251,7 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
||||
/* Additional user defined functions */
|
||||
|
||||
/* RTC function */
|
||||
#if !_FS_READONLY
|
||||
#if !_FS_READONLY && !_FS_NORTC
|
||||
DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
@@ -282,7 +284,6 @@ int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#define FA__ERROR 0x80
|
||||
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.09b (C)ChaN, 2013
|
||||
/----------------------------------------------------------------------------/
|
||||
/
|
||||
/ CAUTION! Do not forget to make clean the project after any changes to
|
||||
/ the configuration options.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 82786 /* Revision ID */
|
||||
/ FatFs - FAT file system module configuration file R0.10c (C)ChaN, 2014
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FFCONF 80376 /* Revision ID */
|
||||
|
||||
#if defined(CPUARM) && !defined(SIMU)
|
||||
#ifdef __cplusplus
|
||||
@@ -21,69 +16,82 @@ extern "C" {
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
|
||||
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
|
||||
/ object instead of the sector buffer in the individual file object for file
|
||||
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
||||
|
||||
#if defined(BOOT)
|
||||
#define _FS_READONLY 1 /* 0:Read/Write or 1:Read only */
|
||||
#define _FS_READONLY 1 /* 0:Read/Write or 1:Read only */
|
||||
#else
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
#endif
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate and useless f_getfree. */
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes basic writing API functions, f_write(),
|
||||
/ f_sync(), f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(),
|
||||
/ f_getfree() and optional writing functions as well. */
|
||||
|
||||
|
||||
#if defined(BOOT)
|
||||
#define _FS_MINIMIZE 1 /* 0 to 3 */
|
||||
#define _FS_MINIMIZE 1 /* 0 to 3 */
|
||||
#else
|
||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||
#endif
|
||||
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
||||
/* This option defines minimization level to remove some API functions.
|
||||
/
|
||||
/ 0: Full function.
|
||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
|
||||
/ are removed.
|
||||
/ 2: f_opendir and f_readdir are removed in addition to 1.
|
||||
/ 3: f_lseek is removed in addition to 2. */
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#if defined(BOOT)
|
||||
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
|
||||
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
|
||||
#else
|
||||
#define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */
|
||||
#define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */
|
||||
#endif
|
||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
|
||||
#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
|
||||
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
||||
#define _USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_READONLY need to be set to 0. */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_LABEL 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable volume label functions, set _USE_LAVEL to 1 */
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
||||
/* To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 1252
|
||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
|
||||
/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows)
|
||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
||||
/ 949 - Korean (DBCS, OEM, Windows)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
||||
@@ -108,8 +116,8 @@ extern "C" {
|
||||
/ 857 - Turkish (OEM)
|
||||
/ 862 - Hebrew (OEM)
|
||||
/ 874 - Thai (OEM, Windows)
|
||||
/ 1 - ASCII only (Valid for non LFN cfg.)
|
||||
*/
|
||||
/ 1 - ASCII (No extended character. Valid for only non-LFN configuration.) */
|
||||
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define _USE_LFN 2 /* 0 to 3 */
|
||||
@@ -118,83 +126,130 @@ extern "C" {
|
||||
#define _USE_LFN 1 /* 0 to 3 */
|
||||
#define _MAX_LFN 32 /* Maximum LFN length to handle (12 to 255) */
|
||||
#endif
|
||||
|
||||
/* The _USE_LFN option switches the LFN support.
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. To enable LFN,
|
||||
/ Unicode handling functions ff_convert() and ff_wtoupper() must be added
|
||||
/ to the project. When enable to use heap, memory control functions
|
||||
/ ff_memalloc() and ff_memfree() must be added to the project. */
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
|
||||
/* To switch the character code set on FatFs API to Unicode,
|
||||
/ enable LFN feature and set _LFN_UNICODE to 1. */
|
||||
#define _LFN_UNICODE 0
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
|
||||
#define _FS_RPATH 2 /* 0 to 2 */
|
||||
/* The _FS_RPATH option configures relative path feature.
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 2
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path. f_chdrive() and f_chdir() are available.
|
||||
/ 2: f_getcwd() is available in addition to 1.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that output of the f_readdir fnction is affected by this option. */
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Physical Drive Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */
|
||||
/* Maximum sector size to be handled.
|
||||
/ Always set 512 for memory card and hard disk but a larger value may be
|
||||
/ required for on-board flash memory, floppy disk and optical disk.
|
||||
/ When _MAX_SS is larger than 512, it configures FatFs to variable sector size
|
||||
/ and GET_SECTOR_SIZE command must be implememted to the disk_ioctl function. */
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */
|
||||
/* When set to 0, each volume is bound to the same physical drive number and
|
||||
/ it can mount only first primaly partition. When it is set to 1, each volume
|
||||
/ is tied to the partitions listed in VolToPart[]. */
|
||||
#define _MULTI_PARTITION 0
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be enabled. */
|
||||
|
||||
|
||||
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable sector erase feature, set _USE_ERASE to 1. CTRL_ERASE_SECTOR command
|
||||
/ should be added to the disk_ioctl functio. */
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _WORD_ACCESS 0 /* 0 or 1 */
|
||||
/* Set 0 first and it is always compatible with all platforms. The _WORD_ACCESS
|
||||
/ option defines which access method is used to the word data on the FAT volume.
|
||||
#define _FS_NORTC 0
|
||||
#define _NORTC_MON 11
|
||||
#define _NORTC_MDAY 9
|
||||
#define _NORTC_YEAR 2014
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
|
||||
#define _FS_LOCK 0
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Byte-by-byte access.
|
||||
/ 1: Word access. Do not choose this unless following condition is met.
|
||||
/
|
||||
/ When the byte order on the memory is big-endian or address miss-aligned word
|
||||
/ access results incorrect behavior, the _WORD_ACCESS must be set to 0.
|
||||
/ If it is not the case, the value can also be set to 1 to improve the
|
||||
/ performance and code size.
|
||||
*/
|
||||
|
||||
|
||||
/* A header file that defines sync object types on the O/S, such as
|
||||
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
#if defined(CPUARM) && !defined(BOOT)
|
||||
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
|
||||
@@ -203,19 +258,45 @@ extern "C" {
|
||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||
#endif
|
||||
|
||||
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||
#define _FS_TIMEOUT 1000
|
||||
|
||||
/* The _FS_REENTRANT option switches the reentrancy (thread safe) of the FatFs module.
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable reentrancy. _SYNC_t and _FS_TIMEOUT have no effect.
|
||||
/ 1: Enable reentrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj
|
||||
/ function must be added to the project. */
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. */
|
||||
|
||||
|
||||
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
|
||||
/* To enable file lock control feature, set _FS_LOCK to 1 or greater.
|
||||
The value defines how many files can be opened simultaneously. */
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 8051 0/1
|
||||
*/
|
||||
|
||||
|
||||
#endif /* _FFCONFIG */
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _INTEGER
|
||||
#define _INTEGER
|
||||
#ifndef _FF_INTEGER
|
||||
#define _FF_INTEGER
|
||||
|
||||
#ifdef _WIN32 /* FatFs development platform */
|
||||
|
||||
@@ -12,24 +12,20 @@
|
||||
|
||||
#else /* Embedded platform */
|
||||
|
||||
/* These types must be 16-bit, 32-bit or larger integer */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types must be 8-bit integer */
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
/* This type MUST be 8 bit */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types must be 16-bit integer */
|
||||
/* These types MUST be 16 bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types must be 32-bit integer */
|
||||
/* These types MUST be 16 bit or 32 bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types MUST be 32 bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3739,10 +3739,10 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
#if !_TINY_TABLE
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
p = sjis2uni;
|
||||
hi = sizeof(sjis2uni) / 4 - 1;
|
||||
hi = sizeof sjis2uni / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
p = uni2sjis;
|
||||
hi = sizeof(uni2sjis) / 4 - 1;
|
||||
hi = sizeof uni2sjis / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
@@ -3764,7 +3764,7 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
p -= 3;
|
||||
c = *p;
|
||||
} else { /* Unicode to OEMCP */
|
||||
li = 0; hi = sizeof(uni2sjis) / 4 - 1;
|
||||
li = 0; hi = sizeof uni2sjis / 4 - 1;
|
||||
for (n = 16; n; n--) {
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == uni2sjis[i * 2]) break;
|
||||
|
||||
@@ -10936,10 +10936,10 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
} else {
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
p = oem2uni;
|
||||
hi = sizeof(oem2uni) / 4 - 1;
|
||||
hi = sizeof oem2uni / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
p = uni2oem;
|
||||
hi = sizeof(uni2oem) / 4 - 1;
|
||||
hi = sizeof uni2oem / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
|
||||
@@ -8565,10 +8565,10 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
} else {
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
p = oem2uni;
|
||||
hi = sizeof(oem2uni) / 4 - 1;
|
||||
hi = sizeof oem2uni / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
p = uni2oem;
|
||||
hi = sizeof(uni2oem) / 4 - 1;
|
||||
hi = sizeof uni2oem / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
|
||||
@@ -6791,10 +6791,10 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
} else {
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
p = oem2uni;
|
||||
hi = sizeof(oem2uni) / 4 - 1;
|
||||
hi = sizeof oem2uni / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
p = uni2oem;
|
||||
hi = sizeof(uni2oem) / 4 - 1;
|
||||
hi = sizeof uni2oem / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
|
||||
@@ -444,7 +444,7 @@ const WCHAR Tbl[] = { /* CP1256(0x80-0xFF) to Unicode conversion table */
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
|
||||
0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
|
||||
0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2
|
||||
}
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 1257
|
||||
#define _TBLDEF 1
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Sample code of OS dependent controls for FatFs */
|
||||
/* (C)ChaN, 2012 */
|
||||
/* (C)ChaN, 2014 */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h> /* ANSI memory controls */
|
||||
#include <malloc.h> /* ANSI memory controls */
|
||||
|
||||
#include "../ff.h"
|
||||
|
||||
@@ -13,33 +11,30 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Synchronization Object
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to create a new
|
||||
/ synchronization object, such as semaphore and mutex. When a FALSE is
|
||||
/ returned, the f_mount function fails with FR_INT_ERR.
|
||||
/* This function is called in f_mount() function to create a new
|
||||
/ synchronization object, such as semaphore and mutex. When a 0 is returned,
|
||||
/ the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any error */
|
||||
int ff_cre_syncobj ( /* !=0:Function succeeded, ==0:Could not create due to any error */
|
||||
BYTE vol, /* Corresponding logical drive being processed */
|
||||
_SYNC_t *sobj /* Pointer to return the created sync object */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
// static _SYNC_t sem[_VOLUMES]; /* FreeRTOS */
|
||||
|
||||
|
||||
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
|
||||
ret = (*sobj != INVALID_HANDLE_VALUE);
|
||||
ret = (int)(*sobj != INVALID_HANDLE_VALUE);
|
||||
|
||||
// *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */
|
||||
// ret = 1; /* The initial value of the semaphore must be 1. */
|
||||
// *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */
|
||||
// ret = 1; /* The initial value of the semaphore must be 1. */
|
||||
|
||||
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
||||
// ret = (err == OS_NO_ERR);
|
||||
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// if (!sem[vol]) /* FreeRTOS */
|
||||
// sem[vol] = xSemaphoreCreateMutex();
|
||||
// *sobj = sem[vol];
|
||||
// ret = (*sobj != NULL);
|
||||
// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
|
||||
// ret = (int)(*sobj != NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -49,12 +44,12 @@ int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any erro
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount function to delete a synchronization
|
||||
/ object that created with ff_cre_syncobj function. When a FALSE is
|
||||
/ returned, the f_mount function fails with FR_INT_ERR.
|
||||
/* This function is called in f_mount() function to delete a synchronization
|
||||
/ object that created with ff_cre_syncobj function. When a 0 is returned,
|
||||
/ the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */
|
||||
int ff_del_syncobj ( /* !=0:Function succeeded, ==0:Could not delete due to any error */
|
||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
||||
)
|
||||
{
|
||||
@@ -66,9 +61,10 @@ int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any erro
|
||||
// ret = 1; /* uITRON (nothing to do) */
|
||||
|
||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
|
||||
// ret = (err == OS_NO_ERR);
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// ret = 1; /* FreeRTOS (nothing to do) */
|
||||
// vSemaphoreDelete(sobj); /* FreeRTOS */
|
||||
// ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -79,23 +75,23 @@ int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any erro
|
||||
/* Request Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on entering file functions to lock the volume.
|
||||
/ When a FALSE is returned, the file function fails with FR_TIMEOUT.
|
||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
|
||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
||||
_SYNC_t sobj /* Sync object to wait */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
|
||||
ret = (int)(WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
|
||||
|
||||
// ret = (wai_sem(sobj) == E_OK); /* uITRON */
|
||||
// ret = (int)(wai_sem(sobj) == E_OK); /* uITRON */
|
||||
|
||||
// OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */
|
||||
// ret = (err == OS_NO_ERR);
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// ret = (xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
|
||||
// ret = (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -137,7 +133,7 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
return malloc(msize);
|
||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +145,7 @@ void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free */
|
||||
)
|
||||
{
|
||||
free(mblock);
|
||||
free(mblock); /* Discard the memory block with POSIX API */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
#if _USE_LFN != 0
|
||||
|
||||
#if _CODE_PAGE == 932
|
||||
#if _CODE_PAGE == 932 /* Japanese Shift_JIS */
|
||||
#include "cc932.c"
|
||||
#elif _CODE_PAGE == 936
|
||||
#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
|
||||
#include "cc936.c"
|
||||
#elif _CODE_PAGE == 949
|
||||
#elif _CODE_PAGE == 949 /* Korean */
|
||||
#include "cc949.c"
|
||||
#elif _CODE_PAGE == 950
|
||||
#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
|
||||
#include "cc950.c"
|
||||
#else
|
||||
#else /* Small character-set */
|
||||
#include "ccsbcs.c"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -252,6 +252,10 @@ EEPROM_PROGRESS_BAR = NO
|
||||
# Values = YES, NO
|
||||
DEBUG = NO
|
||||
|
||||
# Activate writing of SPORT telemetry received data to sport.log file
|
||||
# Values = YES, NO
|
||||
SPORT_FILE_LOG = NO
|
||||
|
||||
# Flight Modes
|
||||
# Values = YES, NO
|
||||
FLIGHT_MODES = YES
|
||||
@@ -293,6 +297,16 @@ CHANNELS_MONITOR_INV_HIDE = NO
|
||||
# Values = NO, YES
|
||||
NANO = NO
|
||||
|
||||
# Enable trace of events into Trace Buffer for debugging purposes
|
||||
# Activating any of these options also activates DEBUG and DEBUG_TRACE_BUFFER
|
||||
# Values = NO, YES
|
||||
# TRACE_SD_CARD SD card operations (read, write, etc)
|
||||
# TRACE_FATFS FatFs file operations
|
||||
# TRACE_AUDIO Audio processing (not yet implemented)
|
||||
TRACE_SD_CARD = NO
|
||||
TRACE_FATFS = NO
|
||||
TRACE_AUDIO = NO
|
||||
|
||||
#------- END BUILD OPTIONS ---------------------------
|
||||
|
||||
# Define programs and commands.
|
||||
@@ -300,13 +314,14 @@ SHELL = sh
|
||||
IMG2LBM = -python ../util/img2lbm.py
|
||||
BIN2LBM = -python ../util/bin2lbm.py
|
||||
TRANSLATE = -python ../util/translate.py
|
||||
VERSION = 2.0.12
|
||||
VERSION = 2.0.13
|
||||
|
||||
SRC =
|
||||
CPPSRC =
|
||||
INCDIRS = . translations
|
||||
EXTRAINCDIRS =
|
||||
LUADEP =
|
||||
DEBUG_TRACE_BUFFER = NO
|
||||
|
||||
# MCU name
|
||||
ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X 9XRPRO TARANIS))
|
||||
@@ -389,7 +404,7 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
|
||||
ARCH = AVR
|
||||
TRGT = avr-
|
||||
MCU = atmega128
|
||||
OPT = 2
|
||||
OPT = s
|
||||
SDCARD = NO
|
||||
THR_TRACE = NO
|
||||
EEPROM_VARIANT += ${M128_VARIANT}
|
||||
@@ -449,7 +464,7 @@ ifeq ($(PCB), $(filter $(PCB), 9X2561))
|
||||
ARCH = AVR
|
||||
TRGT = avr-
|
||||
MCU = atmega2561
|
||||
OPT = 2
|
||||
OPT = s
|
||||
SDCARD = NO
|
||||
THR_TRACE = YES
|
||||
EEPROM_VARIANT += ${M2561_VARIANT}
|
||||
@@ -510,7 +525,7 @@ ifeq ($(PCB), GRUVIN9X)
|
||||
endif
|
||||
TRGT = avr-
|
||||
MCU = atmega2560
|
||||
OPT = 2
|
||||
OPT = s
|
||||
CPPDEFS += -DF_CPU=$(F_CPU)UL -DPCBGRUVIN9X -DCPUM2560 -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC
|
||||
SDCARD = NO
|
||||
BUZZER = NO
|
||||
@@ -550,7 +565,7 @@ ifeq ($(PCB), MEGA2560)
|
||||
ARCH = AVR
|
||||
TRGT = avr-
|
||||
MCU = atmega2560
|
||||
OPT = 2
|
||||
OPT = s
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBMEGA2560 -DCPUM2560 -DEEPROM_VARIANT=0 -DAUDIO -DRTCLOCK
|
||||
SDCARD = YES
|
||||
THR_TRACE = YES
|
||||
@@ -596,7 +611,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
||||
endif
|
||||
TRGT = arm-none-eabi-
|
||||
MCU = cortex-m3
|
||||
OPT = 2
|
||||
OPT = s
|
||||
SDCARD = YES
|
||||
BUZZER = NO
|
||||
THR_TRACE = YES
|
||||
@@ -605,6 +620,9 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
||||
CPPDEFS += -DROTARY_ENCODERS=1
|
||||
CPPSRC += targets/sky9x/rotenc_driver.cpp
|
||||
endif
|
||||
ifeq ($(SPORT_FILE_LOG), YES)
|
||||
CPPDEFS += -DSPORT_FILE_LOG
|
||||
endif
|
||||
INCDIRS += targets/sky9x CoOS/kernel CoOS/portable
|
||||
BOARDSRC = targets/sky9x/board_sky9x.cpp
|
||||
EXTRABOARDSRC = targets/sky9x/lcd_driver.cpp
|
||||
@@ -620,31 +638,26 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
||||
CPPSRC += audio_arm.cpp haptic.cpp gui/view_about.cpp gui/view_text.cpp
|
||||
CPPSRC += targets/sky9x/telemetry_driver.cpp targets/sky9x/second_serial_driver.cpp targets/sky9x/pwr_driver.cpp targets/sky9x/adc_driver.cpp targets/sky9x/eeprom_driver.cpp targets/sky9x/pulses_driver.cpp targets/sky9x/keys_driver.cpp targets/sky9x/audio_driver.cpp targets/sky9x/buzzer_driver.cpp targets/sky9x/haptic_driver.cpp targets/sky9x/sdcard_driver.cpp targets/sky9x/massstorage.cpp
|
||||
CPPSRC += loadboot.cpp
|
||||
|
||||
ifeq ($(SDCARD), YES)
|
||||
CPPDEFS += -DVOICE
|
||||
INCDIRS += FatFs FatFs/option
|
||||
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/sky9x/diskio.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(BUZZER), YES)
|
||||
CPPDEFS += -DBUZZER
|
||||
CPPSRC += buzzer.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(RTCLOCK), YES)
|
||||
CPPDEFS += -DRTCLOCK
|
||||
CPPSRC += rtc.cpp targets/sky9x/rtc_driver.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(BLUETOOTH), YES)
|
||||
CPPDEFS += -DBLUETOOTH
|
||||
CPPSRC += targets/sky9x/bluetooth.cpp
|
||||
CPPDEFS += -DBLUETOOTH
|
||||
CPPSRC += targets/sky9x/bluetooth.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), YES)
|
||||
CPPSRC += debug.cpp
|
||||
SRC += targets/sky9x/syscalls.c
|
||||
SRC += targets/sky9x/syscalls.c
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -661,10 +674,31 @@ ifeq ($(PCB), TARANIS)
|
||||
else
|
||||
CPPDEFS = -DREV4
|
||||
endif
|
||||
ifeq ($(SPORT_FILE_LOG), YES)
|
||||
CPPDEFS += -DSPORT_FILE_LOG
|
||||
endif
|
||||
ifeq ($(TRACE_SD_CARD), YES)
|
||||
DEBUG = YES
|
||||
DEBUG_TRACE_BUFFER = YES
|
||||
CPPDEFS += -DTRACE_SD_CARD
|
||||
endif
|
||||
ifeq ($(TRACE_FATFS), YES)
|
||||
DEBUG = YES
|
||||
DEBUG_TRACE_BUFFER = YES
|
||||
CPPDEFS += -DTRACE_FATFS
|
||||
endif
|
||||
ifeq ($(TRACE_AUDIO), YES)
|
||||
DEBUG = YES
|
||||
DEBUG_TRACE_BUFFER = YES
|
||||
CPPDEFS += -DTRACE_AUDIO
|
||||
endif
|
||||
ifeq ($(DEBUG_TRACE_BUFFER), YES)
|
||||
CPPDEFS += -DDEBUG_TRACE_BUFFER
|
||||
endif
|
||||
LDSCRIPT = targets/taranis/stm32_flash_bl.ld
|
||||
TRGT = arm-none-eabi-
|
||||
MCU = cortex-m3
|
||||
OPT = 2
|
||||
OPT = s
|
||||
CPPDEFS += -DHSE_VALUE=12000000
|
||||
SDCARD = YES
|
||||
THR_TRACE = YES
|
||||
@@ -721,13 +755,11 @@ ifeq ($(PCB), TARANIS)
|
||||
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
|
||||
EXTRABOARDSRC += targets/taranis/usbd_storage_msd.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(NANO), YES)
|
||||
# use newlib-nano for linking
|
||||
NEWLIB_NANO_FLAGS = --specs=nano.specs -u _printf_float
|
||||
CPPDEFS += -DNANO
|
||||
endif
|
||||
|
||||
ifneq ($(LUA), NO)
|
||||
ifeq ($(LUA), YES)
|
||||
CPPDEFS += -DLUA_MODEL_SCRIPTS
|
||||
@@ -741,42 +773,34 @@ ifeq ($(PCB), TARANIS)
|
||||
SRC += $(LUASRC)
|
||||
LUADEP = lua_exports.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(SDCARD), YES)
|
||||
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/taranis/diskio.cpp
|
||||
CPPDEFS += -DVOICE
|
||||
INCDIRS += FatFs FatFs/option
|
||||
endif
|
||||
|
||||
ifeq ($(RTCLOCK), YES)
|
||||
CPPDEFS += -DRTCLOCK
|
||||
CPPSRC += rtc.cpp targets/taranis/rtc_driver.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), YES)
|
||||
CPPSRC += debug.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(DSM2), PPM)
|
||||
CPPSRC += pulses/dsm2_arm.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(HUBSAN), YES)
|
||||
CPPDEFS += -DHUBSAN
|
||||
CPPSRC += pulses/hubsan.cpp
|
||||
CPPSRC += targets/taranis/a7105_driver.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(HAPTIC), YES)
|
||||
CPPDEFS += -DHAPTIC
|
||||
CPPSRC += haptic.cpp
|
||||
CPPSRC += targets/taranis/haptic_driver.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(CHANNELS_MONITOR_INV_HIDE), YES)
|
||||
CPPDEFS += -DCHANNELS_MONITOR_INV_HIDE
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
CC = $(TRGT)gcc
|
||||
@@ -979,7 +1003,7 @@ endif
|
||||
ifeq ($(EXT), $(filter $(EXT), FRSKY FRSKY_SPORT TELEMETREZ))
|
||||
CPPDEFS += -DFRSKY
|
||||
ifeq ($(EXT), FRSKY_SPORT)
|
||||
CPPSRC += telemetry/frsky.cpp telemetry/frsky_sport.cpp telemetry/frsky_d.cpp
|
||||
CPPSRC += telemetry/frsky.cpp telemetry/frsky_sport.cpp telemetry/frsky_d.cpp
|
||||
CPPDEFS += -DFRSKY_SPORT
|
||||
else
|
||||
CPPSRC += telemetry/frsky.cpp telemetry/frsky_d.cpp
|
||||
@@ -1113,6 +1137,7 @@ CPPFLAGS += $(CPPDEFS)
|
||||
CPPFLAGS += -Wall
|
||||
CPPFLAGS += -fno-exceptions
|
||||
CPPFLAGS += -Wno-strict-aliasing
|
||||
CPPFLAGS += -Wformat -Wreturn-type -Wunused -Wuninitialized -Wunknown-pragmas -Wno-switch -Wtype-limits
|
||||
INCFLAGS = $(patsubst %,-I%,$(INCDIRS))
|
||||
EXTRAINCFLAGS = $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||
|
||||
@@ -1285,9 +1310,15 @@ bitmaps/sticks.lbm: bitmaps/sticks_4x1.xbm bitmaps/splash_9x.xbm bitmaps/splash_
|
||||
$(IMG2LBM) bitmaps/about_9x.png bitmaps/about_9x.lbm img
|
||||
$(IMG2LBM) bitmaps/asterisk_4bits.png bitmaps/asterisk_4bits.lbm bmp
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PARSER = avr-cpp
|
||||
else
|
||||
PARSER = gcc -E -x c++
|
||||
endif
|
||||
|
||||
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
|
||||
@$(PARSER) -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 $(VERSION) lua_exports.txt lua_exports.cpp lua_fields.txt
|
||||
@rm lua_exports.txt
|
||||
@@ -1390,7 +1421,7 @@ ifeq ($(ARCH), AVR)
|
||||
$(CC) $(AVRCPPFLAGS) $< --output $@ $(LDFLAGS)
|
||||
else
|
||||
%.o: %.c
|
||||
$(CC) $(ARMCPPFLAGS) $< -o $@
|
||||
$(CC) $(ARMCPPFLAGS) -Wimplicit $< -o $@
|
||||
%.o: %.s
|
||||
$(AS) $< -o $@
|
||||
TMP = $(SRC:.c=.o)
|
||||
@@ -1427,6 +1458,7 @@ clean_list :
|
||||
$(REMOVE) *.lst
|
||||
$(REMOVE) allsrc.cpp
|
||||
$(REMOVE) stamp-opentx.h
|
||||
$(REMOVE) *.lbm
|
||||
$(REMOVE) bitmaps/*.lbm
|
||||
$(REMOVE) fonts/*/*.lbm
|
||||
$(REMOVE) lua_exports.txt lua_exports.cpp lua_fields.txt
|
||||
|
||||
@@ -494,21 +494,6 @@ void audioTask(void* pdata)
|
||||
}
|
||||
#endif
|
||||
|
||||
void AudioQueue::pushBuffer(AudioBuffer *buffer)
|
||||
{
|
||||
buffer->state = AUDIO_BUFFER_FILLED;
|
||||
|
||||
__disable_irq();
|
||||
|
||||
bufferWIdx = nextBufferIdx(bufferWIdx);
|
||||
|
||||
if (dacQueue(buffer)) {
|
||||
buffer->state = AUDIO_BUFFER_PLAYING;
|
||||
}
|
||||
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
void mixSample(uint16_t * result, int sample, unsigned int fade)
|
||||
{
|
||||
*result = limit(0, *result + ((sample >> fade) >> 4), 4095);
|
||||
@@ -762,8 +747,11 @@ void AudioQueue::wakeup()
|
||||
|
||||
// push the buffer if needed
|
||||
if (size > 0) {
|
||||
__disable_irq();
|
||||
bufferWIdx = nextBufferIdx(bufferWIdx);
|
||||
buffer->size = size;
|
||||
pushBuffer(buffer);
|
||||
buffer->state = dacQueue(buffer) ? AUDIO_BUFFER_PLAYING : AUDIO_BUFFER_FILLED;
|
||||
__enable_irq();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ class AudioQueue {
|
||||
AudioBuffer * buffer = &buffers[idx];
|
||||
if (buffer->state == AUDIO_BUFFER_FILLED) {
|
||||
buffer->state = AUDIO_BUFFER_PLAYING;
|
||||
bufferRIdx = idx;
|
||||
return buffer;
|
||||
}
|
||||
idx = nextBufferIdx(idx);
|
||||
@@ -239,8 +240,6 @@ class AudioQueue {
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void pushBuffer(AudioBuffer *buffer);
|
||||
};
|
||||
|
||||
extern AudioQueue audioQueue;
|
||||
|
||||
@@ -44,7 +44,9 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const xcoord_t width
|
||||
uint8_t bmpBuf[LCD_W]; /* maximum with LCD_W */
|
||||
uint8_t *buf = &bmpBuf[0];
|
||||
|
||||
assert(width <= LCD_W);
|
||||
if (width > LCD_W) {
|
||||
return STR_INCOMPATIBLE;
|
||||
}
|
||||
|
||||
FRESULT result = f_open(&bmpFile, filename, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result != FR_OK) {
|
||||
@@ -70,7 +72,7 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const xcoord_t width
|
||||
uint32_t fsize = *((uint32_t *)&buf[2]);
|
||||
uint32_t hsize = *((uint32_t *)&buf[10]); /* header size */
|
||||
|
||||
uint32_t len = limit((uint32_t)0, (uint32_t)(hsize-14), (uint32_t)32);
|
||||
uint32_t len = limit((uint32_t)4, (uint32_t)(hsize-14), (uint32_t)32);
|
||||
result = f_read(&bmpFile, buf, len, &read);
|
||||
if (result != FR_OK || read != len) {
|
||||
f_close(&bmpFile);
|
||||
@@ -152,16 +154,16 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const xcoord_t width
|
||||
*dest++ = w;
|
||||
*dest++ = h;
|
||||
|
||||
memset(dest, 0, w*((h+7)/8)*4);
|
||||
memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 2);
|
||||
|
||||
uint32_t n;
|
||||
uint32_t rowSize;
|
||||
|
||||
switch (depth) {
|
||||
case 1:
|
||||
n = w/8;
|
||||
rowSize = ((w+31)/32)*4;
|
||||
for (uint32_t i=0; i<h; i+=2) {
|
||||
result = f_read(&bmpFile, buf, n*2, &read);
|
||||
if (result != FR_OK || read != n*2) {
|
||||
result = f_read(&bmpFile, buf, rowSize*2, &read);
|
||||
if (result != FR_OK || read != rowSize*2) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
@@ -170,30 +172,33 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const xcoord_t width
|
||||
uint8_t * dst = dest + (h-i-2)/2 * w + j;
|
||||
if (!(buf[j/8] & (1<<(7-(j%8)))))
|
||||
*dst |= 0xF0;
|
||||
if (!(buf[n+j/8] & (1<<(7-(j%8)))))
|
||||
if (!(buf[rowSize+j/8] & (1<<(7-(j%8)))))
|
||||
*dst |= 0x0F;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
rowSize = ((4*w+31)/32)*4;
|
||||
for (int32_t i=h-1; i>=0; i--) {
|
||||
result = f_read(&bmpFile, buf, ((w+7)/8)*4, &read);
|
||||
if (result != FR_OK || read != ((w+7)/8)*4) {
|
||||
result = f_read(&bmpFile, buf, rowSize, &read);
|
||||
if (result != FR_OK || read != rowSize) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
for (uint32_t j=0; j<(w+1)/2; j++) {
|
||||
for (uint32_t j=0; j<rowSize; j++) {
|
||||
uint8_t * dst = dest + (i/2)*w + j*2;
|
||||
if (i & 1) {
|
||||
uint8_t val = palette[(buf[j] >> 4) & 0x0F] << 4;
|
||||
*dst |= val ^ 0xF0;
|
||||
if ((j+1)*2 >= w) break;
|
||||
val = palette[buf[j] & 0x0F] << 4;
|
||||
*(dst+1) |= val ^ 0xF0;
|
||||
}
|
||||
else {
|
||||
uint8_t val = palette[(buf[j] >> 4) & 0x0F];
|
||||
*dst |= val ^ 0x0F;
|
||||
if ((j+1)*2 >= w) break;
|
||||
val = palette[buf[j] & 0x0F];
|
||||
*(dst+1) |= val ^ 0x0F;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ else
|
||||
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc
|
||||
EXTRAINCDIRS += ../targets/taranis
|
||||
EXTRAINCDIRS += ../fonts/std
|
||||
EXTRAINCDIRS += ../
|
||||
|
||||
ifeq ($(PCBREV), REV3)
|
||||
CPPDEFS += -DREV3
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if !defined(SIMU)
|
||||
#if !defined(SIMU) && defined(DEBUG)
|
||||
|
||||
Fifo<512> debugRxFifo;
|
||||
|
||||
@@ -215,3 +215,65 @@ void debugTask(void* pdata)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
|
||||
static struct TraceElement traceBuffer[TRACE_BUFFER_LEN];
|
||||
static uint8_t traceBufferPos;
|
||||
extern Fifo<512> uart3TxFifo;
|
||||
gtime_t filltm(gtime_t *t, struct gtm *tp);
|
||||
|
||||
void trace_event(enum TraceEvent event, uint32_t data)
|
||||
{
|
||||
if (traceBufferPos >= TRACE_BUFFER_LEN) return;
|
||||
__disable_irq();
|
||||
struct TraceElement * p = &traceBuffer[traceBufferPos++];
|
||||
__enable_irq();
|
||||
p->time = g_rtcTime;
|
||||
p->time_ms = g_ms100;
|
||||
p->event = event;
|
||||
p->data = data;
|
||||
}
|
||||
|
||||
void trace_event_i(enum TraceEvent event, uint32_t data)
|
||||
{
|
||||
if (traceBufferPos >= TRACE_BUFFER_LEN) return;
|
||||
struct TraceElement * p = &traceBuffer[traceBufferPos++];
|
||||
p->time = g_rtcTime;
|
||||
p->time_ms = g_ms100;
|
||||
p->event = event;
|
||||
p->data = data;
|
||||
}
|
||||
|
||||
|
||||
const struct TraceElement * getTraceElement(uint16_t idx)
|
||||
{
|
||||
if (idx < TRACE_BUFFER_LEN) return &traceBuffer[idx];
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "stamp-opentx.h"
|
||||
|
||||
void dumpTraceBuffer()
|
||||
{
|
||||
TRACE("Dump of Trace Buffer ("VERS_STR " " DATE_STR " " TIME_STR "):");
|
||||
TRACE("# Time Event Data");
|
||||
for(int n = 0; n < TRACE_BUFFER_LEN; ++n) {
|
||||
struct gtm tp;
|
||||
filltm(&traceBuffer[n].time, &tp);
|
||||
TRACE_INFO_WP("%02d ", n);
|
||||
TRACE_INFO_WP("%4d-%02d-%02d,%02d:%02d:%02d.%02d0", tp.tm_year+1900, tp.tm_mon+1, tp.tm_mday, tp.tm_hour, tp.tm_min, tp.tm_sec, traceBuffer[n].time_ms);
|
||||
TRACE(" %03d 0x%08x", traceBuffer[n].event, traceBuffer[n].data);
|
||||
if (traceBuffer[n].time == 0 && traceBuffer[n].time_ms == 0) break;
|
||||
if ((n % 5) == 0) {
|
||||
while (!uart3TxFifo.empty()) {
|
||||
CoTickDelay(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
TRACE("End of Trace Buffer dump");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#define debug_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "rtc.h"
|
||||
|
||||
#if defined(SIMU)
|
||||
|
||||
@@ -108,5 +109,88 @@ void debugTask(void* pdata);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
|
||||
#define TRACE_BUFFER_LEN 50
|
||||
|
||||
enum TraceEvent {
|
||||
trace_start = 1,
|
||||
|
||||
sd_wait_ready = 10,
|
||||
sd_rcvr_datablock,
|
||||
sd_xmit_datablock_wait_ready,
|
||||
sd_xmit_datablock_rcvr_spi,
|
||||
sd_send_cmd_wait_ready,
|
||||
sd_send_cmd_rcvr_spi,
|
||||
|
||||
sd_SD_ReadSectors = 16,
|
||||
sd_disk_read,
|
||||
sd_SD_WriteSectors,
|
||||
sd_disk_write,
|
||||
|
||||
sd_disk_ioctl_CTRL_SYNC = 20,
|
||||
sd_disk_ioctl_GET_SECTOR_COUNT,
|
||||
sd_disk_ioctl_MMC_GET_CSD,
|
||||
sd_disk_ioctl_MMC_GET_CID,
|
||||
sd_disk_ioctl_MMC_GET_OCR,
|
||||
sd_disk_ioctl_MMC_GET_SDSTAT_1,
|
||||
sd_disk_ioctl_MMC_GET_SDSTAT_2,
|
||||
sd_spi_reset,
|
||||
|
||||
ff_f_write_validate = 30,
|
||||
ff_f_write_flag,
|
||||
ff_f_write_clst,
|
||||
ff_f_write_sync_window,
|
||||
ff_f_write_disk_write_dirty,
|
||||
ff_f_write_clust2sect,
|
||||
ff_f_write_disk_write,
|
||||
ff_f_write_disk_read,
|
||||
ff_f_write_move_window,
|
||||
|
||||
audio_getNextFilledBuffer_skip = 50,
|
||||
};
|
||||
|
||||
struct TraceElement {
|
||||
gtime_t time;
|
||||
uint8_t time_ms;
|
||||
uint8_t event;
|
||||
uint32_t data;
|
||||
};
|
||||
|
||||
void trace_event(enum TraceEvent event, uint32_t data);
|
||||
void trace_event_i(enum TraceEvent event, uint32_t data);
|
||||
const struct TraceElement * getTraceElement(uint16_t idx);
|
||||
void dumpTraceBuffer();
|
||||
|
||||
#define TRACE_EVENT(condition, event, data) if (condition) { trace_event(event, data); }
|
||||
#define TRACEI_EVENT(condition, event, data) if (condition) { trace_event_i(event, data); }
|
||||
|
||||
#else // #if defined(DEBUG_TRACE_BUFFER)
|
||||
|
||||
#define TRACE_EVENT(condition, event, data)
|
||||
#define TRACEI_EVENT(condition, event, data)
|
||||
|
||||
#endif // #if defined(DEBUG_TRACE_BUFFER)
|
||||
|
||||
#if defined(TRACE_SD_CARD)
|
||||
#define TRACE_SD_CARD_EVENT(condition, event, data) TRACE_EVENT(condition, event, data)
|
||||
#else
|
||||
#define TRACE_SD_CARD_EVENT(condition, event, data)
|
||||
#endif
|
||||
#if defined(TRACE_FATFS)
|
||||
#define TRACE_FATFS_EVENT(condition, event, data) TRACE_EVENT(condition, event, data)
|
||||
#else
|
||||
#define TRACE_FATFS_EVENT(condition, event, data)
|
||||
#endif
|
||||
#if defined(TRACE_AUDIO)
|
||||
#define TRACE_AUDIO_EVENT(condition, event, data) TRACE_EVENT(condition, event, data)
|
||||
#define TRACEI_AUDIO_EVENT(condition, event, data) TRACEI_EVENT(condition, event, data)
|
||||
#else
|
||||
#define TRACE_AUDIO_EVENT(condition, event, data)
|
||||
#define TRACEI_AUDIO_EVENT(condition, event, data)
|
||||
#endif
|
||||
|
||||
|
||||
#endif // #ifndef debug_h
|
||||
|
||||
|
||||
@@ -1250,7 +1250,7 @@ void menuGeneralDiagKeys(uint8_t event)
|
||||
|
||||
if (i<8) {
|
||||
y = i/2*FH+FH*4;
|
||||
lcd_img(14*FW, y, sticks, i/2, 0);
|
||||
if (i&1) lcd_img(14*FW, y, sticks, i/2, 0);
|
||||
displayKeyState(i&1? 20*FW : 18*FW, y, (EnumKeys)(TRM_BASE+i));
|
||||
}
|
||||
|
||||
|
||||
@@ -3999,7 +3999,7 @@ void menuModelLimits(uint8_t event)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
putsChn(0, y, k+1, (sub==k && m_posHorz < 0) ? INVERS : 0);
|
||||
if (sub==k && m_posHorz < 0 && event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
if (sub==k && m_posHorz < 0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
|
||||
killEvents(event);
|
||||
MENU_ADD_ITEM(STR_RESET);
|
||||
MENU_ADD_ITEM(STR_COPY_TRIMS_TO_OFS);
|
||||
|
||||
@@ -1433,12 +1433,6 @@ bool isTelemetrySourceAvailable(int source)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
// on Taranis+ we also hide the SWR
|
||||
if (source == TELEM_SWR)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (source >= TELEM_A1 && source <= TELEM_A4) {
|
||||
return g_model.frsky.channels[source-TELEM_A1].ratio != 0;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,9 @@ void menuModelCustomFunctions(uint8_t event);
|
||||
void menuStatisticsView(uint8_t event);
|
||||
void menuStatisticsDebug(uint8_t event);
|
||||
void menuAboutView(uint8_t event);
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
void menuTraceBuffer(uint8_t event);
|
||||
#endif
|
||||
|
||||
#if !defined(CPUM64)
|
||||
void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr);
|
||||
|
||||
@@ -141,6 +141,13 @@ void menuStatisticsDebug(uint8_t event)
|
||||
maxMixerDuration = 0;
|
||||
AUDIO_KEYPAD_UP();
|
||||
break;
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
pushMenu(menuTraceBuffer);
|
||||
return;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
chainMenu(menuStatisticsView);
|
||||
return;
|
||||
@@ -256,3 +263,58 @@ void menuStatisticsDebug(uint8_t event)
|
||||
lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET);
|
||||
lcd_status_line();
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
#include "stamp-opentx.h"
|
||||
|
||||
void menuTraceBuffer(uint8_t event)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
dumpTraceBuffer();
|
||||
killEvents(event);
|
||||
break;
|
||||
}
|
||||
|
||||
SIMPLE_SUBMENU("Trace Buffer " VERS_STR, TRACE_BUFFER_LEN);
|
||||
/* RTC time */
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
putsTime(LCD_W+1, 0, t, TIMEBLINK);
|
||||
|
||||
uint8_t y = 0;
|
||||
uint8_t k = 0;
|
||||
int8_t sub = m_posVert;
|
||||
|
||||
lcd_putc(0, FH, '#');
|
||||
lcd_puts(4*FW, FH, "Time");
|
||||
lcd_puts(14*FW, FH, "Event");
|
||||
lcd_puts(20*FW, FH, "Data");
|
||||
|
||||
for (uint8_t i=0; i<LCD_LINES-2; i++) {
|
||||
y = 1 + (i+2)*FH;
|
||||
k = i+s_pgOfs;
|
||||
|
||||
//item
|
||||
lcd_outdezAtt(0, y, k, LEFT | (sub==k ? INVERS : 0));
|
||||
|
||||
const struct TraceElement * te = getTraceElement(k);
|
||||
if (te) {
|
||||
//time
|
||||
putstime_t tme = te->time % SECS_PER_DAY;
|
||||
putsTimer(4*FW, y, tme, TIMEHOUR|LEFT, TIMEHOUR|LEFT);
|
||||
//event
|
||||
lcd_outdezNAtt(14*FW, y, te->event, LEADING0|LEFT, 3);
|
||||
//data
|
||||
lcd_putsn (20*FW, y, "0x", 2);
|
||||
lcd_outhex4(22*FW-2, y, (uint16_t)(te->data >> 16));
|
||||
lcd_outhex4(25*FW, y, (uint16_t)(te->data & 0xFFFF));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif //#if defined(DEBUG_TRACE_BUFFER)
|
||||
|
||||
@@ -161,8 +161,50 @@ uint8_t barCoord(int16_t value, int16_t min, int16_t max)
|
||||
return limit((uint8_t)0, (uint8_t)(((int32_t)(BAR_WIDTH-1) * (value - min)) / (max - min)), (uint8_t)BAR_WIDTH);
|
||||
}
|
||||
|
||||
#if defined(LUA)
|
||||
|
||||
#define LUA_SCRIPT_ERROR_Y 3*FH
|
||||
// TODO more visual appealing implementation and text translations
|
||||
void displayLuaScriptError(uint8_t state, const char * name, int index)
|
||||
{
|
||||
lcd_putsAtt(0, LUA_SCRIPT_ERROR_Y, name, 0);
|
||||
if (index > 0) {
|
||||
lcd_outdezAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, index, LEFT);
|
||||
}
|
||||
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, ": ", 0);
|
||||
switch (state) {
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Script syntax error", 0);
|
||||
break;
|
||||
case SCRIPT_PANIC:
|
||||
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Script panic", 0);
|
||||
break;
|
||||
case SCRIPT_KILLED:
|
||||
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Script killed", 0);
|
||||
break;
|
||||
default:
|
||||
lcd_putsAtt(lcdLastPos, LUA_SCRIPT_ERROR_Y, "Unknown error", 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void displayVoltagesScreen()
|
||||
{
|
||||
#if defined(LUA)
|
||||
uint8_t state = isTelemetryScriptAvailable(TELEMETRY_VOLTAGES_SCREEN);
|
||||
switch (state) {
|
||||
case SCRIPT_OK:
|
||||
return; //contents will be drawed by Lua Task
|
||||
case SCRIPT_NOFILE:
|
||||
break; //display normal screen
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
case SCRIPT_PANIC:
|
||||
case SCRIPT_KILLED:
|
||||
//display script error
|
||||
displayLuaScriptError(state, "telempw", 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// Volts / Amps / Watts / mAh
|
||||
uint8_t analog = 0;
|
||||
#if defined(CPUARM)
|
||||
@@ -255,8 +297,25 @@ void displayVoltagesScreen()
|
||||
displayRssiLine();
|
||||
}
|
||||
|
||||
|
||||
void displayAfterFlightScreen()
|
||||
{
|
||||
#if defined(LUA)
|
||||
uint8_t state = isTelemetryScriptAvailable(TELEMETRY_AFTER_FLIGHT_SCREEN);
|
||||
switch (state) {
|
||||
case SCRIPT_OK:
|
||||
return; //contents will be drawed by Lua Task
|
||||
case SCRIPT_NOFILE:
|
||||
break; //display normal screen
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
case SCRIPT_PANIC:
|
||||
case SCRIPT_KILLED:
|
||||
//display script error
|
||||
displayLuaScriptError(state, "telemaf", 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t line=1*FH+1;
|
||||
if (IS_GPS_AVAILABLE()) {
|
||||
// Latitude
|
||||
@@ -430,7 +489,20 @@ bool displayTelemetryScreen()
|
||||
{
|
||||
#if defined(LUA)
|
||||
if (s_frsky_view < TELEMETRY_CUSTOM_SCREEN_1) {
|
||||
return isTelemetryScriptAvailable(s_frsky_view);
|
||||
uint8_t state = isTelemetryScriptAvailable(s_frsky_view);
|
||||
switch (state) {
|
||||
case SCRIPT_OK:
|
||||
return true; //contents will be drawed by Lua Task
|
||||
case SCRIPT_NOFILE:
|
||||
return false; //requested lua telemetry screen not available
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
case SCRIPT_PANIC:
|
||||
case SCRIPT_KILLED:
|
||||
//display script error
|
||||
displayLuaScriptError(state, "telem", s_frsky_view+1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -830,7 +830,7 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
{
|
||||
if (idx < 0) {
|
||||
lcd_putcAtt(x-1*FW, y, '!', att);
|
||||
lcd_putcAtt(x-3, y, '!', att);
|
||||
idx = -idx+CURVE_BASE-1;
|
||||
}
|
||||
if (idx < CURVE_BASE)
|
||||
|
||||
@@ -38,7 +38,10 @@
|
||||
|
||||
void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att)
|
||||
{
|
||||
ASSERT_IN_DISPLAY(p);
|
||||
// ASSERT_IN_DISPLAY(p);
|
||||
if ((p) >= DISPLAY_END) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (att&FILL_WHITE) {
|
||||
// TODO I could remove this, it's used for the top bar
|
||||
@@ -71,7 +74,12 @@ void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att)
|
||||
void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att)
|
||||
{
|
||||
if (y >= LCD_H) return;
|
||||
if (x+w > LCD_W) { w = LCD_W - x; }
|
||||
if (x+w > LCD_W) {
|
||||
if (x >= LCD_W ) {
|
||||
return;
|
||||
}
|
||||
w = LCD_W - x;
|
||||
}
|
||||
|
||||
uint8_t *p = &displayBuf[ y / 2 * LCD_W + x ];
|
||||
uint8_t mask = PIXEL_GREY_MASK(y, att);
|
||||
@@ -149,6 +157,9 @@ void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t offset, uint8_
|
||||
width = w;
|
||||
}
|
||||
if (x+width > LCD_W) {
|
||||
if (x >= LCD_W ) {
|
||||
return;
|
||||
}
|
||||
width = LCD_W-x;
|
||||
}
|
||||
uint8_t rows = (pgm_read_byte(q++) + 1) / 2;
|
||||
@@ -157,6 +168,9 @@ void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t offset, uint8_
|
||||
q = img + 2 + row*w + offset;
|
||||
uint8_t *p = &displayBuf[(row + (y/2)) * LCD_W + x];
|
||||
for (xcoord_t i=0; i<width; i++) {
|
||||
if ((p) >= DISPLAY_END) {
|
||||
return;
|
||||
}
|
||||
uint8_t b = pgm_read_byte(q++);
|
||||
if (y & 1) {
|
||||
*p = (*p & 0x0f) + ((b & 0x0f) << 4);
|
||||
|
||||
@@ -115,9 +115,7 @@ const pm_char * openLogs()
|
||||
f_puts("Time,", &g_oLogFile);
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
f_puts("RSSI,A1,A2,A3,A4,", &g_oLogFile);
|
||||
#elif defined(CPUARM) && defined(FRSKY)
|
||||
#if defined(CPUARM) && defined(FRSKY)
|
||||
f_puts("SWR,RSSI,A1,A2,A3,A4,", &g_oLogFile);
|
||||
#elif defined(FRSKY)
|
||||
f_puts("Buffer,RX,TX,A1,A2,", &g_oLogFile);
|
||||
@@ -201,13 +199,15 @@ void writeLogs()
|
||||
|
||||
#if defined(FRSKY)
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
f_printf(&g_oLogFile, "%d,", RAW_FRSKY_MINMAX(frskyData.rssi[0]));
|
||||
if (IS_VALID_XJT_VERSION())
|
||||
f_printf(&g_oLogFile, "%d,%d,", RAW_FRSKY_MINMAX(frskyData.swr), RAW_FRSKY_MINMAX(frskyData.rssi[0]));
|
||||
else
|
||||
f_printf(&g_oLogFile, "-,%d,", RAW_FRSKY_MINMAX(frskyData.rssi[0]));
|
||||
#elif defined(CPUARM)
|
||||
f_printf(&g_oLogFile, "%d,%d,", RAW_FRSKY_MINMAX(frskyData.swr), RAW_FRSKY_MINMAX(frskyData.rssi[0]));
|
||||
#else
|
||||
f_printf(&g_oLogFile, "%d,%d,%d,", frskyStreaming, RAW_FRSKY_MINMAX(frskyData.rssi[0]), RAW_FRSKY_MINMAX(frskyData.rssi[1]));
|
||||
#endif
|
||||
|
||||
for (uint8_t i=0; i<MAX_FRSKY_A_CHANNELS; i++) {
|
||||
int16_t converted_value = applyChannelRatio(i, RAW_FRSKY_MINMAX(frskyData.analog[i]));
|
||||
f_printf(&g_oLogFile, "%d.%02d,", converted_value/100, converted_value%100);
|
||||
|
||||
@@ -294,6 +294,13 @@ static int luaKillEvents(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaGrey(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkinteger(L, 1);
|
||||
lua_pushunsigned(L, GREY(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int luaGetGeneralSettings(lua_State *L)
|
||||
{
|
||||
lua_newtable(L);
|
||||
@@ -417,7 +424,7 @@ static int luaLcdDrawPixmap(lua_State *L)
|
||||
int x = luaL_checkinteger(L, 1);
|
||||
int y = luaL_checkinteger(L, 2);
|
||||
const char * filename = luaL_checkstring(L, 3);
|
||||
uint8_t bitmap[2+LCD_W/2*LCD_H/2]; // width max is LCD_W/2 pixels for saving stack and avoid a malloc here
|
||||
uint8_t bitmap[BITMAP_BUFFER_SIZE(LCD_W/2, LCD_H)]; // width max is LCD_W/2 pixels for saving stack and avoid a malloc here
|
||||
const pm_char * error = bmpLoad(bitmap, filename, LCD_W/2, LCD_H);
|
||||
if (!error) {
|
||||
lcd_bmp(x, y, bitmap);
|
||||
@@ -558,7 +565,7 @@ static int luaModelSetInfo(lua_State *L)
|
||||
|
||||
static int luaModelGetTimer(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < MAX_TIMERS) {
|
||||
TimerData & timer = g_model.timers[idx];
|
||||
lua_newtable(L);
|
||||
@@ -567,7 +574,7 @@ static int luaModelGetTimer(lua_State *L)
|
||||
lua_pushtableinteger(L, "value", timersStates[idx].val);
|
||||
lua_pushtableinteger(L, "countdownBeep", timer.countdownBeep);
|
||||
lua_pushtableboolean(L, "minuteBeep", timer.minuteBeep);
|
||||
lua_pushtableboolean(L, "persistent", timer.persistent);
|
||||
lua_pushtableinteger(L, "persistent", timer.persistent);
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
@@ -577,8 +584,7 @@ static int luaModelGetTimer(lua_State *L)
|
||||
|
||||
static int luaModelSetTimer(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < MAX_TIMERS) {
|
||||
TimerData & timer = g_model.timers[idx];
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
@@ -598,7 +604,7 @@ static int luaModelSetTimer(lua_State *L)
|
||||
timer.countdownBeep = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "minuteBeep")) {
|
||||
timer.minuteBeep = luaL_checkinteger(L, -1);
|
||||
timer.minuteBeep = lua_toboolean(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "persistent")) {
|
||||
timer.persistent = luaL_checkinteger(L, -1);
|
||||
@@ -609,6 +615,15 @@ static int luaModelSetTimer(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaModelResetTimer(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < MAX_TIMERS) {
|
||||
timerReset(idx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getFirstInput(int chn)
|
||||
{
|
||||
for (int i=0; i<MAX_INPUTS; i++) {
|
||||
@@ -621,9 +636,9 @@ static int getFirstInput(int chn)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int getInputsCountFromFirst(int chn, int first)
|
||||
static unsigned int getInputsCountFromFirst(int chn, int first)
|
||||
{
|
||||
int count = 0;
|
||||
unsigned int count = 0;
|
||||
if (first >= 0) {
|
||||
for (int i=first; i<MAX_INPUTS; i++) {
|
||||
ExpoData * expo = expoAddress(i);
|
||||
@@ -634,7 +649,7 @@ static int getInputsCountFromFirst(int chn, int first)
|
||||
return count;
|
||||
}
|
||||
|
||||
static int getInputsCount(int chn)
|
||||
static unsigned int getInputsCount(int chn)
|
||||
{
|
||||
int first = getFirstInput(chn);
|
||||
return getInputsCountFromFirst(chn, first);
|
||||
@@ -642,7 +657,7 @@ static int getInputsCount(int chn)
|
||||
|
||||
static int luaModelGetInputsCount(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
int count = getInputsCount(chn);
|
||||
lua_pushinteger(L, count);
|
||||
return 1;
|
||||
@@ -650,10 +665,10 @@ static int luaModelGetInputsCount(lua_State *L)
|
||||
|
||||
static int luaModelGetInput(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
int first = getFirstInput(chn);
|
||||
int count = getInputsCountFromFirst(chn, first);
|
||||
unsigned int count = getInputsCountFromFirst(chn, first);
|
||||
if (first>=0 && idx<count) {
|
||||
ExpoData * expo = expoAddress(first+idx);
|
||||
lua_newtable(L);
|
||||
@@ -670,11 +685,11 @@ static int luaModelGetInput(lua_State *L)
|
||||
|
||||
static int luaModelInsertInput(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
|
||||
int first = getFirstInput(chn);
|
||||
int count = getInputsCountFromFirst(chn, first);
|
||||
unsigned int count = getInputsCountFromFirst(chn, first);
|
||||
|
||||
if (chn<MAX_INPUTS && getExpoMixCount(1)<MAX_INPUTS && idx<=count) {
|
||||
idx = first+idx;
|
||||
@@ -709,11 +724,11 @@ static int luaModelInsertInput(lua_State *L)
|
||||
|
||||
static int luaModelDeleteInput(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
|
||||
int first = getFirstInput(chn);
|
||||
int count = getInputsCountFromFirst(chn, first);
|
||||
unsigned int count = getInputsCountFromFirst(chn, first);
|
||||
|
||||
if (first>=0 && idx<count) {
|
||||
deleteExpoMix(1, first+idx);
|
||||
@@ -766,7 +781,7 @@ static int getMixesCount(int chn)
|
||||
|
||||
static int luaModelGetMixesCount(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
int count = getMixesCount(chn);
|
||||
lua_pushinteger(L, count);
|
||||
return 1;
|
||||
@@ -774,11 +789,11 @@ static int luaModelGetMixesCount(lua_State *L)
|
||||
|
||||
static int luaModelGetMix(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
int first = getFirstMix(chn);
|
||||
int count = getMixesCountFromFirst(chn, first);
|
||||
if (idx<count) {
|
||||
unsigned int count = getMixesCountFromFirst(chn, first);
|
||||
if (idx < count) {
|
||||
MixData * mix = mixAddress(first+idx);
|
||||
lua_newtable(L);
|
||||
lua_pushtablezstring(L, "name", mix->name);
|
||||
@@ -789,6 +804,13 @@ static int luaModelGetMix(lua_State *L)
|
||||
lua_pushtableinteger(L, "curveType", mix->curve.type);
|
||||
lua_pushtableinteger(L, "curveValue", mix->curve.value);
|
||||
lua_pushtableinteger(L, "multiplex", mix->mltpx);
|
||||
lua_pushtableinteger(L, "flightModes", mix->flightModes);
|
||||
lua_pushtableboolean(L, "carryTrim", mix->carryTrim);
|
||||
lua_pushtableinteger(L, "mixWarn", mix->mixWarn);
|
||||
lua_pushtableinteger(L, "delayUp", mix->delayUp);
|
||||
lua_pushtableinteger(L, "delayDown", mix->delayDown);
|
||||
lua_pushtableinteger(L, "speedUp", mix->speedUp);
|
||||
lua_pushtableinteger(L, "speedDown", mix->speedDown);
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
@@ -798,11 +820,11 @@ static int luaModelGetMix(lua_State *L)
|
||||
|
||||
static int luaModelInsertMix(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
|
||||
int first = getFirstMix(chn);
|
||||
int count = getMixesCountFromFirst(chn, first);
|
||||
unsigned int count = getMixesCountFromFirst(chn, first);
|
||||
|
||||
if (chn<NUM_CHNOUT && getExpoMixCount(0)<MAX_MIXERS && idx<=count) {
|
||||
idx += first;
|
||||
@@ -838,6 +860,27 @@ static int luaModelInsertMix(lua_State *L)
|
||||
else if (!strcmp(key, "multiplex")) {
|
||||
mix->mltpx = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "flightModes")) {
|
||||
mix->flightModes = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "carryTrim")) {
|
||||
mix->carryTrim = lua_toboolean(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "mixWarn")) {
|
||||
mix->mixWarn = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "delayUp")) {
|
||||
mix->delayUp = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "delayDown")) {
|
||||
mix->delayDown = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "speedUp")) {
|
||||
mix->speedUp = luaL_checkinteger(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "speedDown")) {
|
||||
mix->speedDown = luaL_checkinteger(L, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,13 +889,13 @@ static int luaModelInsertMix(lua_State *L)
|
||||
|
||||
static int luaModelDeleteMix(lua_State *L)
|
||||
{
|
||||
int chn = luaL_checkunsigned(L, 1);
|
||||
int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
|
||||
int first = getFirstMix(chn);
|
||||
int count = getMixesCountFromFirst(chn, first);
|
||||
unsigned int count = getMixesCountFromFirst(chn, first);
|
||||
|
||||
if (idx<count) {
|
||||
if (idx < count) {
|
||||
deleteExpoMix(0, first+idx);
|
||||
}
|
||||
|
||||
@@ -867,7 +910,7 @@ static int luaModelDeleteMixes(lua_State *L)
|
||||
|
||||
static int luaModelGetLogicalSwitch(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < NUM_LOGICAL_SWITCH) {
|
||||
LogicalSwitchData * sw = lswAddress(idx);
|
||||
lua_newtable(L);
|
||||
@@ -887,7 +930,7 @@ static int luaModelGetLogicalSwitch(lua_State *L)
|
||||
|
||||
static int luaModelSetLogicalSwitch(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < NUM_LOGICAL_SWITCH) {
|
||||
LogicalSwitchData * sw = lswAddress(idx);
|
||||
memclear(sw, sizeof(LogicalSwitchData));
|
||||
@@ -925,7 +968,7 @@ static int luaModelSetLogicalSwitch(lua_State *L)
|
||||
|
||||
static int luaModelGetCurve(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < MAX_CURVES) {
|
||||
CurveInfo & curveInfo = g_model.curves[idx];
|
||||
lua_newtable(L);
|
||||
@@ -967,7 +1010,7 @@ static int luaModelGetCurve(lua_State *L)
|
||||
|
||||
static int luaModelGetCustomFunction(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < NUM_CFN) {
|
||||
CustomFnData * cfn = &g_model.funcSw[idx];
|
||||
lua_newtable(L);
|
||||
@@ -991,7 +1034,7 @@ static int luaModelGetCustomFunction(lua_State *L)
|
||||
|
||||
static int luaModelSetCustomFunction(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < NUM_CFN) {
|
||||
CustomFnData * cfn = &g_model.funcSw[idx];
|
||||
memclear(cfn, sizeof(CustomFnData));
|
||||
@@ -1030,7 +1073,7 @@ static int luaModelSetCustomFunction(lua_State *L)
|
||||
|
||||
static int luaModelGetOutput(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < NUM_CHNOUT) {
|
||||
LimitData * limit = limitAddress(idx);
|
||||
lua_newtable(L);
|
||||
@@ -1054,7 +1097,7 @@ static int luaModelGetOutput(lua_State *L)
|
||||
|
||||
static int luaModelSetOutput(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < NUM_CHNOUT) {
|
||||
LimitData * limit = limitAddress(idx);
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
@@ -1098,8 +1141,8 @@ static int luaModelSetOutput(lua_State *L)
|
||||
|
||||
static int luaModelGetGlobalVariable(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
int phase = luaL_checkunsigned(L, 2);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int phase = luaL_checkunsigned(L, 2);
|
||||
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS)
|
||||
lua_pushinteger(L, g_model.flightModeData[phase].gvars[idx]);
|
||||
else
|
||||
@@ -1109,8 +1152,8 @@ static int luaModelGetGlobalVariable(lua_State *L)
|
||||
|
||||
static int luaModelSetGlobalVariable(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
int phase = luaL_checkunsigned(L, 2);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int phase = luaL_checkunsigned(L, 2);
|
||||
int value = luaL_checkinteger(L, 3);
|
||||
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_MAX && value <= GVAR_MAX) {
|
||||
g_model.flightModeData[phase].gvars[idx] = value;
|
||||
@@ -1121,7 +1164,7 @@ static int luaModelSetGlobalVariable(lua_State *L)
|
||||
|
||||
static int luaModelGetTelemetryChannel(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
if (idx < MAX_FRSKY_A_CHANNELS) {
|
||||
FrSkyChannelData & channel = g_model.frsky.channels[idx];
|
||||
lua_newtable(L);
|
||||
@@ -1172,7 +1215,7 @@ int findmult(float value, float base)
|
||||
|
||||
static int luaModelSetTelemetryChannel(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
|
||||
if (idx < MAX_FRSKY_A_CHANNELS) {
|
||||
FrSkyChannelData & channel = g_model.frsky.channels[idx];
|
||||
@@ -1362,6 +1405,7 @@ const luaL_Reg opentxLib[] = {
|
||||
{ "defaultStick", luaDefaultStick },
|
||||
{ "defaultChannel", luaDefaultChannel },
|
||||
{ "killEvents", luaKillEvents },
|
||||
{ "GREY", luaGrey },
|
||||
{ NULL, NULL } /* sentinel */
|
||||
};
|
||||
|
||||
@@ -1372,10 +1416,12 @@ const luaR_value_entry opentxConstants[] = {
|
||||
{ "MIDSIZE", MIDSIZE },
|
||||
{ "SMLSIZE", SMLSIZE },
|
||||
{ "INVERS", INVERS },
|
||||
{ "BOLD", BOLD },
|
||||
{ "BLINK", BLINK },
|
||||
{ "FIXEDWIDTH", FIXEDWIDTH },
|
||||
{ "LEFT", LEFT },
|
||||
{ "PREC1", PREC1 },
|
||||
{ "PREC2", PREC2 },
|
||||
{ "BLINK", BLINK },
|
||||
{ "VALUE", 0 },
|
||||
{ "SOURCE", 1 },
|
||||
{ "REPLACE", MLTPX_REP },
|
||||
@@ -1410,6 +1456,9 @@ const luaR_value_entry opentxConstants[] = {
|
||||
{ "GREY_DEFAULT", GREY_DEFAULT },
|
||||
{ "SOLID", SOLID },
|
||||
{ "DOTTED", DOTTED },
|
||||
{ "FORCE", FORCE },
|
||||
{ "ERASE", ERASE },
|
||||
{ "ROUND", ROUND },
|
||||
{ "LCD_W", LCD_W },
|
||||
{ "LCD_H", LCD_H },
|
||||
{ "PLAY_NOW", PLAY_NOW },
|
||||
@@ -1423,6 +1472,7 @@ const luaL_Reg modelLib[] = {
|
||||
{ "setInfo", luaModelSetInfo },
|
||||
{ "getTimer", luaModelGetTimer },
|
||||
{ "setTimer", luaModelSetTimer },
|
||||
{ "resetTimer", luaModelResetTimer },
|
||||
{ "getInputsCount", luaModelGetInputsCount },
|
||||
{ "getInput", luaModelGetInput },
|
||||
{ "insertInput", luaModelInsertInput },
|
||||
@@ -1699,15 +1749,15 @@ bool luaLoadTelemetryScript(uint8_t index)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isTelemetryScriptAvailable(uint8_t index)
|
||||
uint8_t isTelemetryScriptAvailable(uint8_t index)
|
||||
{
|
||||
for (int i=0; i<luaScriptsCount; i++) {
|
||||
ScriptInternalData & sid = scriptInternalData[i];
|
||||
if (sid.reference == SCRIPT_TELEMETRY_FIRST+index) {
|
||||
return true;
|
||||
return sid.state;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return SCRIPT_NOFILE;
|
||||
}
|
||||
|
||||
void luaLoadPermanentScripts()
|
||||
@@ -1881,7 +1931,11 @@ void luaDoOneRunPermanentScript(uint8_t evt, int i)
|
||||
const char *filename;
|
||||
#endif
|
||||
ScriptInputsOutputs * sio = NULL;
|
||||
#if SCRIPT_MIX_FIRST > 0
|
||||
if (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST) {
|
||||
#else
|
||||
if (sid.reference <= SCRIPT_MIX_LAST) {
|
||||
#endif
|
||||
ScriptData & sd = g_model.scriptsData[sid.reference-SCRIPT_MIX_FIRST];
|
||||
sio = &scriptInputsOutputs[sid.reference-SCRIPT_MIX_FIRST];
|
||||
inputsCount = sio->inputsCount;
|
||||
|
||||
@@ -42,7 +42,7 @@ luaR_result luaR_findglobal(const char *name, lu_byte *ptype) {
|
||||
return i+1;
|
||||
}
|
||||
if (!strncmp(lua_rotable[i].name, "__", 2)) {
|
||||
int result = luaR_findentry((void *)(size_t)(i+1), name, ptype);
|
||||
luaR_result result = luaR_findentry((void *)(size_t)(i+1), name, ptype);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ getvalue_t getValue(uint8_t i)
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1) return frskyData.analog[TELEM_ANA_A1].min;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_MIN_A2) return frskyData.analog[TELEM_ANA_A2].min;
|
||||
#if defined(CPUARM)
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_MIN_A3) return frskyData.analog[TELEM_ANA_A3].min;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_MIN_A3) return frskyData.analog[TELEM_ANA_A3].min;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_MIN_A4) return frskyData.analog[TELEM_ANA_A4].min;
|
||||
#endif
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_CSW_MAX) return *(((int16_t*)(&frskyData.hub.minAltitude))+i-(MIXSRC_FIRST_TELEM-1+TELEM_MIN_ALT));
|
||||
@@ -649,10 +649,22 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||
bool mixCondition = (md->flightModes != 0 || md->swtch);
|
||||
delayval_t mixEnabled = (!(md->flightModes & (1 << mixerCurrentFlightMode)) && getSwitch(md->swtch)) ? DELAY_POS_MARGIN+1 : 0;
|
||||
|
||||
#define MIXER_LINE_DISABLE() (mixCondition = true, mixEnabled = 0)
|
||||
|
||||
if (mixEnabled && md->srcRaw >= MIXSRC_FIRST_TRAINER && md->srcRaw <= MIXSRC_LAST_TRAINER && !ppmInValid) {
|
||||
mixEnabled = 0;
|
||||
MIXER_LINE_DISABLE();
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS) && defined(LUA_MODEL_SCRIPTS)
|
||||
// disable mixer if Lua script is used as source and script was killed
|
||||
if (mixEnabled && md->srcRaw >= MIXSRC_FIRST_LUA && md->srcRaw <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div(md->srcRaw-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
if (scriptInternalData[qr.quot].state != SCRIPT_OK) {
|
||||
MIXER_LINE_DISABLE();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//========== VALUE ===============
|
||||
getvalue_t v = 0;
|
||||
if (mode > e_perout_mode_inactive_flight_mode) {
|
||||
|
||||
@@ -362,7 +362,11 @@ void defaultInputs()
|
||||
expo->weight = 100;
|
||||
expo->mode = 3; // TODO constant
|
||||
for (int c=0; c<4; c++) {
|
||||
#if defined(TRANSLATIONS_CZ) && defined(CPUARM)
|
||||
g_model.inputNames[i][c] = char2idx(STR_INPUTNAMES[1+STR_INPUTNAMES[0]*(stick_index-1)+c]);
|
||||
#else
|
||||
g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[1+STR_VSRCRAW[0]*stick_index+c]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
eeDirty(EE_MODEL);
|
||||
@@ -387,7 +391,11 @@ void applyDefaultTemplate()
|
||||
expo->weight = 100;
|
||||
expo->mode = 3; // TODO constant
|
||||
for (int c=0; c<4; c++) {
|
||||
#if defined(TRANSLATIONS_CZ) && defined(CPUARM)
|
||||
g_model.inputNames[i][c] = char2idx(STR_INPUTNAMES[1+STR_INPUTNAMES[0]*(stick_index-1)+c]);
|
||||
#else
|
||||
g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[1+STR_VSRCRAW[0]*stick_index+c]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2144,8 +2152,15 @@ void evalFunctions()
|
||||
|
||||
#if defined(HAPTIC) && !defined(CPUARM)
|
||||
case FUNC_HAPTIC:
|
||||
haptic.event(AU_FRSKY_LAST+CFN_PARAM(sd));
|
||||
{
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
|
||||
if (!lastFunctionTime[i] || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) {
|
||||
lastFunctionTime[i] = tmr10ms;
|
||||
haptic.event(AU_FRSKY_LAST+CFN_PARAM(sd));
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
@@ -2509,6 +2524,10 @@ void opentxStart()
|
||||
{
|
||||
doSplash();
|
||||
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
trace_event(trace_start, 0x12345678);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SDCARD) && !defined(SIMU)
|
||||
for (int i=0; i<500 && !Card_initialized; i++) {
|
||||
CoTickDelay(1); // 2ms
|
||||
@@ -3422,7 +3441,7 @@ inline void opentxInit(OPENTX_INIT_ARGS)
|
||||
btInit();
|
||||
#endif
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
||||
rtcInit();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -433,9 +433,10 @@ enum PotType {
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define BITMAP_BUFFER_SIZE(width, height) (2 + width * ((height+7)/8)*4)
|
||||
#define MODEL_BITMAP_WIDTH 64
|
||||
#define MODEL_BITMAP_HEIGHT 32
|
||||
#define MODEL_BITMAP_SIZE (2+4*(MODEL_BITMAP_WIDTH*MODEL_BITMAP_HEIGHT/8))
|
||||
#define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)
|
||||
extern uint8_t modelBitmap[MODEL_BITMAP_SIZE];
|
||||
void loadModelBitmap(char *name, uint8_t *bitmap);
|
||||
#define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap)
|
||||
@@ -1516,7 +1517,7 @@ enum AUDIO_SOUNDS {
|
||||
void luaExec(const char *filename);
|
||||
int luaGetMemUsed();
|
||||
#define luaGetCpuUsed(idx) scriptInternalData[idx].instructions
|
||||
bool isTelemetryScriptAvailable(uint8_t index);
|
||||
uint8_t isTelemetryScriptAvailable(uint8_t index);
|
||||
#define LUA_LOAD_MODEL_SCRIPTS() luaState |= INTERPRETER_RELOAD_PERMANENT_SCRIPTS
|
||||
#define LUA_LOAD_MODEL_SCRIPT(idx) luaState |= INTERPRETER_RELOAD_PERMANENT_SCRIPTS
|
||||
|
||||
|
||||
@@ -107,9 +107,6 @@ verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
|
||||
#define TM_YEAR_BASE 1900
|
||||
verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0);
|
||||
|
||||
#define SECS_PER_HOUR 3600ul
|
||||
#define SECS_PER_DAY 86400ul
|
||||
|
||||
/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
|
||||
static inline int
|
||||
leapyear (long int year)
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#define SECS_PER_HOUR 3600ul
|
||||
#define SECS_PER_DAY 86400ul
|
||||
|
||||
typedef long int gtime_t;
|
||||
|
||||
struct gtm
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source [find target/stm32f2x_stlink.cfg]
|
||||
reset_config srst_only srst_nogate
|
||||
@@ -436,7 +436,7 @@ DRESULT disk_read (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
BYTE *buff, /* Pointer to the data buffer to store read data */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
UINT count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
if (drv || !count) return RES_PARERR;
|
||||
@@ -473,7 +473,7 @@ DRESULT disk_write (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
const BYTE *buff, /* Pointer to the data to be written */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
UINT count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
if (drv || !count) return RES_PARERR;
|
||||
@@ -682,7 +682,7 @@ void sdMountPoll()
|
||||
if (mountTimer-- == 0) {
|
||||
mountTimer = 100;
|
||||
if (!sdMounted()) {
|
||||
f_mount(0, &g_FATFS_Obj);
|
||||
f_mount(&g_FATFS_Obj, "", 1);
|
||||
f_chdir(ROOT_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ FRESULT f_stat (const TCHAR * name, FILINFO *)
|
||||
return stat(path, &tmp) ? FR_INVALID_NAME : FR_OK;
|
||||
}
|
||||
|
||||
FRESULT f_mount (BYTE, FATFS*)
|
||||
FRESULT f_mount (FATFS* ,const TCHAR*, BYTE opt)
|
||||
{
|
||||
return FR_OK;
|
||||
}
|
||||
@@ -518,7 +518,10 @@ FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
|
||||
|
||||
FRESULT f_read (FIL* fil, void* data, UINT size, UINT* read)
|
||||
{
|
||||
if (fil && fil->fs) *read = fread(data, 1, size, (FILE*)fil->fs);
|
||||
if (fil && fil->fs) {
|
||||
*read = fread(data, 1, size, (FILE*)fil->fs);
|
||||
// TRACE("fread(%p) %u, %u", fil->fs, size, *read);
|
||||
}
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
@@ -586,7 +589,7 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil)
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
FRESULT f_mkfs (unsigned char, unsigned char, unsigned int)
|
||||
FRESULT f_mkfs (const TCHAR *path, BYTE, UINT)
|
||||
{
|
||||
printf("Format SD...\n"); fflush(stdout);
|
||||
return FR_OK;
|
||||
|
||||
@@ -97,9 +97,13 @@ uint32_t transSpeed;
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Lock / unlock functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if !defined(BOOT)
|
||||
static OS_MutexID ioMutex;
|
||||
volatile int mutexCheck = 0;
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||
{
|
||||
*mutex = CoCreateMutex();
|
||||
*mutex = ioMutex;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -118,6 +122,7 @@ int ff_del_syncobj (_SYNC_t mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Get Trans Speed Value (Kbit/s)
|
||||
@@ -1081,7 +1086,7 @@ void sdInit()
|
||||
// Should check the card can do this ****
|
||||
Card_state = SD_ST_DATA;
|
||||
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
|
||||
referenceSystemAudioFiles();
|
||||
Card_state = SD_ST_MOUNTED;
|
||||
}
|
||||
@@ -1093,7 +1098,7 @@ void sdDone()
|
||||
{
|
||||
if (sdMounted()) {
|
||||
audioQueue.stopSD();
|
||||
f_mount(0, 0); // unmount SD
|
||||
f_mount(NULL, "", 0); // unmount SD
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1269,36 +1274,36 @@ DRESULT disk_read (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
BYTE *buff, /* Pointer to the data buffer to store read data */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
UINT count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
uint32_t result ;
|
||||
uint32_t result ;
|
||||
|
||||
if (drv || !count) return RES_PARERR;
|
||||
if (drv || !count) return RES_PARERR;
|
||||
|
||||
if ( sd_card_ready() == 0 ) return RES_NOTRDY;
|
||||
if ( sd_card_ready() == 0 ) return RES_NOTRDY;
|
||||
|
||||
do {
|
||||
result = sd_read_block(sector, dma_sd_buffer) ;
|
||||
if (result) {
|
||||
memcpy(buff, dma_sd_buffer, 512);
|
||||
sector += 1 ;
|
||||
buff += 512 ;
|
||||
count -= 1 ;
|
||||
}
|
||||
else {
|
||||
count = 1 ; // Flag error
|
||||
break ;
|
||||
}
|
||||
} while ( count ) ;
|
||||
do {
|
||||
result = sd_read_block(sector, dma_sd_buffer) ;
|
||||
if (result) {
|
||||
memcpy(buff, dma_sd_buffer, 512);
|
||||
sector += 1 ;
|
||||
buff += 512 ;
|
||||
count -= 1 ;
|
||||
}
|
||||
else {
|
||||
count = 1 ; // Flag error
|
||||
break ;
|
||||
}
|
||||
} while ( count ) ;
|
||||
|
||||
if (!count)
|
||||
return RES_OK;
|
||||
if (!count)
|
||||
return RES_OK;
|
||||
|
||||
if (++sdErrorCount > 3)
|
||||
Card_state = SD_ST_ERR;
|
||||
if (++sdErrorCount > 3)
|
||||
Card_state = SD_ST_ERR;
|
||||
|
||||
return RES_ERROR;
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1312,52 +1317,53 @@ DRESULT disk_write (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
const BYTE *buff, /* Pointer to the data to be written */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
UINT count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
uint32_t result ;
|
||||
uint32_t result ;
|
||||
|
||||
if (drv || !count) return RES_PARERR;
|
||||
if (drv || !count) return RES_PARERR;
|
||||
|
||||
if ( sd_card_ready() == 0 ) return RES_NOTRDY;
|
||||
if ( sd_card_ready() == 0 ) return RES_NOTRDY;
|
||||
|
||||
do {
|
||||
do {
|
||||
|
||||
while (1) {
|
||||
while (1) {
|
||||
|
||||
memcpy(dma_sd_buffer, buff, 512);
|
||||
memcpy(dma_sd_buffer, buff, 512);
|
||||
|
||||
result = sd_write_block(sector, dma_sd_buffer) ;
|
||||
result = sd_write_block(sector, dma_sd_buffer) ;
|
||||
|
||||
sd_read_block(sector, dma_sd_buffer) ;
|
||||
sd_read_block(sector, dma_sd_buffer) ;
|
||||
|
||||
if (!memcmp(dma_sd_buffer, buff, 512))
|
||||
break;
|
||||
else {
|
||||
TRACE_ERROR("Block %d ko SR=%.2X\r\n", sector, HSMCI->HSMCI_SR);
|
||||
// DUMP(buff, 512);
|
||||
// DUMP(copy, 512);
|
||||
}
|
||||
}
|
||||
if (!memcmp(dma_sd_buffer, buff, 512))
|
||||
break;
|
||||
else {
|
||||
TRACE_ERROR("Block %d ko SR=%.2X\r\n", sector, HSMCI->HSMCI_SR);
|
||||
// DUMP(buff, 512);
|
||||
// DUMP(copy, 512);
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
sector += 1 ;
|
||||
buff += 512 ;
|
||||
count -= 1 ;
|
||||
}
|
||||
else {
|
||||
count = 1 ; // Flag error
|
||||
break ;
|
||||
}
|
||||
} while ( count ) ;
|
||||
if (result) {
|
||||
sector += 1 ;
|
||||
buff += 512 ;
|
||||
count -= 1 ;
|
||||
}
|
||||
else {
|
||||
count = 1 ; // Flag error
|
||||
break ;
|
||||
}
|
||||
} while ( count ) ;
|
||||
|
||||
if (!count)
|
||||
return RES_OK;
|
||||
if (!count) {
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
if (++sdErrorCount > 3)
|
||||
Card_state = SD_ST_ERR;
|
||||
if (++sdErrorCount > 3)
|
||||
Card_state = SD_ST_ERR;
|
||||
|
||||
return RES_ERROR;
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1372,89 +1378,88 @@ DRESULT disk_ioctl (
|
||||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
DRESULT res;
|
||||
DRESULT res;
|
||||
|
||||
if (drv) return RES_PARERR;
|
||||
if (drv) return RES_PARERR;
|
||||
|
||||
res = RES_ERROR;
|
||||
res = RES_ERROR;
|
||||
|
||||
if (ctrl == CTRL_POWER) {
|
||||
if (ctrl == CTRL_POWER) {
|
||||
#if 0
|
||||
switch (ptr[0]) {
|
||||
case 0: /* Sub control code (POWER_OFF) */
|
||||
power_off(); /* Power off */
|
||||
res = RES_OK;
|
||||
break;
|
||||
case 1: /* Sub control code (POWER_GET) */
|
||||
ptr[1] = (BYTE)power_status();
|
||||
res = RES_OK;
|
||||
break;
|
||||
default :
|
||||
res = RES_PARERR;
|
||||
}
|
||||
switch (ptr[0]) {
|
||||
case 0: /* Sub control code (POWER_OFF) */
|
||||
power_off(); /* Power off */
|
||||
res = RES_OK;
|
||||
break;
|
||||
case 1: /* Sub control code (POWER_GET) */
|
||||
ptr[1] = (BYTE)power_status();
|
||||
res = RES_OK;
|
||||
break;
|
||||
default :
|
||||
res = RES_PARERR;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
switch (ctrl) {
|
||||
case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */
|
||||
res = RES_OK;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
switch (ctrl) {
|
||||
case CTRL_SYNC : /* Make sure that no pending write process. Do not remove this or written sector might not left updated. */
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
*(DWORD*)buff = SD_GET_BLOCKNR();
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
*(DWORD*)buff = SD_GET_BLOCKNR();
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */
|
||||
*(WORD*)buff = 512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */
|
||||
*(WORD*)buff = 512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
|
||||
*(WORD*)buff = 1;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
|
||||
*(WORD*)buff = 1;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case MMC_GET_TYPE : /* Get card type flags (1 byte) */
|
||||
*ptr = CardType;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case MMC_GET_TYPE : /* Get card type flags (1 byte) */
|
||||
*ptr = CardType;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */
|
||||
if (send_cmd(CMD9, 0) == 0 /* READ_CSD */
|
||||
&& rcvr_datablock(ptr, 16))
|
||||
res = RES_OK;
|
||||
break;
|
||||
case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */
|
||||
if (send_cmd(CMD9, 0) == 0 /* READ_CSD */
|
||||
&& rcvr_datablock(ptr, 16))
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */
|
||||
if (send_cmd(CMD10, 0) == 0 /* READ_CID */
|
||||
&& rcvr_datablock(ptr, 16))
|
||||
res = RES_OK;
|
||||
break;
|
||||
case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */
|
||||
if (send_cmd(CMD10, 0) == 0 /* READ_CID */
|
||||
&& rcvr_datablock(ptr, 16))
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
|
||||
if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
|
||||
for (n = 4; n; n--) *ptr++ = rcvr_spi();
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */
|
||||
if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */
|
||||
rcvr_spi();
|
||||
if (rcvr_datablock(ptr, 64))
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
|
||||
// BSS deselect();
|
||||
case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
|
||||
if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
|
||||
for (n = 4; n; n--) *ptr++ = rcvr_spi();
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
return res;
|
||||
case MMC_GET_SDSTAT : /* Receive SD statsu as a data block (64 bytes) */
|
||||
if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */
|
||||
rcvr_spi();
|
||||
if (rcvr_datablock(ptr, 64))
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
// BSS deselect();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ void usbMassStorage()
|
||||
Card_state = SD_ST_DATA;
|
||||
audioQueue.stopSD();
|
||||
closeLogs();
|
||||
f_mount(0, 0); // unmount SD
|
||||
f_mount(NULL, "", 0); // unmount SD
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
|
||||
@@ -276,5 +276,7 @@ void rtcInit()
|
||||
{
|
||||
#if defined(REVX)
|
||||
readRTC();
|
||||
#else
|
||||
coprocReadData();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ int8_t STORAGE_Read (uint8_t lun,
|
||||
* @retval Status
|
||||
*/
|
||||
|
||||
int8_t SD_WriteSectors(uint8_t *buf, uint32_t sector, uint32_t count);
|
||||
int8_t SD_WriteSectors(const uint8_t *buf, uint32_t sector, uint32_t count);
|
||||
|
||||
int8_t STORAGE_Write (uint8_t lun,
|
||||
uint8_t *buf,
|
||||
|
||||
@@ -121,6 +121,10 @@ void FrskyValueWithMinMax::set(uint8_t value, uint8_t unit)
|
||||
this->value = value;
|
||||
}
|
||||
if (!max || value > max) {
|
||||
if (unit == UNIT_VOLTS) {
|
||||
// we consider that the battery pack was just plugged
|
||||
min = value;
|
||||
}
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
@@ -286,7 +290,7 @@ void telemetryWakeup()
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
uint8_t data;
|
||||
#if defined(DEBUG) && !defined(SIMU)
|
||||
#if defined(SPORT_FILE_LOG) && !defined(SIMU)
|
||||
static tmr10ms_t lastTime = 0;
|
||||
tmr10ms_t newTime = get_tmr10ms();
|
||||
struct gtm utm;
|
||||
@@ -294,7 +298,7 @@ void telemetryWakeup()
|
||||
#endif
|
||||
while (telemetryFifo.pop(data)) {
|
||||
processSerialData(data);
|
||||
#if defined(DEBUG) && !defined(SIMU)
|
||||
#if defined(SPORT_FILE_LOG) && !defined(SIMU)
|
||||
extern FIL g_telemetryFile;
|
||||
if (lastTime != newTime) {
|
||||
f_printf(&g_telemetryFile, "\r\n%4d-%02d-%02d,%02d:%02d:%02d.%02d0: %02X", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100, data);
|
||||
@@ -338,6 +342,12 @@ void telemetryWakeup()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
#define FRSKY_BAD_ANTENNA() (IS_VALID_XJT_VERSION() && frskyData.swr.value > 0x33)
|
||||
#else
|
||||
#define FRSKY_BAD_ANTENNA() (frskyData.swr.value > 0x33)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
static tmr10ms_t alarmsCheckTime = 0;
|
||||
static uint8_t alarmsCheckStep = 0;
|
||||
@@ -347,8 +357,8 @@ void telemetryWakeup()
|
||||
alarmsCheckTime = get_tmr10ms() + 100; /* next check in 1 second */
|
||||
|
||||
if (alarmsCheckStep == ALARM_SWR_STEP) {
|
||||
#if defined(PCBTARANIS) && !defined(REVPLUS)
|
||||
if (IS_FRSKY_SPORT_PROTOCOL() && frskyData.swr.value > 0x33) {
|
||||
#if defined(PCBTARANIS)
|
||||
if (IS_FRSKY_SPORT_PROTOCOL() && FRSKY_BAD_ANTENNA()) {
|
||||
AUDIO_SWR_RED();
|
||||
POPUP_WARNING(STR_ANTENNAPROBLEM);
|
||||
alarmsCheckTime = get_tmr10ms() + 300; /* next check in 3 seconds */
|
||||
|
||||
@@ -311,10 +311,13 @@ struct FrskyData {
|
||||
FrskyValueWithMin rssi[2];
|
||||
#if defined(CPUARM)
|
||||
FrskyValueWithMin swr;
|
||||
uint16_t xjtVersion;
|
||||
#endif
|
||||
FrskySerialData hub;
|
||||
FrskySerialData hub;
|
||||
};
|
||||
|
||||
#define IS_VALID_XJT_VERSION() (frskyData.xjtVersion != 0 && frskyData.xjtVersion != 0xff)
|
||||
|
||||
enum AlarmLevel {
|
||||
alarm_off = 0,
|
||||
alarm_yellow = 1,
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
#define ADC2_ID 0xf103
|
||||
#define BATT_ID 0xf104
|
||||
#define SWR_ID 0xf105
|
||||
#define XJT_VERSION_ID 0xf106
|
||||
|
||||
// Default sensor data IDs (Physical IDs + CRC)
|
||||
#define DATA_ID_VARIO 0x00 // 0
|
||||
@@ -298,9 +299,27 @@ void frskySportProcessPacket(uint8_t *packet)
|
||||
link_counter += 256 / FRSKY_SPORT_AVERAGING;
|
||||
frskyData.rssi[0].set(SPORT_DATA_U8(packet));
|
||||
}
|
||||
if (appId == SWR_ID) {
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
if (appId == XJT_VERSION_ID) {
|
||||
frskyData.xjtVersion = HUB_DATA_U16(packet);
|
||||
if (!IS_VALID_XJT_VERSION()) {
|
||||
frskyData.swr.set(0xff);
|
||||
}
|
||||
}
|
||||
else if (appId == SWR_ID) {
|
||||
if (IS_VALID_XJT_VERSION())
|
||||
frskyData.swr.set(SPORT_DATA_U8(packet));
|
||||
else
|
||||
frskyData.swr.set(0xff);
|
||||
}
|
||||
#else
|
||||
if (appId == XJT_VERSION_ID) {
|
||||
frskyData.xjtVersion = HUB_DATA_U16(packet);
|
||||
}
|
||||
else if (appId == SWR_ID) {
|
||||
frskyData.swr.set(SPORT_DATA_U8(packet));
|
||||
}
|
||||
#endif
|
||||
else if (frskyData.rssi[0].value > 0) {
|
||||
if (appId == ADC1_ID || appId == ADC2_ID) {
|
||||
// A1/A2 of DxR receivers
|
||||
|
||||
|
After Width: | Height: | Size: 318 B |
|
After Width: | Height: | Size: 190 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 242 B |
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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 "gtests.h"
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
TEST(EEPROM, 100_random_writes)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
RlcFile f;
|
||||
uint8_t buf[1000];
|
||||
uint8_t buf2[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<100; i++) {
|
||||
int size = rand()%800;
|
||||
for(int j=0; j<size; j++) {
|
||||
buf[j] = rand() < (RAND_MAX/10000*i) ? 0 : (j&0xff);
|
||||
}
|
||||
f.writeRlc(5, 5, buf, size, 100);
|
||||
// printf("size=%4d red=%4d\n\n\n", size, f.size());
|
||||
f.openRd(5);
|
||||
uint16_t n = f.readRlc(buf2,size+1);
|
||||
EXPECT_EQ(n, size);
|
||||
EXPECT_EQ(memcmp(buf, buf2, size), 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(EEPROM, test2)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
RlcFile f;
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
f.writeRlc(6, 6, buf, 300, 100);
|
||||
|
||||
f.openRd(6);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=f.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 300);
|
||||
}
|
||||
|
||||
TEST(EEPROM, eeCheckImmediately)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
// RlcFile f;
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
theFile.writeRlc(6, 6, buf, 300, false);
|
||||
|
||||
eeCheck(true);
|
||||
|
||||
theFile.openRd(6);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=theFile.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 300);
|
||||
}
|
||||
|
||||
TEST(EEPROM, copy)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
theFile.writeRlc(5, 6, buf, 300, true);
|
||||
|
||||
theFile.copy(6, 5);
|
||||
|
||||
theFile.openRd(6);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=theFile.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 300);
|
||||
}
|
||||
|
||||
TEST(EEPROM, rm)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
theFile.writeRlc(5, 6, buf, 300, true);
|
||||
|
||||
EXPECT_EQ(EFile::exists(5), true);
|
||||
|
||||
EFile::rm(5);
|
||||
|
||||
EXPECT_EQ(EFile::exists(5), false);
|
||||
|
||||
theFile.openRd(5);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=theFile.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 0);
|
||||
}
|
||||
#endif
|
||||
@@ -34,18 +34,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define SWAP_DEFINED
|
||||
#include "opentx.h"
|
||||
|
||||
#define TELEMETRY_RESET() \
|
||||
memclear(&frskyData, sizeof(frskyData)); \
|
||||
frskyData.rssi[0].value = 100
|
||||
|
||||
extern bool checkScreenshot(QString test);
|
||||
#include "gtests.h"
|
||||
|
||||
#if defined(FRSKY) && !defined(FRSKY_SPORT)
|
||||
extern void frskyDProcessPacket(uint8_t *packet);
|
||||
@@ -181,6 +170,7 @@ TEST(FrSkySPORT, frskySetCellVoltage)
|
||||
{
|
||||
uint8_t packet[FRSKY_SPORT_PACKET_SIZE];
|
||||
|
||||
MODEL_RESET();
|
||||
TELEMETRY_RESET();
|
||||
|
||||
// test that simulates 3 cell battery
|
||||
@@ -290,6 +280,7 @@ TEST(FrSkySPORT, frskySetCellVoltageTwoSensors)
|
||||
{
|
||||
uint8_t packet[FRSKY_SPORT_PACKET_SIZE];
|
||||
|
||||
MODEL_RESET();
|
||||
TELEMETRY_RESET();
|
||||
|
||||
//sensor 1: 3 cell battery
|
||||
|
||||
@@ -35,10 +35,17 @@
|
||||
*/
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <gtest/gtest.h>
|
||||
#include "gtests.h"
|
||||
|
||||
#define SWAP_DEFINED
|
||||
#include "opentx.h"
|
||||
int32_t lastAct = 0;
|
||||
uint16_t anaInValues[NUM_STICKS+NUM_POTS] = { 0 };
|
||||
uint16_t anaIn(uint8_t chan)
|
||||
{
|
||||
if (chan < NUM_STICKS+NUM_POTS)
|
||||
return anaInValues[chan];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char _zchar2stringResult[200];
|
||||
const char * zchar2string(const char * zstring, int size)
|
||||
@@ -50,133 +57,6 @@ const char * zchar2string(const char * zstring, int size)
|
||||
return _zchar2stringResult;
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
TEST(EEPROM, 100_random_writes)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
RlcFile f;
|
||||
uint8_t buf[1000];
|
||||
uint8_t buf2[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<100; i++) {
|
||||
int size = rand()%800;
|
||||
for(int j=0; j<size; j++) {
|
||||
buf[j] = rand() < (RAND_MAX/10000*i) ? 0 : (j&0xff);
|
||||
}
|
||||
f.writeRlc(5, 5, buf, size, 100);
|
||||
// printf("size=%4d red=%4d\n\n\n", size, f.size());
|
||||
f.openRd(5);
|
||||
uint16_t n = f.readRlc(buf2,size+1);
|
||||
EXPECT_EQ(n, size);
|
||||
EXPECT_EQ(memcmp(buf, buf2, size), 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(EEPROM, test2)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
RlcFile f;
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
f.writeRlc(6, 6, buf, 300, 100);
|
||||
|
||||
f.openRd(6);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=f.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 300);
|
||||
}
|
||||
|
||||
TEST(EEPROM, eeCheckImmediately)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
// RlcFile f;
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
theFile.writeRlc(6, 6, buf, 300, false);
|
||||
|
||||
eeCheck(true);
|
||||
|
||||
theFile.openRd(6);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=theFile.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 300);
|
||||
}
|
||||
|
||||
TEST(EEPROM, copy)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
theFile.writeRlc(5, 6, buf, 300, true);
|
||||
|
||||
theFile.copy(6, 5);
|
||||
|
||||
theFile.openRd(6);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=theFile.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 300);
|
||||
}
|
||||
|
||||
TEST(EEPROM, rm)
|
||||
{
|
||||
eepromFile = NULL; // in memory
|
||||
|
||||
uint8_t buf[1000];
|
||||
|
||||
EeFsFormat();
|
||||
|
||||
for(int i=0; i<1000; i++) buf[i]='6'+i%4;
|
||||
|
||||
theFile.writeRlc(5, 6, buf, 300, true);
|
||||
|
||||
EXPECT_EQ(EFile::exists(5), true);
|
||||
|
||||
EFile::rm(5);
|
||||
|
||||
EXPECT_EQ(EFile::exists(5), false);
|
||||
|
||||
theFile.openRd(5);
|
||||
uint16_t sz=0;
|
||||
for(int i=0; i<500; i++){
|
||||
uint8_t b;
|
||||
uint16_t n=theFile.readRlc(&b,1);
|
||||
if(n) EXPECT_EQ(b, ('6'+sz%4));
|
||||
sz+=n;
|
||||
}
|
||||
EXPECT_EQ(sz, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef __GTESTS_H
|
||||
#define __GTESTS_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define SWAP_DEFINED
|
||||
#include "opentx.h"
|
||||
|
||||
#define CHANNEL_MAX (1024*256)
|
||||
|
||||
extern int32_t lastAct;
|
||||
extern uint16_t anaInValues[NUM_STICKS+NUM_POTS];
|
||||
|
||||
void doMixerCalculations();
|
||||
|
||||
inline void 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;
|
||||
}
|
||||
|
||||
inline void MIXER_RESET()
|
||||
{
|
||||
memset(channelOutputs, 0, sizeof(channelOutputs));
|
||||
memset(chans, 0, sizeof(chans));
|
||||
memset(ex_chans, 0, sizeof(ex_chans));
|
||||
memset(act, 0, sizeof(act));
|
||||
memset(swOn, 0, sizeof(swOn));
|
||||
#if !defined(CPUARM)
|
||||
s_last_switch_used = 0;
|
||||
s_last_switch_value = 0;
|
||||
#endif
|
||||
mixerCurrentFlightMode = lastFlightMode = 0;
|
||||
lastAct = 0;
|
||||
logicalSwitchesReset();
|
||||
}
|
||||
|
||||
inline void TELEMETRY_RESET()
|
||||
{
|
||||
memclear(&frskyData, sizeof(frskyData));
|
||||
frskyData.rssi[0].value = 100;
|
||||
}
|
||||
|
||||
void MIXER_RESET();
|
||||
|
||||
bool checkScreenshot(QString test);
|
||||
|
||||
#endif
|
||||
@@ -264,6 +264,106 @@ TEST(Lcd, BMPWrapping)
|
||||
bmpLoad(bitmap, "./tests/plane.bmp", 40, 40);
|
||||
lcd_bmp(200, 0, bitmap);
|
||||
lcd_bmp(200, 60, bitmap);
|
||||
lcd_bmp(240, 60, bitmap); // x too big
|
||||
lcd_bmp(20, 200, bitmap); // y too big
|
||||
EXPECT_TRUE(checkScreenshot("bmpwrapping"));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(Lcd, lcd_hlineStip)
|
||||
{
|
||||
lcd_clear();
|
||||
lcd_hlineStip(0, 10, LCD_W, DOTTED);
|
||||
lcd_hlineStip(0, 20, LCD_W, SOLID);
|
||||
lcd_hlineStip(50, 30, LCD_W, 0xEE); //too wide
|
||||
lcd_hlineStip(50, LCD_H + 10, 20, SOLID); //too low
|
||||
lcd_hlineStip(250, 30, LCD_W, SOLID); //x outside display
|
||||
EXPECT_TRUE(checkScreenshot("lcd_hlineStip"));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(Lcd, lcd_vlineStip)
|
||||
{
|
||||
lcd_clear();
|
||||
lcd_vlineStip(10, 0, LCD_H, DOTTED);
|
||||
lcd_vlineStip(20, 0, LCD_H, SOLID);
|
||||
lcd_vlineStip(30, 30, LCD_H, 0xEE); //too high
|
||||
lcd_vlineStip(40, LCD_H + 10, 20, SOLID); //too low
|
||||
lcd_vlineStip(250, LCD_H + 10, LCD_H, SOLID); //x outside display
|
||||
EXPECT_TRUE(checkScreenshot("lcd_vlineStip"));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <int padding> class TestBuffer
|
||||
{
|
||||
private:
|
||||
uint8_t * buf;
|
||||
uint32_t size;
|
||||
public:
|
||||
TestBuffer(uint32_t size) : buf(0), size(size) {
|
||||
buf = new uint8_t[size + padding * 2];
|
||||
memset(buf, 0xA5, padding);
|
||||
memset(buf+padding, 0x00, size);
|
||||
memset(buf+padding+size, 0x5A, padding);
|
||||
};
|
||||
~TestBuffer() { if (buf) delete[] buf; };
|
||||
uint8_t * buffer() { return buf + padding; };
|
||||
void leakCheck() const {
|
||||
uint8_t paddingCompareBuf[padding];
|
||||
memset(paddingCompareBuf, 0xA5, padding);
|
||||
if (memcmp(buf, paddingCompareBuf, padding) != 0) {
|
||||
ADD_FAILURE() << "buffer leaked low";
|
||||
};
|
||||
memset(paddingCompareBuf, 0x5A, padding);
|
||||
if (memcmp(buf+padding+size, paddingCompareBuf, padding) != 0) {
|
||||
ADD_FAILURE() << "buffer leaked high";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(Lcd, lcd_bmpLoadAndDisplay)
|
||||
{
|
||||
lcd_clear();
|
||||
// Test proper BMP files, they should display correctly
|
||||
{
|
||||
TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(7, 32));
|
||||
EXPECT_EQ(bmpLoad(bitmap.buffer(), "./tests/4b_7x32.bmp", 7, 32), (char *)0);
|
||||
bitmap.leakCheck();
|
||||
lcd_bmp(10, 2, bitmap.buffer());
|
||||
}
|
||||
{
|
||||
TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(6, 32));
|
||||
EXPECT_EQ(bmpLoad(bitmap.buffer(), "./tests/1b_6x32.bmp", 6, 32), (char *)0);
|
||||
bitmap.leakCheck();
|
||||
lcd_bmp(20, 2, bitmap.buffer());
|
||||
}
|
||||
{
|
||||
TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(31, 31));
|
||||
EXPECT_EQ(bmpLoad(bitmap.buffer(), "./tests/4b_31x31.bmp", 31, 31), (char *)0);
|
||||
bitmap.leakCheck();
|
||||
lcd_bmp(30, 2, bitmap.buffer());
|
||||
}
|
||||
{
|
||||
TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(39, 32));
|
||||
EXPECT_EQ(bmpLoad(bitmap.buffer(), "./tests/1b_39x32.bmp", 39, 32), (char *)0);
|
||||
bitmap.leakCheck();
|
||||
lcd_bmp(70, 2, bitmap.buffer());
|
||||
}
|
||||
EXPECT_TRUE(checkScreenshot("lcd_bmpLoadAndDisplay"));
|
||||
|
||||
// Test various bad BMP files, they should not display
|
||||
{
|
||||
TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(LCD_W+1, 32));
|
||||
EXPECT_EQ(bmpLoad(bitmap.buffer(), "", LCD_W+1, 32), STR_INCOMPATIBLE) << "to wide";
|
||||
bitmap.leakCheck();
|
||||
}
|
||||
{
|
||||
TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(10, 10));
|
||||
EXPECT_EQ(bmpLoad(bitmap.buffer(), "./tests/1b_39x32.bmp", 10, 10), STR_INCOMPATIBLE) << "to small buffer";
|
||||
bitmap.leakCheck();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 307 B |
|
After Width: | Height: | Size: 326 B |
@@ -34,47 +34,31 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "gtests.h"
|
||||
|
||||
#define SWAP_DEFINED
|
||||
#include "opentx.h"
|
||||
#define CHECK_NO_MOVEMENT(channel, value, duration) \
|
||||
for (int i=1; i<=(duration); i++) { \
|
||||
evalFlightModeMixes(e_perout_mode_normal, 1); \
|
||||
EXPECT_EQ(chans[(channel)], (value)); \
|
||||
}
|
||||
|
||||
#define CHANNEL_MAX (1024*256)
|
||||
#define CHECK_SLOW_MOVEMENT(channel, sign, duration) \
|
||||
do { \
|
||||
for (int i=1; i<=(duration); i++) { \
|
||||
evalFlightModeMixes(e_perout_mode_normal, 1); \
|
||||
lastAct = lastAct + (sign) * (1<<19)/500; /* 100 on ARM */ \
|
||||
EXPECT_EQ(chans[(channel)], 256 * (lastAct >> 8)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
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;
|
||||
|
||||
int32_t lastAct = 0;
|
||||
void MIXER_RESET()
|
||||
{
|
||||
memset(channelOutputs, 0, sizeof(channelOutputs));
|
||||
memset(ex_chans, 0, sizeof(ex_chans));
|
||||
memset(act, 0, sizeof(act));
|
||||
memset(swOn, 0, sizeof(swOn));
|
||||
#if !defined(CPUARM)
|
||||
s_last_switch_used = 0;
|
||||
s_last_switch_value = 0;
|
||||
#endif
|
||||
mixerCurrentFlightMode = lastFlightMode = 0;
|
||||
lastAct = 0;
|
||||
logicalSwitchesReset();
|
||||
}
|
||||
|
||||
uint16_t anaInValues[NUM_STICKS+NUM_POTS] = { 0 };
|
||||
uint16_t anaIn(uint8_t chan)
|
||||
{
|
||||
if (chan < NUM_STICKS+NUM_POTS)
|
||||
return anaInValues[chan];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#define CHECK_DELAY(channel, duration) \
|
||||
do { \
|
||||
int32_t value = chans[(channel)]; \
|
||||
for (int i=1; i<=(duration); i++) { \
|
||||
evalFlightModeMixes(e_perout_mode_normal, 1); \
|
||||
EXPECT_EQ(chans[(channel)], value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
TEST(Trims, throttleTrim)
|
||||
{
|
||||
@@ -640,30 +624,6 @@ TEST(Mixer, RecursiveAddChannelAfterInactivePhase)
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX);
|
||||
}
|
||||
|
||||
#define CHECK_NO_MOVEMENT(channel, value, duration) \
|
||||
for (int i=1; i<=(duration); i++) { \
|
||||
evalFlightModeMixes(e_perout_mode_normal, 1); \
|
||||
EXPECT_EQ(chans[(channel)], (value)); \
|
||||
}
|
||||
|
||||
#define CHECK_SLOW_MOVEMENT(channel, sign, duration) \
|
||||
do { \
|
||||
for (int i=1; i<=(duration); i++) { \
|
||||
evalFlightModeMixes(e_perout_mode_normal, 1); \
|
||||
lastAct = lastAct + (sign) * (1<<19)/500; /* 100 on ARM */ \
|
||||
EXPECT_EQ(chans[(channel)], 256 * (lastAct >> 8)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_DELAY(channel, duration) \
|
||||
do { \
|
||||
int32_t value = chans[(channel)]; \
|
||||
for (int i=1; i<=(duration); i++) { \
|
||||
evalFlightModeMixes(e_perout_mode_normal, 1); \
|
||||
EXPECT_EQ(chans[(channel)], value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if !defined(CPUARM)
|
||||
TEST(Mixer, SlowOnSwitch)
|
||||
{
|
||||
@@ -1006,7 +966,9 @@ TEST(Heli, Mode2Test)
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX/2);
|
||||
EXPECT_EQ(chans[2], CHANNEL_MAX/2);
|
||||
}
|
||||
#elif defined(HELI)
|
||||
#endif
|
||||
|
||||
#if defined(HELI) && !defined(PCBTARANIS)
|
||||
TEST(Heli, SimpleTest)
|
||||
{
|
||||
MODEL_RESET();
|
||||
@@ -1018,3 +980,18 @@ TEST(Heli, SimpleTest)
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX/2);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Trainer, UnpluggedTest)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].mltpx = MLTPX_ADD;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_FIRST_TRAINER;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].delayUp = DELAY_STEP*5;
|
||||
g_model.mixData[0].delayDown = DELAY_STEP*5;
|
||||
ppmInValid = 0;
|
||||
g_ppmIns[0] = 1024;
|
||||
CHECK_DELAY(0, 5000);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,9 @@ const pm_char STR_OPEN9X[] PROGMEM =
|
||||
ISTR(VKEYS)
|
||||
ISTR(VSWITCHES)
|
||||
ISTR(VSRCRAW)
|
||||
#if defined(TRANSLATIONS_CZ) && defined(CPUARM)
|
||||
ISTR(INPUTNAMES)
|
||||
#endif
|
||||
ISTR(VTMRMODES)
|
||||
#if defined(CPUM2560) || defined(CPUARM)
|
||||
ISTR(DATETIME)
|
||||
|
||||
@@ -153,7 +153,12 @@ extern const pm_char STR_OPEN9X[];
|
||||
#endif
|
||||
#define OFS_VSWITCHES (OFS_VKEYS + sizeof(TR_VKEYS))
|
||||
#define OFS_VSRCRAW (OFS_VSWITCHES + sizeof(TR_VSWITCHES))
|
||||
#define OFS_VTMRMODES (OFS_VSRCRAW + sizeof(TR_VSRCRAW))
|
||||
#if defined(TRANSLATIONS_CZ) && defined(CPUARM)
|
||||
#define OFS_INPUTNAMES (OFS_VSRCRAW + sizeof(TR_VSRCRAW))
|
||||
#define OFS_VTMRMODES (OFS_INPUTNAMES + sizeof(TR_INPUTNAMES))
|
||||
#else
|
||||
#define OFS_VTMRMODES (OFS_VSRCRAW + sizeof(TR_VSRCRAW))
|
||||
#endif
|
||||
#define OFS_DATETIME (OFS_VTMRMODES + sizeof(TR_VTMRMODES))
|
||||
#if defined(CPUM2560) || defined(CPUARM)
|
||||
#define OFS_VPERSISTENT (OFS_DATETIME + sizeof(TR_DATETIME))
|
||||
@@ -249,6 +254,9 @@ extern const pm_char STR_OPEN9X[];
|
||||
#define STR_VKEYS (STR_OPEN9X + OFS_VKEYS)
|
||||
#define STR_VSWITCHES (STR_OPEN9X + OFS_VSWITCHES)
|
||||
#define STR_VSRCRAW (STR_OPEN9X + OFS_VSRCRAW)
|
||||
#if defined(TRANSLATIONS_CZ) && defined(CPUARM)
|
||||
#define STR_INPUTNAMES (STR_OPEN9X + OFS_INPUTNAMES)
|
||||
#endif
|
||||
#define STR_VTMRMODES (STR_OPEN9X + OFS_VTMRMODES)
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
|
||||
@@ -457,6 +457,9 @@
|
||||
|
||||
#define TR_VSRCRAW "---\0""Směr""Výšk""Plyn""Křid" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmS" "TrmV" "TrmP" "TrmK" TR_SW_VSRCRAW
|
||||
|
||||
#define LEN_INPUTNAMES "\004"
|
||||
#define TR_INPUTNAMES "Smer""Vysk""Plyn""Krid"
|
||||
|
||||
#define LEN_VTMRMODES "\004"
|
||||
#define TR_VTMRMODES "VYP\0""ABS\0""Pln>""Pln%""Pln*"
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ if docFile:
|
||||
#prepare fields
|
||||
all_exports = [(name, desc) for (id, name, desc) in exports]
|
||||
for (id, nameFormat, descriptionFormat, valuesCount) in exports_multiple:
|
||||
for v in range(valuesCount):
|
||||
for v in range(1, valuesCount + 1):
|
||||
name = nameFormat + str(v)
|
||||
desc = descriptionFormat % v
|
||||
all_exports.append( (name, desc) )
|
||||
|
||||
@@ -630,7 +630,7 @@ def ttsCz():
|
||||
"vat", "vaty", u"vatů", "vatu",
|
||||
"decibel", "decibely", u"decibelů", "decibelu",
|
||||
"stopa", "stopy", "stop", "stopy",
|
||||
"uzel", "uzly", u"uzlů", "uzlu",
|
||||
u"míle za hodinu", u"míle za hodinu", u"mil za hodinu", "míle za hodinu",
|
||||
"hodina", "hodiny", "hodin", "hodiny",
|
||||
"minuta", "minuty", "minut", "minuty",
|
||||
"sekunda", "sekundy", "sekund", "sekundy",
|
||||
@@ -652,6 +652,10 @@ def ttsCz():
|
||||
(u"A1,kritická", "a1_red", NO_ALTERNATE),
|
||||
(u"A2,nízká", "a2_org", NO_ALTERNATE),
|
||||
(u"A2,kritická", "a2_red", NO_ALTERNATE),
|
||||
(u"A3,nízká", "a3_org", NO_ALTERNATE),
|
||||
(u"A3,kritická", "a3_red", NO_ALTERNATE),
|
||||
(u"A4,nízká", "a4_org", NO_ALTERNATE),
|
||||
(u"A4,kritická", "a4_red", NO_ALTERNATE),
|
||||
(u"nízký RF signál", "rssi_org", NO_ALTERNATE),
|
||||
(u"kritický RF signál", "rssi_red", NO_ALTERNATE),
|
||||
(u"problém s anténou rádia", "swr_red", NO_ALTERNATE),
|
||||
@@ -660,8 +664,8 @@ def ttsCz():
|
||||
]:
|
||||
systemSounds.append((s, filename(f, a)))
|
||||
for i, (s, f) in enumerate([
|
||||
(u"podvozek je zasunut", "podvozek0"),
|
||||
(u"podvozek je vysunut", "podvozek1"),
|
||||
(u"podvozek je zasunut", "podvoz0"),
|
||||
(u"podvozek je vysunut", "podvoz1"),
|
||||
(u"klapky jsou zapnuty", "klapky1"),
|
||||
(u"klapky jsou vypnuty", "klapky0"),
|
||||
(u"trenér je zapnut", "trener1"),
|
||||
@@ -670,7 +674,7 @@ def ttsCz():
|
||||
(u"motor je aktivován", "motor1"),
|
||||
(u"jsi příliš vysoko", "vysoko"),
|
||||
(u"jsi příliš nízko", "nizko"),
|
||||
(u"baterie modelu je vybitá", "bytvybita"),
|
||||
(u"baterie modelu je vybitá", "batvybit"),
|
||||
(u"dochází palivo", "palivo"),
|
||||
(u"nízký signál!", "nsignal"),
|
||||
(u"kritický signál!", "ksignal"),
|
||||
@@ -678,10 +682,10 @@ def ttsCz():
|
||||
(u"termický režim aktivován", "r_termik"),
|
||||
(u"normální režim aktivován", "r_norm"),
|
||||
(u"režim start aktivován", "r_start"),
|
||||
(u"režim přistání aktivován", "r_pristani"),
|
||||
(u"režim přistání aktivován", "r_prista"),
|
||||
(u"vario je zapnuto", "vario0"),
|
||||
(u"vario je vypnuto", "vario1"),
|
||||
(u"start povolen", "stpovolen"),
|
||||
(u"start povolen", "startok"),
|
||||
]):
|
||||
sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
|
||||
return systemSounds, sounds
|
||||
|
||||