New ascent rate fix

main
sq2ips 2025-03-29 19:50:11 +01:00
rodzic f0f788ae2d
commit 84ab49f558
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: C383A71588BA55F5
6 zmienionych plików z 40 dodań i 48 usunięć

Wyświetl plik

@ -53,11 +53,6 @@ extern "C" {
#include "stm32l0xx_it.h"
#include "fsk4.h"
#include "config.h"
#if GPS_TYPE == 1
#include "nmea.h"
#elif GPS_TYPE == 2
#include "xm_gps.h"
#endif
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/

Wyświetl plik

@ -27,6 +27,4 @@ typedef struct NMEA_DATA {
void ParseNMEA(NMEA *nmea_data, uint8_t *buffer);
void incTimeCountNmea();
#endif /* INC_NMEA_H_ */

Wyświetl plik

@ -364,8 +364,6 @@ int main(void)
LL_TIM_EnableCounter(TIM6);
LL_TIM_EnableIT_UPDATE(TIM6);
LL_SYSTICK_EnableIT();
/* USER CODE END 2 */
/* Infinite loop */

Wyświetl plik

@ -12,16 +12,11 @@
#endif
#include <string.h>
uint16_t TimeCounter = 0;
char data[DATA_SIZE][SENTENCE_SIZE];
uint8_t correct = 0;
uint16_t olddAlt = 0;
void incTimeCountNmea(){
TimeCounter++;
}
uint32_t olddTime = 0;
uint16_t a_strtof(char *buffer){
uint8_t d_pos = 0;
@ -156,16 +151,27 @@ int nmea_GGA(NMEA *nmea_data, char *inputString){
if(altitude != 0){
nmea_data->Alt = altitude;
if(olddAlt == 0){
olddAlt = nmea_data->Alt;
TimeCounter = 0;
}else if(TimeCounter>=AscentRateTime){
nmea_data->AscentRate = (float)(nmea_data->Alt-olddAlt)/TimeCounter;
olddAlt = nmea_data->Alt;
TimeCounter = 0;
uint32_t currentTime = h*3600+m*60+s;
if(currentTime != 0){
if(olddTime==0){
olddAlt = nmea_data->Alt;
olddTime = currentTime;
}
if((currentTime-olddTime) < 0){
currentTime+=3600*24;
}
if((currentTime-olddTime)>=AscentRateTime){
nmea_data->AscentRate = (float)(nmea_data->Alt-olddAlt)/(currentTime-olddTime);
if((currentTime-olddTime) < 0){
currentTime-=3600*24;
}
olddAlt = nmea_data->Alt;
olddTime = currentTime;
}
}else{
olddTime = 0;
}
}else{
olddAlt = 0;
}
//nmea_data->Fix = values[6][0]-'0';

Wyświetl plik

@ -41,7 +41,6 @@
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
uint32_t TickCounter = 0;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@ -125,15 +124,6 @@ void PendSV_Handler(void)
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
if(TickCounter >= 999){
#if GPS_TYPE == 1
incTimeCountNmea();
#elif GPS_TYPE == 2
incTimeCountGps();
#endif
TickCounter = 0;
}
TickCounter++;
/* USER CODE END SysTick_IRQn 0 */
/* USER CODE BEGIN SysTick_IRQn 1 */

Wyświetl plik

@ -13,11 +13,7 @@ const uint8_t syncChain[] = {0xAA, 0xAA, 0xAA, 0x03};
float oldAlt = 0;
uint16_t TimeCounterr = 0;
void incTimeCountGps(){
TimeCounterr++;
}
uint32_t oldTime = 0;
void ParseXM(XMDATA *GpsData, uint8_t *buffer, uint8_t position){
GpsData->Fix = *(uint8_t *)(buffer+4+position);
@ -51,16 +47,25 @@ void ParseXM(XMDATA *GpsData, uint8_t *buffer, uint8_t position){
((GpsData->Time & 0x0000FF00) << 8);
if(GpsData->Fix > 1 && GpsData->Alt != 0){
if(oldAlt == 0){
oldAlt = GpsData->Alt;
TimeCounterr = 0;
}else if(oldAlt != 0 && TimeCounterr>=AscentRateTime){
GpsData->AscentRate = (float)(GpsData->Alt-oldAlt)/TimeCounterr;
oldAlt = GpsData->Alt;
TimeCounterr = 0;
if(GpsData->Time != 0){
if(oldTime==0){
oldAlt = GpsData->Alt;
oldTime = GpsData->Time;
}
if((GpsData->Time-oldTime) < 0){
GpsData->Time+=3600*24;
}
if((GpsData->Time-oldTime)>=AscentRateTime){
GpsData->AscentRate = (float)(GpsData->Alt-oldAlt)/(GpsData->Time-oldTime);
if((GpsData->Time-oldTime) < 0){
GpsData->Time-=3600*24;
}
oldAlt = GpsData->Alt;
oldTime = GpsData->Time;
}
}else{
oldTime = 0;
}
}else{
oldAlt = 0;
}
GpsData->Hours = (GpsData->Time/3600)%24;