Skip to content

Commit dec18b2

Browse files
committed
[lcd-ltdc-demo] draft-update: some coding style fixes, thx chuckmcm
forgot to remove pedantic..
1 parent 4a85fe2 commit dec18b2

File tree

7 files changed

+666
-562
lines changed

7 files changed

+666
-562
lines changed

examples/stm32/f4/stm32f429i-discovery/lcd-ltdc-touch/Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
OBJS = clock.o gfx_locm3.o lcd_ili9341.o sdram.o fonts/Tamsyn5x9b_9.o fonts/Tamsyn5x9r_9.o
1+
OBJS = clock.o gfx_locm3.o lcd_ili9341.o sdram.o
2+
OBJS += fonts/Tamsyn5x9b_9.o fonts/Tamsyn5x9r_9.o
3+
OBJS += vector_gfx/bezier.o
24
OBJS += i2c.o touchscreen_controller_stmpe811.o
35

46
BINARY = application
57

6-
CFLAGS = -O0 -g
8+
CFLAGS = -O3 -g
79

810
# we use sin/cos from the library
911
LDLIBS = -lm

examples/stm32/f4/stm32f429i-discovery/lcd-ltdc-touch/application.c

+26-27
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ stmpe811_drag_data_t drag_data;
8383
point2d_t touch_point;
8484
point2d_t drag_distance;
8585

86-
static inline
86+
static
8787
void
8888
update_touchscreen_data(void)
8989
{
@@ -118,7 +118,7 @@ update_touchscreen_data(void)
118118
}
119119
}
120120
}
121-
static inline
121+
static
122122
void
123123
print_touchscreen_data(int16_t x, int16_t y)
124124
{
@@ -136,6 +136,9 @@ print_touchscreen_data(int16_t x, int16_t y)
136136
case STMPE811_TOUCH_STATE__TOUCHED_WAITING_FOR_TIMEOUT:
137137
state = "touched waiting";
138138
break;
139+
default:
140+
state = "invalid";
141+
break;
139142
}
140143

