mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Improved consistency of update fn naming. GPS update tidy.
This commit is contained in:
parent
1d6240c9d5
commit
c0d87ca657
12 changed files with 34 additions and 37 deletions
|
@ -163,14 +163,10 @@ static void taskUpdateRxMain(uint32_t currentTime)
|
|||
static void taskProcessGPS(uint32_t currentTime)
|
||||
{
|
||||
// if GPS feature is enabled, gpsThread() will be called at some intervals to check for stuck
|
||||
// hardware, wrong baud rates, init GPS if needed, etc. Don't use SENSOR_GPS here as gpsThread() can and will
|
||||
// hardware, wrong baud rates, init GPS if needed, etc. Don't use SENSOR_GPS here as gpsUdate() can and will
|
||||
// change this based on available hardware
|
||||
if (feature(FEATURE_GPS)) {
|
||||
gpsThread();
|
||||
}
|
||||
|
||||
if (sensors(SENSOR_GPS)) {
|
||||
updateGpsIndicator(currentTime);
|
||||
gpsUpdate(currentTime);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -179,7 +175,7 @@ static void taskProcessGPS(uint32_t currentTime)
|
|||
static void taskUpdateCompass(uint32_t currentTime)
|
||||
{
|
||||
if (sensors(SENSOR_MAG)) {
|
||||
updateCompass(currentTime, &masterConfig.magZero);
|
||||
compassUpdate(currentTime, &masterConfig.magZero);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -228,7 +224,7 @@ static void taskCalculateAltitude(uint32_t currentTime)
|
|||
static void taskUpdateDisplay(uint32_t currentTime)
|
||||
{
|
||||
if (feature(FEATURE_DISPLAY)) {
|
||||
updateDisplay(currentTime);
|
||||
displayUpdate(currentTime);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -248,7 +244,7 @@ static void taskTelemetry(uint32_t currentTime)
|
|||
static void taskLedStrip(uint32_t currentTime)
|
||||
{
|
||||
if (feature(FEATURE_LED_STRIP)) {
|
||||
updateLedStrip(currentTime);
|
||||
ledStripUpdate(currentTime);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -257,7 +253,7 @@ static void taskLedStrip(uint32_t currentTime)
|
|||
static void taskTransponder(uint32_t currentTime)
|
||||
{
|
||||
if (feature(FEATURE_TRANSPONDER)) {
|
||||
updateTransponder(currentTime);
|
||||
transponderUpdate(currentTime);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -779,7 +779,7 @@ void subTaskMainSubprocesses(void)
|
|||
#endif
|
||||
|
||||
#ifdef TRANSPONDER
|
||||
updateTransponder(startTime);
|
||||
transponderUpdate(startTime);
|
||||
#endif
|
||||
if (debugMode == DEBUG_PIDLOOP) {debug[1] = micros() - startTime;}
|
||||
}
|
||||
|
|
|
@ -582,7 +582,7 @@ void showDebugPage(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void updateDisplay(uint32_t currentTime)
|
||||
void displayUpdate(uint32_t currentTime)
|
||||
{
|
||||
static uint8_t previousArmedState = 0;
|
||||
|
||||
|
@ -702,7 +702,7 @@ void displayInit(rxConfig_t *rxConfigToUse)
|
|||
memset(&pageState, 0, sizeof(pageState));
|
||||
displaySetPage(PAGE_WELCOME);
|
||||
|
||||
updateDisplay(micros());
|
||||
displayUpdate(micros());
|
||||
|
||||
displaySetNextPageChangeAt(micros() + (1000 * 1000 * 5));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef enum {
|
|||
|
||||
struct rxConfig_s;
|
||||
void displayInit(struct rxConfig_s *intialRxConfig);
|
||||
void updateDisplay(uint32_t currentTime);
|
||||
void displayUpdate(uint32_t currentTime);
|
||||
|
||||
void displayShowFixedPage(pageId_e pageId);
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ void gpsInit(serialConfig_t *initialSerialConfig, gpsConfig_t *initialGpsConfig)
|
|||
mode &= ~MODE_TX;
|
||||
#endif
|
||||
|
||||
// no callback - buffer will be consumed in gpsThread()
|
||||
// no callback - buffer will be consumed in gpsUpdate()
|
||||
gpsPort = openSerialPort(gpsPortConfig->identifier, FUNCTION_GPS, NULL, gpsInitData[gpsData.baudrateIndex].baudrateIndex, mode, SERIAL_NOT_INVERTED);
|
||||
if (!gpsPort) {
|
||||
featureClear(FEATURE_GPS);
|
||||
|
@ -398,7 +398,16 @@ void gpsInitHardware(void)
|
|||
}
|
||||
}
|
||||
|
||||
void gpsThread(void)
|
||||
static void updateGpsIndicator(uint32_t currentTime)
|
||||
{
|
||||
static uint32_t GPSLEDTime;
|
||||
if ((int32_t)(currentTime - GPSLEDTime) >= 0 && (GPS_numSat >= 5)) {
|
||||
GPSLEDTime = currentTime + 150000;
|
||||
LED1_TOGGLE;
|
||||
}
|
||||
}
|
||||
|
||||
void gpsUpdate(uint32_t currentTime)
|
||||
{
|
||||
// read out available GPS bytes
|
||||
if (gpsPort) {
|
||||
|
@ -423,7 +432,7 @@ void gpsThread(void)
|
|||
gpsData.baudrateIndex++;
|
||||
gpsData.baudrateIndex %= GPS_INIT_ENTRIES;
|
||||
}
|
||||
gpsData.lastMessage = millis();
|
||||
gpsData.lastMessage = currentTime / 1000;
|
||||
// TODO - move some / all of these into gpsData
|
||||
GPS_numSat = 0;
|
||||
DISABLE_STATE(GPS_FIX);
|
||||
|
@ -432,13 +441,16 @@ void gpsThread(void)
|
|||
|
||||
case GPS_RECEIVING_DATA:
|
||||
// check for no data/gps timeout/cable disconnection etc
|
||||
if (millis() - gpsData.lastMessage > GPS_TIMEOUT) {
|
||||
if (currentTime / 1000 - gpsData.lastMessage > GPS_TIMEOUT) {
|
||||
// remove GPS from capability
|
||||
sensorsClear(SENSOR_GPS);
|
||||
gpsSetState(GPS_LOST_COMMUNICATION);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (sensors(SENSOR_GPS)) {
|
||||
updateGpsIndicator(currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
static void gpsNewData(uint16_t c)
|
||||
|
@ -1065,13 +1077,12 @@ static void gpsHandlePassthrough(uint8_t data)
|
|||
gpsNewData(data);
|
||||
#ifdef DISPLAY
|
||||
if (feature(FEATURE_DISPLAY)) {
|
||||
updateDisplay(micros());
|
||||
displayUpdate(micros());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
|
||||
{
|
||||
waitForSerialPortToFinishTransmitting(gpsPort);
|
||||
|
@ -1088,13 +1099,4 @@ void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
|
|||
|
||||
serialPassthrough(gpsPort, gpsPassthroughPort, &gpsHandlePassthrough, NULL);
|
||||
}
|
||||
|
||||
void updateGpsIndicator(uint32_t currentTime)
|
||||
{
|
||||
static uint32_t GPSLEDTime;
|
||||
if ((int32_t)(currentTime - GPSLEDTime) >= 0 && (GPS_numSat >= 5)) {
|
||||
GPSLEDTime = currentTime + 150000;
|
||||
LED1_TOGGLE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -119,6 +119,5 @@ extern uint8_t GPS_svinfo_cno[16]; // Carrier to Noise Ratio (Signal Str
|
|||
|
||||
struct serialConfig_s;
|
||||
void gpsInit(struct serialConfig_s *serialConfig, gpsConfig_t *initialGpsConfig);
|
||||
void gpsThread(void);
|
||||
void gpsUpdate(uint32_t currentTime);
|
||||
bool gpsNewFrame(uint8_t c);
|
||||
void updateGpsIndicator(uint32_t currentTime);
|
||||
|
|
|
@ -926,7 +926,7 @@ static applyLayerFn_timed* layerTable[] = {
|
|||
[timRing] = &applyLedThrustRingLayer
|
||||
};
|
||||
|
||||
void updateLedStrip(uint32_t currentTime)
|
||||
void ledStripUpdate(uint32_t currentTime)
|
||||
{
|
||||
if (!(ledStripInitialised && isWS2811LedStripReady())) {
|
||||
return;
|
||||
|
|
|
@ -167,7 +167,7 @@ void reevaluateLedConfig(void);
|
|||
|
||||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse, modeColorIndexes_t *modeColorsToUse, specialColorIndexes_t *specialColorsToUse);
|
||||
void ledStripEnable(void);
|
||||
void updateLedStrip(uint32_t currentTime);
|
||||
void ledStripUpdate(uint32_t currentTime);
|
||||
|
||||
bool setModeColor(ledModeIndex_e modeIndex, int modeColorIndex, int colorIndex);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static uint32_t nextUpdateAt = 0;
|
|||
#define JITTER_DURATION_COUNT (sizeof(jitterDurations) / sizeof(uint8_t))
|
||||
static uint8_t jitterDurations[] = {0,9,4,8,3,9,6,7,1,6,9,7,8,2,6};
|
||||
|
||||
void updateTransponder(uint32_t currentTime)
|
||||
void transponderUpdate(uint32_t currentTime)
|
||||
{
|
||||
static uint32_t jitterIndex = 0;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ void transponderInit(uint8_t* transponderCode);
|
|||
|
||||
void transponderEnable(void);
|
||||
void transponderDisable(void);
|
||||
void updateTransponder(uint32_t currentTime);
|
||||
void transponderUpdate(uint32_t currentTime);
|
||||
void transponderUpdateData(uint8_t* transponderData);
|
||||
void transponderTransmitOnce(void);
|
||||
void transponderStartRepeating(void);
|
||||
|
|
|
@ -57,7 +57,7 @@ void compassInit(void)
|
|||
magInit = 1;
|
||||
}
|
||||
|
||||
void updateCompass(uint32_t currentTime, flightDynamicsTrims_t *magZero)
|
||||
void compassUpdate(uint32_t currentTime, flightDynamicsTrims_t *magZero)
|
||||
{
|
||||
static uint32_t tCal = 0;
|
||||
static flightDynamicsTrims_t magZeroTempMin;
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef enum {
|
|||
|
||||
void compassInit(void);
|
||||
union flightDynamicsTrims_u;
|
||||
void updateCompass(uint32_t currentTime, union flightDynamicsTrims_u *magZero);
|
||||
void compassUpdate(uint32_t currentTime, union flightDynamicsTrims_u *magZero);
|
||||
|
||||
extern int32_t magADC[XYZ_AXIS_COUNT];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue