Class RefSerialTransmitter

Inheritance Relationships

Base Types

  • public tap::communication::serial::RefSerialData (Class RefSerialData)

  • public modm::Resumable< 8 >

Class Documentation

class RefSerialTransmitter : public tap::communication::serial::RefSerialData, public modm::Resumable<8>

Encapsulates logic for sending messages to the referee system. This includes sending robot-to-robot communication messages and UI drawing instructions to the RoboMaster client.

The instance member functions of this class that return a modm::ResumableResult<void> must be used in a protothread or resumable function. In other words, member functions such as sendGraphic must be in a call of PT_CALL or RF_CALL.

This transmitter allows the user to send data to the referee system from multiple protothreads. An instance of the ref serial transmitter should be instantiated for each protothread. If unique instances are not used, behavior is undefined.

Unnamed Group

modm::ResumableResult<void> sendGraphic(Tx::Graphic1Message *graphicMsg, bool configMsgHeader = true, bool sendMsg = true)

This function and the ones below all configure the message header and sends the specified message struct to the referee system unless configMsgHeader or sendMsg are false.

Todo:

template instantiation?

Parameters:
  • graphicMsg[in] The graphic message to send. Note that this struct is updated with header information in this function.

  • configMsgHeader[in] Whether or not to update the graphicMsg’s header information.

  • sendMsg[in] Whether or not to send the message.

modm::ResumableResult<void> sendGraphic(Tx::Graphic2Message *graphicMsg, bool configMsgHeader = true, bool sendMsg = true)
modm::ResumableResult<void> sendGraphic(Tx::Graphic5Message *graphicMsg, bool configMsgHeader = true, bool sendMsg = true)
modm::ResumableResult<void> sendGraphic(Tx::Graphic7Message *graphicMsg, bool configMsgHeader = true, bool sendMsg = true)
modm::ResumableResult<void> sendGraphic(Tx::GraphicCharacterMessage *graphicMsg, bool configMsgHeader = true, bool sendMsg = true)

Public Functions

RefSerialTransmitter(Drivers *drivers)
modm::ResumableResult<void> deleteGraphicLayer(Tx::DeleteGraphicOperation graphicOperation, uint8_t graphicLayer)

Deletes an entire graphic layer or the entire screen

Parameters:
  • graphicOperation[in] Whether to delete a single layer or the entire screen.

  • graphicLayer[in] The layer to remove. Must be between 0-9

modm::ResumableResult<void> sendRobotToRobotMsg(Tx::RobotToRobotMessage *robotToRobotMsg, uint16_t msgId, RobotId receiverId, uint16_t msgLen)

Public Static Functions

static void configGraphicGenerics(Tx::GraphicData *graphicData, const uint8_t *name, Tx::GraphicOperation operation, uint8_t layer, Tx::GraphicColor color)

Configures the graphicData with all data generic to the type of graphic being configured.

For sending graphics, the general schema is to create a Graphic<n>Message struct, configure the individual GraphicData structs in the graphic message using the configGraphicGenerics and then config<Line|Rectangle|Circle|etc.> functions. Finally, send the graphic message using sendGraphic.

For example, to configure and send a line graphic (refSerialTransmitter is a pointer to a RefSerialTransmitter object):

Graphic1Message msg;
RefSerialTransmitter::configGraphicGenerics(
     &msg.graphicData,
     "\x00\x00\x01",
     RefSerial::GRAPHIC_ADD,1,
     YELLOW);
RefSerialTransmitter::configLine(4, 100, 100, 200, 200, &msg.graphicData);
refSerialTransmitter->sendGraphic(&msg);

Parameters:
  • graphicData[out] The structure where generic data will be stored.

  • name[in] The name of the graphic.

  • operation[in] The graphic operation to be done (add/remove, etc).

  • layer[in] The graphic layer the graphic will be located at. Must be between 0-9

  • color[in] The color of the graphic.

static void configLine(uint16_t width, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, Tx::GraphicData *sharedData)

Configures sharedData with a line graphic whose parameters are specified.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configRectangle(uint16_t width, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, Tx::GraphicData *sharedData)

Configures sharedData with a rectangle graphic whose parameters are specified.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configCircle(uint16_t width, uint16_t centerX, uint16_t centerY, uint16_t radius, Tx::GraphicData *sharedData)

Configures sharedData with a circle graphic whose parameters are specified.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configEllipse(uint16_t width, uint16_t centerX, uint16_t centerY, uint16_t xLen, uint16_t yLen, Tx::GraphicData *sharedData)

Configures sharedData with an ellipse graphic whose parameters are specified.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configArc(uint16_t startAngle, uint16_t endAngle, uint16_t width, uint16_t centerX, uint16_t centerY, uint16_t xLen, uint16_t yLen, Tx::GraphicData *sharedData)

Configures sharedData with an arc graphic whose parameters are specified.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configFloatingNumber(uint16_t fontSize, uint16_t decimalPrecision, uint16_t width, uint16_t startX, uint16_t startY, float value, Tx::GraphicData *sharedData)

Configures sharedData with a floating point number.

Recommended font size and line width ratio is 10:1.

Note

This function doesn’t work because of known issues in the referee system server.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configInteger(uint16_t fontSize, uint16_t width, uint16_t startX, uint16_t startY, int32_t value, Tx::GraphicData *sharedData)

Configures sharedData with an integer.

Recommended font size and line width ratio is 10:1.

Note

This function doesn’t display negative numbers properly because of known issues in the referee system server.

Parameters:

sharedData[out] The graphic data struct to configure.

static void configCharacterMsg(uint16_t fontSize, uint16_t width, uint16_t startX, uint16_t startY, const char *dataToPrint, Tx::GraphicCharacterMessage *sharedData)

Configures a character message in the passed in GraphicCharacterMessage.

Recommended font size and line width ratio is 10:1.

Parameters:

sharedData[out] The message to configure.

static void configFrameHeader(DJISerial::FrameHeader *header, uint16_t msgLen)

Properly constructs the frame header and places it in the passed in header.

Parameters:
  • header[out] The frame header struct to store the constructed frame header.

  • msgLen[in] The length of the message. This includes only the length of the data and not the length of the cmdId or frame tail.

static void configInteractiveHeader(Tx::InteractiveHeader *header, uint16_t cmdId, RobotId senderId, uint16_t receiverId)