-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatriz_leds.h
More file actions
114 lines (106 loc) · 3.11 KB
/
matriz_leds.h
File metadata and controls
114 lines (106 loc) · 3.11 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef CONFIG_MATRIZ_H
#define CONFIG_MATRIZ_H
#include "pico/stdlib.h"
#include "pio_matrix.pio.h"
#include "init_GPIO.h"
#define NUM_PIXELS 25
// pino de saída da matriz(ws2812) da placa
#define OUT_PIN 7
// variaveis para inciar a matriz
uint32_t valor_led;
double r = 0.0, b = 0.0, g = 0.0;
PIO pio = pio0;
uint offset;
uint sm;
void init_pio_matriz()
{
// Configuração da PIO, necessario para matriz
offset = pio_add_program(pio, &pio_matrix_program);
sm = pio_claim_unused_sm(pio, true);
pio_matrix_program_init(pio, sm, offset, OUT_PIN);
}
double apagar_leds[NUM_PIXELS] =
{0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0};
double num_0[NUM_PIXELS] =
{0.0, 0.35, 0.35, 0.35, 0.0,
0.35, 0.0, 0.0, 0.0, 0.35,
0.35, 0.0, 0.0, 0.0, 0.35,
0.35, 0.0, 0.0, 0.0, 0.35,
0.0, 0.35, 0.35, 0.35, 0.0};
double num_1[NUM_PIXELS] =
{0.0, 0.0, 0.2, 0.0, 0.0,
0.0, 0.0, 0.2, 0.2, 0.0,
0.2, 0.0, 0.2, 0.0, 0.0,
0.0, 0.0, 0.2, 0.0, 0.0,
0.0, 0.2, 0.2, 0.2, 0.0};
double num_2[NUM_PIXELS] =
{0.2, 0.2, 0.2, 0.2, 0.2,
0.2, 0.0, 0.0, 0.0, 0.0,
0.2, 0.2, 0.2, 0.2, 0.2,
0.0, 0.0, 0.0, 0.0, 0.2,
0.2, 0.2, 0.2, 0.2, 0.2};
double num_3[NUM_PIXELS] =
{0.0, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.0, 0.35, 0.35, 0.35, 0.35};
double num_4[NUM_PIXELS] =
{0.0, 0.35, 0.0, 0.0, 0.35,
0.35, 0.0, 0.0, 0.35, 0.0,
0.0, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.35};
double num_5[NUM_PIXELS] =
{0.35, 0.35, 0.35, 0.35, 0.35,
0.0, 0.0, 0.0, 0.0, 0.35,
0.35, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.35, 0.35, 0.35, 0.35, 0.35};
double num_6[NUM_PIXELS] =
{0.35, 0.35, 0.35, 0.35, 0.0,
0.0, 0.0, 0.0, 0.0, 0.35,
0.35, 0.35, 0.35, 0.35, 0.0,
0.35, 0.0, 0.0, 0.0, 0.35,
0.35, 0.35, 0.35, 0.35, 0.35};
double num_7[NUM_PIXELS] =
{0.35, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.35};
double num_8[NUM_PIXELS] =
{0.0, 0.35, 0.35, 0.35, 0.0,
0.35, 0.0, 0.0, 0.0, 0.35,
0.35, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.35,
0.0, 0.35, 0.35, 0.35, 0.0};
double num_9[NUM_PIXELS] =
{0.35, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.35,
0.35, 0.35, 0.35, 0.35, 0.35,
0.35, 0.0, 0.0, 0.0, 0.0,
0.0, 0.35, 0.35, 0.35, 0.35};
// rotina para definição da intensidade de cores do led
uint32_t matrix_rgb(double b, double r, double g)
{
unsigned char R, G, B;
R = r * 255;
G = g * 255;
B = b * 255;
return (G << 24) | (R << 16) | (B << 8);
}
// rotinas para acionar a matrix de leds - ws2812b
void liga_matriz(double *desenho, uint32_t valor_led, PIO pio, uint sm, double r, double g, double b)
{
for (int16_t i = 0; i < NUM_PIXELS; i++)
{
valor_led = matrix_rgb(desenho[24 - i], r = 0.0, g = 0.0);
pio_sm_put_blocking(pio, sm, valor_led);
}
}
#endif