Skip to content

Commit

Permalink
spam gps msg at 10hz
Browse files Browse the repository at this point in the history
  • Loading branch information
wvarty committed Jul 2, 2024
1 parent 6a1fdd1 commit cd96da3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Vrx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ bool gotInitialPacket = false;
bool headTrackingEnabled = false;
uint32_t lastSentRequest = 0;

uint32_t lastSentGPS = 0;

device_t *ui_devices[] = {
#ifdef PIN_LED
&LED_device,
Expand Down Expand Up @@ -100,6 +102,9 @@ MSP msp;
ELRS_EEPROM eeprom;
VrxBackpackConfig config;

uint8_t cachedGPS[64];
uint8_t cachedLen = 0;

#ifdef RAPIDFIRE_BACKPACK
Rapidfire vrxModule;
#elif defined(RX5808_BACKPACK)
Expand Down Expand Up @@ -264,6 +269,8 @@ void ProcessMSPPacket(mspPacket_t *packet)
}
DBGLN(""); // Extra line for serial output readability
Serial.write(packet->payload, packet->payloadSize);
memcpy(cachedGPS, packet->payload, packet->payloadSize);
cachedLen = packet->payloadSize;
break;
default:
DBGLN("Unknown command from ESPNOW");
Expand Down Expand Up @@ -533,6 +540,14 @@ void loop()
lastSentRequest = now;
}

// spam out GPS msgs
if (cachedLen > 0 && now - lastSentGPS > 100 && connectionState != binding)
{
DBGLN("Send cached GPS...");
Serial.write(cachedGPS, cachedLen);
lastSentGPS = now;
}

#if !defined(NO_AUTOBIND)
// Power cycle must be done within 30s. Long timeout to allow goggles to boot and shutdown correctly e.g. Orqa.
if (now > BINDING_TIMEOUT && config.GetBootCount() > 0)
Expand Down

0 comments on commit cd96da3

Please sign in to comment.