mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 03:20:00 +03:00
fixed bug in soft_i2c driver (doesnt affect anyone except testing)
added VAR_FLOAT to cli - now allows setting/printing float vars fixed newlines in pwm driver exported new althold tunables to cli (some are floats) - still not enabled by default until I know it works git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@219 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
f3ce558871
commit
817eb09b8a
6 changed files with 2955 additions and 2923 deletions
5837
obj/baseflight.hex
5837
obj/baseflight.hex
File diff suppressed because it is too large
Load diff
32
src/cli.c
32
src/cli.c
|
@ -82,7 +82,8 @@ typedef enum {
|
|||
VAR_INT8,
|
||||
VAR_UINT16,
|
||||
VAR_INT16,
|
||||
VAR_UINT32
|
||||
VAR_UINT32,
|
||||
VAR_FLOAT
|
||||
} vartype_e;
|
||||
|
||||
typedef struct {
|
||||
|
@ -143,6 +144,9 @@ const clivalue_t valueTable[] = {
|
|||
{ "gyro_lpf", VAR_UINT16, &cfg.gyro_lpf, 0, 256 },
|
||||
{ "gyro_cmpf_factor", VAR_UINT16, &cfg.gyro_cmpf_factor, 100, 1000 },
|
||||
{ "mpu6050_scale", VAR_UINT8, &cfg.mpu6050_scale, 0, 1 },
|
||||
{ "baro_tab_size", VAR_UINT8, &cfg.baro_tab_size, 0, BARO_TAB_SIZE_MAX },
|
||||
{ "baro_noise_lpf", VAR_FLOAT, &cfg.baro_noise_lpf, 0, 1 },
|
||||
{ "baro_cf", VAR_FLOAT, &cfg.baro_cf, 0, 1 },
|
||||
{ "mag_declination", VAR_INT16, &cfg.mag_declination, -18000, 18000 },
|
||||
{ "gps_type", VAR_UINT8, &cfg.gps_type, 0, 3 },
|
||||
{ "gps_pos_p", VAR_UINT8, &cfg.P8[PIDPOS], 0, 200 },
|
||||
|
@ -613,12 +617,13 @@ static void cliSave(char *cmdline)
|
|||
static void cliPrintVar(const clivalue_t *var, uint32_t full)
|
||||
{
|
||||
int32_t value = 0;
|
||||
char buf[8];
|
||||
|
||||
switch (var->type) {
|
||||
case VAR_UINT8:
|
||||
value = *(uint8_t *)var->ptr;
|
||||
break;
|
||||
|
||||
|
||||
case VAR_INT8:
|
||||
value = *(int8_t *)var->ptr;
|
||||
break;
|
||||
|
@ -634,6 +639,14 @@ static void cliPrintVar(const clivalue_t *var, uint32_t full)
|
|||
case VAR_UINT32:
|
||||
value = *(uint32_t *)var->ptr;
|
||||
break;
|
||||
|
||||
case VAR_FLOAT:
|
||||
printf("%s", ftoa(*(float *)var->ptr, buf));
|
||||
if (full) {
|
||||
printf(" %s", ftoa((float)var->min, buf));
|
||||
printf(" %s", ftoa((float)var->max, buf));
|
||||
}
|
||||
return; // return from case for float only
|
||||
}
|
||||
printf("%d", value);
|
||||
if (full)
|
||||
|
@ -647,15 +660,19 @@ static void cliSetVar(const clivalue_t *var, const int32_t value)
|
|||
case VAR_INT8:
|
||||
*(char *)var->ptr = (char)value;
|
||||
break;
|
||||
|
||||
|
||||
case VAR_UINT16:
|
||||
case VAR_INT16:
|
||||
*(short *)var->ptr = (short)value;
|
||||
break;
|
||||
|
||||
|
||||
case VAR_UINT32:
|
||||
*(int *)var->ptr = (int)value;
|
||||
break;
|
||||
|
||||
case VAR_FLOAT:
|
||||
*(float *)var->ptr = *(float *)&value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,6 +683,7 @@ static void cliSet(char *cmdline)
|
|||
const clivalue_t *val;
|
||||
char *eqptr = NULL;
|
||||
int32_t value = 0;
|
||||
float valuef = 0;
|
||||
|
||||
len = strlen(cmdline);
|
||||
|
||||
|
@ -682,12 +700,12 @@ static void cliSet(char *cmdline)
|
|||
eqptr++;
|
||||
len--;
|
||||
value = atoi(eqptr);
|
||||
valuef = _atof(eqptr);
|
||||
for (i = 0; i < VALUE_COUNT; i++) {
|
||||
val = &valueTable[i];
|
||||
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0) {
|
||||
// found
|
||||
if (value >= valueTable[i].min && value <= valueTable[i].max) {
|
||||
cliSetVar(val, value);
|
||||
if (valuef >= valueTable[i].min && valuef <= valueTable[i].max) { // here we compare the float value since... it should work, RIGHT?
|
||||
cliSetVar(val, valueTable[i].type == VAR_FLOAT ? *(uint32_t *)&valuef : value); // this is a silly dirty hack. please fix me later.
|
||||
printf("%s set to ", valueTable[i].name);
|
||||
cliPrintVar(val, 0);
|
||||
} else {
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#define SDA_H GPIOB->BSRR = GPIO_Pin_11 /* GPIO_SetBits(GPIOB , GPIO_Pin_11) */
|
||||
#define SDA_L GPIOB->BRR = GPIO_Pin_11 /* GPIO_ResetBits(GPIOB , GPIO_Pin_11) */
|
||||
|
||||
#define SCL_read GPIOB->IDR & GPIO_Pin_10 /* GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_10) */
|
||||
#define SDA_read GPIOB->IDR & GPIO_Pin_11 /* GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_11) */
|
||||
#define SCL_read (GPIOB->IDR & GPIO_Pin_10) /* GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_10) */
|
||||
#define SDA_read (GPIOB->IDR & GPIO_Pin_11) /* GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_11) */
|
||||
|
||||
static void I2C_delay(void)
|
||||
{
|
||||
|
|
|
@ -493,7 +493,7 @@ bool pwmInit(drv_pwm_config_t *init)
|
|||
|
||||
if (init->extraServos) {
|
||||
// remap PWM5..8 as servos when used in extended servo mode
|
||||
if (port >= PWM5 && port <= PWM8)
|
||||
if (port >= PWM5 && port <= PWM8)
|
||||
mask = TYPE_S;
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,6 @@ static void getEstimatedAttitude(void)
|
|||
#define UPDATE_INTERVAL 25000 // 40hz update rate (20hz LPF on acc)
|
||||
#define INIT_DELAY 4000000 // 4 sec initialization delay
|
||||
#define BARO_TAB_SIZE 40
|
||||
#define BARO_TAB_SIZE_MAX 48
|
||||
#define ACC_Z_DEADBAND (acc_1G / 50)
|
||||
|
||||
#ifdef NEW_ACCZ_HOLD
|
||||
|
|
2
src/mw.h
2
src/mw.h
|
@ -3,6 +3,8 @@
|
|||
/* for VBAT monitoring frequency */
|
||||
#define VBATFREQ 6 // to read battery voltage - nth number of loop iterations
|
||||
|
||||
#define BARO_TAB_SIZE_MAX 48
|
||||
|
||||
#define VERSION 211
|
||||
|
||||
#define LAT 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue