Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add support for flightMode? #33

Open
PYJTERSTM32 opened this issue Dec 10, 2023 · 1 comment
Open

How to add support for flightMode? #33

PYJTERSTM32 opened this issue Dec 10, 2023 · 1 comment

Comments

@PYJTERSTM32
Copy link

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

@CapnBry
Copy link
Owner

CapnBry commented Dec 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants