it is important to separate the capabilities of each power meter provider into their own class/source file, as the providers work fundamentally different and their implementations must not be intermangled, which made maintenance and improvements a nightmare in the past.
28 lines
544 B
C++
28 lines
544 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include "PowerMeterProvider.h"
|
|
#include <TaskSchedulerDeclarations.h>
|
|
#include <memory>
|
|
#include <mutex>
|
|
|
|
class PowerMeterClass {
|
|
public:
|
|
void init(Scheduler& scheduler);
|
|
|
|
void updateSettings();
|
|
|
|
float getPowerTotal() const;
|
|
uint32_t getLastUpdate() const;
|
|
bool isDataValid() const;
|
|
|
|
private:
|
|
void loop();
|
|
|
|
Task _loopTask;
|
|
mutable std::mutex _mutex;
|
|
std::unique_ptr<PowerMeterProvider> _upProvider = nullptr;
|
|
};
|
|
|
|
extern PowerMeterClass PowerMeter;
|