Skip to content

Commit 75520e7

Browse files
committed
added tearing test
1 parent 040c319 commit 75520e7

File tree

6 files changed

+84
-2
lines changed

6 files changed

+84
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ prodScreen_ledTest.c \
1010
prodScreen_magnetTest.c \
1111
prodScreen_validation.c \
1212
prodScreen_showImage.c \
13+
prodScreen_tearingTest.c \
1314
prodScreen_gamma.c
1415

1516
# Output

funkey_prod_screens.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ static s_prod_test prod_tests[] = {
2727
{"MAGNET", launch_prod_screen_magnet, 0},
2828
{"VALIDATE", launch_prod_screen_validation, 0},
2929
{"SHOW_IMAGE", launch_prod_screen_showImage, 1},
30-
{"GAMMA", launch_prod_screen_gamma, 0}
30+
{"GAMMA", launch_prod_screen_gamma, 0},
31+
{"TEARING", launch_prod_screen_tearingtest, 0}
3132
};
3233
static int idx_current_prod_test = 0;
3334

funkey_prod_screens.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "prodScreen_validation.h"
1818
#include "prodScreen_showImage.h"
1919
#include "prodScreen_gamma.h"
20+
#include "prodScreen_tearingTest.h"
2021

2122

2223
/// Defines

prodScreen_tearingTest.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
#include <SDL/SDL.h>
4+
#include <SDL/SDL_ttf.h>
5+
//#include <SDL/SDL_image.h>
6+
#include "funkey_prod_screens.h"
7+
8+
static int bright = 0;
9+
10+
/// -------------- FUNCTIONS IMPLEMENTATION --------------
11+
static int wait_event_loop(){
12+
13+
SDL_Event event;
14+
int stop_menu_loop = 0;
15+
int prev_ms = 0;
16+
int res = EXIT_FAILURE;
17+
18+
/// -------- Main loop ---------
19+
while (!stop_menu_loop)
20+
{
21+
/// -------- Handle Keyboard Events ---------
22+
while (SDL_PollEvent(&event))
23+
switch(event.type)
24+
{
25+
case SDL_QUIT:
26+
stop_menu_loop = 1;
27+
break;
28+
case SDL_KEYDOWN:
29+
switch (event.key.keysym.sym)
30+
{
31+
32+
case SDLK_m:
33+
stop_menu_loop = 1;
34+
res = ERROR_MANUAL_FAIL;
35+
break;
36+
37+
case SDLK_n:
38+
case SDLK_ESCAPE:
39+
stop_menu_loop = 1;
40+
res = 0;
41+
break;
42+
43+
default:
44+
break;
45+
}
46+
}
47+
48+
/* Fill screen random */
49+
SDL_Color current_color = {rand() % 128 + 128*bright,
50+
rand() % 256 + 128*bright,
51+
rand() % 256 + 128*bright};
52+
SDL_FillRect(hw_surface, NULL, SDL_MapRGBA(hw_surface->format,
53+
current_color.r, current_color.g, current_color.b, 0) );
54+
bright = 1-bright;
55+
56+
/* To investigate but with Buildroot, we need this: */
57+
SDL_Flip(hw_surface);
58+
59+
/* Sleep for some time */
60+
//SDL_Delay(SLEEP_PERIOD_MS);
61+
}
62+
63+
return res;
64+
}
65+
66+
int launch_prod_screen_tearingtest(int argc, char *argv[]){
67+
SDL_Surface *text_surface = NULL;
68+
SDL_Rect text_pos;
69+
70+
/// Main loop
71+
int res = wait_event_loop();
72+
return res;
73+
}

prodScreen_tearingTest.h

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

prodScreen_waitBattery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int wait_event_loop(){
6666
}
6767
}
6868

69-
/* To inverstigate but with Buildroot, we need this: */
69+
/* To investigate but with Buildroot, we need this: */
7070
SDL_Flip(hw_surface);
7171

7272
if(SDL_GetTicks() - prev_ms > CHECK_BATTERY_DELAY_MS){

0 commit comments

Comments
 (0)