Added some more code

This commit is contained in:
CommanderRedYT
2022-02-28 01:08:13 +01:00
parent 73d01e8516
commit 7f6fa967c8
4 changed files with 59 additions and 5 deletions

View File

@ -257,6 +257,48 @@ uint8_t count_curve_points(BatteryCellType cellType)
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 {
std::optional<float> bootBatPercentage;
std::optional<float> bootBatWh;

View File

@ -6,6 +6,11 @@
// local includes
#include <bobbytypesafeenum.h>
typedef struct {
uint16_t minVoltage;
uint16_t maxVoltage;
} CalibrationPointVoltages;
// battery curves
#define PERCENTAGE(higherVoltage,lowerVoltage,fromAh,toAh) \
if (cellVoltage >= lowerVoltage && cellVoltage <= higherVoltage) \
@ -150,6 +155,8 @@ float getTarget_mAh();
uint8_t count_curve_points(BatteryCellType cellType);
std::optional<CalibrationPointVoltages> get_point_n_voltages(BatteryCellType cellType, uint8_t num);
namespace battery {
extern std::optional<float> bootBatPercentage;
extern std::optional<float> bootBatWh;

View File

@ -4,22 +4,29 @@
#include <screenmanager.h>
// local includes
#include "globals.h"
#include "displays/menus/batterymenu.h"
namespace {
constexpr char TEXT_BATTERY_GRAPH[] = "Battery Level";
} // namespace
void BatteryGraphDisplay::initScreen() {
void BatteryGraphDisplay::initScreen()
{
Base::initScreen();
}
std::string BatteryGraphDisplay::text() const {
std::string BatteryGraphDisplay::text() const
{
return TEXT_BATTERY_GRAPH;
}
void BatteryGraphDisplay::redraw() {
void BatteryGraphDisplay::redraw()
{
using namespace espgui;
Base::redraw();
// tft.drawLine() code
}
void BatteryGraphDisplay::buttonPressed(espgui::Button button)

View File

@ -1,7 +1,5 @@
#pragma once
// 3rdparty lib includes
// local includes
#include "bobbydisplaywithtitle.h"