Cleanup first a bit
This commit is contained in:
@@ -33,8 +33,9 @@ InternalModulePulsesData intmodulePulsesData __DMA;
|
||||
ExternalModulePulsesData extmodulePulsesData __DMA;
|
||||
TrainerPulsesData trainerPulsesData __DMA;
|
||||
|
||||
//use only for PXX
|
||||
void ModuleState::startBind(BindInformation * destination, ModuleCallback bindCallback)
|
||||
// use only for PXX
|
||||
void ModuleState::startBind(BindInformation* destination,
|
||||
ModuleCallback bindCallback)
|
||||
{
|
||||
bindInformation = destination;
|
||||
callback = bindCallback;
|
||||
@@ -46,6 +47,45 @@ void ModuleState::startBind(BindInformation * destination, ModuleCallback bindCa
|
||||
#endif
|
||||
}
|
||||
|
||||
void ModuleState::readModuleInformation(ModuleInformation* destination,
|
||||
int8_t first, int8_t last)
|
||||
{
|
||||
moduleInformation = destination;
|
||||
moduleInformation->current = first;
|
||||
moduleInformation->maximum = last;
|
||||
mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
}
|
||||
|
||||
void ModuleState::readModuleSettings(ModuleSettings* destination)
|
||||
{
|
||||
moduleSettings = destination;
|
||||
moduleSettings->state = PXX2_SETTINGS_READ;
|
||||
mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
}
|
||||
|
||||
void ModuleState::writeModuleSettings(ModuleSettings* source)
|
||||
{
|
||||
moduleSettings = source;
|
||||
moduleSettings->state = PXX2_SETTINGS_WRITE;
|
||||
moduleSettings->timeout = 0;
|
||||
mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
}
|
||||
|
||||
void ModuleState::readReceiverSettings(ReceiverSettings* destination)
|
||||
{
|
||||
receiverSettings = destination;
|
||||
receiverSettings->state = PXX2_SETTINGS_READ;
|
||||
mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
|
||||
void ModuleState::writeReceiverSettings(ReceiverSettings* source)
|
||||
{
|
||||
receiverSettings = source;
|
||||
receiverSettings->state = PXX2_SETTINGS_WRITE;
|
||||
receiverSettings->timeout = 0;
|
||||
mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
|
||||
void getModuleStatusString(uint8_t moduleIdx, char * statusText)
|
||||
{
|
||||
*statusText = 0;
|
||||
|
||||
+7
-109
@@ -67,77 +67,6 @@
|
||||
|
||||
extern uint8_t s_pulses_paused;
|
||||
|
||||
PACK(struct PXX2Version {
|
||||
uint8_t major;
|
||||
uint8_t revision:4;
|
||||
uint8_t minor:4;
|
||||
});
|
||||
|
||||
PACK(struct PXX2HardwareInformation {
|
||||
uint8_t modelID;
|
||||
PXX2Version hwVersion;
|
||||
PXX2Version swVersion;
|
||||
uint8_t variant;
|
||||
uint32_t capabilities; // variable length
|
||||
uint8_t capabilityNotSupported;
|
||||
});
|
||||
|
||||
PACK(struct ModuleInformation {
|
||||
int8_t current;
|
||||
int8_t maximum;
|
||||
uint8_t timeout;
|
||||
PXX2HardwareInformation information;
|
||||
struct {
|
||||
PXX2HardwareInformation information;
|
||||
tmr10ms_t timestamp;
|
||||
} receivers[PXX2_MAX_RECEIVERS_PER_MODULE];
|
||||
});
|
||||
|
||||
class ModuleSettings {
|
||||
public:
|
||||
uint8_t state; // 0x00 = READ 0x40 = WRITE
|
||||
tmr10ms_t timeout;
|
||||
uint8_t externalAntenna;
|
||||
int8_t txPower;
|
||||
uint8_t dirty;
|
||||
};
|
||||
|
||||
class ReceiverSettings {
|
||||
public:
|
||||
uint8_t state; // 0x00 = READ 0x40 = WRITE
|
||||
tmr10ms_t timeout;
|
||||
uint8_t receiverId;
|
||||
uint8_t dirty;
|
||||
uint8_t telemetryDisabled;
|
||||
uint8_t telemetry25mw;
|
||||
uint8_t pwmRate;
|
||||
uint8_t fport;
|
||||
uint8_t enablePwmCh5Ch6;
|
||||
uint8_t fport2;
|
||||
uint8_t outputsCount;
|
||||
uint8_t outputsMapping[24];
|
||||
};
|
||||
|
||||
class BindInformation {
|
||||
public:
|
||||
int8_t step;
|
||||
uint32_t timeout;
|
||||
char candidateReceiversNames[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME + 1];
|
||||
uint8_t candidateReceiversCount;
|
||||
uint8_t selectedReceiverIndex;
|
||||
uint8_t rxUid;
|
||||
uint8_t lbtMode;
|
||||
uint8_t flexMode;
|
||||
PXX2HardwareInformation receiverInformation;
|
||||
};
|
||||
|
||||
class OtaUpdateInformation: public BindInformation {
|
||||
public:
|
||||
char filename[FF_MAX_LFN + 1];
|
||||
uint32_t address;
|
||||
uint32_t module;
|
||||
};
|
||||
|
||||
typedef void (* ModuleCallback)();
|
||||
|
||||
PACK(struct ModuleState {
|
||||
@@ -146,6 +75,8 @@ PACK(struct ModuleState {
|
||||
uint8_t paused:1;
|
||||
uint8_t spare:7;
|
||||
uint16_t counter;
|
||||
|
||||
// PXX specific items
|
||||
union
|
||||
{
|
||||
ModuleInformation * moduleInformation;
|
||||
@@ -157,44 +88,11 @@ PACK(struct ModuleState {
|
||||
ModuleCallback callback;
|
||||
|
||||
void startBind(BindInformation * destination, ModuleCallback bindCallback = nullptr);
|
||||
|
||||
void readModuleInformation(ModuleInformation * destination, int8_t first, int8_t last)
|
||||
{
|
||||
moduleInformation = destination;
|
||||
moduleInformation->current = first;
|
||||
moduleInformation->maximum = last;
|
||||
mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
}
|
||||
|
||||
void readModuleSettings(ModuleSettings * destination)
|
||||
{
|
||||
moduleSettings = destination;
|
||||
moduleSettings->state = PXX2_SETTINGS_READ;
|
||||
mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
}
|
||||
|
||||
void writeModuleSettings(ModuleSettings * source)
|
||||
{
|
||||
moduleSettings = source;
|
||||
moduleSettings->state = PXX2_SETTINGS_WRITE;
|
||||
moduleSettings->timeout = 0;
|
||||
mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
}
|
||||
|
||||
void readReceiverSettings(ReceiverSettings * destination)
|
||||
{
|
||||
receiverSettings = destination;
|
||||
receiverSettings->state = PXX2_SETTINGS_READ;
|
||||
mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
|
||||
void writeReceiverSettings(ReceiverSettings * source)
|
||||
{
|
||||
receiverSettings = source;
|
||||
receiverSettings->state = PXX2_SETTINGS_WRITE;
|
||||
receiverSettings->timeout = 0;
|
||||
mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
void readModuleInformation(ModuleInformation * destination, int8_t first, int8_t last);
|
||||
void readModuleSettings(ModuleSettings * destination);
|
||||
void writeModuleSettings(ModuleSettings * source);
|
||||
void readReceiverSettings(ReceiverSettings * destination);
|
||||
void writeReceiverSettings(ReceiverSettings * source);
|
||||
});
|
||||
|
||||
extern ModuleState moduleState[NUM_MODULES];
|
||||
|
||||
@@ -25,6 +25,21 @@
|
||||
#include "io/frsky_firmware_update.h"
|
||||
#include "libopenui/src/libopenui_file.h"
|
||||
|
||||
PXX2ModuleSetup& getPXX2ModuleSetupBuffer()
|
||||
{
|
||||
return reusableBuffer.moduleSetup.pxx2;
|
||||
}
|
||||
|
||||
BindInformation& getPXX2BindInformationBuffer()
|
||||
{
|
||||
return reusableBuffer.moduleSetup.bindInformation;
|
||||
}
|
||||
|
||||
PXX2HardwareAndSettings& getPXX2HardwareAndSettingsBuffer()
|
||||
{
|
||||
return reusableBuffer.hardwareAndSettings;
|
||||
}
|
||||
|
||||
uint8_t Pxx2Pulses::addFlag0(uint8_t module)
|
||||
{
|
||||
uint8_t flag0 = g_model.header.modelId[module] & 0x3F;
|
||||
|
||||
@@ -316,6 +316,109 @@ enum PXX2ReceiverStatus {
|
||||
PXX2_SETTINGS_OK
|
||||
};
|
||||
|
||||
PACK(struct PXX2Version {
|
||||
uint8_t major;
|
||||
uint8_t revision:4;
|
||||
uint8_t minor:4;
|
||||
});
|
||||
|
||||
PACK(struct PXX2HardwareInformation {
|
||||
uint8_t modelID;
|
||||
PXX2Version hwVersion;
|
||||
PXX2Version swVersion;
|
||||
uint8_t variant;
|
||||
uint32_t capabilities; // variable length
|
||||
uint8_t capabilityNotSupported;
|
||||
});
|
||||
|
||||
PACK(struct ModuleInformation {
|
||||
int8_t current;
|
||||
int8_t maximum;
|
||||
uint8_t timeout;
|
||||
PXX2HardwareInformation information;
|
||||
struct {
|
||||
PXX2HardwareInformation information;
|
||||
tmr10ms_t timestamp;
|
||||
} receivers[PXX2_MAX_RECEIVERS_PER_MODULE];
|
||||
});
|
||||
|
||||
class ModuleSettings {
|
||||
public:
|
||||
uint8_t state; // 0x00 = READ 0x40 = WRITE
|
||||
tmr10ms_t timeout;
|
||||
uint8_t externalAntenna;
|
||||
int8_t txPower;
|
||||
uint8_t dirty;
|
||||
};
|
||||
|
||||
struct PXX2ModuleSetup {
|
||||
union {
|
||||
uint8_t registerStep;
|
||||
uint8_t resetStep;
|
||||
};
|
||||
uint8_t registerPopupVerticalPosition;
|
||||
uint8_t registerPopupHorizontalPosition;
|
||||
int8_t registerPopupEditMode;
|
||||
char registerRxName[PXX2_LEN_RX_NAME];
|
||||
uint8_t registerLoopIndex; // will be removed later
|
||||
union {
|
||||
uint8_t shareReceiverIndex;
|
||||
uint8_t resetReceiverIndex;
|
||||
};
|
||||
uint8_t resetReceiverFlags;
|
||||
ModuleInformation moduleInformation;
|
||||
ModuleSettings moduleSettings;
|
||||
};
|
||||
|
||||
class ReceiverSettings {
|
||||
public:
|
||||
uint8_t state; // 0x00 = READ 0x40 = WRITE
|
||||
tmr10ms_t timeout;
|
||||
uint8_t receiverId;
|
||||
uint8_t dirty;
|
||||
uint8_t telemetryDisabled;
|
||||
uint8_t telemetry25mw;
|
||||
uint8_t pwmRate;
|
||||
uint8_t fport;
|
||||
uint8_t enablePwmCh5Ch6;
|
||||
uint8_t fport2;
|
||||
uint8_t outputsCount;
|
||||
uint8_t outputsMapping[24];
|
||||
};
|
||||
|
||||
class BindInformation {
|
||||
public:
|
||||
int8_t step;
|
||||
uint32_t timeout;
|
||||
char candidateReceiversNames[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME + 1];
|
||||
uint8_t candidateReceiversCount;
|
||||
uint8_t selectedReceiverIndex;
|
||||
uint8_t rxUid;
|
||||
uint8_t lbtMode;
|
||||
uint8_t flexMode;
|
||||
PXX2HardwareInformation receiverInformation;
|
||||
};
|
||||
|
||||
class OtaUpdateInformation: public BindInformation {
|
||||
public:
|
||||
char filename[FF_MAX_LFN + 1];
|
||||
uint32_t address;
|
||||
uint32_t module;
|
||||
};
|
||||
|
||||
struct PXX2HardwareAndSettings {
|
||||
ModuleInformation modules[NUM_MODULES];
|
||||
uint32_t updateTime;
|
||||
ModuleSettings moduleSettings;
|
||||
ReceiverSettings receiverSettings; // when dealing with receiver settings, we
|
||||
// also need module settings
|
||||
char msg[64];
|
||||
};
|
||||
|
||||
PXX2ModuleSetup& getPXX2ModuleSetupBuffer();
|
||||
BindInformation& getPXX2BindInformationBuffer();
|
||||
PXX2HardwareAndSettings& getPXX2HardwareAndSettingsBuffer();
|
||||
|
||||
extern ModuleFifo intmoduleFifo;
|
||||
extern ModuleFifo extmoduleFifo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user