From 7d2e48a99bdb38f2b4b8cd45335d87f29ab1566e Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 23 Jul 2015 22:42:59 +0200 Subject: [PATCH] Fixes #2544 --- companion/src/firmwareinterface.cpp | 104 ++++++++++++++-------------- companion/src/firmwareinterface.h | 12 ++-- 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/companion/src/firmwareinterface.cpp b/companion/src/firmwareinterface.cpp index b812f9444..4f11fcbd4 100755 --- a/companion/src/firmwareinterface.cpp +++ b/companion/src/firmwareinterface.cpp @@ -45,28 +45,30 @@ int getFileType(const QString &fullFileName) FirmwareInterface::FirmwareInterface(const QString &filename): flash(MAX_FSIZE, 0), - flash_size(0), + flashSize(0), versionId(0), - splash_offset(0), - splash_size(0), - splash_width(0), - splash_height(0), + eepromVersion(0), + eepromVariant(0), + splashOffset(0), + splashSize(0), + splashWidth(0), + splashHeight(0), isValidFlag(false) { if (!filename.isEmpty()) { QFile file(filename); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { // reading HEX TEXT file QTextStream inputStream(&file); - flash_size = HexInterface(inputStream).load((uint8_t *)flash.data(), MAX_FSIZE); + flashSize = HexInterface(inputStream).load((uint8_t *)flash.data(), MAX_FSIZE); file.close(); - if (flash_size == 0) { + if (flashSize == 0) { file.open(QIODevice::ReadOnly); - flash_size = file.read((char *)flash.data(), MAX_FSIZE); + flashSize = file.read((char *)flash.data(), MAX_FSIZE); } } } - if (flash_size > 0) { + if (flashSize > 0) { flavour = seekLabel(FW_MARK); version = seekLabel(VERS_MARK); if (version.startsWith("opentx-")) { @@ -153,8 +155,8 @@ bool FirmwareInterface::SeekSplash(QByteArray splash) { int start = flash.indexOf(splash); if (start>0) { - splash_offset = start; - splash_size = splash.size(); + splashOffset = start; + splashSize = splash.size(); return true; } else { @@ -170,8 +172,8 @@ bool FirmwareInterface::SeekSplash(QByteArray sps, QByteArray spe, int size) if (start>0) { int end = start + sps.size() + size; if (end == flash.indexOf(spe, end)) { - splash_offset = start + sps.size(); - splash_size = end - start - sps.size(); + splashOffset = start + sps.size(); + splashSize = end - start - sps.size(); return true; } else { @@ -190,10 +192,10 @@ bool FirmwareInterface::SeekSplash(QByteArray sps, QByteArray spe, int size) void FirmwareInterface::SeekSplash(void) { - splash_size = 0; - splash_offset = 0; - splash_width = SPLASH_WIDTH; - splash_height = SPLASH_HEIGHT; + splashSize = 0; + splashOffset = 0; + splashWidth = SPLASH_WIDTH; + splashHeight = SPLASH_HEIGHT; splash_format = QImage::Format_Mono; if (SeekSplash(QByteArray((const char *)gr9x_splash, sizeof(gr9x_splash))) || SeekSplash(QByteArray((const char *)gr9xv4_splash, sizeof(gr9xv4_splash)))) { @@ -209,8 +211,8 @@ void FirmwareInterface::SeekSplash(void) } if (SeekSplash(QByteArray((const char *)opentxtaranis_splash, sizeof(opentxtaranis_splash)))) { - splash_width = SPLASHX9D_WIDTH; - splash_height = SPLASHX9D_HEIGHT; + splashWidth = SPLASHX9D_WIDTH; + splashHeight = SPLASHX9D_HEIGHT; splash_format = QImage::Format_Indexed8; return; } @@ -224,8 +226,8 @@ void FirmwareInterface::SeekSplash(void) } if (SeekSplash(QByteArray(OTX_SPS_TARANIS, OTX_SPS_SIZE), QByteArray(OTX_SPE, OTX_SPE_SIZE), 6784)) { - splash_width = SPLASHX9D_WIDTH; - splash_height = SPLASHX9D_HEIGHT; + splashWidth = SPLASHX9D_WIDTH; + splashHeight = SPLASHX9D_HEIGHT; splash_format = QImage::Format_Indexed8; return; } @@ -235,14 +237,14 @@ void FirmwareInterface::SeekSplash(void) } if (SeekSplash(QByteArray(ERSPLASH_MARKER, sizeof(ERSPLASH_MARKER)))) { - splash_offset += sizeof(ERSPLASH_MARKER); - splash_size = sizeof(er9x_splash); + splashOffset += sizeof(ERSPLASH_MARKER); + splashSize = sizeof(er9x_splash); } } bool FirmwareInterface::setSplash(const QImage & newsplash) { - if (splash_offset == 0 || splash_size == 0) { + if (splashOffset == 0 || splashSize == 0) { return false; } @@ -250,9 +252,9 @@ bool FirmwareInterface::setSplash(const QImage & newsplash) QColor color; QByteArray splash; if (splash_format == QImage::Format_Indexed8) { - for (unsigned int y=0; y 0) { - for (unsigned int y=0; y 0) { + for (unsigned int y=0; y> 4) : (byte & 0x0F); z = 255-(z*255)/15; QRgb rgb = qRgb(z, z, z); @@ -314,11 +316,11 @@ QImage FirmwareInterface::getSplash() return image; } else { - QImage image(splash_width, splash_height, QImage::Format_Mono); - if (splash_offset > 0) { - for (unsigned int y=0; y 0) { + for (unsigned int y=0; y 0 ? true : false); + return (splashOffset > 0 ? true : false); } bool FirmwareInterface::isValid() @@ -339,7 +341,7 @@ bool FirmwareInterface::isValid() unsigned int FirmwareInterface::save(QString fileName) { uint8_t binflash[MAX_FSIZE]; - memcpy(&binflash, flash.constData(), flash_size); + memcpy(&binflash, flash.constData(), flashSize); QFile file(fileName); int fileType = getFileType(fileName); @@ -350,16 +352,16 @@ unsigned int FirmwareInterface::save(QString fileName) } QTextStream outputStream(&file); HexInterface hex=HexInterface(outputStream); - hex.save(binflash, flash_size); + hex.save(binflash, flashSize); } else { if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) { //reading HEX TEXT file return -1; } - file.write((char*)binflash, flash_size); + file.write((char*)binflash, flashSize); } file.close(); - return flash_size; + return flashSize; } diff --git a/companion/src/firmwareinterface.h b/companion/src/firmwareinterface.h index 2301d04a5..6f78e82ba 100755 --- a/companion/src/firmwareinterface.h +++ b/companion/src/firmwareinterface.h @@ -45,7 +45,7 @@ class FirmwareInterface FirmwareInterface(const QString &filename); inline QString getDate() { return date; } inline QString getTime() { return time; } - int getSize() { return flash_size; } + int getSize() { return flashSize; } QString getFlavour() const; bool isHardwareCompatible(const FirmwareInterface &previousFirmware) const; inline QString getVersion() { return version; } @@ -64,7 +64,7 @@ class FirmwareInterface private: QByteArray flash; - uint flash_size; + uint flashSize; QString seekString(const QString & string); QString seekLabel(const QString & label); void SeekSplash(); @@ -80,10 +80,10 @@ class FirmwareInterface int eepromVersion; int eepromVariant; QByteArray splash; - uint splash_offset; - uint splash_size; - uint splash_width; - uint splash_height; + uint splashOffset; + uint splashSize; + uint splashWidth; + uint splashHeight; QImage::Format splash_format; bool isValidFlag; };