Skip to content

Commit c22119a

Browse files
committed
added BRIGHTNESS validation screen
1 parent 3c3fc40 commit c22119a

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ S_FILES=funkey_prod_screens.c \
33
prodScreen_failScreen.c \
44
prodScreen_waitBattery.c \
55
prodScreen_displayTest.c \
6+
prodScreen_brightnessTest.c \
67
prodScreen_buttonsTest.c \
78
prodScreen_speakerTest.c \
89
prodScreen_ledTest.c \

funkey_prod_screens.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static s_prod_test prod_tests[] = {
1919
{"FAIL", launch_prod_screen_fail, 0},
2020
{"WAIT_BATTERY", launch_prod_screen_waitbattery, 0},
2121
{"DISPLAY", launch_prod_screen_display, 0},
22+
{"BRIGHTNESS", launch_prod_screen_brightness, 0},
2223
{"BUTTONS", launch_prod_screen_buttons, 0},
2324
{"SPEAKER", launch_prod_screen_speaker, 0},
2425
{"LED", launch_prod_screen_LED, 0},

funkey_prod_screens.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "prodScreen_failScreen.h"
1010
#include "prodScreen_waitBattery.h"
1111
#include "prodScreen_displayTest.h"
12+
#include "prodScreen_brightnessTest.h"
1213
#include "prodScreen_buttonsTest.h"
1314
#include "prodScreen_speakerTest.h"
1415
#include "prodScreen_ledTest.h"

prodScreen_brightnessTest.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#include "funkey_prod_screens.h"
2+
3+
4+
/// -------------- FUNCTIONS IMPLEMENTATION --------------
5+
static int wait_event_loop(){
6+
7+
SDL_Event event;
8+
int stop_menu_loop = 0;
9+
int res = EXIT_FAILURE;
10+
11+
/// -------- Main loop ---------
12+
while (!stop_menu_loop)
13+
{
14+
/// -------- Handle Keyboard Events ---------
15+
while (SDL_PollEvent(&event))
16+
switch(event.type)
17+
{
18+
case SDL_QUIT:
19+
stop_menu_loop = 1;
20+
break;
21+
case SDL_KEYDOWN:
22+
switch (event.key.keysym.sym)
23+
{
24+
25+
case SDLK_m:
26+
stop_menu_loop = 1;
27+
res = ERROR_MANUAL_FAIL;
28+
break;
29+
30+
case SDLK_n:
31+
case SDLK_ESCAPE:
32+
stop_menu_loop = 1;
33+
res = 0;
34+
break;
35+
36+
default:
37+
break;
38+
}
39+
}
40+
41+
/* To inverstigate but with Buildroot, we need this: */
42+
SDL_Flip(hw_surface);
43+
44+
/* Sleep for some time */
45+
SDL_Delay(SLEEP_PERIOD_MS);
46+
}
47+
48+
return res;
49+
}
50+
51+
int launch_prod_screen_brightness(int argc, char *argv[]){
52+
SDL_Surface *text_surface = NULL;
53+
SDL_Rect text_pos;
54+
55+
/* Fill screen white */
56+
SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format, bg_color.r, bg_color.g, bg_color.b, 0) );
57+
58+
/* Write Title */
59+
text_surface = TTF_RenderText_Shaded(font_title, "FunKey PCBA Tests", text_color, bg_color);
60+
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2;
61+
text_pos.y = Y_PADDING;
62+
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
63+
SDL_FreeSurface(text_surface);
64+
65+
/* Write "SPEAKER ok ? */
66+
text_surface = TTF_RenderText_Shaded(font_title, "BRIGHTNESS OK ?", text_color, bg_color);
67+
text_pos.x = SCREEN_HORIZONTAL_SIZE/2 - text_surface->w/2;
68+
text_pos.y = SCREEN_VERTICAL_SIZE/2 - text_surface->h/2;
69+
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
70+
SDL_FreeSurface(text_surface);
71+
72+
/* Write:
73+
"Press
74+
L=FAIL
75+
*/
76+
SDL_Color red_color={220,20,20};
77+
text_surface = TTF_RenderText_Shaded(font_info, "Press", red_color, bg_color);
78+
text_pos.x = X_PADDING;
79+
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h;
80+
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
81+
SDL_FreeSurface(text_surface);
82+
text_surface = TTF_RenderText_Shaded(font_info, "L=FAIL", red_color, bg_color);
83+
text_pos.x = X_PADDING;
84+
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h;
85+
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
86+
SDL_FreeSurface(text_surface);
87+
88+
/* Write:
89+
Press
90+
R=OK"
91+
*/
92+
SDL_Color green_color={20,220,20};
93+
text_surface = TTF_RenderText_Shaded(font_info, "Press", green_color, bg_color);
94+
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING;
95+
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - 2*text_surface->h;
96+
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
97+
SDL_FreeSurface(text_surface);
98+
text_surface = TTF_RenderText_Shaded(font_info, "R=OK", green_color, bg_color);
99+
text_pos.x = SCREEN_HORIZONTAL_SIZE - text_surface->w - X_PADDING;
100+
text_pos.y = SCREEN_VERTICAL_SIZE - Y_PADDING - text_surface->h;
101+
SDL_BlitSurface(text_surface, NULL, hw_surface, &text_pos);
102+
SDL_FreeSurface(text_surface);
103+
104+
/* Render screen */
105+
//SDL_Flip(hw_surface);
106+
107+
///
108+
int res = wait_event_loop();
109+
return res;
110+
}

prodScreen_brightnessTest.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef __PROD_SCREEN_BRIGHTNESS__
2+
#define __PROD_SCREEN_BRIGHTNESS__
3+
4+
int launch_prod_screen_brightness(int argc, char *argv[]);
5+
6+
#endif //__PROD_SCREEN_BRIGHTNESS__

0 commit comments

Comments
 (0)