Skip to content

Commit cc41021

Browse files
committed
Still working on compile error
1 parent a18725a commit cc41021

File tree

2 files changed

+61
-63
lines changed

2 files changed

+61
-63
lines changed
Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#ifndef __RGB565_DITHER_H__
22
#define __RGB565_DITHER_H__
33

4+
#include <string.h>
5+
46
#define CALC_THRESHOLD(x, y) (uint8_t)((y & 7) << 3) + (x & 7)
57

6-
uint8_t *red_thresh;
7-
uint8_t *green_thresh;
8-
uint8_t *blue_thresh;
8+
static uint8_t *red_thresh;
9+
static uint8_t *green_thresh;
10+
static uint8_t *blue_thresh;
911

1012
bool rgb565_dither_init(void);
1113

@@ -16,4 +18,60 @@
1618
((((*pixel & 0x1F) << 3) + blue_thresh[treshold_id]) >> 3));
1719
}
1820

21+
static inline bool rgb565_dither_init(void)
22+
{
23+
if (red_thresh == NULL) {
24+
red_thresh = (uint8_t *)malloc(64);
25+
if (red_thresh != NULL) {
26+
memcpy(red_thresh,
27+
(uint8_t []){
28+
1, 7, 3, 5, 0, 8, 2, 6,
29+
7, 1, 5, 3, 8, 0, 6, 2,
30+
3, 5, 0, 8, 2, 6, 1, 7,
31+
5, 3, 8, 0, 6, 2, 7, 1,
32+
0, 8, 2, 6, 1, 7, 3, 5,
33+
8, 0, 6, 2, 7, 1, 5, 3,
34+
2, 6, 1, 7, 3, 5, 0, 8,
35+
6, 2, 7, 1, 5, 3, 8, 0
36+
}, 64);
37+
}
38+
}
39+
40+
if (green_thresh == NULL) {
41+
green_thresh = (uint8_t *)malloc(64);
42+
if (green_thresh != NULL) {
43+
memcpy(green_thresh,
44+
(uint8_t []){
45+
1, 3, 2, 2, 3, 1, 2, 2,
46+
2, 2, 0, 4, 2, 2, 4, 0,
47+
3, 1, 2, 2, 1, 3, 2, 2,
48+
2, 2, 4, 0, 2, 2, 0, 4,
49+
1, 3, 2, 2, 3, 1, 2, 2,
50+
2, 2, 0, 4, 2, 2, 4, 0,
51+
3, 1, 2, 2, 1, 3, 2, 2,
52+
2, 2, 4, 0, 2, 2, 0, 4
53+
}, 64);
54+
}
55+
}
56+
if (blue_thresh == NULL) {
57+
blue_thresh = (uint8_t *)malloc(64);
58+
if (blue_thresh != NULL) {
59+
memcpy(blue_thresh,
60+
(uint8_t []){
61+
5, 3, 8, 0, 6, 2, 7, 1,
62+
3, 5, 0, 8, 2, 6, 1, 7,
63+
8, 0, 6, 2, 7, 1, 5, 3,
64+
0, 8, 2, 6, 1, 7, 3, 5,
65+
6, 2, 7, 1, 5, 3, 8, 0,
66+
2, 6, 1, 7, 3, 5, 0, 8,
67+
7, 1, 5, 3, 8, 0, 6, 2,
68+
1, 7, 3, 5, 0, 8, 2, 6
69+
}, 64);
70+
}
71+
}
72+
73+
if (red_thresh == NULL || blue_thresh == NULL || green_thresh == NULL) return false;
74+
else return true;
75+
}
76+
1977
#endif
Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,3 @@
11

2-
#include "rgb565_dither.h"
3-
#include <string.h>
4-
5-
6-
bool rgb565_dither_init(void)
7-
{
8-
if (red_thresh == NULL) {
9-
red_thresh = (uint8_t *)malloc(64);
10-
if (red_thresh != NULL) {
11-
memcpy(red_thresh,
12-
(uint8_t []){
13-
1, 7, 3, 5, 0, 8, 2, 6,
14-
7, 1, 5, 3, 8, 0, 6, 2,
15-
3, 5, 0, 8, 2, 6, 1, 7,
16-
5, 3, 8, 0, 6, 2, 7, 1,
17-
0, 8, 2, 6, 1, 7, 3, 5,
18-
8, 0, 6, 2, 7, 1, 5, 3,
19-
2, 6, 1, 7, 3, 5, 0, 8,
20-
6, 2, 7, 1, 5, 3, 8, 0
21-
}, 64);
22-
}
23-
}
24-
25-
if (green_thresh == NULL) {
26-
green_thresh = (uint8_t *)malloc(64);
27-
if (green_thresh != NULL) {
28-
memcpy(green_thresh,
29-
(uint8_t []){
30-
1, 3, 2, 2, 3, 1, 2, 2,
31-
2, 2, 0, 4, 2, 2, 4, 0,
32-
3, 1, 2, 2, 1, 3, 2, 2,
33-
2, 2, 4, 0, 2, 2, 0, 4,
34-
1, 3, 2, 2, 3, 1, 2, 2,
35-
2, 2, 0, 4, 2, 2, 4, 0,
36-
3, 1, 2, 2, 1, 3, 2, 2,
37-
2, 2, 4, 0, 2, 2, 0, 4
38-
}, 64);
39-
}
40-
}
41-
if (blue_thresh == NULL) {
42-
blue_thresh = (uint8_t *)malloc(64);
43-
if (blue_thresh != NULL) {
44-
memcpy(blue_thresh,
45-
(uint8_t []){
46-
5, 3, 8, 0, 6, 2, 7, 1,
47-
3, 5, 0, 8, 2, 6, 1, 7,
48-
8, 0, 6, 2, 7, 1, 5, 3,
49-
0, 8, 2, 6, 1, 7, 3, 5,
50-
6, 2, 7, 1, 5, 3, 8, 0,
51-
2, 6, 1, 7, 3, 5, 0, 8,
52-
7, 1, 5, 3, 8, 0, 6, 2,
53-
1, 7, 3, 5, 0, 8, 2, 6
54-
}, 64);
55-
}
56-
}
57-
58-
if (red_thresh == NULL || blue_thresh == NULL || green_thresh == NULL) return false;
59-
else return true;
60-
}
61-
622

633

0 commit comments

Comments
 (0)