diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index 63dec054b..fd31784ac 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -346,6 +346,296 @@ int cliTestNew() return 0; } +#if defined(COLORLCD) + +extern bool perMainEnabled; +typedef void (*graphichTestFunc)(void); + +void testDrawSolidFilledRectangle() +{ + lcdDrawFilledRect(0, 0, LCD_W, LCD_H, SOLID, TEXT_BGCOLOR); +} + +void testDrawFilledRectangle() +{ + lcdDrawFilledRect(0, 0, LCD_W, LCD_H, DOTTED, TEXT_BGCOLOR); +} + +void testDrawSolidFilledRoundedRectangle() +{ + lcdDrawFilledRect(0, 0, LCD_W/2, LCD_H/2, SOLID, ROUND|TEXT_BGCOLOR); +} + +void testDrawBlackOverlay() +{ + lcdDrawBlackOverlay(); +} + +void testDrawSolidHorizontalLine1() +{ + lcdDrawSolidHorizontalLine(0, 0, 1, 0); +} + +void testDrawSolidHorizontalLine2() +{ + lcdDrawSolidHorizontalLine(0, 0, LCD_W, 0); +} + +void testDrawSolidVerticalLine1() +{ + lcdDrawSolidVerticalLine(0, 0, 1, 0); +} + +void testDrawSolidVerticalLine2() +{ + lcdDrawSolidVerticalLine(0, 0, LCD_H, 0); +} + +void testDrawDiagonalLine() +{ + lcdDrawLine(0,0, LCD_W, LCD_H, SOLID, TEXT_COLOR); +} + +void testEmpty() +{ +} + +void testDrawRect() +{ + lcdDrawRect(0, 0, LCD_W, LCD_H, 2, SOLID, TEXT_COLOR); +} + +void testDrawText() +{ + lcdDrawText(0, LCD_H/2, "The quick brown fox jumps over the lazy dog", TEXT_COLOR); +} + +void testDrawTextVertical() +{ + lcdDrawText(30, LCD_H, "The quick brown fox ", TEXT_COLOR|VERTICAL|NO_FONTCACHE); +} + +void testClear() +{ + lcdClear(); +} + +#define GRAPHICS_TEST_RUN_STEP 100 +#define RUN_GRAPHICS_TEST(name, runtime) runGraphicsTest(name, #name, runtime) + +float runGraphicsTest(graphichTestFunc func, const char * name, uint32_t runtime) +{ + uint32_t start = (uint32_t)CoGetOSTime(); + uint32_t noRuns = 0; + while (((uint32_t)CoGetOSTime() - start) < runtime/2 ) { + for (int n=0; n " }, { "stackinfo", cliStackInfo, "" }, { "meminfo", cliMemoryInfo, "" }, - { "test", cliTest, "new | std::exception" }, + { "test", cliTest, "new | std::exception | graphics | memspd" }, { "trace", cliTrace, "on | off" }, #if defined(PCBFLAMENCO) { "read_bq24195", cliReadBQ24195, "" }, diff --git a/radio/src/tasks_arm.cpp b/radio/src/tasks_arm.cpp index 264d88db2..2617a5153 100644 --- a/radio/src/tasks_arm.cpp +++ b/radio/src/tasks_arm.cpp @@ -206,6 +206,10 @@ void scheduleNextMixerCalculation(uint8_t module, uint16_t delay) #define MENU_TASK_PERIOD_TICKS 25 // 50ms +#if defined(COLORLCD) && defined(CLI) +bool perMainEnabled = true; +#endif + void menusTask(void * pdata) { opentxInit(); @@ -225,8 +229,13 @@ void menusTask(void * pdata) #endif uint32_t start = (uint32_t)CoGetOSTime(); DEBUG_TIMER_START(debugTimerPerMain); - DEBUG_TIMER_SAMPLE(debugTimerPerMainPeriod); +#if defined(COLORLCD) && defined(CLI) + if (perMainEnabled) { + perMain(); + } +#else perMain(); +#endif DEBUG_TIMER_STOP(debugTimerPerMain); // TODO remove completely massstorage from sky9x firmware uint32_t runtime = ((uint32_t)CoGetOSTime() - start); diff --git a/radio/src/tests/fonts_480x272.png b/radio/src/tests/fonts_480x272.png new file mode 100644 index 000000000..bbd77c394 Binary files /dev/null and b/radio/src/tests/fonts_480x272.png differ diff --git a/radio/src/tests/lcd_480x272.cpp b/radio/src/tests/lcd_480x272.cpp index 69caf2367..d96f116a7 100644 --- a/radio/src/tests/lcd_480x272.cpp +++ b/radio/src/tests/lcd_480x272.cpp @@ -92,8 +92,8 @@ TEST(Lcd_480x272, vline) TEST(Lcd_480x272, primitives) { lcd->clear(TEXT_BGCOLOR); - lcdDrawText(8, 8, "The quick brown fox jumps over the lazy dog", CURVE_AXIS_COLOR); - lcdDrawText(5, 5, "The quick brown fox jumps over the lazy dog", TEXT_COLOR); + lcdDrawText(8, 8, "The quick brown fox jumps over the lazy dog", CURVE_AXIS_COLOR|NO_FONTCACHE); + lcdDrawText(5, 5, "The quick brown fox jumps over the lazy dog", TEXT_COLOR|NO_FONTCACHE); lcdDrawFilledRect(10, 30, 30, 30, SOLID, TITLE_BGCOLOR); lcdDrawFilledRect(50, 30, 30, 30, DOTTED, TEXT_COLOR); @@ -116,4 +116,59 @@ TEST(Lcd_480x272, primitives) EXPECT_TRUE(checkScreenshot_480x272("primitives")); } +TEST(Lcd_480x272, transparency) +{ + lcd->clear(TEXT_BGCOLOR); + lcdDrawText(8, 8, "The quick brown fox jumps over the lazy dog", TEXT_COLOR|OPACITY(4)|NO_FONTCACHE); + lcdDrawText(5, 5, "The quick brown fox jumps over the lazy dog", TEXT_COLOR|OPACITY(12)|NO_FONTCACHE); + + lcdDrawFilledRect(10, 30, 30, 30, SOLID, TITLE_BGCOLOR|OPACITY(8)); + lcdDrawFilledRect(50, 30, 30, 30, DOTTED, TEXT_COLOR|OPACITY(10)); + lcdDrawFilledRect(90, 30, 30, 30, SOLID, ROUND|TITLE_BGCOLOR|OPACITY(12)); + lcdDrawRect(130, 30, 30, 30, 1, SOLID, TITLE_BGCOLOR|OPACITY(8)); + lcdDrawRect(170, 30, 30, 30, 2, SOLID, TITLE_BGCOLOR|OPACITY(8)); + lcdDrawRect(210, 30, 30, 30, 5, SOLID, TITLE_BGCOLOR|OPACITY(8)); + + lcdDrawVerticalLine(10, 70, 100, SOLID, TITLE_BGCOLOR|OPACITY(2)); + lcdDrawVerticalLine(15, 70, 90, SOLID, TITLE_BGCOLOR|OPACITY(6)); + lcdDrawVerticalLine(20, 70, 80, SOLID, TITLE_BGCOLOR|OPACITY(10)); + lcdDrawVerticalLine(25, 70, 70, SOLID, TITLE_BGCOLOR|OPACITY(OPACITY_MAX)); + + lcdDrawHorizontalLine(30, 70, 100, SOLID, TEXT_COLOR|OPACITY(2)); + lcdDrawHorizontalLine(30, 75, 90, SOLID, TEXT_COLOR|OPACITY(6)); + lcdDrawHorizontalLine(30, 80, 80, SOLID, TEXT_COLOR|OPACITY(10)); + lcdDrawHorizontalLine(30, 85, 70, SOLID, TEXT_COLOR|OPACITY(OPACITY_MAX)); + + + for(int n=0; n<10; n++) { + int x = 120 + n * 20; + int y = 80 + n * 10; + int color = COLOR(n/2 + 5); + int size = 100; + lcdDrawFilledRect(x, y, size, size, SOLID, color|OPACITY(8)); + + } + + EXPECT_TRUE(checkScreenshot_480x272("transparency")); +} + +TEST(Lcd_480x272, fonts) +{ + loadFontCache(); + lcd->clear(TEXT_BGCOLOR); + + lcdDrawText(8, 8, "The quick brown fox jumps over the lazy dog", TEXT_COLOR|OPACITY(4)); + lcdDrawText(5, 5, "The quick brown fox jumps over the lazy dog", TEXT_COLOR|OPACITY(12)); + + lcdDrawText(10, 200, "The quick", TEXT_COLOR|VERTICAL|NO_FONTCACHE); + lcdDrawText(30, 200, "The quick brown fox", TEXT_COLOR|VERTICAL|NO_FONTCACHE); + // lcdDrawText(50, 200, "The quick brown fox jumps over the lazy dog", TEXT_COLOR|VERTICAL|NO_FONTCACHE); + + lcdDrawText(8, 208, "The quick brown fox jumps over the lazy dog", TITLE_BGCOLOR|OPACITY(4)); + lcdDrawText(5, 205, "The quick brown fox jumps over the lazy dog", TITLE_BGCOLOR|OPACITY(12)); + + EXPECT_TRUE(checkScreenshot_480x272("fonts")); +} + + #endif \ No newline at end of file diff --git a/radio/src/tests/transparency_480x272.png b/radio/src/tests/transparency_480x272.png new file mode 100644 index 000000000..18fa167cf Binary files /dev/null and b/radio/src/tests/transparency_480x272.png differ