Changes to allow Lua to access DSM Forward Programming (#7913)

This commit is contained in:
pascallanger
2020-09-02 21:13:58 +02:00
committed by GitHub
parent 79189ebfb0
commit 200116257c
3 changed files with 35 additions and 0 deletions
+15
View File
@@ -47,6 +47,7 @@
#define DSM_BIND_PACKET_LENGTH 12
#define I2C_HIGH_CURRENT 0x03
#define I2C_FWD_PGM 0x09
#define I2C_TEXTGEN 0x0c
#define I2C_GPS 0x17
#define I2C_GPS2 0x17
@@ -349,6 +350,20 @@ void processSpektrumPacket(const uint8_t *packet)
// highest bit indicates that TM1100 is in use, ignore it
uint8_t i2cAddress = (packet[2] & 0x7f);
if (i2cAddress == I2C_FWD_PGM) {
#if defined(LUA)
// Forward Programming
if (Multi_Buffer && memcmp(Multi_Buffer, "DSM", 3) == 0) {
// Multi_Buffer[0..2]=="DSM" -> Lua script is running
// Multi_Buffer[3]==0x70 -> TX to RX data ready to be sent
// Multi_Buffer[4..9]=6 bytes of TX to RX data
// Multi_Buffer[10..25]=16 bytes of RX to TX data
Multi_Buffer[10] = i2cAddress;
memcpy(&Multi_Buffer[11], &packet[3], 15); // Store the received RX answer in the buffer
}
#endif
return; // Not a sensor
}
//SmartBat Hack
if (i2cAddress == I2C_SMART_BAT_BASE_ADDRESS) {
i2cAddress = i2cAddress + (packet[4] >> 4); // use type to create virtual I2CAddresses
+2
View File
@@ -115,6 +115,7 @@ extern uint8_t telemetryProtocol;
|| (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKYX2))
#define IS_R9_MULTI(module) (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKY_R9)
#define IS_HOTT_MULTI(module) (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_HOTT)
#define IS_DSM_MULTI(module) (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM2)
#define IS_RX_MULTI(module) ((g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_AFHDS2A_RX) || (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKYX_RX) \
|| (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_BAYANG_RX) || (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM_RX))
#if defined(HARDWARE_INTERNAL_MODULE)
@@ -126,6 +127,7 @@ extern uint8_t telemetryProtocol;
#define IS_D16_MULTI(module) false
#define IS_R9_MULTI(module) false
#define IS_HOTT_MULTI(module) false
#define IS_DSM_MULTI(module) false
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT)
#define IS_RX_MULTI(module) false
#endif