diff --git a/.vscode/launch.json b/.vscode/launch.json index 2c45abc..7c46088 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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": [ diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp index 346a322..db469b0 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp @@ -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() diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp index 915889f..9dfa44a 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include @@ -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 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);