CapnBry / CRServoF

CRSF to PWM Servo converter for STM32F103

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add support for flightMode?

PYJTERSTM32 opened this issue · 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

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");