Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Oct 24, 2023
2 parents 5bbbe6b + 49a1030 commit eb578f0
Show file tree
Hide file tree
Showing 33 changed files with 631 additions and 653 deletions.
1 change: 1 addition & 0 deletions include/BatteryStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class VictronSmartShuntStats : public BatteryStats {
float _voltage;
float _current;
float _temperature;
bool _tempPresent;
uint8_t _chargeCycles;
uint32_t _timeToGo;
float _chargedEnergy;
Expand Down
1 change: 1 addition & 0 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct CONFIG_T {
uint8_t Battery_JkBmsPollingInterval;

bool Huawei_Enabled;
uint32_t Huawei_CAN_Controller_Frequency;
bool Huawei_Auto_Power_Enabled;
float Huawei_Auto_Power_Voltage_Limit;
float Huawei_Auto_Power_Enable_Voltage_Limit;
Expand Down
3 changes: 2 additions & 1 deletion include/Huawei_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ typedef struct RectifierParameters {

class HuaweiCanCommClass {
public:
bool init(uint8_t huawei_miso, uint8_t huawei_mosi, uint8_t huawei_clk, uint8_t huawei_irq, uint8_t huawei_cs);
bool init(uint8_t huawei_miso, uint8_t huawei_mosi, uint8_t huawei_clk,
uint8_t huawei_irq, uint8_t huawei_cs, uint32_t frequency);
void loop();
bool gotNewRxDataFrame(bool clear);
uint8_t getErrorCode(bool clear);
Expand Down
1 change: 0 additions & 1 deletion include/PinMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class PinMappingClass {
bool isValidNrf24Config();
bool isValidCmt2300Config();
bool isValidEthConfig();
bool isValidVictronConfig();
bool isValidHuaweiConfig();

private:
Expand Down
48 changes: 48 additions & 0 deletions include/VictronMppt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include <mutex>
#include <memory>

#include "VeDirectMpptController.h"

class VictronMpptClass {
public:
VictronMpptClass() = default;
~VictronMpptClass() = default;

void init();
void loop();

bool isDataValid() const;

// returns the data age of all controllers,
// i.e, the youngest data's age is returned.
uint32_t getDataAgeMillis() const;

VeDirectMpptController::spData_t getData(size_t idx = 0) const;

// total output of all MPPT charge controllers in Watts
int32_t getPowerOutputWatts() const;

// total panel input power of all MPPT charge controllers in Watts
int32_t getPanelPowerWatts() const;

// sum of total yield of all MPPT charge controllers in kWh
double getYieldTotal() const;

// sum of today's yield of all MPPT charge controllers in kWh
double getYieldDay() const;

private:
VictronMpptClass(VictronMpptClass const& other) = delete;
VictronMpptClass(VictronMpptClass&& other) = delete;
VictronMpptClass& operator=(VictronMpptClass const& other) = delete;
VictronMpptClass& operator=(VictronMpptClass&& other) = delete;

mutable std::mutex _mutex;
using controller_t = std::unique_ptr<VeDirectMpptController>;
std::vector<controller_t> _controllers;
};

extern VictronMpptClass VictronMppt;
3 changes: 1 addition & 2 deletions include/WebApi_ws_vedirect_live.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class WebApiWsVedirectLiveClass {
AsyncWebSocket _ws;

uint32_t _lastWsPublish = 0;
uint32_t _lastVedirectUpdateCheck = 0;
uint32_t _lastWsCleanup = 0;
uint32_t _newestVedirectTimestamp = 0;
uint32_t _dataAgeMillis = 0;
static constexpr uint16_t _responseSize = 1024 + 128;
};
1 change: 1 addition & 0 deletions include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
#define BATTERY_JKBMS_POLLING_INTERVAL 5

#define HUAWEI_ENABLED false
#define HUAWEI_CAN_CONTROLLER_FREQUENCY 8000000UL
#define HUAWEI_AUTO_POWER_VOLTAGE_LIMIT 42.0
#define HUAWEI_AUTO_POWER_ENABLE_VOLTAGE_LIMIT 42.0
#define HUAWEI_AUTO_POWER_LOWER_POWER_LIMIT 150
Expand Down
Loading

0 comments on commit eb578f0

Please sign in to comment.