mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
begin initial merge of 2.2 features
mw2.2-merged stuff: * implemented profiles 0-2 (called 'setting' in mwiigui) * merged in MSP changes including profile switch * cleaned up rc / aux switch stuff in mw.c based on 2.2 rewrite * main loop switch for baro/sonar shit adjusted todo: basically the rest of 2.2 changes (i think some minor imu/gps/baro updates) baseflight-specific stuff: * made boxitems transmission dynamic, based on enabled features. no more GPS / camstab trash if it's not enabled * cleaned up gyro drivers to return scale factor to imu code * set gyro_lpf now controls every supported gyro - not all take same values, see driver files for allowed ranges, in case of invalid lpf, defaults to something reasonable (around 30-40hz) maybe couple other things I forgot. this is all 100% experimental, untested, and not even flown. thats why there's no hex. merge is still ongoing. git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@294 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
bba9bc291f
commit
491b3627f6
20 changed files with 1009 additions and 559 deletions
37
src/gps.c
37
src/gps.c
|
@ -45,12 +45,12 @@ void gpsInit(uint32_t baudrate)
|
|||
GPS_set_pids();
|
||||
uart2Init(baudrate, GPS_NewData, false);
|
||||
|
||||
if (cfg.gps_type == GPS_UBLOX)
|
||||
if (mcfg.gps_type == GPS_UBLOX)
|
||||
offset = 0;
|
||||
else if (cfg.gps_type == GPS_MTK)
|
||||
else if (mcfg.gps_type == GPS_MTK)
|
||||
offset = 4;
|
||||
|
||||
if (cfg.gps_type != GPS_NMEA) {
|
||||
if (mcfg.gps_type != GPS_NMEA) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
uart2ChangeBaud(init_speed[i]);
|
||||
switch (baudrate) {
|
||||
|
@ -72,12 +72,12 @@ void gpsInit(uint32_t baudrate)
|
|||
}
|
||||
|
||||
uart2ChangeBaud(baudrate);
|
||||
if (cfg.gps_type == GPS_UBLOX) {
|
||||
if (mcfg.gps_type == GPS_UBLOX) {
|
||||
for (i = 0; i < sizeof(ubloxInit); i++) {
|
||||
uart2Write(ubloxInit[i]); // send ubx init binary
|
||||
delay(4);
|
||||
}
|
||||
} else if (cfg.gps_type == GPS_MTK) {
|
||||
} else if (mcfg.gps_type == GPS_MTK) {
|
||||
gpsPrint("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"); // only GGA and RMC sentence
|
||||
gpsPrint("$PMTK220,200*2C\r\n"); // 5 Hz update rate
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ static void gpsPrint(const char *str)
|
|||
{
|
||||
while (*str) {
|
||||
uart2Write(*str);
|
||||
if (cfg.gps_type == GPS_UBLOX)
|
||||
if (mcfg.gps_type == GPS_UBLOX)
|
||||
delay(4);
|
||||
str++;
|
||||
}
|
||||
|
@ -134,6 +134,29 @@ static int16_t GPS_calc_desired_speed(int16_t max_speed, bool _slow);
|
|||
int32_t wrap_18000(int32_t error);
|
||||
static int32_t wrap_36000(int32_t angle);
|
||||
|
||||
typedef struct {
|
||||
int16_t last_velocity;
|
||||
} LeadFilter_PARAM;
|
||||
|
||||
void leadFilter_clear(LeadFilter_PARAM *param)
|
||||
{
|
||||
param->last_velocity = 0;
|
||||
}
|
||||
|
||||
int32_t leadFilter_getPosition(LeadFilter_PARAM *param, int32_t pos, int16_t vel, float lag_in_seconds)
|
||||
{
|
||||
int16_t accel_contribution = (vel - param->last_velocity) * lag_in_seconds * lag_in_seconds;
|
||||
int16_t vel_contribution = vel * lag_in_seconds;
|
||||
|
||||
// store velocity for next iteration
|
||||
param->last_velocity = vel;
|
||||
|
||||
return pos + vel_contribution + accel_contribution;
|
||||
}
|
||||
|
||||
LeadFilter_PARAM xLeadFilter;
|
||||
LeadFilter_PARAM yLeadFilter;
|
||||
|
||||
typedef struct {
|
||||
float kP;
|
||||
float kI;
|
||||
|
@ -752,7 +775,7 @@ static uint8_t hex_c(uint8_t n)
|
|||
|
||||
static bool GPS_newFrame(char c)
|
||||
{
|
||||
switch (cfg.gps_type) {
|
||||
switch (mcfg.gps_type) {
|
||||
case GPS_NMEA: // NMEA
|
||||
case GPS_MTK: // MTK outputs NMEA too
|
||||
return GPS_NMEA_newFrame(c);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue