only on ESP32-S3-USB. this fiddles with the available hardware UARTs to make it possible to use a third Victron MPPT. if three MPPTs are defined int the pin mapping, you will not be able to use the SmartShunt and JK BMS battery interfaces. note that using a second MPPT will also conflict with the SDM power meter, and that conflict is not detected, yet.
63 lines
1.8 KiB
C++
63 lines
1.8 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include <mutex>
|
|
#include <memory>
|
|
|
|
#include "VeDirectMpptController.h"
|
|
#include "Configuration.h"
|
|
#include <TaskSchedulerDeclarations.h>
|
|
|
|
class VictronMpptClass {
|
|
public:
|
|
VictronMpptClass() = default;
|
|
~VictronMpptClass() = default;
|
|
|
|
void init(Scheduler& scheduler);
|
|
void updateSettings();
|
|
|
|
bool isDataValid() const;
|
|
bool isDataValid(size_t idx) const;
|
|
|
|
// returns the data age of all controllers,
|
|
// i.e, the youngest data's age is returned.
|
|
uint32_t getDataAgeMillis() const;
|
|
uint32_t getDataAgeMillis(size_t idx) const;
|
|
|
|
size_t controllerAmount() const { return _controllers.size(); }
|
|
std::optional<VeDirectMpptController::data_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
|
|
float getYieldTotal() const;
|
|
|
|
// sum of today's yield of all MPPT charge controllers in kWh
|
|
float getYieldDay() const;
|
|
|
|
// minimum of all MPPT charge controllers' output voltages in V
|
|
float getOutputVoltage() const;
|
|
|
|
private:
|
|
void loop();
|
|
VictronMpptClass(VictronMpptClass const& other) = delete;
|
|
VictronMpptClass(VictronMpptClass&& other) = delete;
|
|
VictronMpptClass& operator=(VictronMpptClass const& other) = delete;
|
|
VictronMpptClass& operator=(VictronMpptClass&& other) = delete;
|
|
|
|
Task _loopTask;
|
|
|
|
mutable std::mutex _mutex;
|
|
using controller_t = std::unique_ptr<VeDirectMpptController>;
|
|
std::vector<controller_t> _controllers;
|
|
|
|
bool initController(int8_t rx, int8_t tx, bool logging,
|
|
uint8_t instance, uint8_t hwSerialPort);
|
|
};
|
|
|
|
extern VictronMpptClass VictronMppt;
|