|
| 1 | +#include "funkey_prod_screens.h" |
| 2 | + |
| 3 | + |
| 4 | +/// Defines |
| 5 | + |
| 6 | +/// Static variables |
| 7 | + |
| 8 | + |
| 9 | +/// -------------- FUNCTIONS IMPLEMENTATION -------------- |
| 10 | +int launch_prod_screen_gamma(int argc, char *argv[]){ |
| 11 | + SDL_Event event; |
| 12 | + SDL_Surface *text_surface = NULL; |
| 13 | + SDL_Rect text_pos; |
| 14 | + int res = EXIT_FAILURE; |
| 15 | + int stop_menu_loop = 0; |
| 16 | + |
| 17 | + /* Fill screen white */ |
| 18 | + SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format, bg_color.r, bg_color.g, bg_color.b, 0) ); |
| 19 | + |
| 20 | +#if 0 |
| 21 | + /* Write Title */ |
| 22 | + text_surface = TTF_RenderText_Shaded(font_info, "GAMMA", text_color, bg_color); |
| 23 | + int height_title = text_surface->h; |
| 24 | + text_pos.x = hw_surface->w/2 - text_surface->w/2; |
| 25 | + text_pos.y = 0; |
| 26 | + SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); |
| 27 | + SDL_FreeSurface(text_surface); |
| 28 | + |
| 29 | + /* Write: |
| 30 | + "L=FAIL" |
| 31 | + */ |
| 32 | + SDL_Color red_color={220,20,20}; |
| 33 | + text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color); |
| 34 | + int height_buttons = text_surface->h; |
| 35 | + text_pos.x = X_PADDING; |
| 36 | + text_pos.y = hw_surface->h - text_surface->h; |
| 37 | + SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); |
| 38 | + SDL_FreeSurface(text_surface); |
| 39 | + |
| 40 | + /* Write: |
| 41 | + "R=OK" |
| 42 | + */ |
| 43 | + SDL_Color green_color={20,220,20}; |
| 44 | + text_surface = TTF_RenderText_Shaded(font_info, "R=DONE", green_color, bg_color); |
| 45 | + text_pos.x = hw_surface->w - text_surface->w - X_PADDING; |
| 46 | + text_pos.y = hw_surface->h - text_surface->h; |
| 47 | + SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos); |
| 48 | + SDL_FreeSurface(text_surface); |
| 49 | +#endif |
| 50 | + |
| 51 | + /* Load Img */ |
| 52 | + SDL_Surface *image=IMG_Load(IMG_CONSOLE_COLOR_CHART); |
| 53 | + if(!image) { |
| 54 | + printf("ERROR IMG_Load: %s\n", IMG_GetError()); |
| 55 | + printf("IMG path is: %s\n", IMG_CONSOLE_COLOR_CHART); |
| 56 | + exit(1); |
| 57 | + } |
| 58 | + SDL_SetAlpha( image, 0, SDL_ALPHA_OPAQUE ); |
| 59 | + |
| 60 | + /* Convert to RGBA 32bits*/ |
| 61 | + SDL_Surface *image_rgb_RGBA32b = SDL_CreateRGBSurface(SDL_SWSURFACE, image->w, image->h, 32, |
| 62 | + image->format->Rmask, image->format->Gmask, |
| 63 | + image->format->Bmask, image->format->Amask); |
| 64 | + SDL_BlitSurface(image, NULL, image_rgb_RGBA32b, NULL); |
| 65 | + SDL_FreeSurface(image); |
| 66 | + |
| 67 | + /* Resize image */ |
| 68 | + SDL_Surface *image_RGBA32b_resized = zoomSurface(image_rgb_RGBA32b, hw_surface->w, hw_surface->h); |
| 69 | + SDL_FreeSurface(image_rgb_RGBA32b); |
| 70 | + |
| 71 | + /* Blit image */ |
| 72 | + SDL_BlitSurface(image_RGBA32b_resized, NULL, hw_surface, NULL); |
| 73 | + SDL_FreeSurface(image_RGBA32b_resized); |
| 74 | + |
| 75 | + /// -------- Main loop --------- |
| 76 | + while (!stop_menu_loop) |
| 77 | + { |
| 78 | + /// -------- Handle Keyboard Events --------- |
| 79 | + while (SDL_PollEvent(&event)) |
| 80 | + switch(event.type) |
| 81 | + { |
| 82 | + case SDL_QUIT: |
| 83 | + stop_menu_loop = 1; |
| 84 | + break; |
| 85 | + case SDL_KEYDOWN: |
| 86 | + switch (event.key.keysym.sym) |
| 87 | + { |
| 88 | + case SDLK_m: |
| 89 | + stop_menu_loop = 1; |
| 90 | + res = ERROR_MANUAL_FAIL; |
| 91 | + break; |
| 92 | + |
| 93 | + case SDLK_n: |
| 94 | + case SDLK_ESCAPE: |
| 95 | + stop_menu_loop = 1; |
| 96 | + res = 0; |
| 97 | + break; |
| 98 | + |
| 99 | + default: |
| 100 | + break; |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + /* To investigate but with Buildroot, we need this: */ |
| 105 | + SDL_Flip(hw_surface); |
| 106 | + |
| 107 | + /* Sleep for some time */ |
| 108 | + SDL_Delay(SLEEP_PERIOD_MS); |
| 109 | + } |
| 110 | + |
| 111 | + return res; |
| 112 | +} |
| 113 | + |
0 commit comments