New automatic tests added for the LCD
This commit is contained in:
@@ -78,7 +78,7 @@ namespace Open9xGruvin9x {
|
|||||||
#include "radio/src/gui/view_telemetry.cpp"
|
#include "radio/src/gui/view_telemetry.cpp"
|
||||||
#include "radio/src/lcd.cpp"
|
#include "radio/src/lcd.cpp"
|
||||||
#include "radio/src/keys.cpp"
|
#include "radio/src/keys.cpp"
|
||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
#include "radio/src/fonts.cpp"
|
#include "radio/src/fonts.cpp"
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace OpenTxM128 {
|
|||||||
#include "radio/src/gui/view_telemetry.cpp"
|
#include "radio/src/gui/view_telemetry.cpp"
|
||||||
#include "radio/src/lcd.cpp"
|
#include "radio/src/lcd.cpp"
|
||||||
#include "radio/src/keys.cpp"
|
#include "radio/src/keys.cpp"
|
||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
#include "radio/src/fonts.cpp"
|
#include "radio/src/fonts.cpp"
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace OpenTxM64 {
|
|||||||
#include "radio/src/gui/view_telemetry.cpp"
|
#include "radio/src/gui/view_telemetry.cpp"
|
||||||
#include "radio/src/lcd.cpp"
|
#include "radio/src/lcd.cpp"
|
||||||
#include "radio/src/keys.cpp"
|
#include "radio/src/keys.cpp"
|
||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||||
#include "radio/src/telemetry/frsky.cpp"
|
#include "radio/src/telemetry/frsky.cpp"
|
||||||
#include "radio/src/telemetry/frsky_d.cpp"
|
#include "radio/src/telemetry/frsky_d.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace Open9xSky9x {
|
|||||||
#include "radio/src/logs.cpp"
|
#include "radio/src/logs.cpp"
|
||||||
#include "radio/src/targets/sky9x/keys_driver.cpp"
|
#include "radio/src/targets/sky9x/keys_driver.cpp"
|
||||||
#include "radio/src/keys.cpp"
|
#include "radio/src/keys.cpp"
|
||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||||
#include "radio/src/templates.cpp"
|
#include "radio/src/templates.cpp"
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
#include "radio/src/fonts.cpp"
|
#include "radio/src/fonts.cpp"
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ inline int geteepromsize() {
|
|||||||
#include "radio/src/targets/taranis/haptic_driver.cpp"
|
#include "radio/src/targets/taranis/haptic_driver.cpp"
|
||||||
// TODO Because FatFS in not C++ there cannot be namespaces there and the functions are defined several times!
|
// TODO Because FatFS in not C++ there cannot be namespaces there and the functions are defined several times!
|
||||||
#undef SDCARD
|
#undef SDCARD
|
||||||
#include "radio/src/simpgmspace.cpp"
|
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||||
#define SDCARD
|
#define SDCARD
|
||||||
#include "radio/src/translations.cpp"
|
#include "radio/src/translations.cpp"
|
||||||
#include "radio/src/fonts.cpp"
|
#include "radio/src/fonts.cpp"
|
||||||
|
|||||||
@@ -59,16 +59,18 @@ class lcdWidget : public QWidget {
|
|||||||
QPixmap buffer(2*lcdWidth, 2*lcdHeight);
|
QPixmap buffer(2*lcdWidth, 2*lcdHeight);
|
||||||
QPainter p(&buffer);
|
QPainter p(&buffer);
|
||||||
doPaint(p);
|
doPaint(p);
|
||||||
bool toclipboard=g.snapToClpbrd();
|
bool toclipboard = g.snapToClpbrd();
|
||||||
QApplication::clipboard()->setPixmap( buffer );
|
if (toclipboard) {
|
||||||
if (!toclipboard) {
|
QApplication::clipboard()->setPixmap( buffer );
|
||||||
QString Path=g.snapshotDir();
|
}
|
||||||
if (Path.isEmpty() || !QDir(Path).exists()) {
|
else {
|
||||||
Path=".";
|
QString path = g.snapshotDir();
|
||||||
|
if (path.isEmpty() || !QDir(path).exists()) {
|
||||||
|
path = ".";
|
||||||
}
|
}
|
||||||
Path.append(QDir::separator()+fileName);
|
path.append(QDir::separator() + fileName);
|
||||||
qDebug() << "Screenshot" << Path;
|
qDebug() << "Screenshot" << path;
|
||||||
buffer.toImage().save(Path);
|
buffer.toImage().save(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1299,8 +1299,8 @@ FOXLIB=-L/usr/local/lib \
|
|||||||
-lFOX-1.6 \
|
-lFOX-1.6 \
|
||||||
-Wl,-rpath,$(FOXPATH)/src/.libs
|
-Wl,-rpath,$(FOXPATH)/src/.libs
|
||||||
|
|
||||||
simu: stamp_header $(BOARDSRC) $(CPPSRC) Makefile simu.cpp simpgmspace.cpp *.h tra lbm eeprom.bin
|
simu: stamp_header $(BOARDSRC) $(CPPSRC) Makefile simu.cpp targets/simu/simpgmspace.cpp *.h tra lbm eeprom.bin
|
||||||
g++ $(CPPFLAGS) $(INCFLAGS) simu.cpp $(BOARDSRC) $(CPPSRC) $(LUASRC) simpgmspace.cpp -MD -DSIMU -O0 -o simu $(FOXINC) $(FOXLIB) -pthread -fexceptions
|
g++ $(CPPFLAGS) $(INCFLAGS) simu.cpp $(BOARDSRC) $(CPPSRC) $(LUASRC) targets/simu/simpgmspace.cpp -MD -DSIMU -O0 -o simu $(FOXINC) $(FOXLIB) -pthread -fexceptions
|
||||||
|
|
||||||
eeprom.bin:
|
eeprom.bin:
|
||||||
dd if=/dev/zero of=$@ bs=1 count=2048
|
dd if=/dev/zero of=$@ bs=1 count=2048
|
||||||
@@ -1471,5 +1471,5 @@ gtest_main.a : gtest-all.o gtest_main.o
|
|||||||
# gtest_main.a, depending on whether it defines its own main()
|
# gtest_main.a, depending on whether it defines its own main()
|
||||||
# function.
|
# function.
|
||||||
|
|
||||||
gtests: $(BOARDSRC) $(CPPSRC) gtests.cpp simpgmspace.cpp *.h gtest_main.a
|
gtests: $(BOARDSRC) $(CPPSRC) tests/gtests.cpp targets/simu/simpgmspace.cpp *.h gtest_main.a
|
||||||
g++ -std=gnu++0x $(CPPFLAGS) $(BOARDSRC) $(CPPSRC) gtests.cpp simpgmspace.cpp -I$(GTEST_DIR) ${INCFLAGS} -I$(GTEST_DIR)/include -o gtests -lpthread -MD -DSIMU gtest_main.a
|
g++ -std=gnu++0x $(CPPFLAGS) $(BOARDSRC) $(CPPSRC) tests/gtests.cpp targets/simu/simpgmspace.cpp -I$(GTEST_DIR) ${INCFLAGS} -I$(GTEST_DIR)/include -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest_main.a
|
||||||
|
|||||||
+3
-1
@@ -280,7 +280,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
#include "simpgmspace.h"
|
#include "targets/simu/simpgmspace.h"
|
||||||
#elif defined(CPUARM)
|
#elif defined(CPUARM)
|
||||||
typedef const unsigned char pm_uchar;
|
typedef const unsigned char pm_uchar;
|
||||||
typedef const char pm_char;
|
typedef const char pm_char;
|
||||||
@@ -981,7 +981,9 @@ template<class t> FORCEINLINE t min(t a, t b) { return a<b?a:b; }
|
|||||||
template<class t> FORCEINLINE t max(t a, t b) { return a>b?a:b; }
|
template<class t> FORCEINLINE t max(t a, t b) { return a>b?a:b; }
|
||||||
template<class t> FORCEINLINE t sgn(t a) { return a>0 ? 1 : (a < 0 ? -1 : 0); }
|
template<class t> FORCEINLINE t sgn(t a) { return a>0 ? 1 : (a < 0 ? -1 : 0); }
|
||||||
template<class t> FORCEINLINE t limit(t mi, t x, t ma) { return min(max(mi,x),ma); }
|
template<class t> FORCEINLINE t limit(t mi, t x, t ma) { return min(max(mi,x),ma); }
|
||||||
|
#if !defined(SWAP_DEFINED)
|
||||||
template<class t> void swap(t & a, t & b) { t tmp = b; b = a; a = tmp; }
|
template<class t> void swap(t & a, t & b) { t tmp = b; b = a; a = tmp; }
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HELI) || defined(FRSKY_HUB)
|
#if defined(HELI) || defined(FRSKY_HUB)
|
||||||
uint16_t isqrt32(uint32_t n);
|
uint16_t isqrt32(uint32_t n);
|
||||||
|
|||||||
@@ -34,8 +34,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QPainter>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#define SWAP_DEFINED
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
#define CHANNEL_MAX (1024*256)
|
#define CHANNEL_MAX (1024*256)
|
||||||
@@ -938,7 +944,79 @@ TEST(Heli, SimpleTest)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
void doPaint(QPainter & p)
|
||||||
|
{
|
||||||
|
QRgb rgb = qRgb(161, 161, 161);
|
||||||
|
|
||||||
|
p.setBackground(QBrush(rgb));
|
||||||
|
p.eraseRect(0, 0, LCD_W, LCD_H);
|
||||||
|
|
||||||
|
if (1) {
|
||||||
|
#if !defined(PCBTARANIS)
|
||||||
|
rgb = qRgb(0, 0, 0);
|
||||||
|
p.setPen(rgb);
|
||||||
|
p.setBrush(QBrush(rgb));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
unsigned int previousDepth = 0xFF;
|
||||||
|
const int planSize = (LCD_W * ((LCD_H+7) / 8));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int y=0; y<LCD_H; y++) {
|
||||||
|
unsigned int idx = (y/8)*LCD_W;
|
||||||
|
unsigned int mask = (1 << (y%8));
|
||||||
|
for (int x=0; x<LCD_W; x++, idx++) {
|
||||||
|
#if !defined(PCBTARANIS)
|
||||||
|
if (lcd_buf[idx] & mask) {
|
||||||
|
p.drawPoint(x, y);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
unsigned int z = (((lcd_buf[idx] & mask) ? 0x1 : 0) + ((lcd_buf[planSize+idx] & mask) ? 0x2 : 0) + ((lcd_buf[2*planSize+idx] & mask) ? 0x4 : 0) + ((lcd_buf[3*planSize+idx] & mask) ? 0x8 : 0));
|
||||||
|
if (z) {
|
||||||
|
if (z != previousDepth) {
|
||||||
|
previousDepth = z;
|
||||||
|
//if (lightEnable)
|
||||||
|
// rgb = qRgb(_r-(z*_r)/15, _g-(z*_g)/15, _b-(z*_b)/15);
|
||||||
|
//else
|
||||||
|
rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
|
||||||
|
p.setPen(rgb);
|
||||||
|
p.setBrush(QBrush(rgb));
|
||||||
|
}
|
||||||
|
p.drawPoint(x, y);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkScreenshot(QString filename)
|
||||||
|
{
|
||||||
|
lcdRefresh();
|
||||||
|
QImage buffer(LCD_W, LCD_H, QImage::Format_RGB32);
|
||||||
|
QPainter p(&buffer);
|
||||||
|
doPaint(p);
|
||||||
|
buffer.save("/tmp/screenshot.png");
|
||||||
|
QFile screenshot("/tmp/screenshot.png");
|
||||||
|
if (!screenshot.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
|
QFile reference(QString("./tests/%1_%2x%3.png").arg(filename).arg(LCD_W).arg(LCD_H));
|
||||||
|
if (!reference.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
|
return reference.readAll() == screenshot.readAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Lcd, Invers_0_0)
|
||||||
|
{
|
||||||
|
lcd_clear();
|
||||||
|
lcd_putsAtt(0, 0, "Test", INVERS);
|
||||||
|
EXPECT_TRUE(checkScreenshot("invers_0_0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QCoreApplication app(argc, argv);
|
||||||
StartEepromThread(NULL);
|
StartEepromThread(NULL);
|
||||||
g_menuStackPtr = 0;
|
g_menuStackPtr = 0;
|
||||||
g_menuStack[0] = menuMainView;
|
g_menuStack[0] = menuMainView;
|
||||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 350 B |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 373 B |
Reference in New Issue
Block a user