1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-20 23:05:09 +03:00

Merge branch '2.3' of https://github.com/opentx/opentx into 2.3

This commit is contained in:
MRC3742 2019-08-28 19:59:54 -04:00
commit b8408e3b53
61 changed files with 544 additions and 388 deletions

View file

@ -44,6 +44,20 @@ bool ModuleData::isPxx2Module() const
}
}
bool ModuleData::isPxx1Module() const
{
switch(protocol){
case PULSES_PXX_XJT_X16:
case PULSES_PXX_R9M:
case PULSES_PXX_R9M_LITE:
case PULSES_PXX_R9M_LITE_PRO:
return true;
default:
return false;
}
}
QString ModuleData::rfProtocolToString() const
{
switch (protocol) {

View file

@ -183,6 +183,7 @@ class ModuleData {
void clear() { memset(this, 0, sizeof(ModuleData)); }
void convert(RadioDataConversionState & cstate);
bool isPxx2Module() const;
bool isPxx1Module() const;
QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); }
QString rfProtocolToString() const;
QString subTypeToString(int type = -1) const;

View file

@ -1856,10 +1856,11 @@ class CustomScreenField: public StructField {
class SensorField: public TransformedField {
public:
SensorField(DataField * parent, SensorData & sensor, Board::Type board, unsigned int version):
SensorField(DataField * parent, const ModelData& model, SensorData & sensor, Board::Type board, unsigned int version):
TransformedField(parent, internalField),
internalField(this, "Sensor"),
sensor(sensor),
model(model),
version(version),
_param(0)
{
@ -1921,7 +1922,10 @@ class SensorField: public TransformedField {
if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) {
sensor.id = _id;
sensor.subid = _subid;
sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance
if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module())
sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance
else
sensor.instance = _instance;
sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx
sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx
sensor.ratio = _ratio;
@ -1954,6 +1958,7 @@ class SensorField: public TransformedField {
protected:
StructField internalField;
SensorData & sensor;
const ModelData& model;
unsigned int version;
unsigned int _id;
unsigned int _subid;
@ -2426,7 +2431,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig
}
for (int i=0; i<MAX_TELEMETRY_SENSORS(board, version); ++i) {
internalField.Append(new SensorField(this, modelData.sensorData[i], board, version));
internalField.Append(new SensorField(this, modelData, modelData.sensorData[i], board, version));
}
if (IS_TARANIS_X9E(board)) {

View file

@ -97,7 +97,7 @@ void *bin_l_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
free(ptr);
}
}
return NULL;
return nullptr;
}
else {
#if defined(DEBUG)

View file

@ -95,7 +95,7 @@ char * Bluetooth::readline(bool error_reset)
state = BLUETOOTH_STATE_OFF;
wakeupTime = get_tmr10ms() + 100; /* 1s */
#endif
return NULL;
return nullptr;
}
else
#endif

View file

@ -70,7 +70,7 @@ int toLongLongInt(const char ** argv, int index, long long int * val)
base = 16;
s = &argv[index][2];
}
char * endptr = NULL;
char * endptr = nullptr;
*val = strtoll(s, &endptr, base);
if (*endptr == '\0')
return 1;
@ -782,7 +782,7 @@ const MemArea memAreas[] = {
{ "USART1", USART1, sizeof(USART_TypeDef) },
{ "USART2", USART2, sizeof(USART_TypeDef) },
{ "USART3", USART3, sizeof(USART_TypeDef) },
{ NULL, NULL, 0 },
{ nullptr, nullptr, 0 },
};
int cliSet(const char ** argv)
@ -947,7 +947,7 @@ int cliDisplay(const char ** argv)
{
long long int address = 0;
for (const MemArea * area = memAreas; area->name != NULL; area++) {
for (const MemArea * area = memAreas; area->name != nullptr; area++) {
if (!strcmp(area->name, argv[1])) {
dump((uint8_t *)area->start, area->size);
return 0;
@ -1218,12 +1218,12 @@ const CliCommand cliCommands[] = {
#if defined(BLUETOOTH)
{ "bt", cliBlueTooth, "<baudrate>|<command>" },
#endif
{ NULL, NULL, NULL } /* sentinel */
{ nullptr, nullptr, nullptr } /* sentinel */
};
int cliHelp(const char ** argv)
{
for (const CliCommand * command = cliCommands; command->name != NULL; command++) {
for (const CliCommand * command = cliCommands; command->name != nullptr; command++) {
if (argv[1][0] == '\0' || !strcmp(command->name, argv[0])) {
serialPrint("%s %s", command->name, command->args);
if (argv[1][0] != '\0') {
@ -1242,7 +1242,7 @@ int cliExecCommand(const char ** argv)
if (argv[0][0] == '\0')
return 0;
for (const CliCommand * command = cliCommands; command->name != NULL; command++) {
for (const CliCommand * command = cliCommands; command->name != nullptr; command++) {
if (!strcmp(command->name, argv[0])) {
return command->func(argv);
}

View file

@ -249,12 +249,16 @@ enum UartModes {
enum TelemetryProtocol
{
TELEM_PROTO_FRSKY_D,
TELEM_PROTO_FRSKY_SPORT,
TELEM_PROTO_CROSSFIRE,
TELEM_PROTO_SPEKTRUM,
TELEM_PROTO_LUA,
TELEM_PROTO_FLYSKY_IBUS,
PROTOCOL_TELEMETRY_FIRST,
PROTOCOL_TELEMETRY_FRSKY_SPORT = PROTOCOL_TELEMETRY_FIRST,
PROTOCOL_TELEMETRY_FRSKY_D,
PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY,
PROTOCOL_TELEMETRY_CROSSFIRE,
PROTOCOL_TELEMETRY_SPEKTRUM,
PROTOCOL_TELEMETRY_FLYSKY_IBUS,
PROTOCOL_TELEMETRY_MULTIMODULE,
PROTOCOL_TELEMETRY_LAST=PROTOCOL_TELEMETRY_MULTIMODULE,
PROTOCOL_TELEMETRY_LUA
};
#define TELEM_LABEL_LEN 4

View file

@ -379,7 +379,7 @@ PACK(struct TelemetrySensor {
int32_t getPrecDivisor() const;
bool isSameInstance(TelemetryProtocol protocol, uint8_t instance)
{
if (protocol == TELEM_PROTO_FRSKY_SPORT) {
if (protocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
if (((this->instance ^ instance) & 0x9F) == 0) {
this->instance = instance; // update the instance in case we had telemetry switching
return true;

View file

@ -22,12 +22,6 @@ set(GUI_SRC
view_statistics.cpp
)
set(SRC
${SRC}
gui/common/widgets.cpp
gui/common/arm/widgets.cpp
)
if(FLIGHT_MODES)
set(GUI_SRC
${GUI_SRC}

View file

@ -813,21 +813,6 @@ void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att)
drawSwitch(x, y, mode, att);
}
void drawTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(fm, idx);
uint8_t mode = v.mode;
uint8_t p = mode >> 1;
char s[] = "--";
if (mode != TRIM_MODE_NONE) {
if (mode % 2 == 0)
s[0] = ':';
else
s[0] = '+';
s[1] = '0'+p;
}
lcdDrawText(x, y, s, att);
}
void drawShortTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(fm, idx);
@ -841,15 +826,6 @@ void drawShortTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags a
}
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
lcdDrawTextAtIndex(lcdLastRightPos/*+1*/, y, STR_VTELEMUNIT, unit, 0);
}
}
void drawGPSCoord(coord_t x, coord_t y, int32_t value, const char * direction, LcdFlags att, bool seconds=true)
{
att &= ~RIGHT & ~BOLD;

View file

@ -130,7 +130,6 @@ void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
void drawShortTrimMode(coord_t x, coord_t y, uint8_t mode, uint8_t idx, LcdFlags att);
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)

View file

@ -33,7 +33,7 @@ void onModelCustomScriptMenu(const char *result)
ScriptData &sd = g_model.scriptsData[s_currIdx];
if (result == STR_UPDATE_LIST) {
if (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) {
if (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), nullptr)) {
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
}
}

View file

@ -31,7 +31,7 @@ const unsigned char sticks[] = {
#define SLIDER_5POS(y, value, label, event, attr) { \
int8_t tmp = value; \
drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, 2+tmp, 4, attr); \
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, nullptr, tmp, -2, +2, attr, event); \
}
#if defined(SPLASH)

View file

@ -550,7 +550,7 @@ void menuMainView(event_t event)
lcdDrawText(lcdLastRightPos, 5*FH, "%", BOLD);
}
lcdDrawText(lcdLastRightPos, 5*FH, "]", BOLD);
warningText = NULL;
warningText = nullptr;
}
#endif

View file

@ -22,12 +22,6 @@ set(GUI_SRC
view_statistics.cpp
)
set(SRC
${SRC}
gui/common/widgets.cpp
gui/common/arm/widgets.cpp
)
if(FLIGHT_MODES)
set(GUI_SRC
${GUI_SRC}

View file

@ -718,33 +718,6 @@ void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att)
drawSwitch(x, y, mode, att);
}
void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(phase, idx);
unsigned int mode = v.mode;
unsigned int p = mode >> 1;
if (mode == TRIM_MODE_NONE) {
lcdDrawText(x, y, "--", att);
}
else {
if (mode % 2 == 0)
lcdDrawChar(x, y, ':', att|FIXEDWIDTH);
else
lcdDrawChar(x, y, '+', att|FIXEDWIDTH);
lcdDrawChar(lcdNextPos, y, '0'+p, att);
}
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
lcdDrawTextAtIndex(lcdLastRightPos/*+1*/, y, STR_VTELEMUNIT, unit, 0);
}
}
void drawGPSCoord(coord_t x, coord_t y, int32_t value, const char * direction, LcdFlags att, bool seconds=true)
{
uint32_t absvalue = abs(value);

View file

@ -123,7 +123,6 @@ void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att=0);
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);

View file

@ -143,7 +143,7 @@ void copySelection(char * dst, const char * src, uint8_t size)
void onModelSetupBitmapMenu(const char * result)
{
if (result == STR_UPDATE_LIST) {
if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), NULL)) {
if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), nullptr)) {
POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
}
}

View file

@ -52,7 +52,7 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
strcpy(directory, SOUNDS_PATH);
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
}
if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), NULL)) {
if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), nullptr)) {
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
}
}

