CT Card now inherit expansion card

This commit is contained in:
Siwat Sirichai 2024-02-27 14:38:15 +07:00
parent e380606742
commit 594ea6bf54
3 changed files with 11 additions and 5 deletions

4
.vscode/launch.json vendored
View File

@ -8,8 +8,8 @@
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO",
"program": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/build/Debug/outDebug",
"cwd": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/src",
"program": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/src/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [

View File

@ -14,9 +14,14 @@ void CurrentTransformerCard::bindFRAM(FRAM *fram, uint32_t framAddress)
this->framAddress = framAddress;
}
void CurrentTransformerCard::begin()
bool CurrentTransformerCard::begin()
{
// Is analogCard a nullptr?
if (this->analogCard == nullptr) {
return false;
}
this->beginConversion();
return true;
}
void CurrentTransformerCard::loop()

View File

@ -1,5 +1,6 @@
#pragma once
#include <AnalogCard.hpp>
#include <ExpansionCard.hpp>
#include <FRAM.h>
#include <map>
@ -10,12 +11,12 @@
* Also supports storing energy to FRAM.
*/
class CurrentTransformerCard
class CurrentTransformerCard : public ExpansionCard
{
public:
CurrentTransformerCard(AnalogCard* analogCard, uint8_t pin, float *voltage, std::function<float(uint16_t)> adcToCurrent, uint32_t conversionInterval);
void bindFRAM(FRAM *fram, uint32_t framAddress); // Takes 16 bytes of FRAM (long double energy)
void begin();
bool begin();
void loop();
void beginConversion();
void setEnergy(float energy);