1
0
Fork 0
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:
timecop@gmail.com 2012-09-18 13:29:35 +00:00
parent f3ce558871
commit 817eb09b8a
6 changed files with 2955 additions and 2923 deletions

File diff suppressed because it is too large Load diff

View file

@ -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,6 +617,7 @@ 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:
@ -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)
@ -656,6 +669,10 @@ static void cliSetVar(const clivalue_t *var, const int32_t value)
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 {

View file

@ -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)
{

View file

@ -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

View file

@ -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