NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
battery.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Copyright: collective.
5  * Cleanup: Martin Schröder <mkschreder.uk@gmail.com>
6  * Original source from Cleanflight.
7  *
8  * Ninjaflight is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Ninjaflight is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 typedef enum {
30 
31 #define VBAT_SCALE_DEFAULT 110
32 #define VBAT_RESDIVVAL_DEFAULT 10
33 #define VBAT_RESDIVMULTIPLIER_DEFAULT 1
34 #define VBAT_SCALE_MIN 0
35 #define VBAT_SCALE_MAX 255
36 
38  uint8_t vbatscale; // adjust this to match battery voltage to reported value
39  uint8_t vbatresdivval; // resistor divider R2 (default NAZE 10(K))
40  uint8_t vbatresdivmultiplier; // multiplier for scale (e.g. 2.5:1 ratio with multiplier of 4 can use '100' instead of '25' in ratio) to get better precision
41  uint8_t vbatmaxcellvoltage; // maximum voltage per cell, used for auto-detecting battery voltage in 0.1V units, default is 43 (4.3V)
42  uint8_t vbatmincellvoltage; // minimum voltage per cell, this triggers battery critical alarm, in 0.1V units, default is 33 (3.3V)
43  uint8_t vbatwarningcellvoltage; // warning voltage per cell, this triggers battery warning alarm, in 0.1V units, default is 35 (3.5V)
44 
45  int16_t currentMeterScale; // scale the current sensor output voltage to milliamps. Value in 1/10th mV/A
46  uint16_t currentMeterOffset; // offset of the current sensor in millivolt steps
47  current_sensor_type_t currentMeterType; // type of current meter used, either ADC or virtual
48 
49  // FIXME this doesn't belong in here since it's a concern of MSP, not of the battery code.
50  uint8_t multiwiiCurrentMeterOutput; // if set to 1 output the amperage in milliamp steps instead of 0.01A steps via msp
51  uint16_t batteryCapacity; // mAh
52 } __attribute__((packed)) ;
53 
uint8_t vbatscale
Definition: battery.h:38
Definition: battery.h:26
uint16_t currentMeterOffset
Definition: battery.h:46
uint8_t vbatresdivmultiplier
Definition: battery.h:40
typedef __attribute__
Definition: battery.h:25
Definition: battery.h:28
int16_t currentMeterScale
Definition: battery.h:45
uint16_t batteryCapacity
Definition: battery.h:51
uint8_t vbatmaxcellvoltage
Definition: battery.h:41
current_sensor_type_t
Definition: battery.h:24
Definition: battery.h:37
Definition: battery.h:27
current_sensor_type_t currentMeterType
Definition: battery.h:47
uint8_t vbatwarningcellvoltage
Definition: battery.h:43
uint8_t vbatmincellvoltage
Definition: battery.h:42
uint8_t vbatresdivval
Definition: battery.h:39
uint8_t multiwiiCurrentMeterOutput
Definition: battery.h:50