mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
De-couple battery code.
This fixes a bug where buzzerFreq could be uninitialised before it's use. This improves performance by only checking whether to sound the battery alarm after the battery voltage has been recalculated. There were unused battery beep codes which have been deleted to save code size. Configuration structure extracted from mw.h into config.h. Moved mixer configuration structures into flight_mixer.h. Added a build_config.c in order to decouple pwm_common.h from config.h. Finally, battery configuration values now live in a batteryConfig structure which means that battery.c does not depend on config.h and all of it's dependencies. Fixed the use of plurals on defines that were not collection objects. PIDITEMS and CHECKBOXITEMS are now PID_ITEM_COUNT and CHECKBOX_ITEM_COUNT.
This commit is contained in:
parent
64d16e1987
commit
89612bd881
14 changed files with 322 additions and 261 deletions
|
@ -93,11 +93,11 @@ struct box_t {
|
|||
{ BOXGOV, "GOVERNOR;", 18 },
|
||||
{ BOXOSD, "OSD SW;", 19 },
|
||||
{ BOXTELEMETRY, "TELEMETRY;", 20 },
|
||||
{ CHECKBOXITEMS, NULL, 0xFF }
|
||||
{ CHECKBOX_ITEM_COUNT, NULL, 0xFF }
|
||||
};
|
||||
|
||||
// this is calculated at startup based on enabled features.
|
||||
static uint8_t availableBoxes[CHECKBOXITEMS];
|
||||
static uint8_t availableBoxes[CHECKBOX_ITEM_COUNT];
|
||||
// this is the number of filled indexes in above array
|
||||
static uint8_t numberBoxItems = 0;
|
||||
// from mixer.c
|
||||
|
@ -305,7 +305,7 @@ static void evaluateCommand(void)
|
|||
headSerialReply(0);
|
||||
break;
|
||||
case MSP_SET_PID:
|
||||
for (i = 0; i < PIDITEMS; i++) {
|
||||
for (i = 0; i < PID_ITEM_COUNT; i++) {
|
||||
cfg.P8[i] = read8();
|
||||
cfg.I8[i] = read8();
|
||||
cfg.D8[i] = read8();
|
||||
|
@ -336,9 +336,9 @@ static void evaluateCommand(void)
|
|||
read16();
|
||||
read32();
|
||||
cfg.mag_declination = read16() * 10;
|
||||
mcfg.vbatscale = read8(); // actual vbatscale as intended
|
||||
mcfg.vbatmincellvoltage = read8(); // vbatlevel_warn1 in MWC2.3 GUI
|
||||
mcfg.vbatmaxcellvoltage = read8(); // vbatlevel_warn2 in MWC2.3 GUI
|
||||
mcfg.batteryConfig.vbatscale = read8(); // actual vbatscale as intended
|
||||
mcfg.batteryConfig.vbatmincellvoltage = read8(); // vbatlevel_warn1 in MWC2.3 GUI
|
||||
mcfg.batteryConfig.vbatmaxcellvoltage = read8(); // vbatlevel_warn2 in MWC2.3 GUI
|
||||
read8(); // vbatlevel_crit (unused)
|
||||
headSerialReply(0);
|
||||
break;
|
||||
|
@ -488,8 +488,8 @@ static void evaluateCommand(void)
|
|||
serialize8(cfg.thrExpo8);
|
||||
break;
|
||||
case MSP_PID:
|
||||
headSerialReply(3 * PIDITEMS);
|
||||
for (i = 0; i < PIDITEMS; i++) {
|
||||
headSerialReply(3 * PID_ITEM_COUNT);
|
||||
for (i = 0; i < PID_ITEM_COUNT; i++) {
|
||||
serialize8(cfg.P8[i]);
|
||||
serialize8(cfg.I8[i]);
|
||||
serialize8(cfg.D8[i]);
|
||||
|
@ -523,9 +523,9 @@ static void evaluateCommand(void)
|
|||
serialize16(0); // plog useless shit
|
||||
serialize32(0); // plog useless shit
|
||||
serialize16(cfg.mag_declination / 10); // TODO check this shit
|
||||
serialize8(mcfg.vbatscale);
|
||||
serialize8(mcfg.vbatmincellvoltage);
|
||||
serialize8(mcfg.vbatmaxcellvoltage);
|
||||
serialize8(mcfg.batteryConfig.vbatscale);
|
||||
serialize8(mcfg.batteryConfig.vbatmincellvoltage);
|
||||
serialize8(mcfg.batteryConfig.vbatmaxcellvoltage);
|
||||
serialize8(0);
|
||||
break;
|
||||
case MSP_MOTOR_PINS:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue