1
0
mirror of synced 2024-11-27 17:11:01 +01:00

修复 NodeMCU 灯效。

This commit is contained in:
Sucareto 2021-08-15 19:56:27 +08:00
parent 507daace85
commit 1b6174d696
2 changed files with 13 additions and 15 deletions

View File

@ -62,23 +62,22 @@ void setup() {
// SerialDevice.begin(119200);//high_baudrate=true
SerialDevice.setTimeout(0);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
nfc.begin();
if (!nfc.getFirmwareVersion()) {
while (1) {
fill_solid(leds, NUM_LEDS, 0xFF0000);
FastLED[0].show(leds, NUM_LEDS, BRI);
delay(500);
fill_solid(leds, NUM_LEDS, 0x000000);
FastLED[0].show(leds, NUM_LEDS, BRI);
delay(500);
}
while (!nfc.getFirmwareVersion()) {
fill_solid(leds, NUM_LEDS, 0xFF0000);
FastLED.show();
delay(500);
fill_solid(leds, NUM_LEDS, 0x000000);
FastLED.show();
delay(500);
}
nfc.setPassiveActivationRetries(0x10);//设定等待次数
nfc.SAMConfig();
memset(&req, 0, sizeof(req.bytes));
memset(&res, 0, sizeof(res.bytes));
fill_solid(leds, NUM_LEDS, 0x0000FF);
FastLED[0].show(leds, NUM_LEDS, BRI);
FastLED.show();
}
void loop() {

9
cmd.h
View File

@ -1,7 +1,6 @@
#include "FastLED.h"
#define NUM_LEDS 6
#define DATA_PIN D5
#define BRI 50
#define DATA_PIN 14
CRGB leds[NUM_LEDS];
#include <Wire.h>
@ -139,7 +138,7 @@ static void sg_nfc_cmd_reset() {//重置读卡器
return;
}
fill_solid(leds, NUM_LEDS, 0xFFFF00);
FastLED[0].show(leds, NUM_LEDS, BRI);
FastLED.show();
}
static void sg_nfc_cmd_get_fw_version() {
@ -167,7 +166,7 @@ static void sg_led_cmd_reset() {
sg_res_init(1);
res.reset_payload = 0;
fill_solid(leds, NUM_LEDS, 0x000000);
FastLED[0].show(leds, NUM_LEDS, BRI);
FastLED.show();
}
static void sg_led_cmd_get_info() {
@ -181,7 +180,7 @@ static void sg_led_cmd_set_color() {
uint8_t g = req.color_payload[1];
uint8_t b = req.color_payload[2];
fill_solid(leds, NUM_LEDS, CRGB(r, g, b));
FastLED[0].show(leds, NUM_LEDS, BRI);
FastLED.show();
}
static void sg_nfc_cmd_radio_on() {