Skip to content

Commit 746a4f5

Browse files
committed
[BH-2084] Add new battery profile for fuel gauge
Added new battery profile configuration to fuel gauge chip to support battery of larger capacity that will be used in Harmony 2 Pro version.
1 parent 17a7c2b commit 746a4f5

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

module-bsp/devices/power/CW2015Regs.hpp

+38-29
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
namespace bsp::devices::power::CW2015Regs
99
{
10-
constexpr inline auto ADDRESS = 0x62;
10+
inline constexpr auto ADDRESS = 0x62;
1111

1212
struct Config
1313
{
14-
constexpr static auto ADDRESS = 0x08;
14+
static constexpr auto ADDRESS = 0x08;
1515

1616
explicit Config(const std::uint8_t raw) : reg{raw}
1717
{}
1818

19-
units::SOC get_alert_threshold() const
19+
[[nodiscard]] units::SOC get_alert_threshold() const
2020
{
2121
return (reg & alert_mask) >> alert_shift;
2222
}
@@ -28,7 +28,7 @@ namespace bsp::devices::power::CW2015Regs
2828
return *this;
2929
}
3030

31-
bool is_ufg_set() const
31+
[[nodiscard]] bool is_ufg_set() const
3232
{
3333
return (reg & ufg_mask) != 0;
3434
}
@@ -40,7 +40,7 @@ namespace bsp::devices::power::CW2015Regs
4040
return *this;
4141
}
4242

43-
std::uint8_t get_raw() const
43+
[[nodiscard]] std::uint8_t get_raw() const
4444
{
4545
return reg;
4646
}
@@ -57,13 +57,13 @@ namespace bsp::devices::power::CW2015Regs
5757

5858
struct Mode
5959
{
60-
constexpr static auto ADDRESS = 0x0A;
60+
static constexpr auto ADDRESS = 0x0A;
6161

6262
Mode() = default;
6363
explicit Mode(const std::uint8_t raw) : reg{raw}
6464
{}
6565

66-
bool is_sleep() const
66+
[[nodiscard]] bool is_sleep() const
6767
{
6868
return (reg & sleep_mask) == sleep_mask;
6969
}
@@ -92,7 +92,7 @@ namespace bsp::devices::power::CW2015Regs
9292
return *this;
9393
}
9494

95-
std::uint8_t get_raw() const
95+
[[nodiscard]] std::uint8_t get_raw() const
9696
{
9797
return reg;
9898
}
@@ -111,15 +111,15 @@ namespace bsp::devices::power::CW2015Regs
111111

112112
struct RRT_ALERT
113113
{
114-
constexpr static auto ADDRESS_H = 0x06;
115-
constexpr static auto ADDRESS_L = 0x07;
114+
static constexpr auto ADDRESS_H = 0x06;
115+
static constexpr auto ADDRESS_L = 0x07;
116116

117-
RRT_ALERT(const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast<uint16_t>(lsb | (msb << 8))}
117+
RRT_ALERT(const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast<std::uint16_t>(lsb | (msb << 8))}
118118
{}
119119
explicit RRT_ALERT(const std::uint16_t reg) : reg{reg}
120120
{}
121121

122-
bool is_alert_triggered() const
122+
[[nodiscard]] bool is_alert_triggered() const
123123
{
124124
return (reg & 0x8000) == 0;
125125
}
@@ -130,12 +130,12 @@ namespace bsp::devices::power::CW2015Regs
130130
return *this;
131131
}
132132

133-
std::uint16_t rrt() const
133+
[[nodiscard]] std::uint16_t rrt() const
134134
{
135135
return reg & 0x1FFF;
136136
}
137137

138-
std::uint8_t get_raw() const
138+
[[nodiscard]] std::uint8_t get_raw() const
139139
{
140140
return reg;
141141
}
@@ -146,20 +146,20 @@ namespace bsp::devices::power::CW2015Regs
146146

