From 75520e7e6b90ab7d292c884cd355afc9e6ab5676 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Fri, 6 Nov 2020 15:26:22 +0100 Subject: [PATCH] added tearing test --- Makefile | 1 + funkey_prod_screens.c | 3 +- funkey_prod_screens.h | 1 + prodScreen_tearingTest.c | 73 ++++++++++++++++++++++++++++++++++++++++ prodScreen_tearingTest.h | 6 ++++ prodScreen_waitBattery.c | 2 +- 6 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 prodScreen_tearingTest.c create mode 100644 prodScreen_tearingTest.h diff --git a/Makefile b/Makefile index f7c90ed..464ca15 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ prodScreen_ledTest.c \ prodScreen_magnetTest.c \ prodScreen_validation.c \ prodScreen_showImage.c \ +prodScreen_tearingTest.c \ prodScreen_gamma.c # Output diff --git a/funkey_prod_screens.c b/funkey_prod_screens.c index 31eafd1..aafe6d8 100644 --- a/funkey_prod_screens.c +++ b/funkey_prod_screens.c @@ -27,7 +27,8 @@ static s_prod_test prod_tests[] = { {"MAGNET", launch_prod_screen_magnet, 0}, {"VALIDATE", launch_prod_screen_validation, 0}, {"SHOW_IMAGE", launch_prod_screen_showImage, 1}, - {"GAMMA", launch_prod_screen_gamma, 0} + {"GAMMA", launch_prod_screen_gamma, 0}, + {"TEARING", launch_prod_screen_tearingtest, 0} }; static int idx_current_prod_test = 0; diff --git a/funkey_prod_screens.h b/funkey_prod_screens.h index ad2efe5..586b0cd 100644 --- a/funkey_prod_screens.h +++ b/funkey_prod_screens.h @@ -17,6 +17,7 @@ #include "prodScreen_validation.h" #include "prodScreen_showImage.h" #include "prodScreen_gamma.h" +#include "prodScreen_tearingTest.h" /// Defines diff --git a/prodScreen_tearingTest.c b/prodScreen_tearingTest.c new file mode 100644 index 0000000..0f1d0b5 --- /dev/null +++ b/prodScreen_tearingTest.c @@ -0,0 +1,73 @@ +#include +#include +#include +#include +//#include +#include "funkey_prod_screens.h" + +static int bright = 0; + +/// -------------- FUNCTIONS IMPLEMENTATION -------------- +static int wait_event_loop(){ + + SDL_Event event; + int stop_menu_loop = 0; + int prev_ms = 0; + int res = EXIT_FAILURE; + + /// -------- Main loop --------- + while (!stop_menu_loop) + { + /// -------- Handle Keyboard Events --------- + while (SDL_PollEvent(&event)) + switch(event.type) + { + case SDL_QUIT: + stop_menu_loop = 1; + break; + case SDL_KEYDOWN: + switch (event.key.keysym.sym) + { + + case SDLK_m: + stop_menu_loop = 1; + res = ERROR_MANUAL_FAIL; + break; + + case SDLK_n: + case SDLK_ESCAPE: + stop_menu_loop = 1; + res = 0; + break; + + default: + break; + } + } + + /* Fill screen random */ + SDL_Color current_color = {rand() % 128 + 128*bright, + rand() % 256 + 128*bright, + rand() % 256 + 128*bright}; + SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format, + current_color.r, current_color.g, current_color.b, 0) ); + bright = 1-bright; + + /* To investigate but with Buildroot, we need this: */ + SDL_Flip(hw_surface); + + /* Sleep for some time */ + //SDL_Delay(SLEEP_PERIOD_MS); + } + + return res; +} + +int launch_prod_screen_tearingtest(int argc, char *argv[]){ + SDL_Surface *text_surface = NULL; + SDL_Rect text_pos; + + /// Main loop + int res = wait_event_loop(); + return res; +} \ No newline at end of file diff --git a/prodScreen_tearingTest.h b/prodScreen_tearingTest.h new file mode 100644 index 0000000..802ac62 --- /dev/null +++ b/prodScreen_tearingTest.h @@ -0,0 +1,6 @@ +#ifndef __PROD_SCREEN_TEARINGTEST__ +#define __PROD_SCREEN_TEARINGTEST__ + +int launch_prod_screen_tearingtest(int argc, char *argv[]); + +#endif //__PROD_SCREEN_TEARINGTEST__ \ No newline at end of file diff --git a/prodScreen_waitBattery.c b/prodScreen_waitBattery.c index a547144..a231f91 100644 --- a/prodScreen_waitBattery.c +++ b/prodScreen_waitBattery.c @@ -66,7 +66,7 @@ static int wait_event_loop(){ } } - /* To inverstigate but with Buildroot, we need this: */ + /* To investigate but with Buildroot, we need this: */ SDL_Flip(hw_surface); if(SDL_GetTicks() - prev_ms > CHECK_BATTERY_DELAY_MS){