Skip to content

Commit 4e3f357

Browse files
authored
Update ATOM_LITE.ino
fixed loop()'s position
1 parent 4717fcf commit 4e3f357

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <M5Atom.h>
1+
#include <M5Atom.h>
22
#include <Adafruit_NeoPixel.h>
33

44
#define PIN 27 //定义NeoPixel的控制引脚
@@ -14,24 +14,6 @@ void setup() {
1414
pixels.begin(); // Init the NeoPixel library. 初始化NeoPixel库
1515
}
1616

17-
void loop() {
18-
rainbow(20);
19-
}
20-
21-
void rainbow(uint8_t wait) {
22-
uint16_t i, j;
23-
24-
for (j = 0; j < 256; j++) {
25-
for (i = 0; i < pixels.numPixels(); i++) {
26-
pixels.setPixelColor(i, Wheel((i + j) & 255));
27-
while (M5.Btn.read() == 1)
28-
;
29-
}
30-
pixels.show();
31-
delay(wait);
32-
}
33-
}
34-
3517
// Input a value 0 to 255 to get a color value.
3618
// The colours are a transition r - g - b - back to r.
3719
uint32_t Wheel(byte WheelPos) {
@@ -46,3 +28,21 @@ uint32_t Wheel(byte WheelPos) {
4628
WheelPos -= 170;
4729
return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
4830
}
31+
32+
void rainbow(uint8_t wait) {
33+
uint16_t i, j;
34+
35+
for (j = 0; j < 256; j++) {
36+
for (i = 0; i < pixels.numPixels(); i++) {
37+
pixels.setPixelColor(i, Wheel((i + j) & 255));
38+
while (M5.Btn.read() == 1)
39+
;
40+
}
41+
pixels.show();
42+
delay(wait);
43+
}
44+
}
45+
46+
void loop() {
47+
rainbow(20);
48+
}

0 commit comments

Comments
 (0)