Skip to content

Commit

Permalink
[lcd-ltdc-demo] draft-update: some coding style fixes, thx chuckmcm
Browse files Browse the repository at this point in the history
forgot to remove pedantic..
  • Loading branch information
h2obrain committed Aug 13, 2016
1 parent 4a85fe2 commit dec18b2
Show file tree
Hide file tree
Showing 7 changed files with 666 additions and 562 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
OBJS = clock.o gfx_locm3.o lcd_ili9341.o sdram.o fonts/Tamsyn5x9b_9.o fonts/Tamsyn5x9r_9.o
OBJS = clock.o gfx_locm3.o lcd_ili9341.o sdram.o
OBJS += fonts/Tamsyn5x9b_9.o fonts/Tamsyn5x9r_9.o
OBJS += vector_gfx/bezier.o
OBJS += i2c.o touchscreen_controller_stmpe811.o

BINARY = application

CFLAGS = -O0 -g
CFLAGS = -O3 -g

# we use sin/cos from the library
LDLIBS = -lm
Expand Down
53 changes: 26 additions & 27 deletions examples/stm32/f4/stm32f429i-discovery/lcd-ltdc-touch/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ stmpe811_drag_data_t drag_data;
point2d_t touch_point;
point2d_t drag_distance;

static inline
static
void
update_touchscreen_data(void)
{
Expand Down Expand Up @@ -118,7 +118,7 @@ update_touchscreen_data(void)
}
}
}
static inline
static
void
print_touchscreen_data(int16_t x, int16_t y)
{
Expand All @@ -136,6 +136,9 @@ print_touchscreen_data(int16_t x, int16_t y)
case STMPE811_TOUCH_STATE__TOUCHED_WAITING_FOR_TIMEOUT:
state = "touched waiting";
break;
default:
state = "invalid";
break;
}

