Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register Esp32Flash for use with QML #373

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions esp32/esp32flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool Esp32Flash::disconnectEsp()
return true;
}

bool Esp32Flash::flashFirmware(QByteArray data, size_t address)
bool Esp32Flash::flashFirmware(QByteArray data, quint64 address)
{
#ifdef HAS_SERIALPORT
if (!sPort->isOpen()) {
Expand Down Expand Up @@ -187,7 +187,7 @@ bool Esp32Flash::flashFirmware(QByteArray data, size_t address)
#endif
}

bool Esp32Flash::eraseFlash(size_t size, size_t address)
bool Esp32Flash::eraseFlash(quint64 size, quint64 address)
{
#ifdef HAS_SERIALPORT
esp_loader_error_t err = esp_loader_flash_start(address, size, 1024);
Expand Down
16 changes: 8 additions & 8 deletions esp32/esp32flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class Esp32Flash : public QObject
explicit Esp32Flash(QObject *parent = nullptr);
~Esp32Flash();

bool connectEsp(QString port);
bool disconnectEsp();
bool flashFirmware(QByteArray data, size_t address);
bool eraseFlash(size_t size, size_t address);
QString espPort();
bool isBuiltinUsb();
bool isEspConnected();
target_chip_t getTarget();
Q_INVOKABLE bool connectEsp(QString port);
Q_INVOKABLE bool disconnectEsp();
Q_INVOKABLE bool flashFirmware(QByteArray data, quint64 address);
Q_INVOKABLE bool eraseFlash(quint64 size, quint64 address);
Q_INVOKABLE QString espPort();
Q_INVOKABLE bool isBuiltinUsb();
Q_INVOKABLE bool isEspConnected();
Q_INVOKABLE target_chip_t getTarget();

signals:
void flashProgress(double prog);
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ int main(int argc, char *argv[])
qmlRegisterType<Commands>("Vedder.vesc.commands", 1, 0, "Commands");
qmlRegisterType<ConfigParams>("Vedder.vesc.configparams", 1, 0, "ConfigParams");
qmlRegisterType<FwHelper>("Vedder.vesc.fwhelper", 1, 0, "FwHelper");
qmlRegisterType<Esp32Flash>("Vedder.vesc.esp32flash", 1, 0, "Esp32Flash");
qmlRegisterType<TcpServerSimple>("Vedder.vesc.tcpserversimple", 1, 0, "TcpServerSimple");
qmlRegisterType<UdpServerSimple>("Vedder.vesc.udpserversimple", 1, 0, "UdpServerSimple");
qmlRegisterType<Vesc3dItem>("Vedder.vesc.vesc3ditem", 1, 0, "Vesc3dItem");
Expand Down
11 changes: 11 additions & 0 deletions utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,17 @@ QString Utility::md2html(QString md)
return result;
}

QByteArray Utility::readAllFromFile(const QString &filePath)
{
QFile file(filePath);
if (!file.open(QIODevice::ReadOnly)) {
return QByteArray();
}
QByteArray data = file.readAll();
file.close();
return data;
}

void Utility::setDarkMode(bool isDarkSetting)
{
isDark = isDarkSetting;
Expand Down
2 changes: 2 additions & 0 deletions utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class Utility : public QObject

Q_INVOKABLE static QString md2html(QString md);

Q_INVOKABLE QByteArray readAllFromFile(const QString &filePath);

signals:

public slots:
Expand Down
Loading