CRServoF icon indicating copy to clipboard operation
CRServoF copied to clipboard

How to add support for flightMode?

Open PYJTERSTM32 opened this issue 1 year ago • 1 comments

Hello, I would like to add support for flight mode to the library, but I'm not quite sure how to do it. In the Arduino file, I added a function:

void sendFlightMode(uint8_t flightMode) { crsf.queuePacket(CRSF_SYNC_BYTE, CRSF_FRAMETYPE_FLIGHT_MODE, &flightMode, sizeof(flightMode)); }

I uncommented the line // CRSF_FRAMETYPE_FLIGHT_MODE = 0x21, //no need to support?'

I don't know how to modify the other library files. Could someone help me?

PETER

PYJTERSTM32 avatar Dec 10 '23 16:12 PYJTERSTM32

Your flightMode is 1 byte according to your code there, and CRSF defines it as a string. You probably want something like this:

void sendFlightMode(const char *flightMode)
{
  uint8_t len = min(strlen(flightMode), 15);  // limit to 15 chars max
  uint8_t buf[16];
  buf[0] = len;
  memcpy(&buf[1], flightMode, len);
  crsf.queuePacket(CRSF_SYNC_BYTE, CRSF_FRAMETYPE_FLIGHT_MODE, buf, len+1);
}

//usage:
sendFlightMode("ACRO");

CapnBry avatar Dec 12 '23 18:12 CapnBry