sprintf(conv_buf,
Expand Down Expand Up @@ -163,7 +166,7 @@ print_touchscreen_data(int16_t x, int16_t y)
#define FROWNY_WIDTH 101
#define FROWNY_HEIGHT 121
uint16_t frowny[FROWNY_WIDTH * FROWNY_HEIGHT];
static inline void init_floodfill4(void)
static void init_floodfill4(void)
{
/* init flood-fill (also offscreen rendering demo) */
gfx_offscreen_rendering_begin(frowny, FROWNY_WIDTH, FROWNY_HEIGHT);
Expand Down Expand Up @@ -207,9 +210,9 @@ static inline void init_floodfill4(void)
/* resume normal rendering */
gfx_offscreen_rendering_end();
}
static inline void draw_floodfill4(demo_mode_t demo_mode)
static void draw_floodfill4(demo_mode_t demo_mode)
{
int16_t x, y;
int16_t x, y, px,py;
static int16_t scan_x = -1, scan_y = -1;

switch (demo_mode) {
Expand Down Expand Up @@ -260,8 +263,8 @@ static inline void draw_floodfill4(demo_mode_t demo_mode)
}

/* Worst case dots */
for (int16_t px = x+1; px < x+100; px += 4) {
for (int16_t py = y+1; py < y+120; py += 2) {
for (px = x+1; px < x+100; px += 4) {
for (py = y+1; py < y+120; py += 2) {
gfx_draw_pixel(px, py, GFX_COLOR_GREEN2);
gfx_draw_pixel(px+2, py+1, GFX_COLOR_GREEN2);
}
Expand Down Expand Up @@ -295,20 +298,19 @@ static inline void draw_floodfill4(demo_mode_t demo_mode)
* Bezier demonstration
*/
uint16_t color = GFX_COLOR_BLACK;
void draw_segment(point2d_t p1, point2d_t p2);
void draw_segment(point2d_t p1, point2d_t p2)
static void draw_segment(point2d_t p1, point2d_t p2)
{
gfx_draw_line(
(int16_t)p1.x, (int16_t)p1.y,
(int16_t)p2.x, (int16_t)p2.y,
color
);
}
static inline
void draw_point_list(point2d_t *points, size_t points_count, uint16_t _color)
static void draw_point_list(point2d_t *points, size_t points_count, uint16_t _color)
{
unsigned int i;
color = _color;
for (size_t i = 0; i < points_count-1; i++) {
for (i = 0; i < points_count-1; i++) {
draw_segment(points[i], points[i+1]);
}
}
Expand All @@ -335,14 +337,14 @@ point2d_t pentagram[] = {
};
uint32_t num_points;
uint32_t num_ipoints;
static inline void init_bezier(void)
static void init_bezier(void)
{
num_points = sizeof(pentagram)/sizeof(pentagram[0]);
num_ipoints = h2_bezier_calculate_int_points_length(num_points);
num_ipoints = bezier_calculate_int_points_length(num_points);
}
#define TENSION_MIN 0.15f
#define TENSION_MAX 3.0f
static inline void draw_bezier(demo_mode_t demo_mode)
static void draw_bezier(demo_mode_t demo_mode)
{
switch (demo_mode) {
case DEMO_MODE_ALL:
Expand Down Expand Up @@ -451,9 +453,9 @@ static inline void draw_bezier(demo_mode_t demo_mode)
tension_change = 1/tension_change;
}
point2d_t pi1[num_ipoints];
h2_bezier_cubic(pi1, pentagram_, num_points, 0.0001f, tension);
bezier_cubic(pi1, pentagram_, num_points, 0.0001f, tension);
for (i = 0; i < num_ipoints-1; i += 3) {
h2_bezier_draw_cubic(
bezier_draw_cubic(
draw_segment,
15,
pi1[i],
Expand All @@ -468,7 +470,7 @@ static inline void draw_bezier(demo_mode_t demo_mode)
* Bezier interactive demo
*/

static inline void draw_bezier_interactive(demo_mode_t demo_mode)
static void draw_bezier_interactive(demo_mode_t demo_mode)
{
switch (demo_mode) {
case DEMO_MODE_ALL:
Expand Down Expand Up @@ -526,7 +528,7 @@ static inline void draw_bezier_interactive(demo_mode_t demo_mode)

/* draw bezier */
color = GFX_COLOR_RED;
h2_bezier_draw_cubic(
bezier_draw_cubic(
draw_segment,
20,
curve_points[0],
Expand Down Expand Up @@ -564,7 +566,7 @@ static inline void draw_bezier_interactive(demo_mode_t demo_mode)
balls_t ball_simulation;
ball_t balls[100];
uint64_t ball_timeout;
static inline void init_balls(void)
static void init_balls(void)
{
ball_setup(
&ball_simulation,
Expand Down Expand Up @@ -608,9 +610,7 @@ static inline void init_balls(void)

ball_timeout = mtime() + 5000;
}
static inline
void
draw_balls(demo_mode_t demo_mode)
static void draw_balls(demo_mode_t demo_mode)
{
uint64_t ctime = mtime();
switch (demo_mode) {
Expand Down Expand Up @@ -646,17 +646,16 @@ draw_balls(demo_mode_t demo_mode)
/**
* Re-/draw background
*/
static inline
void
draw_background(demo_mode_t demo_mode)
static void draw_background(demo_mode_t demo_mode)
{
ili9341_set_layer1();

gfx_fill_screen(GFX_COLOR_BLACK);

gfx_draw_rect(0, 0, gfx_width() , 40 , GFX_COLOR_DARKGREY);
gfx_fill_rect(1, 1, gfx_width()-2, 40-2,
ltdc_get_rgb565_from_rgb888(0x111111));
((0x11 << 11) | (0x11 << 5) | 0x11));
/* ltdc_get_rgb565_from_rgb888(0x111111));*/

gfx_set_font_scale(3);
gfx_puts2(10, 10, "äLTDC Demo", &font_Tamsyn5x9b_9 , GFX_COLOR_WHITE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@

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

typedef union {
struct { int16_t x, y; };
struct { int16_t w, h; };
} gfx_vec2_t;

/*
* Python
* def get_rgb565(x) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static inline
uint16_t*
ili9341_get_current_layer_buffer_address(void) {
return __gfx_state.surface;
};
}

/* Flip the double_buffer */
void ili9341_flip_layer1_buffer(void);
Expand Down
Loading

0 comments on commit dec18b2

Please sign in to comment.