View file

@ -33,7 +33,7 @@ const unsigned char sticks[] = {
#define SLIDER_5POS(y, value, label, event, attr) { \
int8_t tmp = value; \
drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, label, nullptr, tmp, -2, +2, attr, event); \
}
#if defined(SPLASH)

View file

@ -92,7 +92,7 @@ choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label, LcdFlags attr, event_t event )
{
drawCheckBox(x, y, value, attr);
return editChoice(x, y, label, NULL, value, 0, 1, attr, event);
return editChoice(x, y, label, nullptr, value, 0, 1, attr, event);
}
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event)

View file

@ -26,12 +26,6 @@ set(GUI_SRC
view_statistics.cpp
)
set(SRC
${SRC}
gui/common/widgets.cpp
gui/common/arm/widgets.cpp
)
if(FLIGHT_MODES)
set(GUI_SRC
${GUI_SRC}

View file

@ -18,11 +18,11 @@
* GNU General Public License for more details.
*/
#ifndef _WIDGETS_H_
#define _WIDGETS_H_
#ifndef _DRAW_FUNCTIONS_H_
#define _DRAW_FUNCTIONS_H_
#include "opentx.h"
#include <stdio.h>
#include "common/colorlcd/draw_functions.h"
#define OPTION_MENU_NO_FOOTER 0x01
#define OPTION_MENU_TITLE_BAR 0x02
@ -78,4 +78,4 @@ void drawTrims(uint8_t flightMode);
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags);
#endif // _WIDGETS_H_
#endif // _DRAW_FUNCTIONS_H_

View file

@ -24,7 +24,7 @@
#include "gui_common.h"
#include "lcd.h"
#include "menus.h"
#include "widgets.h"
#include "draw_functions.h"
#include "bitmaps.h"
#include "theme.h"

View file

@ -18,6 +18,7 @@
* GNU General Public License for more details.
*/
#include <stdio.h>
#include "opentx.h"
unsigned int Topbar::getZonesCount() const

View file

@ -1,6 +1,6 @@
set(GUI_SRC
${GUI_SRC}
../common/colorlcd/widgets.cpp
../common/colorlcd/draw_functions.cpp
)
if(HELI)

View file

