[X-LiteS] Gyro added

This commit is contained in:
Bertrand Songis
2019-04-02 20:12:50 +02:00
parent b967d5b08a
commit a13ee14bbb
18 changed files with 468 additions and 318 deletions
+5
View File
@@ -723,6 +723,11 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx + 1, att);
}
}
#if defined(GYRO)
else if (idx <= MIXSRC_GYRO2) {
drawStringWithIndex(x, y, "Gyr", idx - MIXSRC_GYRO1 + 1, att);
}
#endif
else if (idx >= MIXSRC_FIRST_SWITCH && idx <= MIXSRC_LAST_SWITCH) {
idx = idx-MIXSRC_FIRST_SWITCH;
if (ZEXIST(g_eeGeneral.switchNames[idx])) {
+4 -20
View File
@@ -45,23 +45,7 @@ enum {
ITEM_MODULE_SETTINGS_COUNT
};
/* Options order:
* - RF Protocol (0x01)
* - External antenna (0x02)
* - Power (0x04)
*/
const uint8_t moduleOptions[] = {
0b11111111, // None = display all options
0b11111011, // XJT
0b11111011, // IXJT
0b11111011, // IXJT-PRO
0b11111011, // IXJT-S
0b11111100, // R9M
0b11111100, // R9MLite
0b11111100, // R9MLite-PRO
};
#define IF_MODULE_OPTIONS(option, count) uint8_t((moduleOptions[modelId] & (1 << option)) ? count : HIDDEN_ROW)
#define IF_MODULE_OPTIONS(option, count) uint8_t(isModuleOptionAvailable(modelId, option) ? count : HIDDEN_ROW)
void drawPower(coord_t x, coord_t y, int8_t dBm)
{
@@ -123,9 +107,9 @@ void menuModelModuleOptions(event_t event)
// uint8_t variant = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.variant;
SUBMENU_NOTITLE(ITEM_MODULE_SETTINGS_COUNT, {
IF_MODULE_OPTIONS(0, 0),
IF_MODULE_OPTIONS(1, 0),
IF_MODULE_OPTIONS(2, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_RF_PROTOCOL, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_EXTERNAL_ANTENNA, 0),
IF_MODULE_OPTIONS(MODULE_OPTION_POWER, 0),
});
if (event == EVT_ENTRY) {
@@ -21,14 +21,13 @@
#include <opentx.h>
#include "opentx.h"
void pxx2ModuleRequiredScreen(event_t event);
extern uint8_t g_moduleIdx;
void menuRadioPowerMeter(event_t event)
{
if (TELEMETRY_STREAMING()) {
lcdDrawCenteredText(LCD_H/2, "Turn off receiver");
if(event == EVT_KEY_FIRST(KEY_EXIT)) {
if (event == EVT_KEY_FIRST(KEY_EXIT)) {
killEvents(event);
popMenu();
}
@@ -20,14 +20,13 @@
#include "opentx.h"
extern void pxx2ModuleRequiredScreen(event_t event);
extern uint8_t g_moduleIdx;
void menuRadioSpectrumAnalyser(event_t event)
{
if (TELEMETRY_STREAMING()) {
lcdDrawCenteredText(15, "Turn off receiver");
if(event == EVT_KEY_FIRST(KEY_EXIT)) {
if (event == EVT_KEY_FIRST(KEY_EXIT)) {
killEvents(event);
popMenu();
}
+14 -48
View File
@@ -22,19 +22,6 @@
extern uint8_t g_moduleIdx;
void pxx2ModuleRequiredScreen(event_t event)
{
lcdClear();
lcdDrawCenteredText(15, "THIS FEATURE REQUIRES");
lcdDrawCenteredText(30, "ACCESS UPGRADE ON");
lcdDrawCenteredText(45, "YOUR INTERNAL MODULE");
if (event == EVT_KEY_FIRST(KEY_EXIT)) {
killEvents(event);
popMenu();
}
}
void addRadioTool(uint8_t index, const char * label, void (* tool)(event_t event), uint8_t module, event_t event)
{
int8_t sub = menuVerticalPosition - HEADER_LINE;
@@ -49,64 +36,43 @@ void addRadioTool(uint8_t index, const char * label, void (* tool)(event_t event
}
}
bool hasSpektrumAnalyserCapability(uint8_t module)
{
#if defined(SIMU)
return true;
#else
return (reusableBuffer.hardwareAndSettings.modules[module].information.modelID == PXX2_MODULE_IXJT_S ||
reusableBuffer.hardwareAndSettings.modules[module].information.modelID == PXX2_MODULE_IXJT_PRO ||
reusableBuffer.hardwareAndSettings.modules[module].information.modelID >= PXX2_MODULE_R9M_LITE_PRO);
#endif
}
bool hasPowerMeterCapablity(uint8_t module)
{
#if defined(SIMU)
return true;
#else
return (reusableBuffer.hardwareAndSettings.modules[module].information.modelID == PXX2_MODULE_IXJT_PRO ||
reusableBuffer.hardwareAndSettings.modules[module].information.modelID == PXX2_MODULE_R9M_LITE_PRO);
#endif
}
void menuRadioTools(event_t event)
{
uint8_t spektrum_modules = 0, power_modules = 0;
if(event == EVT_ENTRY || event == EVT_ENTRY_UP) {
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
memclear(&reusableBuffer.hardwareAndSettings, sizeof(reusableBuffer.hardwareAndSettings));
#if defined(PXX2)
for (uint8_t idx=0; idx < NUM_MODULES; idx++) {
if (isModulePXX2(idx) && (idx == INTERNAL_MODULE ? IS_INTERNAL_MODULE_ON() : IS_EXTERNAL_MODULE_ON())) {
reusableBuffer.hardwareAndSettings.modules[idx].current = PXX2_HW_INFO_TX_ID;
reusableBuffer.hardwareAndSettings.modules[idx].maximum = PXX2_HW_INFO_TX_ID;
moduleSettings[idx].mode = MODULE_MODE_GET_HARDWARE_INFO;
for (uint8_t module = 0; module < NUM_MODULES; module++) {
if (isModulePXX2(module) && (module == INTERNAL_MODULE ? IS_INTERNAL_MODULE_ON() : IS_EXTERNAL_MODULE_ON())) {
reusableBuffer.hardwareAndSettings.modules[module].current = PXX2_HW_INFO_TX_ID;
reusableBuffer.hardwareAndSettings.modules[module].maximum = PXX2_HW_INFO_TX_ID;
moduleSettings[module].mode = MODULE_MODE_GET_HARDWARE_INFO;
}
}
#endif
}
for (uint8_t idx=0; idx < NUM_MODULES; idx++) {
if(hasSpektrumAnalyserCapability(idx)) {
for (uint8_t module = 0; module < NUM_MODULES; module++) {
if (isModuleOptionAvailable(module, MODULE_OPTION_SPEKTRUM_ANALYSER)) {
spektrum_modules++;
}
if(hasPowerMeterCapablity(idx)) {
if (isModuleOptionAvailable(module, MODULE_OPTION_POWER_METER)) {
power_modules++;
}
}
SIMPLE_MENU("TOOLS", menuTabGeneral, MENU_RADIO_TOOLS, HEADER_LINE + spektrum_modules + power_modules);
uint8_t menu_index=0;
uint8_t menu_index = 0;
#if defined(PXX2)
if(hasSpektrumAnalyserCapability(INTERNAL_MODULE))
if (isModuleOptionAvailable(INTERNAL_MODULE, MODULE_OPTION_SPEKTRUM_ANALYSER))
addRadioTool(menu_index++, "Spectrum (INT)", menuRadioSpectrumAnalyser, INTERNAL_MODULE, event);
if(hasPowerMeterCapablity(INTERNAL_MODULE))
if (isModuleOptionAvailable(INTERNAL_MODULE, MODULE_OPTION_POWER_METER))
addRadioTool(menu_index++, "Power Meter (INT)", menuRadioPowerMeter, INTERNAL_MODULE, event);
if(hasSpektrumAnalyserCapability(EXTERNAL_MODULE))
if (isModuleOptionAvailable(EXTERNAL_MODULE, MODULE_OPTION_SPEKTRUM_ANALYSER))
addRadioTool(menu_index++, "Spectrum (EXT)", menuRadioSpectrumAnalyser, EXTERNAL_MODULE, event);
if(hasPowerMeterCapablity(EXTERNAL_MODULE))
if (isModuleOptionAvailable(EXTERNAL_MODULE, MODULE_OPTION_POWER_METER))
addRadioTool(menu_index++, "Power Meter (EXT)", menuRadioPowerMeter, EXTERNAL_MODULE, event);
#endif
}
+16 -12
View File
@@ -224,32 +224,36 @@ bool isSourceAvailableInCustomSwitches(int source)
bool isInputSourceAvailable(int source)
{
if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
if (source >= MIXSRC_FIRST_POT && source <= MIXSRC_LAST_POT)
return IS_POT_SLIDER_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
}
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
#if defined(GYRO)
if (source >= MIXSRC_GYRO1 && source <= MIXSRC_GYRO2)
return true;
#endif
if (source >= MIXSRC_Rud && source <= MIXSRC_MAX)
return true;
if (source>=MIXSRC_FIRST_TRIM && source<=MIXSRC_LAST_TRIM)
if (source >= MIXSRC_FIRST_TRIM && source <= MIXSRC_LAST_TRIM)
return true;
if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH)
return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH);
if (source >= MIXSRC_FIRST_SWITCH && source <= MIXSRC_LAST_SWITCH)
return SWITCH_EXISTS(source - MIXSRC_FIRST_SWITCH);
if (source>=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH)
if (source >= MIXSRC_FIRST_CH && source <= MIXSRC_LAST_CH)
return true;
if (source>=MIXSRC_FIRST_LOGICAL_SWITCH && source<=MIXSRC_LAST_LOGICAL_SWITCH) {
LogicalSwitchData * cs = lswAddress(source-MIXSRC_SW1);
if (source >= MIXSRC_FIRST_LOGICAL_SWITCH && source <= MIXSRC_LAST_LOGICAL_SWITCH) {
LogicalSwitchData * cs = lswAddress(source - MIXSRC_SW1);
return (cs->func != LS_FUNC_NONE);
}
if (source>=MIXSRC_FIRST_TRAINER && source<=MIXSRC_LAST_TRAINER)
if (source >= MIXSRC_FIRST_TRAINER && source <= MIXSRC_LAST_TRAINER)
return true;
if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) {
div_t qr = div(source-MIXSRC_FIRST_TELEM, 3);
if (source >= MIXSRC_FIRST_TELEM && source <= MIXSRC_LAST_TELEM) {
div_t qr = div(source - MIXSRC_FIRST_TELEM, 3);
return isTelemetryFieldAvailable(qr.quot) && isTelemetryFieldComparisonAvailable(qr.quot);
}