mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 15:25:17 +03:00
Reset SF can now reset individual telemetry items (fix #161)
This commit is contained in:
parent
51500d4455
commit
aced02f2bb
5 changed files with 48 additions and 8 deletions
|
@ -41,6 +41,7 @@ CustomFunctionsContext modelFunctionsContext = { 0 };
|
|||
|
||||
#if defined(CPUARM)
|
||||
CustomFunctionsContext globalFunctionsContext = { 0 };
|
||||
extern TelemetryItem telemetryItems[];
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -355,6 +356,12 @@ void evalFunctions()
|
|||
break;
|
||||
#endif
|
||||
}
|
||||
#if defined(CPUARM)
|
||||
if (CFN_PARAM(cfn)>=FUNC_RESET_PARAM_FIRST_TELEM) {
|
||||
TelemetryItem * telemetryItem = & telemetryItems[CFN_PARAM(cfn)-FUNC_RESET_PARAM_FIRST_TELEM];
|
||||
telemetryItem->clear();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
#if defined(CPUARM)
|
||||
|
|
|
@ -211,8 +211,18 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
|
|||
int16_t val_min = 0;
|
||||
int16_t val_max = 255;
|
||||
if (func == FUNC_RESET) {
|
||||
val_max = FUNC_RESET_PARAM_LAST;
|
||||
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(cfn), attr);
|
||||
val_max = FUNC_RESET_PARAM_FIRST_TELEM+lastUsedTelemetryIndex();
|
||||
int param = CFN_PARAM(cfn);
|
||||
if (param < FUNC_RESET_PARAM_FIRST_TELEM) {
|
||||
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, param, attr);
|
||||
}
|
||||
else {
|
||||
if (param > FUNC_RESET_PARAM_FIRST_TELEM) {
|
||||
INCDEC_ENABLE_CHECK(isSensorAvailableInResetSpecialFunction);
|
||||
}
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[param-FUNC_RESET_PARAM_FIRST_TELEM];
|
||||
lcd_putsnAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sensor->label, TELEM_LABEL_LEN, attr|ZCHAR);
|
||||
}
|
||||
}
|
||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
else if (func == FUNC_OVERRIDE_CHANNEL) {
|
||||
|
|
|
@ -130,6 +130,7 @@
|
|||
#define NUM_POTS 5
|
||||
#define NUM_XPOTS 3
|
||||
#endif
|
||||
#define TELEM_VALUES_MAX 32
|
||||
#elif defined(CPUARM)
|
||||
#define MAX_MODELS 60
|
||||
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
|
||||
|
@ -141,6 +142,7 @@
|
|||
#define NUM_TRAINER 16
|
||||
#define NUM_POTS 3
|
||||
#define NUM_XPOTS 0
|
||||
#define TELEM_VALUES_MAX 16
|
||||
#elif defined(CPUM2560) || defined(CPUM2561)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
|
@ -152,6 +154,7 @@
|
|||
#define NUM_TRAINER 8
|
||||
#define NUM_POTS 3
|
||||
#define NUM_XPOTS 0
|
||||
#define TELEM_VALUES_MAX 0
|
||||
#elif defined(CPUM128)
|
||||
#define MAX_MODELS 30
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
|
@ -163,6 +166,7 @@
|
|||
#define NUM_TRAINER 8
|
||||
#define NUM_POTS 3
|
||||
#define NUM_XPOTS 0
|
||||
#define TELEM_VALUES_MAX 0
|
||||
#else
|
||||
#define MAX_MODELS 16
|
||||
#define NUM_CHNOUT 16 // number of real output channels CH1-CH16
|
||||
|
@ -174,6 +178,7 @@
|
|||
#define NUM_TRAINER 8
|
||||
#define NUM_POTS 3
|
||||
#define NUM_XPOTS 0
|
||||
#define TELEM_VALUES_MAX 0
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
|
@ -584,9 +589,13 @@ enum ResetFunctionParam {
|
|||
#endif
|
||||
#if ROTARY_ENCODERS > 1
|
||||
FUNC_RESET_ROTENC2,
|
||||
#endif
|
||||
#if defined(CPUARM)
|
||||
FUNC_RESET_PARAM_FIRST_TELEM,
|
||||
FUNC_RESET_PARAM_LAST_TELEM = FUNC_RESET_PARAM_FIRST_TELEM + TELEM_VALUES_MAX,
|
||||
#endif
|
||||
FUNC_RESET_PARAMS_COUNT,
|
||||
FUNC_RESET_PARAM_LAST = FUNC_RESET_PARAMS_COUNT-1
|
||||
FUNC_RESET_PARAM_LAST = FUNC_RESET_PARAMS_COUNT-1,
|
||||
};
|
||||
|
||||
enum AdjustGvarFunctionParam {
|
||||
|
@ -1211,11 +1220,6 @@ PACK(typedef struct {
|
|||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#if defined(PCBTARANIS)
|
||||
#define TELEM_VALUES_MAX 32
|
||||
#else
|
||||
#define TELEM_VALUES_MAX 16
|
||||
#endif
|
||||
#define TELEM_LABEL_LEN 4
|
||||
//#define TELEM_FLAG_TIMEOUT 0x01
|
||||
#define TELEM_FLAG_LOG 0x02
|
||||
|
|
|
@ -453,6 +453,23 @@ int availableTelemetryIndex()
|
|||
return -1;
|
||||
}
|
||||
|
||||
int lastUsedTelemetryIndex()
|
||||
{
|
||||
for (int index=TELEM_VALUES_MAX-1; index>=0; index--) {
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||
if (telemetrySensor.isAvailable()) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool isSensorAvailableInResetSpecialFunction(int index)
|
||||
{
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index-FUNC_RESET_PARAM_FIRST_TELEM];
|
||||
return telemetrySensor.isAvailable();
|
||||
}
|
||||
|
||||
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
|
||||
{
|
||||
int index = getTelemetryIndex(protocol, id, instance);
|
||||
|
|
|
@ -185,6 +185,8 @@ inline bool isTelemetryFieldComparisonAvailable(int index)
|
|||
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec);
|
||||
void delTelemetryIndex(uint8_t index);
|
||||
int availableTelemetryIndex();
|
||||
int lastUsedTelemetryIndex();
|
||||
bool isSensorAvailableInResetSpecialFunction(int index);
|
||||
int32_t getTelemetryValue(uint8_t index, uint8_t & prec);
|
||||
int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t destUnit, uint8_t destPrec);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue