I have ESP32 project using Arduino framework and I have problem. I want to create my class, which would be inheriting from SPIFFS class. Just want to add readConfig method and use it in my project.
Is it possible?
I am using something like. SSDReader.h
#pragma once
#include <Arduino.h>
#include <SPIFFS.h>
#include <FS.h>
using namespace fs;
class SSDReader: public SPIFFSFS {
public:
void getConfig();
};
extern SSDReader ssd;
SSDReader.cpp
#include "SSDReader.h"
void SSDReader::getConfig() {
}
main.cpp
#pragma once
#include <Arduino.h>
#include "include/SSDReader.h“
void setup() {
// Init SSDReader
if (!ssd.begin()) {
}
}
void loop() {
}
It compiles, but the ssd is then:
.pioenvs/esp32dev/src/main.cpp.o:(.literal._Z5setupv+0x10): undefined reference to `ssd'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32dev/firmware.elf] Error 1
Thanks, Regards, Petr Sourek
Thanks to KIIV I have been able to edit my code like this.
SSDReader.h
#pragma once
#include <Arduino.h>
#include <SPIFFS.h>
using namespace fs;
class SSDReader : public SPIFFSFS {
public:
SSDReader() : SPIFFSFS{ SPIFFS } { };
void getConfig();
protected:
};
SSDReader.cpp
#include "SSDReader.h"
//SSDReader::SSDReader() {}
void SSDReader::getConfig() {
}
main.cpp
#include <Arduino.h>
#include "include/SSDReader.h"
//#include "include/Display.h"
// Variables
SSDReader ssd;
bool enableSerial = false;
//Display display;
void setup() {
if (enableSerial)
Serial.println(9600);
// Init SSDReader
if (!ssd.begin()) {
}
}
void loop() {
}
And it works. Thank you very much. I am going to selfstudy more.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.