Skip to content

Commit ee77593

Browse files
committed
Merge branch 'master' of github.com:m5stack/M5Stack into master
2 parents 5f688d2 + 4e8896f commit ee77593

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed

examples/Basics/FactoryTest/FactoryTest.ino

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#include <Arduino.h>
12
#include <M5Stack.h>
3+
#include <stdlib.h>
4+
//#include "FastLED.h"
25

36
#include "WiFi.h"
47
#include "utility/MPU9250.h"
@@ -12,6 +15,11 @@ extern const unsigned char m5stack_startup_music[];
1215

1316
MPU9250 IMU;
1417

18+
19+
// #define LEDS_PIN 15
20+
// #define LEDS_NUM 10
21+
// CRGB ledsBuff[LEDS_NUM];
22+
1523
void startupLogo() {
1624
static uint8_t brightness, pre_brightness;
1725
uint32_t length = strlen((char *)m5stack_startup_music);
@@ -120,20 +128,53 @@ void writeFile(fs::FS &fs, const char *path, const char *message) {
120128
}
121129

122130
void buttons_test() {
123-
if (M5.BtnA.wasPressed()) {
131+
if (M5.BtnA.wasReleased() || M5.BtnA.pressedFor(1000, 200)) {
124132
M5.Lcd.printf("A");
125133
Serial.printf("A");
126134
}
127-
if (M5.BtnB.wasPressed()) {
135+
if (M5.BtnB.wasReleased() || M5.BtnB.pressedFor(1000, 200)) {
128136
M5.Lcd.printf("B");
129137
Serial.printf("B");
130138
}
131-
if (M5.BtnC.wasPressed()) {
139+
if (M5.BtnC.wasReleased() || M5.BtnC.pressedFor(1000, 200)) {
132140
M5.Lcd.printf("C");
133141
Serial.printf("C");
134142
}
135143
}
136144

145+
static byte c1;
146+
147+
byte utf8ascii(byte ascii) {
148+
if ( ascii<128 ) // Standard ASCII-set 0..0x7F handling
149+
{ c1=0;
150+
return( ascii );
151+
}
152+
153+
// get previous input
154+
byte last = c1; // get last char
155+
c1=ascii; // remember actual character
156+
157+
switch (last) // conversion depending on first UTF8-character
158+
{ case 0xC2: return (ascii); break;
159+
case 0xC3: return (ascii | 0xC0); break;
160+
case 0x82: if(ascii==0xAC) return(0x80); // special case Euro-symbol
161+
}
162+
163+
return (0); // otherwise: return zero, if character has to be ignored
164+
}
165+
166+
String utf8ascii(String s)
167+
{
168+
String r="";
169+
char c;
170+
for (int i=0; i<s.length(); i++)
171+
{
172+
c = utf8ascii(s.charAt(i));
173+
if (c!=0) r+=c;
174+
}
175+
return r;
176+
}
177+
137178
void wifi_test() {
138179
WiFi.mode(WIFI_STA);
139180
WiFi.disconnect();
@@ -160,18 +201,18 @@ void wifi_test() {
160201
M5.Lcd.print(i + 1);
161202
Serial.print(": ");
162203
M5.Lcd.print(": ");
163-
Serial.print(WiFi.SSID(i));
164-
M5.Lcd.print(WiFi.SSID(i));
204+
Serial.print(WiFi.SSID(i).c_str());
205+
M5.Lcd.print(utf8ascii(WiFi.SSID(i).c_str()));
165206
Serial.print(" (");
166207
M5.Lcd.print(" (");
167208
Serial.print(WiFi.RSSI(i));
168209
M5.Lcd.print(WiFi.RSSI(i));
169210
Serial.print(")");
170211
M5.Lcd.print(")");
171212
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " "
172-
: "*");
213+
: "*");
173214
M5.Lcd.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " "
174-
: "*");
215+
: "*");
175216
delay(5);
176217
}
177218
}
@@ -409,6 +450,15 @@ unsigned long testFilledRoundRects() {
409450
return micros() - start;
410451
}
411452

453+
// void ledBar()
454+
// {
455+
// FastLED.addLeds<SK6812, LEDS_PIN>(ledsBuff, LEDS_NUM);
456+
// for (int i = 0; i < LEDS_NUM; i++) {
457+
// ledsBuff[i].setRGB(20, 20, 20);
458+
// }
459+
// FastLED.show();
460+
// }
461+
412462
// the setup routine runs once when M5Stack starts up
413463
void setup() {
414464
// gpio test
@@ -436,8 +486,8 @@ void setup() {
436486
// {
437487
// adc_test();
438488
// }
439-
440489
startupLogo();
490+
//ledBar();
441491
Wire.begin();
442492

443493
// Lcd display
@@ -629,4 +679,4 @@ void setup() {
629679
void loop() {
630680
buttons_test();
631681
M5.update();
632-
}
682+
}

0 commit comments

Comments
 (0)