added Tearing test

This commit is contained in:
Vincent-FK 2020-11-07 11:44:45 +01:00
parent 77b25c10e3
commit 0f1c90f7e1
3 changed files with 46 additions and 24 deletions

View File

@ -17,18 +17,18 @@ char *prog_title = "FUNKEY S TESTS";
/* Static Variables */ /* Static Variables */
static s_prod_test prod_tests[] = { static s_prod_test prod_tests[] = {
{"FAIL", launch_prod_screen_fail, 0}, {"FAIL", launch_prod_screen_fail, 0, NULL},
{"WAIT_BATTERY", launch_prod_screen_waitbattery, 0}, {"WAIT_BATTERY", launch_prod_screen_waitbattery, 0, NULL},
{"DISPLAY", launch_prod_screen_display, 0}, {"DISPLAY", launch_prod_screen_display, 0, NULL},
{"BRIGHTNESS", launch_prod_screen_brightness, 0}, {"BRIGHTNESS", launch_prod_screen_brightness, 0, NULL},
{"BUTTONS", launch_prod_screen_buttons, 0}, {"BUTTONS", launch_prod_screen_buttons, 0, NULL},
{"SPEAKER", launch_prod_screen_speaker, 0}, {"SPEAKER", launch_prod_screen_speaker, 0, NULL},
{"LED", launch_prod_screen_LED, 0}, {"LED", launch_prod_screen_LED, 0, NULL},
{"MAGNET", launch_prod_screen_magnet, 0}, {"MAGNET", launch_prod_screen_magnet, 0, NULL},
{"VALIDATE", launch_prod_screen_validation, 0}, {"VALIDATE", launch_prod_screen_validation, 0, NULL},
{"SHOW_IMAGE", launch_prod_screen_showImage, 1}, {"SHOW_IMAGE", launch_prod_screen_showImage, 1, "img_path"},
{"GAMMA", launch_prod_screen_gamma, 0}, {"GAMMA", launch_prod_screen_gamma, 0, NULL},
{"TEARING", launch_prod_screen_tearingtest, 0} {"TEARING", launch_prod_screen_tearingtest, 0, "(FPS)"}
}; };
static int idx_current_prod_test = 0; static int idx_current_prod_test = 0;
@ -65,10 +65,11 @@ void init_libraries(){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/// Open HW screen and set video mode 240x240 /// Open HW screen and set video mode 240x240
hw_surface = SDL_SetVideoMode(SCREEN_HORIZONTAL_SIZE, SCREEN_VERTICAL_SIZE, hw_surface = SDL_SetVideoMode(SCREEN_HORIZONTAL_SIZE, SCREEN_VERTICAL_SIZE,
32, SDL_HWSURFACE | SDL_DOUBLEBUF); 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
/*hw_surface = SDL_SetVideoMode(SCREEN_HORIZONTAL_SIZE, SCREEN_VERTICAL_SIZE,
32, SDL_HWSURFACE);*/
if (hw_surface == NULL) if (hw_surface == NULL)
{ {
fprintf(stderr, "ERROR SDL_SetVideoMode: %s\n", SDL_GetError()); fprintf(stderr, "ERROR SDL_SetVideoMode: %s\n", SDL_GetError());
@ -95,12 +96,12 @@ void usage(char *progname){
fprintf(stderr, "Usage: %s [prod_test] [optionnal: arg]\n\n", progname); fprintf(stderr, "Usage: %s [prod_test] [optionnal: arg]\n\n", progname);
fprintf(stderr, "\"prod_tests\" in:\n"); fprintf(stderr, "\"prod_tests\" in:\n");
for (i = 0; i < sizeof(prod_tests)/sizeof(prod_tests[0]); i++ ){ for (i = 0; i < sizeof(prod_tests)/sizeof(prod_tests[0]); i++ ){
if(!prod_tests[i].nb_args_needed){ if(prod_tests[i].args_description == NULL){
fprintf(stderr, " %s\n", prod_tests[i].cmd_line_argument); fprintf(stderr, " %s\n", prod_tests[i].cmd_line_argument);
} }
else{ else{
fprintf(stderr, " %s [needs %d additional args]\n", fprintf(stderr, " %s %s\n",
prod_tests[i].cmd_line_argument, prod_tests[i].nb_args_needed); prod_tests[i].cmd_line_argument, prod_tests[i].args_description);
} }
} }
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -128,7 +129,7 @@ int main(int argc, char *argv[])
} }
} }
if(test_found && (prod_tests[i].nb_args_needed+2 != argc) ){ if(test_found && (argc < prod_tests[i].nb_args_needed+2) ){
fprintf(stderr, "ERROR: %s needs %d additional args\n", fprintf(stderr, "ERROR: %s needs %d additional args\n",
prod_tests[idx_current_prod_test].cmd_line_argument, prod_tests[idx_current_prod_test].cmd_line_argument,
prod_tests[idx_current_prod_test].nb_args_needed); prod_tests[idx_current_prod_test].nb_args_needed);

View File

@ -17,6 +17,7 @@
#include "prodScreen_validation.h" #include "prodScreen_validation.h"
#include "prodScreen_showImage.h" #include "prodScreen_showImage.h"
#include "prodScreen_gamma.h" #include "prodScreen_gamma.h"
#include "prodScreen_tearingTest.h"
/// Defines /// Defines
@ -37,7 +38,7 @@
#define Y_PADDING 10 #define Y_PADDING 10
#define X_PADDING 20 #define X_PADDING 20
#define FOLDER_RESSOURCES "/usr/local/sbin/ProdResources" #define FOLDER_RESSOURCES "/usr/local/share/ProdResources"
#define FONT_NAME_TITLE FOLDER_RESSOURCES"/FreeSansBold.ttf" #define FONT_NAME_TITLE FOLDER_RESSOURCES"/FreeSansBold.ttf"
#define FONT_SIZE_TITLE 20 #define FONT_SIZE_TITLE 20
#define FONT_NAME_INFO FONT_NAME_TITLE #define FONT_NAME_INFO FONT_NAME_TITLE
@ -48,6 +49,7 @@ typedef struct
char *cmd_line_argument; char *cmd_line_argument;
int (*ptr_function_launch_test)(int argc, char *argv[]); int (*ptr_function_launch_test)(int argc, char *argv[]);
int nb_args_needed; int nb_args_needed;
const char *args_description;
} s_prod_test; } s_prod_test;

View File

@ -8,12 +8,13 @@
static int bright = 0; static int bright = 0;
/// -------------- FUNCTIONS IMPLEMENTATION -------------- /// -------------- FUNCTIONS IMPLEMENTATION --------------
static int wait_event_loop(){ static int wait_event_loop(uint32_t fps){
SDL_Event event; SDL_Event event;
int stop_menu_loop = 0; int stop_menu_loop = 0;
int prev_ms = 0;
int res = EXIT_FAILURE; int res = EXIT_FAILURE;
uint32_t prev_ms = SDL_GetTicks();
uint32_t cur_ms = SDL_GetTicks();
/// -------- Main loop --------- /// -------- Main loop ---------
while (!stop_menu_loop) while (!stop_menu_loop)
@ -53,11 +54,17 @@ static int wait_event_loop(){
current_color.r, current_color.g, current_color.b, 0) ); current_color.r, current_color.g, current_color.b, 0) );
bright = 1-bright; bright = 1-bright;
/* To investigate but with Buildroot, we need this: */ /* Flip screen */
SDL_Flip(hw_surface); SDL_Flip(hw_surface);
/* Sleep for some time */ /* Handle FPS */
//SDL_Delay(SLEEP_PERIOD_MS); if(fps){
cur_ms = SDL_GetTicks();
if(cur_ms-prev_ms < 1000/fps){
SDL_Delay(1000/fps - (cur_ms-prev_ms));
}
prev_ms = SDL_GetTicks();
}
} }
return res; return res;
@ -67,7 +74,19 @@ int launch_prod_screen_tearingtest(int argc, char *argv[]){
SDL_Surface *text_surface = NULL; SDL_Surface *text_surface = NULL;
SDL_Rect text_pos; SDL_Rect text_pos;
int fps = 0; // non stop
if(argc > 0 && argv[0] != NULL){
fps = atoi(argv[0]);
if(!fps){
printf("Cannot convert %s to int\n", argv[0]);
return EXIT_FAILURE;
}
}
printf("fps = %d, argv[0] = %s\n", fps, argv[0]);
/// Main loop /// Main loop
int res = wait_event_loop(); int res = wait_event_loop(fps);
return res; return res;
} }