-
Notifications
You must be signed in to change notification settings - Fork 1
/
WS2812B.ino
74 lines (52 loc) · 1.81 KB
/
WS2812B.ino
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
#include <Adafruit_NeoPixel.h>
#define LED_PIN 33
#define LED_COUNT 3
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
uint8_t ws2_module_num;
enum ColorName {
BLACK = 0x0000,
BLUE = 0x001F,
RED = 0xF800,
GREEN = 0x07E0,
CYAN = 0x07FF,
MAGENTA = 0xF81F,
YELLOW = 0xFFE0,
WHITE = 0xFFFF
};
bool ws2812_boot ( uint8_t mybootnum ) {
ws2_module_num = mybootnum;
//tcaselect(TCA_SI7);
//if (!si7021.begin()) return false;
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.setBrightness(20); // Set BRIGHTNESS to about 1/5 (max = 255)
strip.fill(0, 0, 3);
strip.show(); // Turn OFF all pixels ASAP
return true;
}
void ws2812_read () {
if (!ModuleData[ws2_module_num].Register.ModuleDetected) return;
//tcaselect(TCA_SI7);
//SensorData.si7021Data.temperature = si7021.readTemperature();
//SensorData.si7021Data.humidity = si7021.readHumidity();
}
void ws2812_print () {
//printf( "SI7: T[%.2f] H[%.2f] \n", SensorData.si7021Data.temperature, SensorData.si7021Data.humidity );
strip.setPixelColor(0, 0, 0, 40);
strip.setPixelColor(1, 0, 40, 0);
strip.setPixelColor(2, 40, 0, 0);
strip.setPixelColor(0, BLUE);
strip.setPixelColor(1, GREEN);
strip.setPixelColor(2, RED);
strip.show();
}
void ws2812_SetRGB(uint8_t n, uint8_t r, uint8_t g, uint8_t b) {
strip.setPixelColor(n, g, r, b);
printf("WS2: RGB set.\n");
strip.show();
}
void ws2812_SetIntensity(uint8_t Intensity) {
strip.setBrightness(Intensity); // Set BRIGHTNESS to about 1/5 (max = 255)
printf("WS2: Intensity set.\n");
strip.show(); // Turn OFF all pixels ASAP
}
// usar a ColorHSV para funçoes do mpu9550