Skip to content

Commit

Permalink
Merge branch 'master' of github.com:m5stack/M5Stack into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyu-Zhao committed Jul 27, 2022
2 parents 5f688d2 + 4e8896f commit ee77593
Showing 1 changed file with 59 additions and 9 deletions.
68 changes: 59 additions & 9 deletions examples/Basics/FactoryTest/FactoryTest.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <Arduino.h>
#include <M5Stack.h>
#include <stdlib.h>
//#include "FastLED.h"

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

MPU9250 IMU;


// #define LEDS_PIN 15
// #define LEDS_NUM 10
// CRGB ledsBuff[LEDS_NUM];

void startupLogo() {
static uint8_t brightness, pre_brightness;
uint32_t length = strlen((char *)m5stack_startup_music);
Expand Down Expand Up @@ -120,20 +128,53 @@ void writeFile(fs::FS &fs, const char *path, const char *message) {
}

void buttons_test() {
if (M5.BtnA.wasPressed()) {
if (M5.BtnA.wasReleased() || M5.BtnA.pressedFor(1000, 200)) {
M5.Lcd.printf("A");
Serial.printf("A");
}
if (M5.BtnB.wasPressed()) {
if (M5.BtnB.wasReleased() || M5.BtnB.pressedFor(1000, 200)) {
M5.Lcd.printf("B");
Serial.printf("B");
}
if (M5.BtnC.wasPressed()) {
if (M5.BtnC.wasReleased() || M5.BtnC.pressedFor(1000, 200)) {
M5.Lcd.printf("C");
Serial.printf("C");
}
}

static byte c1;

byte utf8ascii(byte ascii) {
if ( ascii<128 ) // Standard ASCII-set 0..0x7F handling
{ c1=0;
return( ascii );
}

// get previous input
byte last = c1; // get last char
c1=ascii; // remember actual character

switch (last) // conversion depending on first UTF8-character
{ case 0xC2: return (ascii); break;
case 0xC3: return (ascii | 0xC0); break;
case 0x82: if(ascii==0xAC) return(0x80); // special case Euro-symbol
}

return (0); // otherwise: return zero, if character has to be ignored
}

String utf8ascii(String s)
{
String r="";
char c;
for (int i=0; i<s.length(); i++)
{
c = utf8ascii(s.charAt(i));
if (c!=0) r+=c;
}
return r;
}

void wifi_test() {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Expand All @@ -160,18 +201,18 @@ void wifi_test() {
M5.Lcd.print(i + 1);
Serial.print(": ");
M5.Lcd.print(": ");
Serial.print(WiFi.SSID(i));
M5.Lcd.print(WiFi.SSID(i));
Serial.print(WiFi.SSID(i).c_str());
M5.Lcd.print(utf8ascii(WiFi.SSID(i).c_str()));
Serial.print(" (");
M5.Lcd.print(" (");
Serial.print(WiFi.RSSI(i));
M5.Lcd.print(WiFi.RSSI(i));
Serial.print(")");
M5.Lcd.print(")");
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " "
: "*");
: "*");
M5.Lcd.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " "
: "*");
: "*");
delay(5);
}
}
Expand Down Expand Up @@ -409,6 +450,15 @@ unsigned long testFilledRoundRects() {
return micros() - start;
}

// void ledBar()
// {
// FastLED.addLeds<SK6812, LEDS_PIN>(ledsBuff, LEDS_NUM);
// for (int i = 0; i < LEDS_NUM; i++) {
// ledsBuff[i].setRGB(20, 20, 20);
// }
// FastLED.show();
// }

// the setup routine runs once when M5Stack starts up
void setup() {
// gpio test
Expand Down Expand Up @@ -436,8 +486,8 @@ void setup() {
// {
// adc_test();
// }

startupLogo();
//ledBar();
Wire.begin();

// Lcd display
Expand Down Expand Up @@ -629,4 +679,4 @@ void setup() {
void loop() {
buttons_test();
M5.update();
}
}

0 comments on commit ee77593

Please sign in to comment.