1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 09:45:33 +03:00

Merge pull request #8480 from JulioCesarMatias/DisplayPortMSPAddMacros

[Displayport MSP] Add Macros
This commit is contained in:
Paweł Spychalski 2022-10-20 09:26:30 +02:00 committed by GitHub
commit d1f6f19aa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -38,6 +38,8 @@
#include "msp/msp_protocol.h" #include "msp/msp_protocol.h"
#include "msp/msp_serial.h" #include "msp/msp_serial.h"
#define MSP_OSD_MAX_STRING_LENGTH 30
static displayPort_t mspDisplayPort; static displayPort_t mspDisplayPort;
extern uint8_t cliMode; extern uint8_t cliMode;
@ -70,21 +72,21 @@ static int grab(displayPort_t *displayPort)
static int release(displayPort_t *displayPort) static int release(displayPort_t *displayPort)
{ {
uint8_t subcmd[] = { 1 }; uint8_t subcmd[] = { MSP_DP_RELEASE };
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
} }
static int clearScreen(displayPort_t *displayPort) static int clearScreen(displayPort_t *displayPort)
{ {
uint8_t subcmd[] = { 2 }; uint8_t subcmd[] = { MSP_DP_CLEAR_SCREEN };
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
} }
static int drawScreen(displayPort_t *displayPort) static int drawScreen(displayPort_t *displayPort)
{ {
uint8_t subcmd[] = { 4 }; uint8_t subcmd[] = { MSP_DP_DRAW_SCREEN };
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd)); return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
} }
@ -96,7 +98,7 @@ static int screenSize(const displayPort_t *displayPort)
static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *string, textAttributes_t attr) static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, const char *string, textAttributes_t attr)
{ {
UNUSED(attr); UNUSED(attr);
#define MSP_OSD_MAX_STRING_LENGTH 30 // FIXME move this
uint8_t buf[MSP_OSD_MAX_STRING_LENGTH + 4]; uint8_t buf[MSP_OSD_MAX_STRING_LENGTH + 4];
int len = strlen(string); int len = strlen(string);
@ -104,7 +106,7 @@ static int writeString(displayPort_t *displayPort, uint8_t col, uint8_t row, con
len = MSP_OSD_MAX_STRING_LENGTH; len = MSP_OSD_MAX_STRING_LENGTH;
} }
buf[0] = 3; buf[0] = MSP_DP_WRITE_STRING;
buf[1] = row; buf[1] = row;
buf[2] = col; buf[2] = col;
buf[3] = 0; buf[3] = 0;

View file

@ -20,5 +20,11 @@
#include "config/parameter_group.h" #include "config/parameter_group.h"
#include "drivers/display.h" #include "drivers/display.h"
// MSP Display Port commands
#define MSP_DP_RELEASE 1
#define MSP_DP_CLEAR_SCREEN 2
#define MSP_DP_WRITE_STRING 3
#define MSP_DP_DRAW_SCREEN 4
struct displayPort_s; struct displayPort_s;
struct displayPort_s *displayPortMspInit(void); struct displayPort_s *displayPortMspInit(void);