diff --git a/src/main/build/debug.c b/src/main/build/debug.c index 4bf55bd0c2..bc8556077f 100644 --- a/src/main/build/debug.c +++ b/src/main/build/debug.c @@ -67,4 +67,5 @@ const char * const debugModeNames[DEBUG_COUNT] = { "SDIO", "CURRENT_SENSOR", "USB", + "SMARTAUDIO", }; diff --git a/src/main/build/debug.h b/src/main/build/debug.h index 9df27c8828..62b90ea707 100644 --- a/src/main/build/debug.h +++ b/src/main/build/debug.h @@ -85,6 +85,7 @@ typedef enum { DEBUG_SDIO, DEBUG_CURRENT, DEBUG_USB, + DEBUG_SMARTAUDIO, DEBUG_COUNT } debugType_e; diff --git a/src/main/io/vtx_smartaudio.c b/src/main/io/vtx_smartaudio.c index 813c678643..4592d36384 100644 --- a/src/main/io/vtx_smartaudio.c +++ b/src/main/io/vtx_smartaudio.c @@ -54,12 +54,12 @@ #define SMARTAUDIO_POLLING_INTERVAL 150 // Minimum time between state polling #define SMARTAUDIO_POLLING_WINDOW 1000 // Time window after command polling for state change -//#define SMARTAUDIO_DPRINTF -//#define SMARTAUDIO_DEBUG_MONITOR +//#define USE_SMARTAUDIO_DPRINTF +//#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART1 -#ifdef SMARTAUDIO_DPRINTF +#ifdef USE_SMARTAUDIO_DPRINTF serialPort_t *debugSerialPort = NULL; -#endif // SMARTAUDIO_DPRINTF +#endif // USE_SMARTAUDIO_DPRINTF static serialPort_t *smartAudioSerialPort = NULL; @@ -180,7 +180,7 @@ static uint8_t CRC8(const uint8_t *data, const int8_t len) } -#ifdef SMARTAUDIO_DPRINTF +#ifdef USE_SMARTAUDIO_DPRINTF static void saPrintSettings(void) { dprintf(("Current status: version: %d\r\n", saDevice.version)); @@ -290,12 +290,10 @@ static void saProcessResponse(uint8_t *buf, int len) saDevice.mode = buf[4]; saDevice.freq = (buf[5] << 8)|buf[6]; -#ifdef SMARTAUDIO_DEBUG_MONITOR - debug[0] = saDevice.version * 100 + saDevice.mode; - debug[1] = saDevice.channel; - debug[2] = saDevice.freq; - debug[3] = saDevice.power; -#endif + DEBUG_SET(DEBUG_SMARTAUDIO, 0, saDevice.version * 100 + saDevice.mode); + DEBUG_SET(DEBUG_SMARTAUDIO, 1, saDevice.channel); + DEBUG_SET(DEBUG_SMARTAUDIO, 2, saDevice.freq); + DEBUG_SET(DEBUG_SMARTAUDIO, 3, saDevice.power); break; case SA_CMD_SET_POWER: // Set Power @@ -336,7 +334,7 @@ static void saProcessResponse(uint8_t *buf, int len) #ifdef USE_CMS //if changes then trigger saCms update saCmsResetOpmodel(); #endif -#ifdef SMARTAUDIO_DPRINTF // Debug +#ifdef USE_SMARTAUDIO_DPRINTF // Debug saPrintSettings(); #endif } @@ -503,7 +501,7 @@ static saCmdQueue_t sa_queue[SA_QSIZE]; static uint8_t sa_qhead = 0; static uint8_t sa_qtail = 0; -#ifdef DPRINTF_SMARTAUDIO +#ifdef USE_DPRINTF_SMARTAUDIO static int saQueueLength(void) { if (sa_qhead >= sa_qtail) { @@ -667,7 +665,7 @@ void saSetPowerByIndex(uint8_t index) bool vtxSmartAudioInit(void) { -#ifdef SMARTAUDIO_DPRINTF +#ifdef USE_SMARTAUDIO_DPRINTF // Setup debugSerialPort debugSerialPort = openSerialPort(DPRINTF_SERIAL_PORT, FUNCTION_NONE, NULL, NULL, 115200, MODE_RXTX, 0); diff --git a/src/main/io/vtx_smartaudio.h b/src/main/io/vtx_smartaudio.h index 90ab32f0e3..a0ad9ee504 100644 --- a/src/main/io/vtx_smartaudio.h +++ b/src/main/io/vtx_smartaudio.h @@ -103,14 +103,9 @@ void saSetFreq(uint16_t freq); void saSetPitFreq(uint16_t freq); bool vtxSmartAudioInit(void); -#ifdef SMARTAUDIO_DPRINTF -#ifdef OMNIBUSF4 -#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART3 -#else -#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART1 -#endif +#ifdef USE_SMARTAUDIO_DPRINTF extern serialPort_t *debugSerialPort; #define dprintf(x) if (debugSerialPort) printf x #else #define dprintf(x) -#endif // SMARTAUDIO_DPRINTF +#endif // USE_SMARTAUDIO_DPRINTF