优化xbox,盖世小鸡蓝牙手柄控制,增加动作集控制

This commit is contained in:
myperworld committed 2025-10-17 13:18:12 +08:00
1 parent 9cc5186a58
commit e33a6b894d
10 files changed
+606 -356

No files matched your search

@@ -0,0 +1,50 @@
/* ---------------------------------
* LED 控制模块实现
------------------------------------- */
#include "RGBController.h"
// LED 全局变量定义(与主文件解耦)
CRGB leds[NUM_LEDS];
unsigned long previousBlinkMillis = 0;
int blinkState = 0;
int blinkCount = 0;
bool isBlinking = false;
CRGB blinkColors[6] = {CRGB::Red, CRGB::Red, CRGB::Yellow, CRGB::Yellow, CRGB::Green, CRGB::Green};
// 初始化LED(替代原setup中的FastLED初始化代码)
void initLEDs() {
FastLED.addLeds<WS2812, RGB_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
fill_solid(leds, NUM_LEDS, CRGB::Black); // 初始熄灭
FastLED.show();
}
// 处理LED闪烁逻辑(原handleLEDBlink函数,逻辑不变)
void handleLEDBlink() {
if (!isBlinking) return;
unsigned long currentMillis = millis();
if (currentMillis - previousBlinkMillis >= 100) {
previousBlinkMillis = currentMillis;
if (blinkState == 0) {
fill_solid(leds, NUM_LEDS, blinkColors[blinkCount]);
FastLED.show();
blinkState = 1;
} else {
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
blinkState = 0;
blinkCount++;
if (blinkCount >= 6) {
isBlinking = false;
blinkCount = 0;
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
}
}
}
}