@ -20,6 +20,155 @@
#include "opentx.h"
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix)
{
char s[64];
char * tmp = (prefix ? strAppend(s, prefix) : s);
tmp = strAppend(tmp, str);
tmp = strAppendUnsigned(tmp, abs(idx));
if (suffix)
strAppend(tmp, suffix);
lcdDrawText(x, y, s, flags);
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
char unitStr[8];
strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]);
lcdDrawNumber(x, y, val, att, 0, NULL, unitStr);
}
else {
lcdDrawNumber(x, y, val, att);
}
}
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event)
{
if (attr & INVERS) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
return value;
}
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event )
{
value = editChoice(x, y, NULL, value, 0, 1, attr, event);
drawCheckBox(x, y, value, attr);
return value;
}
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event)
{
if (attr & INVERS) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
drawSwitch(x, y, value, attr);
return value;
}
void drawFatalErrorScreen(const char * message)
{
lcdClear();
lcdDrawText(LCD_W/2, LCD_H/2-20, message, DBLSIZE|CENTERED|TEXT_BGCOLOR);
lcdRefresh();
}
void runFatalErrorScreen(const char * message)
{
while (1) {
drawFatalErrorScreen(message);
backlightEnable(100);
uint8_t refresh = false;
while (1) {
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
boardOff();
return; // only happens in SIMU, required for proper shutdown
}
else if (pwr_check == e_power_press) {
refresh = true;
}
else if (pwr_check == e_power_on && refresh) {
break;
}
}
}
}
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att)
{
float power_W_PREC1 = pow(10.0, (dBm - 30.0) / 10.0) * 10;
if (dBm >= 30) {
lcdDrawNumber(x, y, power_W_PREC1, PREC1 | att);
lcdDrawText(lcdNextPos, y, "W", att);
}
else if (dBm < 10) {
uint16_t power_MW_PREC1 = round(power_W_PREC1 * 1000);
lcdDrawNumber(x, y, power_MW_PREC1, PREC1 | att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
else {
uint16_t power_MW = round(power_W_PREC1 * 100);
if (power_MW >= 50) {
power_MW = (power_MW / 5) * 5;
lcdDrawNumber(x, y, power_MW, att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
else {
lcdDrawNumber(x, y, power_MW, att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
}
}
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags)
{
lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, flags);
}
#if defined(FLIGHT_MODES)
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
{
if (idx==0) {
lcdDrawMMM(x, y, att);
return;
}
// TODO this code was not included in Taranis! and used with abs(...) on Horus
if (idx < 0) {
lcdDrawChar(x-2, y, '!', att);
idx = -idx;
}
#if defined(CONDENSED)
if (att & CONDENSED) {
lcdDrawNumber(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
return;
}
#endif
drawStringWithIndex(x, y, STR_FM, idx-1, att);
}
#endif
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* 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 "opentx.h"
void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags att)
{
if (curve.value != 0) {
@ -133,7 +282,7 @@ void drawSourceCustomValue(coord_t x, coord_t y, source_t source, int32_t value,
lcdDrawNumber(x, y, value, flags|PREC1);
}
#if defined(INTERNAL_GPS)
else if (source == MIXSRC_TX_GPS) {
else if (source == MIXSRC_TX_GPS) {
if (gpsData.fix) {
drawGPSPosition(x, y, gpsData.longitude, gpsData.latitude, flags);
}
@ -144,7 +293,7 @@ void drawSourceCustomValue(coord_t x, coord_t y, source_t source, int32_t value,
}
#endif
#if defined(GVARS)
else if (source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR) {
else if (source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR) {
drawGVarValue(x, y, source - MIXSRC_FIRST_GVAR, value, flags);
}
#endif

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __COLORLCD_DRAW_FUNCTIONS__
#define __COLORLCD_DRAW_FUNCTIONS__
#include "lcd.h"
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix);
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att);
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
void drawFatalErrorScreen(const char * message);
void runFatalErrorScreen(const char * message);
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att);
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags);
#if defined(FLIGHT_MODES)
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att);
#endif
#endif // __COLORLCD_DRAW_FUNCTIONS__

View file

@ -1,121 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* 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 "opentx.h"
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix)
{
char s[64];
char * tmp = (prefix ? strAppend(s, prefix) : s);
tmp = strAppend(tmp, str);
tmp = strAppendUnsigned(tmp, abs(idx));
if (suffix)
strAppend(tmp, suffix);
lcdDrawText(x, y, s, flags);
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
char unitStr[8];
strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]);
lcdDrawNumber(x, y, val, att, 0, NULL, unitStr);
}
else {
lcdDrawNumber(x, y, val, att);
}
}
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event)
{
if (attr & INVERS) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
return value;
}
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event )
{
value = editChoice(x, y, NULL, value, 0, 1, attr, event);
drawCheckBox(x, y, value, attr);
return value;
}
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event)
{
if (attr & INVERS) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
drawSwitch(x, y, value, attr);
return value;
}
void drawFatalErrorScreen(const char * message)
{
lcdClear();
lcdDrawText(LCD_W/2, LCD_H/2-20, message, DBLSIZE|CENTERED|TEXT_BGCOLOR);
lcdRefresh();
}
void runFatalErrorScreen(const char * message)
{
while (1) {
drawFatalErrorScreen(message);
backlightEnable(100);
uint8_t refresh = false;
while (1) {
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
boardOff();
return; // only happens in SIMU, required for proper shutdown
}
else if (pwr_check == e_power_press) {
refresh = true;
}
else if (pwr_check == e_power_on && refresh) {
break;
}
}
}
}
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att)
{
float power_W_PREC1 = pow(10.0, (dBm - 30.0) / 10.0) * 10;
if (dBm >= 30) {
lcdDrawNumber(x, y, power_W_PREC1, PREC1 | att);
lcdDrawText(lcdNextPos, y, "W", att);
}
else if (dBm < 10) {
uint16_t power_MW_PREC1 = round(power_W_PREC1 * 1000);
lcdDrawNumber(x, y, power_MW_PREC1, PREC1 | att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
else {
uint16_t power_MW = round(power_W_PREC1 * 100);
if (power_MW >= 50) {
power_MW = (power_MW / 5) * 5;
lcdDrawNumber(x, y, power_MW, att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
else {
lcdDrawNumber(x, y, power_MW, att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
}
}

View file

@ -3,7 +3,7 @@ add_definitions(-DGRAPHICS)
set(GUI_SRC
${GUI_SRC}
../common/stdlcd/menus.cpp
../common/stdlcd/widgets.cpp
../common/stdlcd/draw_functions.cpp
../common/stdlcd/popups.cpp
../common/stdlcd/model_inputs.cpp
../common/stdlcd/model_mixes.cpp

View file

@ -33,6 +33,33 @@ void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, Lc
}
}
void drawTrimMode(coord_t x, coord_t y, uint8_t flightMode, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(flightMode, idx);
unsigned int mode = v.mode;
unsigned int p = mode >> 1;
if (mode == TRIM_MODE_NONE) {
lcdDrawText(x, y, "--", att);
}
else {
if (mode % 2 == 0)
lcdDrawChar(x, y, ':', att|FIXEDWIDTH);
else
lcdDrawChar(x, y, '+', att|FIXEDWIDTH);
lcdDrawChar(lcdNextPos, y, '0'+p, att);
}
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
lcdDrawTextAtIndex(lcdLastRightPos/*+1*/, y, STR_VTELEMUNIT, unit, 0);
}
}
FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModesType value, uint8_t attr)
{
int posHorz = menuHorizontalPosition;
@ -233,3 +260,179 @@ void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverI
lcdDrawText(x, y, "External", flags);
}
}
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags)
{
lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, flags);
}
#if defined(FLIGHT_MODES)
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
{
if (idx==0) {
lcdDrawMMM(x, y, att);
return;
}
// TODO this code was not included in Taranis! and used with abs(...) on Horus
if (idx < 0) {
lcdDrawChar(x-2, y, '!', att);
idx = -idx;
}
#if defined(CONDENSED)
if (att & CONDENSED) {
lcdDrawNumber(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
return;
}
#endif
drawStringWithIndex(x, y, STR_FM, idx-1, att);
}
#endif
void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags att)
{
if (curve.value != 0) {
switch (curve.type) {
case CURVE_REF_DIFF:
lcdDrawText(x, y, "D", att);
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
break;
case CURVE_REF_EXPO:
lcdDrawText(x, y, "E", att);
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
break;
case CURVE_REF_FUNC:
lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, curve.value, att);
break;
case CURVE_REF_CUSTOM:
drawCurveName(x, y, curve.value, att);
break;
}
}
}
void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, int32_t value, LcdFlags flags)
{
if (sensor >= MAX_TELEMETRY_SENSORS) {
// Lua luaLcdDrawChannel() can call us with a bad value
return;
}
TelemetryItem & telemetryItem = telemetryItems[sensor];
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[sensor];
if (telemetrySensor.unit == UNIT_DATETIME) {
drawDate(x, y, telemetryItem, flags);
}
else if (telemetrySensor.unit == UNIT_GPS) {
drawGPSSensorValue(x, y, telemetryItem, flags);
}
else if (telemetrySensor.unit == UNIT_BITFIELD) {
if (IS_FRSKY_SPORT_PROTOCOL()) {
if (telemetrySensor.id >= RBOX_STATE_FIRST_ID && telemetrySensor.id <= RBOX_STATE_LAST_ID) {
if (telemetrySensor.subId == 0) {
if (value == 0) {
lcdDrawText(x, y, "OK", flags);
}
else {
for (uint8_t i=0; i<16; i++) {
if (value & (1 << i)) {
char s[] = "CH__ KO";
strAppendUnsigned(&s[2], i+1, 2);
lcdDrawText(x, flags & DBLSIZE ? y+1 : y, s, flags & ~DBLSIZE);
break;
}
}
}
}
else {
if (value == 0) {
lcdDrawText(x, flags & DBLSIZE ? y+1 : y, "Rx OK", flags & ~DBLSIZE);
}
else {
static const char * const RXS_STATUS[] = {
"Rx1 Ovl",
"Rx2 Ovl",
"SBUS Ovl",
"Rx1 FS",
"Rx1 LF",
"Rx2 FS",
"Rx2 LF",
"Rx1 Lost",
"Rx2 Lost",
"Rx1 NS",
"Rx2 NS",
};
for (uint8_t i=0; i<DIM(RXS_STATUS); i++) {
if (value & (1<<i)) {
lcdDrawText(x, flags & DBLSIZE ? y+1 : y, RXS_STATUS[i], flags & ~DBLSIZE);
break;
}
}
}
}
}
}
}
else if (telemetrySensor.unit == UNIT_TEXT) {
lcdDrawSizedText(x, flags & DBLSIZE ? y+1 : y, telemetryItem.text, sizeof(telemetryItem.text), flags & ~DBLSIZE);
}
else {
if (telemetrySensor.prec > 0) {
flags |= (telemetrySensor.prec==1 ? PREC1 : PREC2);
}
drawValueWithUnit(x, y, value, telemetrySensor.unit == UNIT_CELLS ? UNIT_VOLTS : telemetrySensor.unit, flags);
}
}
void drawSourceCustomValue(coord_t x, coord_t y, source_t source, int32_t value, LcdFlags flags)
{
if (source >= MIXSRC_FIRST_TELEM) {
source = (source-MIXSRC_FIRST_TELEM) / 3;
drawSensorCustomValue(x, y, source, value, flags);
}
else if (source >= MIXSRC_FIRST_TIMER || source == MIXSRC_TX_TIME) {
if (value < 0) flags |= BLINK|INVERS;
drawTimer(x, y, value, flags);
}
else if (source == MIXSRC_TX_VOLTAGE) {
lcdDrawNumber(x, y, value, flags|PREC1);
}
#if defined(INTERNAL_GPS)
else if (source == MIXSRC_TX_GPS) {
if (gpsData.fix) {
drawGPSPosition(x, y, gpsData.longitude, gpsData.latitude, flags);
}
else {
lcdDrawText(x, y, "sats: ", flags);
lcdDrawNumber(lcdNextPos, y, gpsData.numSat, flags);
}
}
#endif
#if defined(GVARS)
else if (source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR) {
drawGVarValue(x, y, source - MIXSRC_FIRST_GVAR, value, flags);
}
#endif
else if (source < MIXSRC_FIRST_CH) {
lcdDrawNumber(x, y, calcRESXto100(value), flags);
}
else if (source <= MIXSRC_LAST_CH) {
#if defined(PPM_UNIT_PERCENT_PREC1)
lcdDrawNumber(x, y, calcRESXto1000(value), flags|PREC1);
#else
lcdDrawNumber(x, y, calcRESXto100(value), flags);
#endif
}
else {
lcdDrawNumber(x, y, value, flags);
}
}
void drawSourceValue(coord_t x, coord_t y, source_t source, LcdFlags flags)
{
getvalue_t value = getValue(source);
drawSourceCustomValue(x, y, source, value, flags);
}

