diff --git a/Makefile b/Makefile index 6d49bcc..f7c90ed 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,8 @@ prodScreen_speakerTest.c \ prodScreen_ledTest.c \ prodScreen_magnetTest.c \ prodScreen_validation.c \ -prodScreen_showImage.c +prodScreen_showImage.c \ +prodScreen_gamma.c # Output EXEC=funkey_prod_screens diff --git a/ProdResources/background2.png b/ProdResources/background2.png new file mode 100644 index 0000000..90916e0 Binary files /dev/null and b/ProdResources/background2.png differ diff --git a/ProdResources/color_chart.png b/ProdResources/color_chart.png new file mode 100644 index 0000000..f4beb0c Binary files /dev/null and b/ProdResources/color_chart.png differ diff --git a/ProdResources/gamegear.png b/ProdResources/gamegear.png new file mode 100644 index 0000000..5b0025e Binary files /dev/null and b/ProdResources/gamegear.png differ diff --git a/ProdResources/gba.png b/ProdResources/gba.png new file mode 100644 index 0000000..f181c25 Binary files /dev/null and b/ProdResources/gba.png differ diff --git a/funkey_prod_screens.c b/funkey_prod_screens.c index 1156938..31eafd1 100644 --- a/funkey_prod_screens.c +++ b/funkey_prod_screens.c @@ -26,7 +26,8 @@ static s_prod_test prod_tests[] = { {"LED", launch_prod_screen_LED, 0}, {"MAGNET", launch_prod_screen_magnet, 0}, {"VALIDATE", launch_prod_screen_validation, 0}, - {"SHOW_IMAGE", launch_prod_screen_showImage, 1} + {"SHOW_IMAGE", launch_prod_screen_showImage, 1}, + {"GAMMA", launch_prod_screen_gamma, 0} }; static int idx_current_prod_test = 0; diff --git a/funkey_prod_screens.h b/funkey_prod_screens.h index d24db0b..ad2efe5 100644 --- a/funkey_prod_screens.h +++ b/funkey_prod_screens.h @@ -16,6 +16,7 @@ #include "prodScreen_magnetTest.h" #include "prodScreen_validation.h" #include "prodScreen_showImage.h" +#include "prodScreen_gamma.h" /// Defines @@ -42,10 +43,6 @@ #define FONT_NAME_INFO FONT_NAME_TITLE #define FONT_SIZE_INFO 18 -#define IMG_CONSOLE_LAYOUT FOLDER_RESSOURCES"/funkey_with_buttons.png" -#define IMG_BUTTON_LR_GREEN FOLDER_RESSOURCES"/button_LR_green.png" -#define IMG_BUTTON_NORMAL_GREEN FOLDER_RESSOURCES"/button_round_green.png" - typedef struct { char *cmd_line_argument; diff --git a/prodScreen_buttonsTest.h b/prodScreen_buttonsTest.h index 10293cc..8dad42c 100644 --- a/prodScreen_buttonsTest.h +++ b/prodScreen_buttonsTest.h @@ -1,6 +1,10 @@ #ifndef __PROD_SCREEN_BUTTONS__ #define __PROD_SCREEN_BUTTONS__ +#define IMG_CONSOLE_LAYOUT FOLDER_RESSOURCES"/funkey_with_buttons.png" +#define IMG_BUTTON_LR_GREEN FOLDER_RESSOURCES"/button_LR_green.png" +#define IMG_BUTTON_NORMAL_GREEN FOLDER_RESSOURCES"/button_round_green.png" + int launch_prod_screen_buttons(int argc, char *argv[]); #endif //__PROD_SCREEN_BUTTONS__ \ No newline at end of file diff --git a/prodScreen_gamma.c b/prodScreen_gamma.c new file mode 100644 index 0000000..a7dbd79 --- /dev/null +++ b/prodScreen_gamma.c @@ -0,0 +1,113 @@ +#include "funkey_prod_screens.h" + + +/// Defines + +/// Static variables + + +/// -------------- FUNCTIONS IMPLEMENTATION -------------- +int launch_prod_screen_gamma(int argc, char *argv[]){ + SDL_Event event; + SDL_Surface *text_surface = NULL; + SDL_Rect text_pos; + int res = EXIT_FAILURE; + int stop_menu_loop = 0; + + /* Fill screen white */ + SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format, bg_color.r, bg_color.g, bg_color.b, 0) ); + +#if 0 + /* Write Title */ + text_surface = TTF_RenderText_Shaded(font_info, "GAMMA", text_color, bg_color); + int height_title = text_surface->h; + text_pos.x = hw_surface->w/2 - text_surface->w/2; + text_pos.y = 0; + SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); + SDL_FreeSurface(text_surface); + + /* Write: + "L=FAIL" + */ + SDL_Color red_color={220,20,20}; + text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); + int height_buttons = text_surface->h; + text_pos.x = X_PADDING; + text_pos.y = hw_surface->h - text_surface->h; + SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); + SDL_FreeSurface(text_surface); + + /* Write: + "R=OK" + */ + SDL_Color green_color={20,220,20}; + text_surface = TTF_RenderText_Shaded(font_info, "R=DONE", green_color, bg_color); + text_pos.x = hw_surface->w - text_surface->w - X_PADDING; + text_pos.y = hw_surface->h - text_surface->h; + SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); + SDL_FreeSurface(text_surface); +#endif + + /* Load Img */ + SDL_Surface *image=IMG_Load(IMG_CONSOLE_COLOR_CHART); + if(!image) { + printf("ERROR IMG_Load: %s\n", IMG_GetError()); + printf("IMG path is: %s\n", IMG_CONSOLE_COLOR_CHART); + exit(1); + } + SDL_SetAlpha( image, 0, SDL_ALPHA_OPAQUE ); + + /* Convert to RGBA 32bits*/ + SDL_Surface *image_rgb_RGBA32b = SDL_CreateRGBSurface(SDL_SWSURFACE, image->w, image->h, 32, + image->format->Rmask, image->format->Gmask, + image->format->Bmask, image->format->Amask); + SDL_BlitSurface(image, NULL, image_rgb_RGBA32b, NULL); + SDL_FreeSurface(image); + + /* Resize image */ + SDL_Surface *image_RGBA32b_resized = zoomSurface(image_rgb_RGBA32b, hw_surface->w, hw_surface->h); + SDL_FreeSurface(image_rgb_RGBA32b); + + /* Blit image */ + SDL_BlitSurface(image_RGBA32b_resized, NULL, hw_surface, NULL); + SDL_FreeSurface(image_RGBA32b_resized); + + /// -------- 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; + } + } + + /* To investigate but with Buildroot, we need this: */ + SDL_Flip(hw_surface); + + /* Sleep for some time */ + SDL_Delay(SLEEP_PERIOD_MS); + } + + return res; +} + diff --git a/prodScreen_gamma.h b/prodScreen_gamma.h new file mode 100644 index 0000000..52b1fcc --- /dev/null +++ b/prodScreen_gamma.h @@ -0,0 +1,8 @@ +#ifndef __PROD_SCREEN_GAMMA__ +#define __PROD_SCREEN_GAMMA__ + +#define IMG_CONSOLE_COLOR_CHART FOLDER_RESSOURCES"/color_chart.png" + +int launch_prod_screen_gamma(int argc, char *argv[]); + +#endif //__PROD_SCREEN_GAMMA__ \ No newline at end of file diff --git a/prodScreen_showImage.h b/prodScreen_showImage.h index 17f21cd..09a5d31 100644 --- a/prodScreen_showImage.h +++ b/prodScreen_showImage.h @@ -2,5 +2,6 @@ #define __PROD_SCREEN_SHOW_IMAGE__ int launch_prod_screen_showImage(int argc, char *argv[]); +SDL_Surface * zoomSurface(SDL_Surface *src_surface, int dst_width, int dst_height); #endif //__PROD_SCREEN_SHOW_IMAGE__ \ No newline at end of file