-
Notifications
You must be signed in to change notification settings - Fork 4
/
WS2812B_Key.ino
97 lines (84 loc) · 1.57 KB
/
WS2812B_Key.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* @Description: None
* @version: V1.0.0
* @Author: None
* @Date: 2023-08-28 13:41:49
* @LastEditors: LILYGO_L
* @LastEditTime: 2023-11-22 10:16:33
* @License: GPL 3.0
*/
#include <Arduino.h>
#include "T-Keyboard_S3_Drive.h"
#include "pin_config.h"
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 4
#define DATA_PIN WS2812B_DATA
// Define the array of leds
CRGB leds[NUM_LEDS];
void WS2812B_KEY_Loop(void)
{
switch (Key1_Flag)
{
case 0:
leds[0] = CRGB::Black;
FastLED.show();
break;
case 1:
leds[0] = CRGB::White;
FastLED.show();
break;
default:
break;
}
switch (Key2_Flag)
{
case 0:
leds[1] = CRGB::Black;
FastLED.show();
break;
case 1:
leds[1] = CRGB::White;
FastLED.show();
break;
default:
break;
}
switch (Key3_Flag)
{
case 0:
leds[2] = CRGB::Black;
FastLED.show();
break;
case 1:
leds[2] = CRGB::White;
FastLED.show();
break;
default:
break;
}
switch (Key4_Flag)
{
case 0:
leds[3] = CRGB::Black;
FastLED.show();
break;
case 1:
leds[3] = CRGB::White;
FastLED.show();
break;
default:
break;
}
}
void setup()
{
Serial.begin(115200);
T_Keyboard_S3_Key_Initialization();
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); // GRB ordering is typical
FastLED.setBrightness(50);
}
void loop()
{
WS2812B_KEY_Loop();
}