Added some more code
This commit is contained in:
@ -257,6 +257,48 @@ uint8_t count_curve_points(BatteryCellType cellType)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<CalibrationPointVoltages> get_point_n_voltages(BatteryCellType cellType, uint8_t num)
|
||||||
|
{
|
||||||
|
#define GET_POINT_N_VOLTAGES(higherVoltage,lowerVoltage,fromAh,toAh) \
|
||||||
|
if (count == num) { \
|
||||||
|
uint16_t minVoltage = (lowerVoltage) * 100; \
|
||||||
|
uint16_t maxVoltage = (higherVoltage) * 100; \
|
||||||
|
return CalibrationPointVoltages{ .minVoltage=minVoltage, .maxVoltage=maxVoltage }; \
|
||||||
|
} \
|
||||||
|
count++;
|
||||||
|
|
||||||
|
uint8_t count = 0;
|
||||||
|
CalibrationPointVoltages point;
|
||||||
|
switch (cellType)
|
||||||
|
{
|
||||||
|
case BatteryCellType::_22P:
|
||||||
|
{
|
||||||
|
BAT_CURVE_22P(GET_POINT_N_VOLTAGES);
|
||||||
|
}
|
||||||
|
case BatteryCellType::HG2:
|
||||||
|
{
|
||||||
|
BAT_CURVE_HG2(GET_POINT_N_VOLTAGES);
|
||||||
|
}
|
||||||
|
case BatteryCellType::MH1:
|
||||||
|
{
|
||||||
|
BAT_CURVE_MH1(GET_POINT_N_VOLTAGES);
|
||||||
|
}
|
||||||
|
case BatteryCellType::VTC5:
|
||||||
|
{
|
||||||
|
BAT_CURVE_VTC5(GET_POINT_N_VOLTAGES);
|
||||||
|
}
|
||||||
|
case BatteryCellType::BAK_25R:
|
||||||
|
{
|
||||||
|
BAT_CURVE_25R(GET_POINT_N_VOLTAGES);
|
||||||
|
}
|
||||||
|
case BatteryCellType::HE4:
|
||||||
|
{
|
||||||
|
BAT_CURVE_HE4(GET_POINT_N_VOLTAGES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
namespace battery {
|
namespace battery {
|
||||||
std::optional<float> bootBatPercentage;
|
std::optional<float> bootBatPercentage;
|
||||||
std::optional<float> bootBatWh;
|
std::optional<float> bootBatWh;
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
// local includes
|
// local includes
|
||||||
#include <bobbytypesafeenum.h>
|
#include <bobbytypesafeenum.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t minVoltage;
|
||||||
|
uint16_t maxVoltage;
|
||||||
|
} CalibrationPointVoltages;
|
||||||
|
|
||||||
// battery curves
|
// battery curves
|
||||||
#define PERCENTAGE(higherVoltage,lowerVoltage,fromAh,toAh) \
|
#define PERCENTAGE(higherVoltage,lowerVoltage,fromAh,toAh) \
|
||||||
if (cellVoltage >= lowerVoltage && cellVoltage <= higherVoltage) \
|
if (cellVoltage >= lowerVoltage && cellVoltage <= higherVoltage) \
|
||||||
@ -150,6 +155,8 @@ float getTarget_mAh();
|
|||||||
|
|
||||||
uint8_t count_curve_points(BatteryCellType cellType);
|
uint8_t count_curve_points(BatteryCellType cellType);
|
||||||
|
|
||||||
|
std::optional<CalibrationPointVoltages> get_point_n_voltages(BatteryCellType cellType, uint8_t num);
|
||||||
|
|
||||||
namespace battery {
|
namespace battery {
|
||||||
extern std::optional<float> bootBatPercentage;
|
extern std::optional<float> bootBatPercentage;
|
||||||
extern std::optional<float> bootBatWh;
|
extern std::optional<float> bootBatWh;
|
||||||
|
@ -4,22 +4,29 @@
|
|||||||
#include <screenmanager.h>
|
#include <screenmanager.h>
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
|
#include "globals.h"
|
||||||
#include "displays/menus/batterymenu.h"
|
#include "displays/menus/batterymenu.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr char TEXT_BATTERY_GRAPH[] = "Battery Level";
|
constexpr char TEXT_BATTERY_GRAPH[] = "Battery Level";
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void BatteryGraphDisplay::initScreen() {
|
void BatteryGraphDisplay::initScreen()
|
||||||
|
{
|
||||||
Base::initScreen();
|
Base::initScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BatteryGraphDisplay::text() const {
|
std::string BatteryGraphDisplay::text() const
|
||||||
|
{
|
||||||
return TEXT_BATTERY_GRAPH;
|
return TEXT_BATTERY_GRAPH;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryGraphDisplay::redraw() {
|
void BatteryGraphDisplay::redraw()
|
||||||
|
{
|
||||||
|
using namespace espgui;
|
||||||
Base::redraw();
|
Base::redraw();
|
||||||
|
|
||||||
|
// tft.drawLine() code
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryGraphDisplay::buttonPressed(espgui::Button button)
|
void BatteryGraphDisplay::buttonPressed(espgui::Button button)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// 3rdparty lib includes
|
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "bobbydisplaywithtitle.h"
|
#include "bobbydisplaywithtitle.h"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user