Skip to content

Commit 040c319

Browse files
committed
added gamma_test
1 parent cb331d8 commit 040c319

File tree

11 files changed

+131
-6
lines changed

11 files changed

+131
-6
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ prodScreen_speakerTest.c \
99
prodScreen_ledTest.c \
1010
prodScreen_magnetTest.c \
1111
prodScreen_validation.c \
12-
prodScreen_showImage.c
12+
prodScreen_showImage.c \
13+
prodScreen_gamma.c
1314

1415
# Output
1516
EXEC=funkey_prod_screens

ProdResources/background2.png

22 KB
Loading

ProdResources/color_chart.png

10.6 KB
Loading

ProdResources/gamegear.png

66.3 KB
Loading

ProdResources/gba.png

72.3 KB
Loading

funkey_prod_screens.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ static s_prod_test prod_tests[] = {
2626
{"LED", launch_prod_screen_LED, 0},
2727
{"MAGNET", launch_prod_screen_magnet, 0},
2828
{"VALIDATE", launch_prod_screen_validation, 0},
29-
{"SHOW_IMAGE", launch_prod_screen_showImage, 1}
29+
{"SHOW_IMAGE", launch_prod_screen_showImage, 1},
30+
{"GAMMA", launch_prod_screen_gamma, 0}
3031
};
3132
static int idx_current_prod_test = 0;
3233

funkey_prod_screens.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "prodScreen_magnetTest.h"
1717
#include "prodScreen_validation.h"
1818
#include "prodScreen_showImage.h"
19+
#include "prodScreen_gamma.h"
1920

2021

2122
/// Defines
@@ -42,10 +43,6 @@
4243
#define FONT_NAME_INFO FONT_NAME_TITLE
4344
#define FONT_SIZE_INFO 18
4445

45-
#define IMG_CONSOLE_LAYOUT FOLDER_RESSOURCES"/funkey_with_buttons.png"
46-
#define IMG_BUTTON_LR_GREEN FOLDER_RESSOURCES"/button_LR_green.png"
47-
#define IMG_BUTTON_NORMAL_GREEN FOLDER_RESSOURCES"/button_round_green.png"
48-
4946
typedef struct
5047
{
5148
char *cmd_line_argument;

prodScreen_buttonsTest.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef __PROD_SCREEN_BUTTONS__
22
#define __PROD_SCREEN_BUTTONS__
33

4+
#define IMG_CONSOLE_LAYOUT FOLDER_RESSOURCES"/funkey_with_buttons.png"
5+
#define IMG_BUTTON_LR_GREEN FOLDER_RESSOURCES"/button_LR_green.png"
6+
#define IMG_BUTTON_NORMAL_GREEN FOLDER_RESSOURCES"/button_round_green.png"
7+
48
int launch_prod_screen_buttons(int argc, char *argv[]);
59

610
#endif //__PROD_SCREEN_BUTTONS__

prodScreen_gamma.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+

prodScreen_gamma.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __PROD_SCREEN_GAMMA__
2+
#define __PROD_SCREEN_GAMMA__
3+
4+
#define IMG_CONSOLE_COLOR_CHART FOLDER_RESSOURCES"/color_chart.png"
5+
6+
int launch_prod_screen_gamma(int argc, char *argv[]);
7+
8+
#endif //__PROD_SCREEN_GAMMA__

0 commit comments

Comments
 (0)