fix(AFHDS3): Sync UI with Flysky AFHDS3 module stored settings (#3501)

* Refresh UI module settings when AHFDS3 config is updated.

* Fix scroll order for module options when 'FlySky' module type selected.
Fix simulator crash issues related to FlySky module.

* Fixed UI refresh problems in UI widget ordering fix.

* Refresh config when receiver is connected.

* Disable change of bind time options when receiver is connected.

* Rename methods to better distinguish between buffer fill or actual send.

* Clean and tidy up AFHDS3 state flow.

* Implemented settings sync upon setting changes.

* Added RF power settings for IRM301/FRM303.

* Added RF power sensors for FRM303.

* Fixed config not saved and only FRM303 supports RF power settings.

* Fixed RF power command error.

* Fixed a crash for IRM301.

* Always check if port exists and return nullptr for driver.

* fix: Make Companion preserve settings *as is*

---------

Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
richardclli
2023-06-19 19:00:02 +08:00
committed by GitHub
co-authored by Phil Mitchell Peter Feerick
parent bdb78ba2ef
commit cb533f4493
33 changed files with 598 additions and 197 deletions
+11 -9
View File
@@ -67,7 +67,7 @@ void FrameTransport::clear()
esc_state = 0;
}
void FrameTransport::sendByte(uint8_t b)
void FrameTransport::putByte(uint8_t b)
{
*(data_ptr++) = b;
}
@@ -78,15 +78,15 @@ void FrameTransport::putBytes(uint8_t* data, int length)
uint8_t byte = data[i];
crc += byte;
if (END == byte) {
sendByte(ESC);
sendByte(ESC_END);
putByte(ESC);
putByte(ESC_END);
}
else if (ESC == byte) {
sendByte(ESC);
sendByte(ESC_ESC);
putByte(ESC);
putByte(ESC_ESC);
}
else {
sendByte(byte);
putByte(byte);
}
}
}
@@ -99,7 +99,7 @@ void FrameTransport::putFrame(COMMAND command, FRAME_TYPE frameType,
data_ptr = trsp_buffer;
crc = 0;
sendByte(START);
putByte(START);
uint8_t buffer[] = {frameAddress, frameIndex, frameType, command};
putBytes(buffer, 4);
@@ -112,7 +112,7 @@ void FrameTransport::putFrame(COMMAND command, FRAME_TYPE frameType,
// footer
uint8_t crcValue = crc ^ 0xff;
putBytes(&crcValue, 1);
sendByte(END);
putByte(END);
}
uint32_t FrameTransport::getFrameSize()
@@ -236,7 +236,7 @@ void Transport::clear()
operationState = State::UNKNOWN;
}
void Transport::sendFrame(COMMAND command, FRAME_TYPE frameType, uint8_t* data,
void Transport::putFrame(COMMAND command, FRAME_TYPE frameType, uint8_t* data,
uint8_t dataLength)
{
operationState = State::SENDING_COMMAND;
@@ -264,9 +264,11 @@ void Transport::enqueue(COMMAND command, FRAME_TYPE frameType, bool useData,
void Transport::sendBuffer()
{
#if !defined(SIMU)
auto drv = modulePortGetSerialDrv(mod_st->tx);
auto ctx = modulePortGetCtx(mod_st->tx);
drv->sendBuffer(ctx, (uint8_t*)trsp.trsp_buffer, trsp.getFrameSize());
#endif
}
bool Transport::processQueue()