View file

@ -18,12 +18,13 @@
* GNU General Public License for more details.
*/
#ifndef _COMMON_DRAW_FUNCTIONS_H_
#define _COMMON_DRAW_FUNCTIONS_H_
#ifndef _STDLCD_DRAW_FUNCTIONS_H_
#define _STDLCD_DRAW_FUNCTIONS_H_
#include "lcd.h"
void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, LcdFlags att=0);
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att=0);
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att = 0);
void drawGVarName(coord_t x, coord_t y, int8_t index, LcdFlags flags=0);
@ -40,4 +41,7 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration);
void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message);
void drawSleepBitmap();
#endif // _COMMON_DRAW_FUNCTIONS_H_
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags=0);
void drawTrimMode(coord_t x, coord_t y, uint8_t flightMode, uint8_t idx, LcdFlags att=0);
#endif // _STDLCD_DRAW_FUNCTIONS_H_

View file

@ -1,48 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* 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 "opentx.h"
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags)
{
lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, flags);
}
#if defined(FLIGHT_MODES)
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
{
if (idx==0) {
lcdDrawMMM(x, y, att);
return;
}
// TODO this code was not included in Taranis! and used with abs(...) on Horus
if (idx < 0) {
lcdDrawChar(x-2, y, '!', att);
idx = -idx;
}
#if defined(CONDENSED)
if (att & CONDENSED) {
lcdDrawNumber(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
return;
}
#endif
drawStringWithIndex(x, y, STR_FM, idx-1, att);
}
#endif

View file

@ -72,7 +72,6 @@ bool isRssiSensorAvailable(int sensor)
}
}
bool isSensorAvailable(int sensor)
{
if (sensor == 0)

View file

@ -95,7 +95,6 @@ void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
swsrc_t checkIncDecMovedSwitch(swsrc_t val);
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags flags);
void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags flags=0);
void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags flags=0);
void drawTelemScreenDate(coord_t x, coord_t y, source_t sensor, LcdFlags flags=0);
@ -116,8 +115,6 @@ void drawFatalErrorScreen(const char * message);
void runFatalErrorScreen(const char * message);
#endif
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags=0);
// model_setup Defines that are used in all uis in the same way
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON((uint8_t)1)
#define EXTERNAL_MODULE_CHANNELS_ROWS IF_EXTERNAL_MODULE_ON((isModuleDSM2(EXTERNAL_MODULE) || isModuleCrossfire(EXTERNAL_MODULE) || isModuleSBUS(EXTERNAL_MODULE) || (isModuleMultimodule(EXTERNAL_MODULE) && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) != MODULE_SUBTYPE_MULTI_DSM2)) ? (uint8_t)0 : (uint8_t)1)

View file

