-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.c
58 lines (52 loc) · 1.92 KB
/
screen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* screen.c
*
* Created: 05.05.2013 16:59:39
* Author: Christoph
*/
#include "screen.h"
uint8_t screen_data[SCREEN_WIDTH * SCREEN_HEIGHT * 3];
uint8_t gamma_table[] ={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 2,
2, 2, 2, 2, 3, 3, 3, 3, 3, 4,
4, 4, 4, 5, 5, 5, 5, 6, 6, 6,
7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 12, 12, 13, 13, 13, 14,
14, 15, 15, 16, 16, 17, 17, 18, 18, 19,
19, 20, 21, 21, 22, 22, 23, 23, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 31,
32, 33, 33, 34, 35, 36, 36, 37, 38, 39,
40, 40, 41, 42, 43, 44, 45, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 55, 56,
57, 58, 59, 60, 61, 62, 63, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 77, 78,
79, 80, 81, 82, 84, 85, 86, 87, 88, 90,
91, 92, 93, 95, 96, 97, 99, 100, 101, 103,
104, 105, 107, 108, 109, 111, 112, 114, 115, 117,
118, 119, 121, 122, 124, 125, 127, 128, 130, 131,
133, 135, 136, 138, 139, 141, 142, 144, 146, 147,
149, 151, 152, 154, 156, 157, 159, 161, 162, 164,
166, 168, 169, 171, 173, 175, 176, 178, 180, 182,
184, 186, 187, 189, 191, 193, 195, 197, 199, 201,
203, 205, 207, 209, 211, 213, 215, 217, 219, 221,
223, 225, 227, 229, 231, 233, 235, 237, 239, 241,
244, 246, 248, 250, 252, 255
};
void screen_setPixel(uint8_t x, uint8_t y, uint8_t r, uint8_t g, uint8_t b) {
screen_data[(x * 3) + (y * SCREEN_WIDTH * 3) + 0] =gamma_table[r];
screen_data[(x * 3) + (y * SCREEN_WIDTH * 3) + 1] =gamma_table[g];
screen_data[(x * 3) + (y * SCREEN_WIDTH * 3) + 2] =gamma_table[b];
}
void screen_show() {
for(uint8_t x =0;x <SCREEN_WIDTH;x++) {
for(uint8_t y =0;y <SCREEN_HEIGHT;y++) {
ws2803_setPixel(screen_data[(x * 3) + (y * SCREEN_WIDTH * 3) + 0], screen_data[(x * 3) + (y * SCREEN_WIDTH * 3) + 1], screen_data[(x * 3) + (y * SCREEN_WIDTH * 3) + 2]);
}
}
for(int16_t i =0;i <(WS2803_NUM_ICS * 6) - (SCREEN_WIDTH * SCREEN_HEIGHT);i++) {
ws2803_setPixel(0, 0, 0);
}
ws2803_show();
}