147147
struct VCELL
148148
{
149-
constexpr static auto ADDRESS_H = 0x02;
150-
constexpr static auto ADDRESS_L = 0x03;
149+
static constexpr auto ADDRESS_H = 0x02;
150+
static constexpr auto ADDRESS_L = 0x03;
151151

152-
VCELL(const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast<uint16_t>(lsb | (msb << 8))}
152+
VCELL(const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast<std::uint16_t>(lsb | (msb << 8))}
153153
{}
154154
explicit VCELL(const std::uint16_t reg) : reg{reg}
155155
{}
156156

157-
units::Voltage get_voltage() const
157+
[[nodiscard]] units::Voltage get_voltage() const
158158
{
159159
return reg & 0x3FFF;
160160
}
161161

162-
std::uint8_t get_raw() const
162+
[[nodiscard]] std::uint8_t get_raw() const
163163
{
164164
return reg;
165165
}
@@ -170,15 +170,15 @@ namespace bsp::devices::power::CW2015Regs
170170

171171
struct SOC
172172
{
173-
constexpr static auto ADDRESS_H = 0x04;
174-
constexpr static auto ADDRESS_L = 0x05;
173+
static constexpr auto ADDRESS_H = 0x04;
174+
static constexpr auto ADDRESS_L = 0x05;
175175

176-
SOC(const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast<uint16_t>(lsb | (msb << 8))}
176+
SOC(const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast<std::uint16_t>(lsb | (msb << 8))}
177177
{}
178178
explicit SOC(const std::uint16_t reg) : reg{reg}
179179
{}
180180

181-
units::Voltage get_soc() const
181+
[[nodiscard]] units::Voltage get_soc() const
182182
{
183183
return (reg & 0xFF00) >> 8U;
184184
}
@@ -189,26 +189,35 @@ namespace bsp::devices::power::CW2015Regs
189189

190190
class BATTINFO
191191
{
192-
constexpr static auto BATTERY_INFO_SIZE = 64;
192+
static constexpr auto BATTERY_INFO_SIZE = 64;
193193
using Type = const std::array<std::uint8_t, BATTERY_INFO_SIZE>;
194194

195-
/* got from ODM init code */
196-
constexpr static Type config_info = {
195+
/* Init code from ODM */
196+
#if defined(CONFIG_VERSION_PRO) && (CONFIG_VERSION_PRO == 1)
197+
static constexpr Type config_info = {
198+
// BH21P_3400mAh_DM140X_PROFILE_20241106
199+
0x14, 0x97, 0x39, 0x1B, 0x14, 0x27, 0x4A, 0x5C, 0x64, 0x5E, 0x4B, 0x53, 0x4D, 0x4E, 0x52, 0x56,
200+
0x5B, 0x5C, 0x5A, 0x5B, 0x4F, 0x67, 0x6B, 0x74, 0x71, 0x62, 0x0A, 0x3E, 0x45, 0x69, 0x83, 0x8F,
201+
0x8E, 0x89, 0x88, 0x73, 0x45, 0x20, 0xFF, 0x48, 0x09, 0x3B, 0x59, 0x85, 0x8F, 0x90, 0x90, 0x38,
202+
0x53, 0x84, 0x92, 0x92, 0x80, 0xBF, 0xDE, 0xCB, 0x2F, 0x00, 0x64, 0xA5, 0xB5, 0xC1, 0x46, 0xAE};
203+
#else
204+
static constexpr Type config_info = {
197205
// profile_DEM50X_2nd_20211012
198206
0x15, 0x15, 0x6E, 0x67, 0x65, 0x62, 0x60, 0x60, 0x5F, 0x5E, 0x5B, 0x59, 0x55, 0x50, 0x41, 0x33,
199207
0x2A, 0x26, 0x24, 0x27, 0x31, 0x46, 0x55, 0x5B, 0x47, 0x4A, 0x0A, 0x3E, 0x38, 0x58, 0x59, 0x63,
200208
0x67, 0x63, 0x62, 0x64, 0x3D, 0x1B, 0x6F, 0x15, 0x07, 0x21, 0x54, 0x85, 0x8F, 0x90, 0x90, 0x44,
201209
0x63, 0x86, 0x94, 0x99, 0x80, 0x89, 0xBC, 0xCB, 0x2F, 0x00, 0x64, 0xA5, 0xB5, 0xC1, 0x46, 0xAE};
210+
#endif
202211

203212
public:
204-
constexpr static auto ADDRESS = 0x10;
213+
static constexpr auto ADDRESS = 0x10;
205214

206-
Type::const_iterator begin() const noexcept
215+
[[nodiscard]] Type::const_iterator begin() const noexcept
207216
{
208217
return config_info.begin();
209218
}
210219

211-
Type::const_iterator end() const noexcept
220+
[[nodiscard]] Type::const_iterator end() const noexcept
212221
{
213222
return config_info.end();
214223
}

products/BellHybrid/services/evtmgr/backlight-handler/BacklightHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ namespace backlight
191191
using namespace screen_light_control;
192192

193193
const auto &brightnessString = getValue(settings::Brightness::brightnessLevel);
194-
const auto percentValue = utils::frontlight::fixedValToPercentage(utils::toNumeric(brightnessString));
194+
const auto percentValue = utils::frontlight::fixedValToPercentage(utils::toNumeric(brightnessString));
195195
const ConstLinearProgressModeParameters params{percentValue};
196196
screenLightController->processRequest(Action::setAutomaticModeParameters, Parameters(params));
197197
}

0 commit comments

Comments
 (0)