WiP: Simu and modules fixes

This commit is contained in:
Raphael Coeffic
2021-07-25 08:33:57 +02:00
parent f99389c4a2
commit 74f2445558
16 changed files with 67 additions and 13 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ void CurveDataEdit::update()
uint8_t curvePointsCount = 5 + curve.points;
// Point number
for (uint8_t i = 0; i < curvePointsCount; i++) {
for (int i = 0; i < curvePointsCount; i++) {
auto txt = new StaticText(
this,
{i * boxWidth + PAGE_PADDING, 10, boxWidth - PAGE_PADDING, boxHeight},
@@ -60,7 +60,7 @@ void CurveDataEdit::update()
// x value
if (curve.type == CURVE_TYPE_CUSTOM) {
// Adjustable points for custom curves
for (uint8_t i = 0; i < curvePointsCount; i++) {
for (int i = 0; i < curvePointsCount; i++) {
int8_t* points = curveAddress(index);
auto pointEdit = new NumberEdit(
this,
+10
View File
@@ -622,6 +622,16 @@ class ModuleWindow : public FormGroup {
rfChoice->setFocus(SET_FOCUS_DEFAULT);
});
}
else if (isModuleFlySky(moduleIdx)) {
rfChoice = new Choice(this, grid.getFieldSlot(2, 1), STR_FLYSKY_PROTOCOLS, 0, MODULE_SUBTYPE_ISRM_PXX2_ACCST_LR12,
GET_DEFAULT(g_model.moduleData[moduleIdx].subType),
[=](int32_t newValue) {
g_model.moduleData[moduleIdx].subType = newValue;
SET_DIRTY();
update();
rfChoice->setFocus(SET_FOCUS_DEFAULT);
});
}
#if defined(MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
Choice * mmSubProtocol = nullptr;
+7
View File
@@ -628,6 +628,13 @@ bool isInternalModuleAvailable(int moduleType)
return true;
#endif
}
#if (defined(AFHDS3) || defined(AFHDS2A)) && (defined(INTERNAL_MODULE_AFHDS2A) || defined(INTERNAL_MODULE_AFHDS3))
if (moduleType == MODULE_TYPE_AFHDS3) {
return true;
}
#endif
return false;
}
#else
+2
View File
@@ -102,7 +102,9 @@ struct Data
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
void sendByte(uint8_t b)
{
#if !defined(SIMU)
*ptr++ = b;
#endif
}
const uint8_t* getData()
+6
View File
@@ -38,6 +38,7 @@ enum ModuleType {
MODULE_TYPE_SBUS,
MODULE_TYPE_XJT_LITE_PXX2,
MODULE_TYPE_AFHDS3, //no more protocols possible because of 4 bits value
//MODULE_TYPE_AFHDS2A,
MODULE_TYPE_COUNT,
MODULE_TYPE_MAX = MODULE_TYPE_COUNT - 1
};
@@ -222,6 +223,11 @@ enum ModuleSubtypeDSM2 {
DSM2_PROTO_DSMX,
};
enum ModuleSubtypeFlysky {
FLYSKY_SUBTYPE_AFHDS3=0,
FLYSKY_SUBTYPE_AFHDS2A
};
enum FailsafeModes {
FAILSAFE_NOT_SET,
FAILSAFE_HOLD,
+14 -1
View File
@@ -319,9 +319,22 @@ inline bool isModuleSBUS(uint8_t moduleIdx)
return g_model.moduleData[moduleIdx].type == MODULE_TYPE_SBUS;
}
inline bool isModuleFlySky(uint8_t idx)
{
return
(g_model.moduleData[idx].type == MODULE_TYPE_AFHDS3);
}
inline bool isModuleAFHDS2A(uint8_t idx)
{
return isModuleFlySky(idx)
&& (g_model.moduleData[idx].subType == FLYSKY_SUBTYPE_AFHDS2A);
}
inline bool isModuleAFHDS3(uint8_t idx)
{
return g_model.moduleData[idx].type == MODULE_TYPE_AFHDS3;
return isModuleFlySky(idx)
&& (g_model.moduleData[idx].subType == FLYSKY_SUBTYPE_AFHDS3);
}
// order is the same as in enum Protocols in myeeprom.h (none, ppm, pxx, pxx2, dsm, crossfire, multi, r9m, r9m2, sbus)
+14 -2
View File
@@ -187,9 +187,13 @@ uint8_t getRequiredProtocol(uint8_t module)
break;
#endif
#if defined(AFHDS3)
#if defined(AFHDS3) || defined(AFHDS2)
case MODULE_TYPE_AFHDS3:
protocol = PROTOCOL_CHANNELS_AFHDS3;
if (isModuleAFHDS3(module)) {
protocol = PROTOCOL_CHANNELS_AFHDS3;
} else if (isModuleAFHDS2A(module)) {
protocol = PROTOCOL_CHANNELS_AFHDS2A;
}
break;
#endif
@@ -505,6 +509,14 @@ static void enablePulsesInternalModule(uint8_t protocol)
break;
#endif
#if defined(AFHDS2)
case PROTOCOL_CHANNELS_AFHDS2A:
extmodulePulsesData.afhds2.init(INTERNAL_MODULE);
extmoduleSerialStart();
mixerSchedulerSetPeriod(INTERNAL_MODULE, 2 * 1000 /* us */);
break;
#endif
default:
// internal module stopped, set internal period to 0 and start the scheduler
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
+2
View File
@@ -273,6 +273,7 @@ union InternalModulePulsesData {
#if defined(INTERNAL_MODULE_PPM)
PpmPulsesData<pulse_duration_t> ppm;
#endif
} __ALIGNED(4);
union ExternalModulePulsesData {
@@ -389,6 +390,7 @@ enum ChannelsProtocols {
PROTOCOL_CHANNELS_SBUS,
PROTOCOL_CHANNELS_PXX2_LOWSPEED,
PROTOCOL_CHANNELS_PXX2_HIGHSPEED,
PROTOCOL_CHANNELS_AFHDS2A,
PROTOCOL_CHANNELS_AFHDS3,
PROTOCOL_CHANNELS_GHOST
};
@@ -59,7 +59,7 @@ void interrupt1ms()
++pre_scale;
// 1 ms loop
#if defined(FLYSKY_HALL_STICKS)
#if defined(FLYSKY_HALL_STICKS) && !defined(SIMU)
flysky_hall_stick_loop(); // TODO: need to put in 1ms timer loop for best performance
#endif
+1
View File
@@ -43,6 +43,7 @@ set(FLAVOUR nv14)
#add_definitions(-DPCBNV14 -DPCBFLYSKY -DINTERNAL_MODULE_BAUDRATE=${PCB_RF_BAUD})
add_definitions(-DPCBNV14 -DPCBFLYSKY -DINTERNAL_MODULE_SERIAL -DAFHDS2_BAUDRATE=${PCB_RF_BAUD})
add_definitions(-DBATTERY_CHARGE) # -DSOFTWARE_VOLUME
add_definitions(-DINTERNAL_MODULE_AFHDS2A)
set(TARGET_SRC
${TARGET_SRC}
+1 -1
View File
@@ -297,13 +297,13 @@ void adcRead()
#endif
}
#if !defined(SIMU)
uint16_t getRTCBatteryVoltage()
{
#warning "TODO RTC voltage"
return 330;
}
#if !defined(SIMU)
uint16_t getAnalogValue(uint8_t index)
{
if (IS_POT(index) && !IS_POT_SLIDER_AVAILABLE(index)) {
+1 -1
View File
@@ -483,7 +483,7 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode);
void telemetryPortSetDirectionOutput();
void telemetryPortSetDirectionInput();
void sportSendBuffer(uint8_t * buffer, uint32_t count);
uint8_t telemetryGetByte(uint8_t * byte);
bool telemetryGetByte(uint8_t * byte);
void telemetryClearFifo();
void sportSendByte(uint8_t byte);
extern uint32_t telemetryErrors;
+1 -1
View File
@@ -60,7 +60,7 @@ constexpr uint32_t MENU_FOOTER_TOP = LCD_H - MENU_FOOTER_HEIGHT;
constexpr uint32_t MENU_BODY_HEIGHT = MENU_FOOTER_TOP - MENU_BODY_TOP;
constexpr uint32_t MENUS_MARGIN_LEFT = 6;
constexpr uint32_t PAGE_PADDING = 8;
constexpr coord_t PAGE_PADDING = 8;
constexpr uint32_t PAGE_LINE_HEIGHT = 26;
constexpr uint32_t PAGE_LINE_SPACING = 6;
constexpr uint32_t PAGE_INDENT_WIDTH = 10;
+1 -1
View File
@@ -471,7 +471,7 @@ void sportSendByte(uint8_t byte)
{
}
void sportSendBuffer(const uint8_t * buffer, uint32_t count)
void sportSendBuffer(uint8_t * buffer, uint32_t count)
{
}
+1
View File
@@ -166,6 +166,7 @@ extern const char STR_XJT_ACCST_RF_PROTOCOLS[];
extern const char STR_ISRM_RF_PROTOCOLS[];
extern const char STR_R9M_PXX2_RF_PROTOCOLS[];
extern const char STR_DSM_PROTOCOLS[];
extern const char STR_FLYSKY_PROTOCOLS[];
extern const char STR_CRSF_BAUDRATE[];
extern const char STR_PPM_POL[];
extern const char STR_SBUS_INVERSION_VALUES[];
+3 -3
View File
@@ -111,10 +111,10 @@
#endif
#define LEN_EXTERNAL_MODULE_PROTOCOLS "\014"
#define TR_EXTERNAL_MODULE_PROTOCOLS "OFF\0 ""PPM\0 ""XJT\0 ""ISRM\0 ""DSM2\0 ""CRSF\0 ""MULTI\0 ""R9M\0 ""R9M ACCESS\0 " TR_MODULE_R9M_LITE "R9ML ACCESS\0""GHST\0 ""R9MLP ACCESS""SBUS\0 ""XJT Lite\0 ""AFHDS3\0 "
#define TR_EXTERNAL_MODULE_PROTOCOLS "OFF\0 ""PPM\0 ""XJT\0 ""ISRM\0 ""DSM2\0 ""CRSF\0 ""MULTI\0 ""R9M\0 ""R9M ACCESS\0 " TR_MODULE_R9M_LITE "R9ML ACCESS\0""GHST\0 ""R9MLP ACCESS""SBUS\0 ""XJT Lite\0 ""FLYSKY\0 "
#define LEN_FLYSKY_PROTOCOLS "\006"
#define TR_FLYSKY_PROTOCOLS
#define LEN_FLYSKY_PROTOCOLS "\007"
#define TR_FLYSKY_PROTOCOLS "AFHDS3\0""AFHDS2A"
#define LEN_INTERNAL_MODULE_PROTOCOLS LEN_EXTERNAL_MODULE_PROTOCOLS
#define TR_INTERNAL_MODULE_PROTOCOLS TR_EXTERNAL_MODULE_PROTOCOLS