Added an other charging state which wasn't an error : when both lines are high, this indicates that no charger is currently plugged to the watch
This commit is contained in:
parent
242fbc3df9
commit
099fe8cea7
@ -59,7 +59,7 @@ void watch_peripherals_init(int8_t adcOffset)
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t watch_peripherals_get_battery_voltage(Battery_Unit_e unit)
|
||||
uint16_t watch_peripherals_get_battery_voltage(battery_unit_e unit)
|
||||
{
|
||||
tls_gpio_write(BATTERY_VOLTAGE_DIVIDER_ENABLE, 1);
|
||||
int batteryVoltage = adc_get_inputVolt(BATTERY_VOLTAGE_ADC_CHANNEL, 1, 1) * 2 + _adc_offset;
|
||||
@ -67,10 +67,10 @@ uint16_t watch_peripherals_get_battery_voltage(Battery_Unit_e unit)
|
||||
|
||||
switch (unit)
|
||||
{
|
||||
case Battery_Unit_mV:
|
||||
case battery_unit_mv:
|
||||
return batteryVoltage < 0 ? 0 : batteryVoltage;
|
||||
break;
|
||||
case Battery_Unit_percent:
|
||||
case battery_unit_percent:
|
||||
return battery_voltage_to_percentage(batteryVoltage < 0 ? 0 : batteryVoltage);
|
||||
break;
|
||||
default:
|
||||
@ -107,8 +107,10 @@ battery_controller_status_e watch_peripherals_get_battery_controller_status(void
|
||||
return BATTERY_CHARGING;
|
||||
else if(!charging && charged)
|
||||
return BATTERY_CHARGED;
|
||||
|
||||
return BATTERY_STATUS_ERROR;
|
||||
else if (!charging && !charged)
|
||||
return BATTERY_DISCHARGING;
|
||||
else
|
||||
return BATTERY_ERROR;
|
||||
}
|
||||
|
||||
void watch_peripherals_vibrate(uint8_t strength, uint32_t durationMs)
|
||||
|
@ -6,17 +6,18 @@
|
||||
#define WATCH_PERIPHERALS_H
|
||||
#include "wm_type_def.h"
|
||||
|
||||
typedef enum Battery_Unit
|
||||
typedef enum battery_unit
|
||||
{
|
||||
Battery_Unit_mV = 0,
|
||||
Battery_Unit_percent
|
||||
} Battery_Unit_e;
|
||||
battery_unit_mv = 0,
|
||||
battery_unit_percent
|
||||
} battery_unit_e;
|
||||
|
||||
typedef enum battery_controller_status
|
||||
{
|
||||
BATTERY_CHARGING = 0,
|
||||
BATTERY_CHARGED,
|
||||
BATTERY_STATUS_ERROR
|
||||
BATTERY_DISCHARGING,
|
||||
BATTERY_ERROR
|
||||
} battery_controller_status_e;
|
||||
|
||||
/**
|
||||
@ -36,7 +37,7 @@ void watch_peripherals_init(int8_t adcOffset);
|
||||
* @param unit the unit of the data to be returned : mV or corresponding capacity in percentage
|
||||
* @return uint16_t the voltage in mV or the battery left capacity in %
|
||||
*/
|
||||
uint16_t watch_peripherals_get_battery_voltage(Battery_Unit_e unit);
|
||||
uint16_t watch_peripherals_get_battery_voltage(battery_unit_e unit);
|
||||
|
||||
/**
|
||||
* @brief Converts the given battery voltage to the corresponding battery capacity for a single cell LiPo only (4.2V to 3.2V)
|
||||
|
Loading…
Reference in New Issue
Block a user