141144
sprintf(conv_buf,
@@ -163,7 +166,7 @@ print_touchscreen_data(int16_t x, int16_t y)
163166
#define FROWNY_WIDTH 101
164167
#define FROWNY_HEIGHT 121
165168
uint16_t frowny[FROWNY_WIDTH * FROWNY_HEIGHT];
166-
static inline void init_floodfill4(void)
169+
static void init_floodfill4(void)
167170
{
168171
/* init flood-fill (also offscreen rendering demo) */
169172
gfx_offscreen_rendering_begin(frowny, FROWNY_WIDTH, FROWNY_HEIGHT);
@@ -207,9 +210,9 @@ static inline void init_floodfill4(void)
207210
/* resume normal rendering */
208211
gfx_offscreen_rendering_end();
209212
}
210-
static inline void draw_floodfill4(demo_mode_t demo_mode)
213+
static void draw_floodfill4(demo_mode_t demo_mode)
211214
{
212-
int16_t x, y;
215+
int16_t x, y, px,py;
213216
static int16_t scan_x = -1, scan_y = -1;
214217

215218
switch (demo_mode) {
@@ -260,8 +263,8 @@ static inline void draw_floodfill4(demo_mode_t demo_mode)
260263
}
261264

262265
/* Worst case dots */
263-
for (int16_t px = x+1; px < x+100; px += 4) {
264-
for (int16_t py = y+1; py < y+120; py += 2) {
266+
for (px = x+1; px < x+100; px += 4) {
267+
for (py = y+1; py < y+120; py += 2) {
265268
gfx_draw_pixel(px, py, GFX_COLOR_GREEN2);
266269
gfx_draw_pixel(px+2, py+1, GFX_COLOR_GREEN2);
267270
}
@@ -295,20 +298,19 @@ static inline void draw_floodfill4(demo_mode_t demo_mode)
295298
* Bezier demonstration
296299
*/
297300
uint16_t color = GFX_COLOR_BLACK;
298-
void draw_segment(point2d_t p1, point2d_t p2);
299-
void draw_segment(point2d_t p1, point2d_t p2)
301+
static void draw_segment(point2d_t p1, point2d_t p2)
300302
{
301303
gfx_draw_line(
302304
(int16_t)p1.x, (int16_t)p1.y,
303305
(int16_t)p2.x, (int16_t)p2.y,
304306
color
305307
);
306308
}
307-
static inline
308-
void draw_point_list(point2d_t *points, size_t points_count, uint16_t _color)
309+
static void draw_point_list(point2d_t *points, size_t points_count, uint16_t _color)
309310
{
311+
unsigned int i;
310312
color = _color;
311-
for (size_t i = 0; i < points_count-1; i++) {
313+
for (i = 0; i < points_count-1; i++) {
312314
draw_segment(points[i], points[i+1]);
313315
}
314316
}
@@ -335,14 +337,14 @@ point2d_t pentagram[] = {
335337
};
336338
uint32_t num_points;
337339
uint32_t num_ipoints;
338-
static inline void init_bezier(void)
340+
static void init_bezier(void)
339341
{
340342
num_points = sizeof(pentagram)/sizeof(pentagram[0]);
341-
num_ipoints = h2_bezier_calculate_int_points_length(num_points);
343+
num_ipoints = bezier_calculate_int_points_length(num_points);
342344
}
343345
#define TENSION_MIN 0.15f
344346
#define TENSION_MAX 3.0f
345-
static inline void draw_bezier(demo_mode_t demo_mode)
347+
static void draw_bezier(demo_mode_t demo_mode)
346348
{
347349
switch (demo_mode) {
348350
case DEMO_MODE_ALL:
@@ -451,9 +453,9 @@ static inline void draw_bezier(demo_mode_t demo_mode)
451453
tension_change = 1/tension_change;
452454
}
453455
point2d_t pi1[num_ipoints];
454-
h2_bezier_cubic(pi1, pentagram_, num_points, 0.0001f, tension);
456+
bezier_cubic(pi1, pentagram_, num_points, 0.0001f, tension);
455457
for (i = 0; i < num_ipoints-1; i += 3) {
456-
h2_bezier_draw_cubic(
458+
bezier_draw_cubic(
457459
draw_segment,
458460
15,
459461
pi1[i],
@@ -468,7 +470,7 @@ static inline void draw_bezier(demo_mode_t demo_mode)
468470
* Bezier interactive demo
469471
*/
470472

471-
static inline void draw_bezier_interactive(demo_mode_t demo_mode)
473+
static void draw_bezier_interactive(demo_mode_t demo_mode)
472474
{
473475
switch (demo_mode) {
474476
case DEMO_MODE_ALL:
@@ -526,7 +528,7 @@ static inline void draw_bezier_interactive(demo_mode_t demo_mode)
526528

527529
/* draw bezier */
528530
color = GFX_COLOR_RED;
529-
h2_bezier_draw_cubic(
531+
bezier_draw_cubic(
530532
draw_segment,
531533
20,
532534
curve_points[0],
@@ -564,7 +566,7 @@ static inline void draw_bezier_interactive(demo_mode_t demo_mode)
564566
balls_t ball_simulation;
565567
ball_t balls[100];
566568
uint64_t ball_timeout;
567-
static inline void init_balls(void)
569+
static void init_balls(void)
568570
{
569571
ball_setup(
570572
&ball_simulation,
@@ -608,9 +610,7 @@ static inline void init_balls(void)
608610

609611
ball_timeout = mtime() + 5000;
610612
}
611-
static inline
612-
void
613-
draw_balls(demo_mode_t demo_mode)
613+
static void draw_balls(demo_mode_t demo_mode)
614614
{
615615
uint64_t ctime = mtime();
616616
switch (demo_mode) {
@@ -646,17 +646,16 @@ draw_balls(demo_mode_t demo_mode)
646646
/**
647647
* Re-/draw background
648648
*/
649-
static inline
650-
void
651-
draw_background(demo_mode_t demo_mode)
649+
static void draw_background(demo_mode_t demo_mode)
652650
{
653651
ili9341_set_layer1();
654652

655653
gfx_fill_screen(GFX_COLOR_BLACK);
656654

657655
gfx_draw_rect(0, 0, gfx_width() , 40 , GFX_COLOR_DARKGREY);
658656
gfx_fill_rect(1, 1, gfx_width()-2, 40-2,
659-
ltdc_get_rgb565_from_rgb888(0x111111));
657+
((0x11 << 11) | (0x11 << 5) | 0x11));
658+
/* ltdc_get_rgb565_from_rgb888(0x111111));*/
660659

661660
gfx_set_font_scale(3);
662661
gfx_puts2(10, 10, "äLTDC Demo", &font_Tamsyn5x9b_9 , GFX_COLOR_WHITE);

examples/stm32/f4/stm32f429i-discovery/lcd-ltdc-touch/gfx_locm3.h

-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333

3434
#define swap(a, b) { int16_t t = a; a = b; b = t; }
3535

36-
typedef union {
37-
struct { int16_t x, y; };
38-
struct { int16_t w, h; };
39-
} gfx_vec2_t;
40-
4136
/*
4237
* Python
4338
* def get_rgb565(x) :

examples/stm32/f4/stm32f429i-discovery/lcd-ltdc-touch/lcd_ili9341.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static inline
177177
uint16_t*
178178
ili9341_get_current_layer_buffer_address(void) {
179179
return __gfx_state.surface;
180-
};
180+
}
181181

182182
/* Flip the double_buffer */
183183
void ili9341_flip_layer1_buffer(void);

0 commit comments

Comments
 (0)