New tests, Cleaned up tests, check screen dimensions before SDL_SetVideoMode

This commit is contained in:
Vincent Buso 2023-01-16 20:55:28 +01:00
parent c78ba94025
commit ab76d63f46
15 changed files with 1324 additions and 247 deletions

View File

@ -23,8 +23,10 @@ CC=$(CROSS_COMPILE)gcc
# Other options # Other options
ifeq ($(platform), funkey) ifeq ($(platform), funkey)
CFLAGS += $(shell /opt/FunKey-sdk-2.3.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config --cflags) CFLAGS += $(shell /opt/FunKey-sdk-2.3.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config --cflags)
CFLAGS += -O2 -mfloat-abi=hard -ffast-math -funsafe-math-optimizations -fno-PIC -march=armv7-a+neon-vfpv4 -mtune=cortex-a7 -mfpu=neon-vfpv4
#CFLAGS += -O2 #CFLAGS += -O2
CFLAGS += -O3
CFLAGS += -mfloat-abi=hard -ffast-math -funsafe-math-optimizations -fno-PIC -march=armv7-a+neon-vfpv4 -mtune=cortex-a7 -mfpu=neon-vfpv4
#CFLAGS += -ffreestanding -mfpu=neon -mfloat-abi=hard
LIBS += $(shell /opt/FunKey-sdk-2.3.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config --libs) LIBS += $(shell /opt/FunKey-sdk-2.3.0/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config --libs)
else else
CFLAGS += `sdl-config --cflags` CFLAGS += `sdl-config --cflags`

View File

