Skip to content

Commit

Permalink
修复 NodeMCU 灯效。
Browse files Browse the repository at this point in the history
  • Loading branch information
Sucareto committed Aug 15, 2021
1 parent 507daac commit 1b6174d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
19 changes: 9 additions & 10 deletions Arduino-Aime-Reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 4 additions & 5 deletions cmd.h
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down

0 comments on commit 1b6174d

Please sign in to comment.