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": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"externalConsole": true, "externalConsole": true,
"cwd": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO", "cwd": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/src",
"program": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/build/Debug/outDebug", "program": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/src/build/Debug/outDebug",
"MIMode": "gdb", "MIMode": "gdb",
"miDebuggerPath": "gdb", "miDebuggerPath": "gdb",
"setupCommands": [ "setupCommands": [

View File

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

View File

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