@ -432,6 +432,11 @@ When called without parameters, it will only return the status of the output buf
static int luaSportTelemetryPush(lua_State * L)
{
if (telemetryProtocol != PROTOCOL_TELEMETRY_FRSKY_SPORT) {
lua_pushboolean(L, false);
return 1;
}
if (lua_gettop(L) == 0) {
lua_pushboolean(L, outputTelemetryBuffer.isAvailable());
return 1;
@ -629,6 +634,11 @@ When called without parameters, it will only return the status of the output buf
*/
static int luaCrossfireTelemetryPush(lua_State * L)
{
if (telemetryProtocol != PROTOCOL_TELEMETRY_CROSSFIRE) {
lua_pushboolean(L, false);
return 1;
}
if (lua_gettop(L) == 0) {
lua_pushboolean(L, outputTelemetryBuffer.isAvailable());
}
@ -1275,7 +1285,7 @@ static int luaSetTelemetryValue(lua_State * L)
zname[3] = hex2zchar((id & 0x000f) >> 0);
}
if (id | subId | instance) {
int index = setTelemetryValue(TELEM_PROTO_LUA, id, subId, instance, value, unit, prec);
int index = setTelemetryValue(PROTOCOL_TELEMETRY_LUA, id, subId, instance, value, unit, prec);
if (index >= 0) {
TelemetrySensor &telemetrySensor = g_model.telemetrySensors[index];
telemetrySensor.id = id;
@ -1599,6 +1609,7 @@ const luaR_value_entry opentxConstants[] = {
{ "SHADOWED", SHADOWED },
{ "COLOR", ZoneOption::Color },
{ "BOOL", ZoneOption::Bool },
{ "STRING", ZoneOption::String },
{ "CUSTOM_COLOR", CUSTOM_COLOR },
{ "TEXT_COLOR", TEXT_COLOR },
{ "TEXT_BGCOLOR", TEXT_BGCOLOR },

View file

@ -36,7 +36,7 @@ extern "C" {
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100)
#define LUA_WARNING_INFO_LEN 64
lua_State *lsScripts = NULL;
lua_State *lsScripts = nullptr;
uint8_t luaState = 0;
uint8_t luaScriptsCount = 0;
ScriptInternalData scriptInternalData[MAX_SCRIPTS];
@ -256,7 +256,7 @@ void luaClose(lua_State ** L)
if (*L == lsScripts) luaDisable();
}
UNPROTECT_LUA();
*L = NULL;
*L = nullptr;
}
}
@ -362,7 +362,7 @@ static void luaDumpState(lua_State * L, const char * filename, const FILINFO * f
luaU_dump(L, getproto(L->top - 1), luaDumpWriter, &D, stripDebug);
lua_unlock(L);
if (f_close(&D) == FR_OK) {
if (finfo != NULL)
if (finfo != nullptr)
f_utime(filename, finfo); // set the file mod time
TRACE("luaDumpState(%s): Saved bytecode to file.", filename);
}
@ -404,7 +404,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
{
if (luaState == INTERPRETER_PANIC) {
return SCRIPT_PANIC;
} else if (filename == NULL) {
} else if (filename == nullptr) {
return SCRIPT_NOFILE;
}
@ -412,7 +412,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
char lmode[6] = "bt";
uint8_t ret = SCRIPT_NOFILE;
if (mode != NULL) {
if (mode != nullptr) {
strncpy(lmode, mode, sizeof(lmode)-1);
lmode[sizeof(lmode)-1] = '\0';
}
@ -432,7 +432,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
fnamelen = strlen(filename);
// check if file extension is already in the file name and strip it
getFileExtension(filename, fnamelen, 0, NULL, &extlen);
getFileExtension(filename, fnamelen, 0, nullptr, &extlen);
fnamelen -= extlen;
if (fnamelen > sizeof(filenameFull) - sizeof(SCRIPT_BIN_EXT)) {
TRACE_ERROR("luaLoadScriptFileToState(%s, %s): Error loading script: filename buffer overflow.\n", filename, lmode);
@ -507,7 +507,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
TRACE("luaLoadScriptFileToState(%s, %s): loading %s", filename, lmode, filenameFull);
// we don't pass <mode> on to loadfilex() because we want lua to load whatever file we specify, regardless of content
lstatus = luaL_loadfilex(L, filenameFull, NULL);
lstatus = luaL_loadfilex(L, filenameFull, nullptr);
#if defined(LUA_COMPILER)
// Check for bytecode encoding problem, eg. compiled for x64. Unfortunately Lua doesn't provide a unique error code for this. See Lua/src/lundump.c.
if (lstatus == LUA_ERRSYNTAX && loadFileType == 2 && frLuaS == FR_OK && strstr(lua_tostring(L, -1), "precompiled")) {
@ -515,7 +515,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
scriptNeedsCompile = true;
strcpy(filenameFull + fnamelen, SCRIPT_EXT);
TRACE_ERROR("luaLoadScriptFileToState(%s, %s): Error loading script: %s\n\tRetrying with %s\n", filename, lmode, lua_tostring(L, -1), filenameFull);
lstatus = luaL_loadfilex(L, filenameFull, NULL);
lstatus = luaL_loadfilex(L, filenameFull, nullptr);
}
if (lstatus == LUA_OK) {
if (scriptNeedsCompile && loadFileType == 1) {
@ -545,7 +545,7 @@ int luaLoadScriptFileToState(lua_State * L, const char * filename, const char *
return ret;
}
static int luaLoad(lua_State * L, const char * filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=NULL)
static int luaLoad(lua_State * L, const char * filename, ScriptInternalData & sid, ScriptInputsOutputs * sio=nullptr)
{
int init = 0;
int lstatus = 0;
@ -910,7 +910,7 @@ bool luaDoOneRunPermanentScript(event_t evt, int i, uint32_t scriptType)
#if defined(SIMU) || defined(DEBUG)
const char *filename;
#endif
ScriptInputsOutputs * sio = NULL;
ScriptInputsOutputs * sio = nullptr;
#if SCRIPT_MIX_FIRST > 0
if ((scriptType & RUN_MIX_SCRIPT) && (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST)) {
#else
@ -1082,13 +1082,13 @@ void luaInit()
if (luaState != INTERPRETER_PANIC) {
#if defined(USE_BIN_ALLOCATOR)
lsScripts = lua_newstate(bin_l_alloc, NULL); //we use our own allocator!
lsScripts = lua_newstate(bin_l_alloc, nullptr); //we use our own allocator!
#elif defined(LUA_ALLOCATOR_TRACER)
memset(&lsScriptsTrace, 0 , sizeof(lsScriptsTrace));
lsScriptsTrace.script = "lua_newstate(scripts)";
lsScripts = lua_newstate(tracer_alloc, &lsScriptsTrace); //we use tracer allocator
#else
lsScripts = lua_newstate(l_alloc, NULL); //we use Lua default allocator
lsScripts = lua_newstate(l_alloc, nullptr); //we use Lua default allocator
#endif
if (lsScripts) {
// install our panic handler

View file

@ -261,19 +261,6 @@ enum ThrottleSources {
THROTTLE_SOURCE_CH1,
};
enum TelemetryProtocols
{
PROTOCOL_TELEMETRY_FIRST,
PROTOCOL_TELEMETRY_FRSKY_SPORT = PROTOCOL_TELEMETRY_FIRST,
PROTOCOL_TELEMETRY_FRSKY_D,
PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY,
PROTOCOL_TELEMETRY_CROSSFIRE,
PROTOCOL_TELEMETRY_SPEKTRUM,
PROTOCOL_TELEMETRY_FLYSKY_IBUS,
PROTOCOL_TELEMETRY_MULTIMODULE,
PROTOCOL_TELEMETRY_LAST=PROTOCOL_TELEMETRY_MULTIMODULE
};
enum DisplayTrims
{
DISPLAY_TRIMS_NEVER,

View file

@ -2048,7 +2048,7 @@ uint32_t pwrPressedDuration()
uint32_t pwrCheck()
{
const char * message = NULL;
const char * message = nullptr;
enum PwrCheckState {
PWR_CHECK_ON,

View file

@ -1210,7 +1210,7 @@ extern union ReusableBuffer reusableBuffer;
uint8_t zlen(const char *str, uint8_t size);
bool zexist(const char *str, uint8_t size);
unsigned int effectiveLen(const char * str, unsigned int size);
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defaultName=NULL, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defaultName=nullptr, uint8_t defaultNameSize=0, uint8_t defaultIdx=0);
#define strcatFlightmodeName(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, STR_FM, PSIZE(TR_FM), idx+1)
#if defined(EEPROM)
#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1)

View file

@ -18,8 +18,8 @@
* GNU General Public License for more details.
*/
#ifndef _HELPERS_H_
#define _HELPERS_H_
#ifndef _OPENTX_HELPERS_H_
#define _OPENTX_HELPERS_H_
template<class t> inline t min(t a, t b) { return a<b?a:b; }
template<class t> inline t max(t a, t b) { return a>b?a:b; }
@ -27,4 +27,4 @@ template<class t> inline t sgn(t a) { return a>0 ? 1 : (a < 0 ? -1 : 0); }
template<class t> inline t limit(t mi, t x, t ma) { return min(max(mi,x),ma); }
template<class t> inline void SWAP(t & a, t & b) { t tmp = b; b = a; a = tmp; }
#endif // _HELPERS_H_
#endif // _OPENTX_HELPERS_H_

View file

@ -23,7 +23,7 @@
#include "bitfield.h"
#include "definitions.h"
#include "helpers.h"
#include "opentx_helpers.h"
#include "telemetry/telemetry.h"
#if defined(MULTIMODULE)
#include "telemetry/multi.h"

View file

@ -68,7 +68,7 @@ const char * sdCheckAndCreateDirectory(const char * path)
f_closedir(&archiveFolder);
}
return NULL;
return nullptr;
}
bool isFileAvailable(const char * path, bool exclDir)
@ -95,7 +95,7 @@ bool isFileAvailable(const char * path, bool exclDir)
@param match Optional container to hold the matched file extension (wide enough to hold LEN_FILE_EXTENSION_MAX + 1).
@retval true if a file was found, false otherwise.
*/
bool isFilePatternAvailable(const char * path, const char * file, const char * pattern = NULL, bool exclDir = true, char * match = NULL)
bool isFilePatternAvailable(const char * path, const char * file, const char * pattern = nullptr, bool exclDir = true, char * match = nullptr)
{
uint8_t fplen;
char fqfp[LEN_FILE_PATH_MAX + _MAX_LFN + 1] = "\0";
@ -110,7 +110,7 @@ bool isFilePatternAvailable(const char * path, const char * file, const char * p
strcpy(fqfp + fplen, "/");
strncat(fqfp + (++fplen), file, _MAX_LFN);
if (pattern == NULL) {
if (pattern == nullptr) {
// no extensions list, just check the filename as-is
return isFileAvailable(fqfp, exclDir);
}
@ -129,13 +129,13 @@ bool isFilePatternAvailable(const char * path, const char * file, const char * p
while (plen > 0 && ext) {
strncat(fqfp + len, ext, extlen);
if (isFileAvailable(fqfp, exclDir)) {
if (match != NULL) strncat(&(match[0]='\0'), ext, extlen);
if (match != nullptr) strncat(&(match[0]='\0'), ext, extlen);
return true;
}
plen -= extlen;
if (plen > 0) {
fqfp[len] = '\0';
ext = getFileExtension(pattern, plen, 0, NULL, &extlen);
ext = getFileExtension(pattern, plen, 0, nullptr, &extlen);
}
}
}
@ -147,7 +147,7 @@ char * getFileIndex(char * filename, unsigned int & value)
value = 0;
char * pos = (char *)getFileExtension(filename);
if (!pos || pos == filename)
return NULL;
return nullptr;
int multiplier = 1;
while (pos > filename) {
pos--;
@ -179,7 +179,7 @@ int findNextFileIndex(char * filename, uint8_t size, const char * directory)
uint8_t extlen;
char * indexPos = getFileIndex(filename, index);
char extension[LEN_FILE_EXTENSION_MAX+1] = "\0";
char * p = (char *)getFileExtension(filename, 0, 0, NULL, &extlen);
char * p = (char *)getFileExtension(filename, 0, 0, nullptr, &extlen);
if (p) strncat(extension, p, sizeof(extension)-1);
while (1) {
index++;
@ -188,7 +188,7 @@ int findNextFileIndex(char * filename, uint8_t size, const char * directory)
}
char * pos = strAppendUnsigned(indexPos, index);
strAppend(pos, extension);
if (!isFilePatternAvailable(directory, filename, NULL, false)) {
if (!isFilePatternAvailable(directory, filename, nullptr, false)) {
return index;
}
}
@ -249,12 +249,12 @@ bool isExtensionMatching(const char * extension, const char * pattern, char * ma
plen = (int)fnlen;
while (plen > 0 && ext) {
if (!strncasecmp(extension, ext, extlen)) {
if (match != NULL) strncat(&(match[0]='\0'), ext, extlen);
if (match != nullptr) strncat(&(match[0]='\0'), ext, extlen);
return true;
}
plen -= extlen;
if (plen > 0) {
ext = getFileExtension(pattern, plen, 0, NULL, &extlen);
ext = getFileExtension(pattern, plen, 0, nullptr, &extlen);
}
}
return false;
@ -275,7 +275,7 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen
if (selection) {
s_last_flags = flags;
if (!isFilePatternAvailable(path, selection, ((flags & LIST_SD_FILE_EXT) ? NULL : extension))) selection = NULL;
if (!isFilePatternAvailable(path, selection, ((flags & LIST_SD_FILE_EXT) ? nullptr : extension))) selection = nullptr;
}
else {
flags = s_last_flags;
@ -475,7 +475,7 @@ const char * sdCopyFile(const char * srcPath, const char * destPath)
return SDCARD_ERROR(result);
}
return NULL;
return nullptr;
}
const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir)

View file

@ -271,7 +271,7 @@ void convertModelData_218_to_219(ModelData &model)
for (uint8_t i=0; i<MAX_TELEMETRY_SENSORS_218; i++) {
newModel.telemetrySensors[i].id = oldModel.telemetrySensors[i].id;
if (oldModel.telemetrySensors[i].type == 0)
if (oldModel.telemetrySensors[i].type == 0 && (oldModel.moduleData[0].type == MODULE_TYPE_XJT_PXX1 || oldModel.moduleData[1].type == MODULE_TYPE_XJT_PXX1))
newModel.telemetrySensors[i].instance = 0xE0 + (oldModel.telemetrySensors[i].instance & 0x1F) - 1;
else
newModel.telemetrySensors[i].instance = oldModel.telemetrySensors[i].instance;
@ -321,7 +321,7 @@ void convertModelData_218_to_219(ModelData &model)
ZoneOptionValue & option = zoneData->widgetData.options[0];
option.unsignedValue = convertSource_218_to_219(option.unsignedValue);
}
#else
newModel.screensType = oldModel.frsky.screensType;
memmove(&newModel.screens, &oldModel.frsky.screens, sizeof(newModel.screens));

View file

@ -14,7 +14,6 @@ option(DSM2 "DSM2 TX Module" ON)
option(SBUS "SBUS TX Module" ON)
option(CROSSFIRE "Crossfire TX Module" ON)
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON)
option(MULTI_SPORT "SPORT telemetry support" OFF)
option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY
option(DEBUG_INTERRUPTS "Count interrupts" OFF)
option(DEBUG_LATENCY "Debug latency" OFF)
@ -152,10 +151,6 @@ if(MULTIMODULE)
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp)
endif()
if(MULTI_SPORT)
add_definitions(-DMULTI_SPORT)
endif()
if(CROSSFIRE)
add_definitions(-DCROSSFIRE)
set(PULSES_SRC

View file

@ -378,7 +378,7 @@ void audioInit()
audioSendRiffHeader();
}
uint8_t * currentBuffer = NULL;
uint8_t * currentBuffer = nullptr;
uint32_t currentSize = 0;
int16_t newVolume = -1;
@ -389,7 +389,7 @@ void audioSetCurrentBuffer(const AudioBuffer * buffer)
currentSize = buffer->size * 2;
}
else {
currentBuffer = NULL;
currentBuffer = nullptr;
currentSize = 0;
}
}
@ -413,7 +413,7 @@ void audioConsumeCurrentBuffer()
currentSize -= written;
if (currentSize == 0) {
audioQueue.buffersFifo.freeNextFilledBuffer();
currentBuffer = NULL;
currentBuffer = nullptr;
currentSize = 0;
}
}

View file

@ -365,7 +365,7 @@ void sdDone()
#if defined(LOG_TELEMETRY)
f_close(&g_telemetryFile);
#endif
f_mount(NULL, "", 0); // unmount SD
f_mount(nullptr, "", 0); // unmount SD
}
}
#endif

View file

@ -52,7 +52,7 @@ void firmwareTraceCb(const char * text)
OpenTxSimulator::OpenTxSimulator() :
SimulatorInterface(),
m_timer10ms(NULL),
m_timer10ms(nullptr),
m_resetOutputsData(true),
m_stopRequested(false)
{
@ -62,7 +62,7 @@ OpenTxSimulator::OpenTxSimulator() :
OpenTxSimulator::~OpenTxSimulator()
{
traceCallback = NULL;
traceCallback = nullptr;
tracebackDevices.clear();
if (m_timer10ms)

View file

@ -51,7 +51,7 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface
public slots:
virtual void init();
virtual void start(const char * filename = NULL, bool tests = true);
virtual void start(const char * filename = nullptr, bool tests = true);
virtual void stop();
virtual void setSdPath(const QString & sdPath = "", const QString & settingsPath = "");
virtual void setVolumeGain(const int value);

View file

@ -220,8 +220,8 @@ void StopSimu()
simu_shutdown = true;
pthread_join(mixerTaskId, NULL);
pthread_join(menusTaskId, NULL);
pthread_join(mixerTaskId, nullptr);
pthread_join(menusTaskId, nullptr);
simu_running = false;
}
@ -348,7 +348,7 @@ void * audioThread(void *)
wanted.channels = 1; /* 1 = mono, 2 = stereo */
wanted.samples = AUDIO_BUFFER_SIZE*2; /* Good low-latency value for callback */
wanted.callback = fillAudioBuffer;
wanted.userdata = NULL;
wanted.userdata = nullptr;
/*
SDL_OpenAudio() internally calls SDL_InitSubSystem(SDL_INIT_AUDIO),
@ -390,7 +390,7 @@ void StartAudioThread(int volumeGain)
void StopAudioThread()
{
simuAudio.threadRunning = false;
pthread_join(simuAudio.threadPid, NULL);
pthread_join(simuAudio.threadPid, nullptr);
}
#endif // #if defined(SIMU_AUDIO)

View file

@ -361,7 +361,7 @@ TCHAR * f_gets (TCHAR* buff, int len, FIL* fil)
{
if (fil && fil->obj.fs) {
buff = fgets(buff, len, (FILE*)fil->obj.fs);
if (buff != NULL) {
if (buff != nullptr) {
fil->fptr = *buff;
}
// TRACE_SIMPGMSPACE("fgets(%p) %u, %s", fil->obj.fs, len, buff);
@ -396,7 +396,7 @@ FRESULT f_close (FIL * fil)
TRACE_SIMPGMSPACE("f_close(%p) (FIL:%p)", fil->obj.fs, fil);
if (fil->obj.fs) {
fclose((FILE*)fil->obj.fs);
fil->obj.fs = NULL;
fil->obj.fs = nullptr;
}
return FR_OK;
}
@ -516,7 +516,7 @@ FRESULT f_rename(const TCHAR *oldname, const TCHAR *newname)
FRESULT f_utime(const TCHAR* path, const FILINFO* fno)
{
if (fno == NULL)
if (fno == nullptr)
return FR_INVALID_PARAMETER;
std::string simpath = convertToSimuPath(path);

View file

@ -1013,7 +1013,7 @@ void sdDone()
{
if (sdMounted()) {
audioQueue.stopSD();
f_mount(NULL, "", 0); // unmount SD
f_mount(nullptr, "", 0); // unmount SD
}
}

View file

@ -171,7 +171,7 @@ void usbMassStorage()
Card_state = SD_ST_DATA;
audioQueue.stopSD();
logsClose();
f_mount(NULL, "", 0); // unmount SD
f_mount(nullptr, "", 0); // unmount SD
}
if (!initialized) {

View file

@ -69,7 +69,7 @@ const CrossfireSensor & getCrossfireSensor(uint8_t id, uint8_t subId)
void processCrossfireTelemetryValue(uint8_t index, int32_t value)
{
const CrossfireSensor & sensor = crossfireSensors[index];
setTelemetryValue(TELEM_PROTO_CROSSFIRE, sensor.id, 0, sensor.subId, value, sensor.unit, sensor.precision);
setTelemetryValue(PROTOCOL_TELEMETRY_CROSSFIRE, sensor.id, 0, sensor.subId, value, sensor.unit, sensor.precision);
}
bool checkCrossfireTelemetryFrameCRC()
@ -164,7 +164,7 @@ void processCrossfireTelemetryFrame()
const CrossfireSensor & sensor = crossfireSensors[FLIGHT_MODE_INDEX];
for (int i=0; i<min<int>(16, telemetryRxBuffer[1]-2); i+=4) {
uint32_t value = *((uint32_t *)&telemetryRxBuffer[3+i]);
setTelemetryValue(TELEM_PROTO_CROSSFIRE, sensor.id, 0, sensor.subId, value, sensor.unit, i);
setTelemetryValue(PROTOCOL_TELEMETRY_CROSSFIRE, sensor.id, 0, sensor.subId, value, sensor.unit, i);
}
break;
}

View file

@ -106,17 +106,17 @@ static void processFlySkySensor(const uint8_t *packet)
else if (sensor->unit == UNIT_VOLTS)
// Voltage types are signed 16bit integers
value = (int16_t)value;
setTelemetryValue(TELEM_PROTO_FLYSKY_IBUS, id, 0, instance, value, sensor->unit, sensor->precision);
setTelemetryValue(PROTOCOL_TELEMETRY_FLYSKY_IBUS, id, 0, instance, value, sensor->unit, sensor->precision);
return;
}
}
setTelemetryValue(TELEM_PROTO_FLYSKY_IBUS, id, 0, instance, value, UNIT_RAW, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_FLYSKY_IBUS, id, 0, instance, value, UNIT_RAW, 0);
}
void processFlySkyPacket(const uint8_t *packet)
{
// Set TX RSSI Value, reverse MULTIs scaling
setTelemetryValue(TELEM_PROTO_FLYSKY_IBUS, TX_RSSI_ID, 0, 0, packet[0], UNIT_RAW, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_FLYSKY_IBUS, TX_RSSI_ID, 0, 0, packet[0], UNIT_RAW, 0);
for (int sensor = 0; sensor < 7; sensor++) {
int index = 1 + (4 * sensor);

View file

@ -68,9 +68,9 @@ void frskyDProcessPacket(const uint8_t *packet)
{
case LINKPKT: // A1/A2/RSSI values
{
setTelemetryValue(TELEM_PROTO_FRSKY_D, D_A1_ID, 0, 0, packet[1], UNIT_VOLTS, 0);
setTelemetryValue(TELEM_PROTO_FRSKY_D, D_A2_ID, 0, 0, packet[2], UNIT_VOLTS, 0);
setTelemetryValue(TELEM_PROTO_FRSKY_D, D_RSSI_ID, 0, 0, packet[3], UNIT_RAW, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_D, D_A1_ID, 0, 0, packet[1], UNIT_VOLTS, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_D, D_A2_ID, 0, 0, packet[2], UNIT_VOLTS, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_D, D_RSSI_ID, 0, 0, packet[3], UNIT_RAW, 0);
telemetryData.rssi.set(packet[3]);
telemetryStreaming = TELEMETRY_TIMEOUT10ms; // reset counter only if valid packets are being detected
break;
@ -258,7 +258,7 @@ void processHubPacket(uint8_t id, int16_t value)
}
}
setTelemetryValue(TELEM_PROTO_FRSKY_D, id, 0, 0, data, unit, precision);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_D, id, 0, 0, data, unit, precision);
}
void frskyDSetDefault(int index, uint16_t id)

View file

@ -128,14 +128,14 @@ void sportProcessTelemetryPacket(uint16_t id, uint8_t subId, uint8_t instance, u
uint8_t cellsCount = (data & 0xF0) >> 4;
uint8_t cellIndex = (data & 0x0F);
uint32_t mask = (cellsCount << 24) + (cellIndex << 16);
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, id, subId, instance, mask + (((data & 0x000FFF00) >> 8) / 5), unit, precision);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_SPORT, id, subId, instance, mask + (((data & 0x000FFF00) >> 8) / 5), unit, precision);
if (cellIndex+1 < cellsCount) {
mask += (1 << 16);
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, id, subId, instance, mask + (((data & 0xFFF00000) >> 20) / 5), unit, precision);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_SPORT, id, subId, instance, mask + (((data & 0xFFF00000) >> 20) / 5), unit, precision);
}
}
else {
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, id, subId, instance, data, unit, precision);
setTelemetryValue(PROTOCOL_TELEMETRY_FRSKY_SPORT, id, subId, instance, data, unit, precision);
}
}
@ -170,7 +170,7 @@ void sportProcessTelemetryPacketWithoutCrc(uint8_t origin, const uint8_t * packe
data = SPORT_DATA_U8(packet);
if (g_model.rssiSource) {
TelemetrySensor * sensor = &g_model.telemetrySensors[g_model.rssiSource - 1];
if (sensor->isSameInstance(TELEM_PROTO_FRSKY_SPORT, instance)) {
if (sensor->isSameInstance(PROTOCOL_TELEMETRY_FRSKY_SPORT, instance)) {
telemetryData.rssi.set(data);
}
}

View file

@ -138,14 +138,12 @@ static void processMultiTelemetryPaket(const uint8_t *packet)
TRACE("[MP] Received Frsky HUB telemetry len %d < 4", len);
break;
#if defined(MULTI_SPORT)
case FrSkySportTelemtry:
if (len >= 4)
sportProcessTelemetryPacket(data);
else
TRACE("[MP] Received sport telemetry len %d < 4", len);
break;
#endif
case InputSync:
if (len >= 6)
@ -158,7 +156,7 @@ static void processMultiTelemetryPaket(const uint8_t *packet)
// Just an ack to our command, ignore for now
break;
#if defined(MULTI_SPORT) && defined(LUA)
#if defined(LUA)
case FrskySportPolling:
if (len >= 1 && outputTelemetryBuffer.destination == TELEMETRY_ENDPOINT_SPORT && data[0] == outputTelemetryBuffer.sport.physicalId) {
TRACE("MP Sending sport data out.");

View file

@ -271,7 +271,7 @@ bool isSpektrumValidValue(int32_t value, const SpektrumDataType type)
void processSpektrumPacket(const uint8_t *packet)
{
setTelemetryValue(TELEM_PROTO_SPEKTRUM, (I2C_PSEUDO_TX << 8) + 0, 0, 0, packet[1], UNIT_RAW, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, (I2C_PSEUDO_TX << 8) + 0, 0, 0, packet[1], UNIT_RAW, 0);
// highest bit indicates that TM1100 is in use, ignore it
uint8_t i2cAddress = (packet[2] & 0x7f);
uint8_t instance = packet[3];
@ -283,10 +283,10 @@ void processSpektrumPacket(const uint8_t *packet)
for (int i=5; i<SPEKTRUM_TELEMETRY_LENGTH; i++)
{
setTelemetryValue(TELEM_PROTO_SPEKTRUM, pseudoId, 0, instance, packet[i], UNIT_TEXT, i-5);
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, pseudoId, 0, instance, packet[i], UNIT_TEXT, i-5);
}
// Set a sential \0 just for safety since we have the space there
setTelemetryValue(TELEM_PROTO_SPEKTRUM, pseudoId, 0, instance, '\0', UNIT_TEXT, 13);
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, pseudoId, 0, instance, '\0', UNIT_TEXT, 13);
return;
@ -335,7 +335,7 @@ void processSpektrumPacket(const uint8_t *packet)
}
uint16_t pseudoId = (sensor->i2caddress << 8 | sensor->startByte);
setTelemetryValue(TELEM_PROTO_SPEKTRUM, pseudoId, 0, instance, value, sensor->unit, sensor->precision);
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, pseudoId, 0, instance, value, sensor->unit, sensor->precision);
}
}
if (!handled) {
@ -344,7 +344,7 @@ void processSpektrumPacket(const uint8_t *packet)
for (int startByte=0; startByte<14; startByte+=2) {
int32_t value = spektrumGetValue(packet + 4, startByte, uint16);
uint16_t pseudoId = i2cAddress << 8 | startByte;
setTelemetryValue(TELEM_PROTO_SPEKTRUM, pseudoId, 0, instance, value, UNIT_RAW, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, pseudoId, 0, instance, value, UNIT_RAW, 0);
}
}
}
@ -397,7 +397,7 @@ void processDSMBindPacket(const uint8_t *packet)
debugval = packet[7] << 24 | packet[6] << 16 | packet[5] << 8 | packet[4];
/* log the bind packet as telemetry for quick debugging */
setTelemetryValue(TELEM_PROTO_SPEKTRUM, (I2C_PSEUDO_TX << 8) + 4, 0, 0, debugval, UNIT_RAW, 0);
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, (I2C_PSEUDO_TX << 8) + 4, 0, 0, debugval, UNIT_RAW, 0);
/* Finally stop binding as the rx just told us that it is bound */
if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_MULTIMODULE && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) == MODULE_SUBTYPE_MULTI_DSM2 && moduleState[EXTERNAL_MODULE].mode == MODULE_MODE_BIND) {

View file

@ -509,27 +509,27 @@ int setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, ui
int index = availableTelemetryIndex();
if (index >= 0) {
switch (protocol) {
case TELEM_PROTO_FRSKY_SPORT:
case PROTOCOL_TELEMETRY_FRSKY_SPORT:
frskySportSetDefault(index, id, subId, instance);
break;
case TELEM_PROTO_FRSKY_D:
case PROTOCOL_TELEMETRY_FRSKY_D:
frskyDSetDefault(index, id);
break;
#if defined(CROSSFIRE)
case TELEM_PROTO_CROSSFIRE:
case PROTOCOL_TELEMETRY_CROSSFIRE:
crossfireSetDefault(index, id, instance);
break;
#endif
#if defined(MULTIMODULE)
case TELEM_PROTO_SPEKTRUM:
case PROTOCOL_TELEMETRY_SPEKTRUM:
spektrumSetDefault(index, id, subId, instance);
break;
case TELEM_PROTO_FLYSKY_IBUS:
case PROTOCOL_TELEMETRY_FLYSKY_IBUS:
flySkySetDefault(index,id, subId, instance);
break;
#endif
#if defined(LUA)
case TELEM_PROTO_LUA:
case PROTOCOL_TELEMETRY_LUA:
// Sensor will be initialized by calling function
// This drops the first value
return index;

View file

@ -86,65 +86,53 @@ def main():
maxsize = 65536 * 4
elif board_name == "x9lite":
cmake_options["PCB"] = "X9LITE"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9lite
maxsize = 65536 * 8
elif board_name == "x7":
cmake_options["PCB"] = "X7"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
elif board_name == "xlite":
cmake_options["PCB"] = "XLITE"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_xlite
maxsize = 65536 * 8
elif board_name == "xlites":
cmake_options["PCB"] = "XLITES"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_xlites
maxsize = 65536 * 8
elif board_name == "x9d":
cmake_options["PCB"] = "X9D"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9d
maxsize = 65536 * 8
elif board_name == "x9d+":
cmake_options["PCB"] = "X9D+"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
elif board_name == "x9d+2019":
cmake_options["PCB"] = "X9D+"
cmake_options["PCBREV"] = "2019"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
elif board_name == "x9e":
cmake_options["PCB"] = "X9E"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9e
maxsize = 65536 * 8
elif board_name == "x10":
cmake_options["PCB"] = "X10"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x10
maxsize = 2 * 1024 * 1024
elif board_name == "x10express":
cmake_options["PCB"] = "X10"
cmake_options["PCBREV"] = "EXPRESS"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x10
maxsize = 2 * 1024 * 1024
elif board_name == "x12s":
cmake_options["PCB"] = "X12S"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x12s
maxsize = 2 * 1024 * 1024
elif board_name == "t12":
cmake_options["PCB"] = "X7"
cmake_options["PCBREV"] = "T12"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
else: