Skip to content

Commit e1f2cb9

Browse files
committed
Update SpiritLevel.ino.
Fix M5.dis.displaybuff() last line does not display the correct color. Example format.
1 parent 43d901f commit e1f2cb9

4 files changed

Lines changed: 30 additions & 28 deletions

File tree

examples/Advanced/WIFI/BasicHttpClient/BasicHttpClient.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ WiFiMulti wifiMulti;
2020
HTTPClient http;
2121

2222
void setup() {
23-
M5.begin(); // Init M5Atom. 初始化 M5Atom
23+
M5.begin(); // Init M5Atom. 初始化 M5Atom
2424
wifiMulti.addAP("YOUR-WIFINAME",
2525
"YOUR_WIFIPASSWORD"); // Storage wifi configuration
2626
// information. 存储wifi配置信息

examples/Basics/FactoryTest/ATOM_LITE/ATOM_LITE.ino

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,41 @@ Adafruit_NeoPixel pixels = Adafruit_NeoPixel(
88
NUMPIXELS, PIN,
99
NEO_GRB + NEO_KHZ800); // set number of LEDs, pin number, LED type.
1010
// 设置灯的数量,控制引脚编号,灯灯类型
11-
11+
1212
void setup() {
1313
M5.begin(); // Init M5Atom. 初始化 M5Atom
1414
pixels.begin(); // Init the NeoPixel library. 初始化NeoPixel库
15-
1615
}
1716

1817
void loop() {
1918
rainbow(20);
2019
}
2120

22-
2321
void rainbow(uint8_t wait) {
24-
uint16_t i, j;
25-
26-
for(j=0; j<256; j++) {
27-
for(i=0; i<pixels.numPixels(); i++) {
28-
pixels.setPixelColor(i, Wheel((i+j) & 255));
29-
while(M5.Btn.read()== 1);
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);
3032
}
31-
pixels.show();
32-
delay(wait);
33-
}
3433
}
3534

36-
3735
// Input a value 0 to 255 to get a color value.
3836
// The colours are a transition r - g - b - back to r.
3937
uint32_t Wheel(byte WheelPos) {
40-
WheelPos = 255 - WheelPos;
41-
if(WheelPos < 85) {
42-
return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
43-
}
44-
if(WheelPos < 170) {
45-
WheelPos -= 85;
46-
return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
47-
}
48-
WheelPos -= 170;
49-
return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
38+
WheelPos = 255 - WheelPos;
39+
if (WheelPos < 85) {
40+
return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
41+
}
42+
if (WheelPos < 170) {
43+
WheelPos -= 85;
44+
return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
45+
}
46+
WheelPos -= 170;
47+
return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
5048
}

examples/Basics/SpiritLevel/SpiritLevel.ino

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/atom_matrix
88
*
99
* Describe: SpiritLevel
10-
* Date: 2021/7/21
10+
* Date: 2023/8/5
1111
*******************************************************************************
12+
Shake the M5Atom and the matrix light will change with the position, you can
13+
set a new reference point by pressing the button.
14+
晃动M5Atom,矩阵灯将会随着位置的变化而变化,你可以通过按下按键来设定新的基准点位
1215
*/
1316
#include "M5Atom.h"
1417

@@ -39,6 +42,7 @@ The loop() function is an infinite loop in which the program runs repeatedly
3942
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
4043
loop()函数是一个死循环,其中的程序会不断的重复运行 */
4144
void loop() {
45+
M5.update();
4246
static float offX = 0., offY = 0.;
4347
static float smoX = 0., smoY = 0.;
4448

@@ -53,8 +57,8 @@ void loop() {
5357
smoY = ALPHA * accY + BETA * smoY;
5458

5559
if (M5.Btn.wasPressed()) { // Check if the key is pressed. 判断按键是否按下
56-
offX = smoX;
57-
offY = smoY;
60+
offX = smoX; // Set the current position as the reference point.
61+
offY = smoY; // 设定当前位置为基准点位
5862
}
5963

6064
float xc = (offX - smoX) * SENSITIVITY + 2.0;

src/utility/LED_DisPlay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LED_DisPlay : public Task {
2121
int32_t _am_count = -1;
2222
uint8_t *_am_buffptr;
2323
uint16_t _yRows = 5;
24-
uint16_t _xColumns = 6;
24+
uint16_t _xColumns = 5;
2525

2626
SemaphoreHandle_t _xSemaphore = NULL;
2727

0 commit comments

Comments
 (0)