@ -8,11 +8,6 @@
#include <signal.h> #include <signal.h>
void intHandler(int dummy) {
deinit_libraries();
exit(EXIT_FAILURE);
}
/* Global variables */ /* Global variables */
SDL_Surface *hw_surface = NULL; SDL_Surface *hw_surface = NULL;
@ -21,6 +16,8 @@ TTF_Font *font_info = NULL;
SDL_Color bg_color = {COLOR_BG_R, COLOR_BG_G, COLOR_BG_B}; SDL_Color bg_color = {COLOR_BG_R, COLOR_BG_G, COLOR_BG_B};
SDL_Color text_color = {COLOR_TEXT_R, COLOR_TEXT_G, COLOR_TEXT_B}; SDL_Color text_color = {COLOR_TEXT_R, COLOR_TEXT_G, COLOR_TEXT_B};
char *prog_title = "FUNKEY S TESTS"; char *prog_title = "FUNKEY S TESTS";
int display_width = 0;
int display_height = 0;
/* Static Variables */ /* Static Variables */
static s_prod_test prod_tests[] = { static s_prod_test prod_tests[] = {
@ -42,8 +39,26 @@ static int idx_current_prod_test = 0;
/// -------------- FUNCTIONS IMPLEMENTATION -------------- /// -------------- FUNCTIONS IMPLEMENTATION --------------
void deinit_libraries(){
/// ------ Close font -------
TTF_CloseFont(font_title);
TTF_CloseFont(font_info);
/// deinit libs
TTF_Quit();
SDL_Quit();
}
void intHandler(int dummy) {
deinit_libraries();
exit(EXIT_FAILURE);
}
void init_libraries(){ void init_libraries(){
/* Vars */
SDL_Rect **modes;
/* Catch SIGINT and exit */ /* Catch SIGINT and exit */
signal(SIGINT, intHandler); signal(SIGINT, intHandler);
@ -64,7 +79,7 @@ void init_libraries(){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/// ----- Loading the fonts ----- /* Loading the fonts */
font_title = TTF_OpenFont(FONT_NAME_TITLE, FONT_SIZE_TITLE); font_title = TTF_OpenFont(FONT_NAME_TITLE, FONT_SIZE_TITLE);
if(!font_title){ if(!font_title){
printf("ERROR in init_menu_SDL: Could not open menu font %s, %s\n", FONT_NAME_TITLE, SDL_GetError()); printf("ERROR in init_menu_SDL: Could not open menu font %s, %s\n", FONT_NAME_TITLE, SDL_GetError());
@ -76,32 +91,49 @@ void init_libraries(){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Get available fullscreen/hardware modes */
modes=SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE);
/* Check is there are any modes available */
if(modes == (SDL_Rect **)0){
printf("No modes available!\n");
exit(-1);
}
/* Check if our resolution is restricted */
if(modes == (SDL_Rect **)-1){
printf("All resolutions available.\n");
}
else{
/* Print valid modes */
printf("Available Modes:\n");
for(int i=0;modes[i];++i){
printf(" %d x %d\n", modes[i]->w, modes[i]->h);
}
}
/* Get display dimensions (1st returned mode) */
display_width = modes[0]->w;
display_height = modes[0]->h;
/// 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(display_width, display_height,
32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN); 16, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);
/*hw_surface = SDL_SetVideoMode(SCREEN_HORIZONTAL_SIZE, SCREEN_VERTICAL_SIZE, /*hw_surface = SDL_SetVideoMode(display_width, display_height,
32, SDL_HWSURFACE);*/ 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);*/
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());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Extra */
SDL_ShowCursor(0); SDL_ShowCursor(0);
char prog_name[50]; char prog_name[50];
sprintf(prog_name, "FunKey_Prod_%s", prod_tests[idx_current_prod_test].cmd_line_argument ); sprintf(prog_name, "FunKey_Prod_%s", prod_tests[idx_current_prod_test].cmd_line_argument );
SDL_WM_SetCaption(prog_name, NULL); SDL_WM_SetCaption(prog_name, NULL);
} }
void deinit_libraries(){
/// ------ Close font -------
TTF_CloseFont(font_title);
TTF_CloseFont(font_info);
/// deinit libs
TTF_Quit();
SDL_Quit();
}
void usage(char *progname){ void usage(char *progname){
int i; int i;
fprintf(stderr, "Usage: %s [prod_test] [optionnal: arg]\n\n", progname); fprintf(stderr, "Usage: %s [prod_test] [optionnal: arg]\n\n", progname);

View File

@ -26,9 +26,6 @@
/// Defines /// Defines
#define ERROR_MANUAL_FAIL 2 #define ERROR_MANUAL_FAIL 2
#define SCREEN_HORIZONTAL_SIZE 240
#define SCREEN_VERTICAL_SIZE 240
#define SLEEP_PERIOD_MS 100 #define SLEEP_PERIOD_MS 100
#define COLOR_BG_R 255 #define COLOR_BG_R 255
@ -63,6 +60,8 @@ extern TTF_Font *font_info;
extern SDL_Color bg_color; extern SDL_Color bg_color;
extern SDL_Color text_color; extern SDL_Color text_color;
extern char *prog_title; extern char *prog_title;
extern int display_width;
extern int display_height;
#endif //__FUNKEY_PROD_SCREENS__ #endif //__FUNKEY_PROD_SCREENS__

View File

@ -38,8 +38,8 @@ 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); //SDL_Flip(hw_surface);
/* Sleep for some time */ /* Sleep for some time */
SDL_Delay(SLEEP_PERIOD_MS); SDL_Delay(SLEEP_PERIOD_MS);
@ -57,15 +57,15 @@ int launch_prod_screen_brightness(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Write "SPEAKER ok ? */ /* Write "SPEAKER ok ? */
text_surface = TTF_RenderText_Shaded(font_title, "BRIGHTNESS OK ?", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "BRIGHTNESS OK ?", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2; text_pos.y = display_height/2 - text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -76,12 +76,12 @@ int launch_prod_screen_brightness(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -91,18 +91,18 @@ int launch_prod_screen_brightness(int argc, char *argv[]){
*/ */
SDL_Color green_color={20,220,20}; SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Render screen */ /* Render screen */
//SDL_Flip(hw_surface); SDL_Flip(hw_surface);
/// ///
int res = wait_event_loop(); int res = wait_event_loop();

View File

@ -64,7 +64,7 @@ int launch_prod_screen_buttons(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -72,7 +72,7 @@ int launch_prod_screen_buttons(int argc, char *argv[]){
/* Write "Screen ok ? */ /* Write "Screen ok ? */
sprintf(str_title_buttons, "Press all buttons...%ds", time_left); sprintf(str_title_buttons, "Press all buttons...%ds", time_left);
text_surface = TTF_RenderText_Shaded(font_info, str_title_buttons, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, str_title_buttons, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = 2*Y_PADDING + text_surface->h/2; text_pos.y = 2*Y_PADDING + text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);

View File

@ -26,23 +26,23 @@ int launch_prod_screen_display(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Write "Screen ok ? */ /* Write "Screen ok ? */
text_surface = TTF_RenderText_Shaded(font_title, "SCREEN OK ?", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "SCREEN OK ?", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2 - Y_PADDING; text_pos.y = display_height/2 - text_surface->h/2 - Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Write timeout */ /* Write timeout */
sprintf(str_title, "%d", timeout); sprintf(str_title, "%d", timeout);
text_surface = TTF_RenderText_Shaded(font_title, str_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, str_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2 + Y_PADDING; text_pos.y = display_height/2 - text_surface->h/2 + Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -53,12 +53,12 @@ int launch_prod_screen_display(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -68,13 +68,13 @@ int launch_prod_screen_display(int argc, char *argv[]){
*/ */
SDL_Color green_color={20,220,20}; SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);

View File

@ -58,16 +58,16 @@ int launch_prod_screen_fail(int argc, char *argv[]){
/* Write Title */ /* Write Title */
SDL_Color red={255,0,0}; SDL_Color red={255,0,0};
text_surface = TTF_RenderText_Shaded(font_title, prog_title, red, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, red, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Write "Screen ok ? */ /* Write "Screen ok ? */
text_surface = TTF_RenderText_Shaded(font_title, "FAILED", red, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "FAILED", red, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2; text_pos.y = display_height/2 - text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -78,12 +78,12 @@ int launch_prod_screen_fail(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=STOP", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=STOP", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -93,13 +93,13 @@ int launch_prod_screen_fail(int argc, char *argv[]){
*/ */
SDL_Color green_color={20,20,220}; SDL_Color green_color={20,20,220};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=RESTART", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=RESTART", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING/2; text_pos.x = display_width - text_surface->w - X_PADDING/2;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);

View File

@ -9,8 +9,8 @@
/// -------------- FUNCTIONS IMPLEMENTATION -------------- /// -------------- FUNCTIONS IMPLEMENTATION --------------
int launch_prod_screen_gamma(int argc, char *argv[]){ int launch_prod_screen_gamma(int argc, char *argv[]){
SDL_Event event; SDL_Event event;
SDL_Surface *text_surface = NULL; //SDL_Surface *text_surface = NULL;
SDL_Rect text_pos; //SDL_Rect text_pos;
int res = EXIT_FAILURE; int res = EXIT_FAILURE;
int stop_menu_loop = 0; int stop_menu_loop = 0;

View File

@ -56,14 +56,14 @@ int launch_prod_screen_LED(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
/* Write "LED ok ? */ /* Write "LED ok ? */
text_surface = TTF_RenderText_Shaded(font_title, "LED OK ?", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "LED OK ?", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2; text_pos.y = display_height/2 - text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -74,12 +74,12 @@ int launch_prod_screen_LED(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -89,13 +89,13 @@ int launch_prod_screen_LED(int argc, char *argv[]){
*/ */
SDL_Color green_color={20,220,20}; SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);

View File

@ -89,7 +89,7 @@ int launch_prod_screen_magnet(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -99,14 +99,14 @@ int launch_prod_screen_magnet(int argc, char *argv[]){
(close the console)*/ (close the console)*/
int y_pad_tmp = 11; int y_pad_tmp = 11;
text_surface = TTF_RenderText_Shaded(font_title, "MAGNET TEST", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "MAGNET TEST", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2 - y_pad_tmp; text_pos.y = display_height/2 - text_surface->h/2 - y_pad_tmp;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_title, "(close the console)", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "(close the console)", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2 + y_pad_tmp; text_pos.y = display_height/2 - text_surface->h/2 + y_pad_tmp;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -117,12 +117,12 @@ int launch_prod_screen_magnet(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -132,13 +132,13 @@ int launch_prod_screen_magnet(int argc, char *argv[]){
*/ */
/*SDL_Color green_color={20,220,20}; /*SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface);*/ SDL_FreeSurface(text_surface);*/

View File

@ -57,15 +57,15 @@ int launch_prod_screen_speaker(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Write "SPEAKER ok ? */ /* Write "SPEAKER ok ? */
text_surface = TTF_RenderText_Shaded(font_title, "SPEAKER OK ?", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "SPEAKER OK ?", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2; text_pos.y = display_height/2 - text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -76,12 +76,12 @@ int launch_prod_screen_speaker(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -91,13 +91,13 @@ int launch_prod_screen_speaker(int argc, char *argv[]){
*/ */
SDL_Color green_color={20,220,20}; SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);

View File

@ -48,9 +48,9 @@ static int wait_event_loop(uint32_t fps){
} }
/* Fill screen random */ /* Fill screen random */
SDL_Color current_color = {rand() % 256 + 128*bright, SDL_Color current_color = {rand() % 127 + 128*bright,
rand() % 256 + 128*bright, rand() % 127 + 128*bright,
rand() % 256 + 128*bright}; rand() % 127 + 128*bright};
SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format, SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format,
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;
@ -73,10 +73,8 @@ static int wait_event_loop(uint32_t fps){
} }
int launch_prod_screen_tearingtest(int argc, char *argv[]){ int launch_prod_screen_tearingtest(int argc, char *argv[]){
SDL_Surface *text_surface = NULL;
SDL_Rect text_pos;
int fps = 0; // non stop int fps = 0; // non stop
if(argc > 0 && argv[0] != NULL){ if(argc > 0 && argv[0] != NULL){
fps = atoi(argv[0]); fps = atoi(argv[0]);
if(!fps){ if(!fps){

File diff suppressed because one or more lines are too long

View File

@ -57,15 +57,15 @@ int launch_prod_screen_validation(int argc, char *argv[]){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING; text_pos.y = Y_PADDING;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
/* Write "Screen ok ? */ /* Write "Screen ok ? */
text_surface = TTF_RenderText_Shaded(font_title, "ALL TESTS DONE", text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "ALL TESTS DONE", text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2; text_pos.y = display_height/2 - text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -76,12 +76,12 @@ int launch_prod_screen_validation(int argc, char *argv[]){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -91,13 +91,13 @@ int launch_prod_screen_validation(int argc, char *argv[]){
*/ */
SDL_Color green_color={20,220,20}; SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h; text_pos.y = display_height - Y_PADDING - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h; text_pos.y = display_height - Y_PADDING - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);

View File

@ -27,9 +27,9 @@ typedef enum{BAT_TESTS} ENUM_BAT_TESTS;
/// ----------- STATIC VARS -------------- /// ----------- STATIC VARS --------------
#undef X /*#undef X
#define X(a, b) b, #define X(a, b) b,
static const char *bat_tests_strings[] = {BAT_TESTS}; static const char *bat_tests_strings[] = {BAT_TESTS};*/
static int bat_measurements[NB_BAT_MESUREMENTS] = {0}; static int bat_measurements[NB_BAT_MESUREMENTS] = {0};
static int idx_bat_measurements = 0; static int idx_bat_measurements = 0;
@ -64,7 +64,7 @@ static int is_battery_present(){
static int get_battery_voltage(){ static int get_battery_voltage(){
char buf[10]; char buf[10];
FILE *fp; FILE *fp;
int res = 0; //int res = 0;
/* Read battery voltage file */ /* Read battery voltage file */
char *file = BATTERY_VOLTAGE_NOW_FILE; char *file = BATTERY_VOLTAGE_NOW_FILE;
@ -113,7 +113,7 @@ static void render_static_text(){
/* Write Title */ /* Write Title */
text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color); text_surface = TTF_RenderText_Shaded(font_title, prog_title, text_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = Y_PADDING_BAT_RES; text_pos.y = Y_PADDING_BAT_RES;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -122,15 +122,15 @@ static void render_static_text(){
/*SDL_Color dark_gray={20,20,20}; /*SDL_Color dark_gray={20,20,20};
text_surface = TTF_RenderText_Shaded(font_title, "BATTERY TESTS:", dark_gray, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "BATTERY TESTS:", dark_gray, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - (text_surface->h*(NB_BAT_TESTS+1) + Y_PADDING_BAT_RES*NB_BAT_TESTS)/2; text_pos.y = display_height/2 - (text_surface->h*(NB_BAT_TESTS+1) + Y_PADDING_BAT_RES*NB_BAT_TESTS)/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface);*/ SDL_FreeSurface(text_surface);*/
/* Write "Test title*/ /* Write "Test title*/
/*SDL_Color red={255,0,0}; /*SDL_Color red={255,0,0};
text_surface = TTF_RenderText_Shaded(font_title, "INSERT BATTERY", red, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "INSERT BATTERY", red, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2; text_pos.y = display_height/2 - text_surface->h/2;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface);*/ SDL_FreeSurface(text_surface);*/
@ -141,12 +141,12 @@ static void render_static_text(){
SDL_Color red_color={220,20,20}; SDL_Color red_color={220,20,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING_BAT_RES - 2*text_surface->h; text_pos.y = display_height - Y_PADDING_BAT_RES - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
text_pos.x = X_PADDING; text_pos.x = X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING_BAT_RES - text_surface->h; text_pos.y = display_height - Y_PADDING_BAT_RES - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -156,13 +156,13 @@ static void render_static_text(){
*/ */
/*SDL_Color green_color={20,220,20}; /*SDL_Color green_color={20,220,20};
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING_BAT_RES - 2*text_surface->h; text_pos.y = display_height - Y_PADDING_BAT_RES - 2*text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color); text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING; text_pos.x = display_width - text_surface->w - X_PADDING;
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING_BAT_RES - text_surface->h; text_pos.y = display_height - Y_PADDING_BAT_RES - text_surface->h;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface);*/ SDL_FreeSurface(text_surface);*/
@ -239,8 +239,8 @@ static int wait_event_loop(){
/* Show ERROR message */ /* Show ERROR message */
SDL_Color red={255,0,0}; SDL_Color red={255,0,0};
text_surface = TTF_RenderText_Shaded(font_title, "CONNECT BATTERY", red, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "CONNECT BATTERY", red, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2 text_pos.y = display_height/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2
+ (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx; + (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -266,8 +266,8 @@ static int wait_event_loop(){
/* Show ERROR message */ /* Show ERROR message */
SDL_Color red={255,0,0}; SDL_Color red={255,0,0};
text_surface = TTF_RenderText_Shaded(font_title, "UNPLUG USB", red, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "UNPLUG USB", red, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2 text_pos.y = display_height/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2
+ (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx; + (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -306,8 +306,8 @@ static int wait_event_loop(){
if(false_measurement_found){ if(false_measurement_found){
SDL_Color red={255,0,0}; SDL_Color red={255,0,0};
text_surface = TTF_RenderText_Shaded(font_title, "WRONG VOLTAGE", red, bg_color); text_surface = TTF_RenderText_Shaded(font_title, "WRONG VOLTAGE", red, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2 text_pos.y = display_height/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2
+ (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx; + (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);
@ -326,8 +326,8 @@ static int wait_event_loop(){
char text_tmp[40]; char text_tmp[40];
sprintf(text_tmp, "Check voltage (%d/%d)...", idx_bat_measurements, NB_BAT_MESUREMENTS); sprintf(text_tmp, "Check voltage (%d/%d)...", idx_bat_measurements, NB_BAT_MESUREMENTS);
text_surface = TTF_RenderText_Shaded(font_info, text_tmp, dark_gray, bg_color); text_surface = TTF_RenderText_Shaded(font_info, text_tmp, dark_gray, bg_color);
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2; text_pos.x = display_width/2 - text_surface->w/2;
text_pos.y = SCREEN_VERTICAL_SIZE/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2 text_pos.y = display_height/2 - Y_PADDING - (text_surface->h*(NB_BAT_TESTS) + Y_PADDING_BAT_RES*(NB_BAT_TESTS-1))/2
+ (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx; + (text_surface->h+Y_PADDING_BAT_RES)*cur_bat_test_idx;
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
SDL_FreeSurface(text_surface); SDL_FreeSurface(text_surface);