Merge branch 'betaflight' of https://github.com/borisbstyle/betaflight into betaflight

This commit is contained in:
borisbstyle 2016-04-22 12:23:25 +02:00
commit 8bffa11d19
8 changed files with 98 additions and 1 deletions

View File

@ -599,9 +599,11 @@ COLIBRI_RACE_SRC = \
drivers/bus_bst_stm32f30x.c \
drivers/accgyro_mpu.c \
drivers/accgyro_mpu6500.c \
drivers/accgyro_spi_mpu6000.c \
drivers/accgyro_spi_mpu6500.c \
drivers/accgyro_mpu6500.c \
drivers/barometer_ms5611.c \
drivers/compass_ak8963.c \
drivers/compass_ak8975.c \
drivers/compass_hmc5883l.c \
drivers/display_ug2864hsweg01.c \

View File

@ -323,9 +323,17 @@ extern uint32_t currentTime;
//From rx.c:
extern uint16_t rssi;
//From gyro.c
extern uint32_t targetLooptime;
//From rc_controls.c
extern uint32_t rcModeActivationMask;
static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED;
static uint32_t blackboxLastArmingBeep = 0;
static uint32_t blackboxLastFlightModeFlags = 0; // New event tracking of flight modes
static struct {
uint32_t headerIndex;
@ -857,6 +865,8 @@ void startBlackbox(void)
* it finally plays the beep for this arming event.
*/
blackboxLastArmingBeep = getArmingBeepTimeMicros();
blackboxLastFlightModeFlags = rcModeActivationMask; // record startup status
blackboxSetState(BLACKBOX_STATE_PREPARE_LOG_FILE);
}
@ -1166,6 +1176,24 @@ static bool blackboxWriteSysinfo()
blackboxPrintfHeaderLine("currentMeter:%d,%d", masterConfig.batteryConfig.currentMeterOffset, masterConfig.batteryConfig.currentMeterScale);
}
break;
case 13:
blackboxPrintfHeaderLine("rcExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcExpo8);
break;
case 14:
blackboxPrintfHeaderLine("rcYawExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcYawExpo8);
break;
case 15:
blackboxPrintfHeaderLine("superExpoFactor:%d", masterConfig.rxConfig.superExpoFactor);
break;
case 16:
blackboxPrintfHeaderLine("rates:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[0],
masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[1],
masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[2]);
break;
case 17:
blackboxPrintfHeaderLine("looptime:%d", targetLooptime);
break;
default:
return true;
}
@ -1193,6 +1221,10 @@ void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data)
case FLIGHT_LOG_EVENT_SYNC_BEEP:
blackboxWriteUnsignedVB(data->syncBeep.time);
break;
case FLIGHT_LOG_EVENT_FLIGHTMODE: // New flightmode flags write
blackboxWriteUnsignedVB(data->flightMode.flags);
blackboxWriteUnsignedVB(data->flightMode.lastFlags);
break;
case FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT:
if (data->inflightAdjustment.floatFlag) {
blackboxWrite(data->inflightAdjustment.adjustmentFunction + FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT_FUNCTION_FLOAT_VALUE_FLAG);
@ -1233,6 +1265,21 @@ static void blackboxCheckAndLogArmingBeep()
}
}
/* monitor the flight mode event status and trigger an event record if the state changes */
static void blackboxCheckAndLogFlightMode()
{
flightLogEvent_flightMode_t eventData; // Add new data for current flight mode flags
// Use != so that we can still detect a change if the counter wraps
if (rcModeActivationMask != blackboxLastFlightModeFlags) {
eventData.lastFlags = blackboxLastFlightModeFlags;
blackboxLastFlightModeFlags = rcModeActivationMask;
eventData.flags = rcModeActivationMask;
blackboxLogEvent(FLIGHT_LOG_EVENT_FLIGHTMODE, (flightLogEventData_t *) &eventData);
}
}
/*
* Use the user's num/denom settings to decide if the P-frame of the given index should be logged, allowing the user to control
* the portion of logged loop iterations.
@ -1277,6 +1324,7 @@ static void blackboxLogIteration()
writeIntraframe();
} else {
blackboxCheckAndLogArmingBeep();
blackboxCheckAndLogFlightMode(); // Check for FlightMode status change event
if (blackboxShouldLogPFrame(blackboxPFrameIndex)) {
/*

View File

@ -106,6 +106,7 @@ typedef enum FlightLogEvent {
FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT = 13,
FLIGHT_LOG_EVENT_LOGGING_RESUME = 14,
FLIGHT_LOG_EVENT_GTUNE_RESULT = 20,
FLIGHT_LOG_EVENT_FLIGHTMODE = 30, // Add new event type for flight mode status.
FLIGHT_LOG_EVENT_LOG_END = 255
} FlightLogEvent;
@ -113,6 +114,11 @@ typedef struct flightLogEvent_syncBeep_s {
uint32_t time;
} flightLogEvent_syncBeep_t;
typedef struct flightLogEvent_flightMode_s { // New Event Data type
uint32_t flags;
uint32_t lastFlags;
} flightLogEvent_flightMode_t;
typedef struct flightLogEvent_inflightAdjustment_s {
uint8_t adjustmentFunction;
bool floatFlag;
@ -135,6 +141,7 @@ typedef struct flightLogEvent_gtuneCycleResult_s {
typedef union flightLogEventData_u {
flightLogEvent_syncBeep_t syncBeep;
flightLogEvent_flightMode_t flightMode; // New event data
flightLogEvent_inflightAdjustment_t inflightAdjustment;
flightLogEvent_loggingResume_t loggingResume;
flightLogEvent_gtuneCycleResult_t gtuneCycleResult;

View File

@ -144,6 +144,11 @@ char *itoa(int i, char *a, int base)
#endif
/* Note: the floatString must be at least 13 bytes long to cover all cases.
* This includes up to 10 digits (32 bit ints can hold numbers up to 10
* digits long) + the decimal point + negative sign or space + null
* terminator.
*/
char *ftoa(float x, char *floatString)
{
int32_t value;

View File

@ -21,7 +21,17 @@ void li2a(long num, char *bf);
void ui2a(unsigned int num, unsigned int base, int uc, char *bf);
void i2a(int num, char *bf);
char a2i(char ch, const char **src, int base, int *nump);
/* Simple conversion of a float to a string. Will display completely
* inaccurate results for floats larger than about 2.15E6 (2^31 / 1000)
* (same thing for negative values < -2.15E6).
* Will always display 3 decimals, so anything smaller than 1E-3 will
* not be displayed.
* The floatString will be filled in with the result and will be
* returned. It must be at least 13 bytes in length to cover all cases!
*/
char *ftoa(float x, char *floatString);
float fastA2F(const char *p);
#ifndef HAVE_ITOA_FUNCTION

View File

@ -245,6 +245,19 @@ const ledConfig_t defaultLedStripConfig[] = {
{ CALCULATE_LED_XY( 1, 1), 3, LED_FUNCTION_THRUST_RING},
{ CALCULATE_LED_XY( 1, 1), 3, LED_FUNCTION_THRUST_RING},
};
#elif defined(USE_COLIBTI_RACE_LED_DEFAULT_CONFIG)
const ledConfig_t defaultLedStripConfig[] = {
{ CALCULATE_LED_XY( 0, 0), 6, LED_DIRECTION_WEST | LED_FUNCTION_WARNING | LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 0, 1), 6, LED_DIRECTION_WEST | LED_FUNCTION_WARNING | LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 0, 8), 6, LED_DIRECTION_WEST | LED_FUNCTION_WARNING | LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 7, 15), 6, LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 8, 15), 6, LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 7, 14), 6, LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 8, 14), 6, LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 15, 8), 6, LED_DIRECTION_EAST | LED_FUNCTION_WARNING | LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 15, 1), 6, LED_DIRECTION_EAST | LED_FUNCTION_WARNING | LED_FUNCTION_COLOR },
{ CALCULATE_LED_XY( 15, 0), 6, LED_DIRECTION_EAST | LED_FUNCTION_WARNING | LED_FUNCTION_COLOR },
};
#else
const ledConfig_t defaultLedStripConfig[] = {
{ CALCULATE_LED_XY(15, 15), 0, LED_DIRECTION_SOUTH | LED_DIRECTION_EAST | LED_FUNCTION_INDICATOR | LED_FUNCTION_ARM_STATE },

View File

@ -2447,7 +2447,7 @@ static void cliWrite(uint8_t ch)
static void cliPrintVar(const clivalue_t *var, uint32_t full)
{
int32_t value = 0;
char buf[8];
char buf[13];
void *ptr = var->ptr;
if ((var->type & VALUE_SECTION_MASK) == PROFILE_VALUE) {

View File

@ -43,6 +43,11 @@
#define MPU6500_CS_PIN GPIO_Pin_4
#define MPU6500_SPI_INSTANCE SPI1
#define MPU6000_CS_GPIO_CLK_PERIPHERAL RCC_AHBPeriph_GPIOA
#define MPU6000_CS_GPIO GPIOA
#define MPU6000_CS_PIN GPIO_Pin_4
#define MPU6000_SPI_INSTANCE SPI1
#define USE_SPI
#define USE_SPI_DEVICE_1
@ -60,11 +65,15 @@
#define EXTI_CALLBACK_HANDLER_COUNT 1 // MPU data ready
#define GYRO
#define USE_GYRO_SPI_MPU6000
#define GYRO_MPU6000_ALIGN CW270_DEG
#define USE_GYRO_MPU6500
#define USE_GYRO_SPI_MPU6500
#define GYRO_MPU6500_ALIGN CW270_DEG
#define ACC
#define USE_ACC_SPI_MPU6000
#define ACC_MPU6000_ALIGN CW270_DEG
#define USE_ACC_MPU6500
#define USE_ACC_SPI_MPU6500
#define ACC_MPU6500_ALIGN CW270_DEG
@ -73,7 +82,9 @@
#define USE_BARO_MS5611
#define MAG
#define USE_MPU9250_MAG
#define USE_MAG_HMC5883
#define USE_MAG_AK8963
#define USE_MAG_AK8975
#define BEEPER
@ -155,6 +166,7 @@
#define GPS
//#define GTUNE
#define LED_STRIP
#define USE_COLIBTI_RACE_LED_DEFAULT_CONFIG
#define LED_STRIP_TIMER TIM16