Coder Social home page Coder Social logo

m5unified's Introduction

M5Unified

Arduino / ESP-IDF Library for M5Stack Series

Usage

This library provides access to the built-in hardware of M5Stack controllers. Library functionality is available through the m5 namespace, and includes the following:

  • LCD display access, fonts, and graphical primitives (in conjunction with M5GFX)
  • Touchscreen and hardware button access
  • Speaker and microphone access
  • Power and battery charging control
  • Accelerometer, gyroscope, magnetometer access
  • Real-time clock and wakeup timer access

M5Unified requires M5GFX to be installed.

How To Use

#include "M5Unified.h"

Examples and Demonstrations

In the Arduino IDE, once the M5Unified library is installed through Library Manager, the following example programs are available under File > Examples > M5Unified > Basic.

  • Combined demonstration: A demonstration exhibiting several functions in a single example is in HowToUse
Separate examples
  • Displays: A basic demonstration of printing text on each of the supported M5Stack displays is in Displays.
  • Buttons: A demo of detecting and responding to button presses is in Button.
  • Touch: A demo of detecting and reacting to touch events is in Touch.
  • Speaker: An example of playing wave audio through built-in speakers and accessories that support audio is in Speaker
  • Clock: An example of connecting to an Internet time server over WiFi and setting the built-in clock is in RTC.
  • Microphone: An example that records a short clip and plays it back through the speaker is in Microphone.
  • IMU: An example demonstrating the accelerometer / gyro / magnetometer is in IMU
  • Advanced examples include playing audio over Bluetooth and streaming and decoding MP3 audio, and are in the Advanced folder.
M5Stack hardware functionality supported by the ESP32 ecosystem

The following functionality is built in to the ESP32 framework or available elsewhere, independent of any hardware included in the M5Stack products, and do not require or have explicit support in the M5Unified library. To use these functions, simply use existing ESP32 or Arduino supporting libraries. This list is provided for the benefit of newcomers who may be asking where the "M5Unified" support for a particular feature is found, before discovering that it's either already part of the basic ESP32 platform, or a device that is generic enough (e.g. I2C or SPI) to be fully supported with generic libraries found online, including in the Arduino library manager, that work with any platform.

  • Network access using WiFi (built into ESP32)
  • Micro SD card access (SD cards are generic SPI devices)
  • Infrared remote control transmitter
  • Color-changing LED (e.g. on Atom)
Desirable examples worthy of future contribution
  • Power: A demonstration of detecting the battery level and charging state, powering off, and entering deep sleep mode when power off is unavailable.
  • Battery lifespan management: An example/utility sketch that runs the battery down to an optimum storage percentage (~40%) before powering off as fully as possible, and as a separate function, charges it to a lifespan-preserving 75% maximum, on each M5Stack device where the power management hardware supports this.
  • RTC wakeup: A demonstration of using the realtime clock to set a wakeup timer to power-on, or bring the device out of sleep mode after a pre-determined number of seconds, on devices that support this.

Supported frameworks

  • ESP-IDF
  • Arduino IDE

Supported devices (ESP32)

  • M5Stack Core (BASIC / GRAY / GO / FIRE)
  • M5Stack Core2 / Core2 v1.1 / Tough
  • M5Stick C / CPlus / CPlus2
  • M5Stack CoreInk
  • M5Station
  • M5Paper
  • M5ATOM Lite / Matrix / ECHO / PSRAM / U
  • M5STAMP PICO

Supported devices (ESP32-S3)

  • M5Stack CoreS3
  • M5ATOMS3 / S3Lite / S3U
  • M5STAMPS3
  • M5Dial
  • M5DinMeter
  • M5Capsule
  • M5Cardputer

Supported devices (ESP32-C3)

  • M5STAMPC3 / C3U

Supported devices (ESP32-C6)

  • M5NanoC6

Supported external displays and video adapters

  • Unit LCD
  • Unit OLED
  • Unit Mini OLED
  • Unit RCA
  • Unit GLASS
  • Unit GLASS2
  • ATOM Display adapter (HDMI output for M5ATOM Lite / Matrix / PSRAM / S3 / S3Lite)
  • Module Display adapter (HDMI output for M5Stack Core / Core2 / Tough)
  • Module RCA adapter (composite NTSC/PAL output for M5Stack Core / Core2 / Tough)

Supported external speakers and audio adapters

  • SPK HAT (with M5StickC / CPlus / M5Stack CoreInk)
  • SPK HAT2 (with M5StickCPlus)
  • ATOMIC SPK (with M5ATOM Lite / PSRAM / ATOMS3 / S3Lite)
  • Module Display adapter (Audio over HDMI for M5Stack Core / Core2 / Tough)
  • Module RCA adapter (M5Stack Core / Core2 / Tough)

Other supported external accessories

  • Unit RTC
  • Unit IMU

Hardware information

ESP32 GPIO list

M5Stack
BASIC
GRAY
M5Stack
GO/FIRE
M5Stack
Core2(AWS)
Tough
M5Stick
C/CPlus
M5Stick
CPlus2
M5Stack
CoreInk
M5Paper M5Station M5ATOM
Lite/Matrix
ECHO/U
PSRAM
M5STAMP
PICO
GPIO 0
ADC2_CH1
M-Bus
IIS_MK
M-Bus
IIS_MK
M-Bus
SPK_LRCK
PDM_C
(Core2)
HAT
PAD
PDM_C
HAT
PDM_C
EPD_RST --- --- --- GPIO 0
ADC2_CH1
GPIO 1
USB_TX
M-Bus
Serial
M-Bus
Serial
M-Bus
Serial
Serial Serial Serial Serial Serial Serial Serial GPIO 1
USB_TX
GPIO 2
ADC2_CH2
M-Bus
M-Bus
M-Bus
SPK_D
PAD
Beep(CPlus)
Beep Beep PW_Hold ReadEn --- --- GPIO 2
ADC2_CH2
GPIO 3
USB_RX
M-Bus
Serial
M-Bus
Serial
M-Bus
Serial
Serial Serial Serial Serial Serial Serial Serial GPIO 3
USB_RX
GPIO 4
ADC2_CH0
TF_CS TF_CS TF_CS --- PW_Hold EPD_BUSY TF_CS RGB LED --- --- GPIO 4
ADC2_CH0
GPIO 5 M-Bus M-Bus LCD_CS LCD_CS LCD_CS BTN_HAT EXT_5V LCD_CS Bus(P)
PDM_C(U)
--- GPIO 5
GPIO 9 --- --- --- InfraRed --- EPD_CS --- --- --- --- GPIO 9
GPIO10 --- --- --- LED --- LED --- --- --- --- GPIO10
GPIO12
ADC2_CH5
M-Bus
IIS_SK
M-Bus
IIS_SK
SPK_BCLK --- LCD_RST PW_Hold SPI_MOSI USB_PW InfraRed --- GPIO12
ADC2_CH5
GPIO13
ADC2_CH4
M-Bus
IIS_WS
M-Bus
IIS_WS
M-Bus
RXD2
SPI_SCLK SPI_SCLK MI-Bus
RXD2
SPI_MISO PORT.C1 --- --- GPIO13
ADC2_CH4
GPIO14
ADC2_CH6
LCD_CS LCD_CS M-Bus
TXD2
--- LCD_D/C MI-Bus
TXD2
SPI_SCLK PORT.C1 --- --- GPIO14
ADC2_CH6
GPIO15
ADC2_CH3
M-Bus
IIS_OUT
M-Bus
RGB LED
LCD_D/C SPI_MOSI SPI_MOSI EPD_D/C EPD_CS LCD_RST --- --- GPIO15
ADC2_CH3
GPIO16
PSRAM
M-Bus
RXD2
M-Bus
PORT.C
RXD2
--- --- --- --- --- PORT.C2
RXD2
--- --- GPIO16
PSRAM
GPIO17
PSRAM
M-Bus
TXD2
M-Bus
PORT.C
TXD2
--- --- --- --- --- PORT.C2
TXD2
--- --- GPIO17
PSRAM
GPIO18 M-Bus
SPI_SCLK
M-Bus
SPI_SCLK
SPI_SCLK LCD_RST --- MI-Bus
SPI_SCLK
PORT.C SPI_SCLK --- GPIO18
GPIO19 M-Bus
SPI_MISO
M-Bus
SPI_MISO
M-Bus --- LED
InfraRed
RTC_INT PORT.C LCD_D/C Bus
SPK_C(ECHO)
*PDM_D(U)
GPIO19
GPIO21 M-Bus
PORT.A
I2C0_SDA
M-Bus
PORT.A
I2C0_SDA
I2C1_SDA I2C1_SDA I2C1_SDA MI-Bus
I2C1_SDA
I2C1_SDA I2C1_SDA Bus
I2C1_SCL
GPIO21
GPIO22 M-Bus
PORT.A
I2C0_SCL
M-Bus
PORT.A
I2C0_SCL
I2C1_SCL I2C1_SCL I2C1_SCL MI-Bus
I2C1_SCL
I2C1_SCL I2C1_SCL Bus
SPK_D(ECHO)
GPIO22
GPIO23 M-Bus
SPI_MOSI
M-Bus
SPI_MOSI
SPI_MOSI LCD_D/C --- MI-Bus
SPI_MOSI
EPD_RST SPI_MOSI Bus
PDM_D(ECHO)
--- GPIO23
GPIO25
DAC1
M-Bus
SPK_DAC
M-Bus
SPK_DAC
M-Bus
RGB LED(AWS)
HAT(CPlus)
PAD
HAT MI-Bus
HAT
PORT.A
I2C0_SDA
PORT.B1 Bus
I2C1_SDA
GPIO25
DAC1
GPIO26
DAC2
M-Bus M-Bus
PORT.B
M-Bus HAT
PAD
HAT MI-Bus
HAT
PORT.B PORT.B2 PORT.A
I2C0_SDA
GPIO26
DAC2
GPIO27
ADC2_CH7
LCD_D/C LCD_D/C M-Bus AXP192 VBUSEN LCD_BL BTN_PWR EPD_BUSY IMU_INT RGB LED RGB LED GPIO27
ADC2_CH7
GPIO32
ADC1_CH4
LCD_BL LCD_BL M-Bus
PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
PORT.A
I2C0_SCL
PORT.A
I2C0_SDA
PORT.A
I2C0_SCL
PORT.A
I2C0_SDA
GPIO32
ADC1_CH4
GPIO33
ADC1_CH5
LCD_RST LCD_RST M-Bus
PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
PORT.B PORT.A
I2C0_SCL
Bus
PDM_C(ECHO)
PORT.A
I2C0_SCL
GPIO33
ADC1_CH5
GPIO34
ADC1_CH6
M-Bus
IIS_IN
M-Bus
MIC_ADC
IIS_IN
M-Bus
PDM_D(Core2)
PDM_D PDM_D MI-Bus
SPI_MISO
--- USB Current? --- GPIO34
ADC1_CH6
GPIO35
ADC1_CH7
M-Bus M-Bus M-Bus RTC_INT BTN_PWR BAT_V BAT_V PORT.B1 --- --- GPIO35
ADC1_CH7
GPIO36
ADC1_CH0
M-Bus M-Bus
PORT.B
M-Bus HAT
PAD
HAT MI-Bus
HAT
TP_INT PORT.B2 --- --- GPIO36
ADC1_CH0
GPIO37
ADC1_CH1
BTN_C BTN_C --- BTN_A BTN_A SW_Up SW_Up BTN_A --- --- GPIO37
ADC1_CH1
GPIO38
ADC1_CH2
BTN_B BTN_B M-Bus
SPI_MISO
PAD BAT_V SW_Press SW_Press BTN_B --- --- GPIO38
ADC1_CH2
GPIO39
ADC1_CH3
BTN_A BTN_A TP_INT BTN_B BTN_B SW_Down SW_Down BTN_C BTN BTN GPIO39
ADC1_CH3
M5Stack
BASIC
GRAY
M5Stack
GO/FIRE
M5Stack
Core2(AWS)
Tough
M5Stick
C/CPlus
M5Stick
CPlus2
M5Stack
CoreInk
M5Paper M5Station M5ATOM
Lite/Matrix
ECHO/U
PSRAM
M5STAMP
PICO

ESP32C3 GPIO list

M5Stamp
C3
M5Stamp
C3U
GPIO 0 PORT.A
I2C0_SCL
PORT.A
I2C_SCL
GPIO 0
GPIO 1 PORT.A
I2C0_SDA
PORT.A
I2C_SDA
GPIO 1
GPIO 2 RGB LED RGB LED GPIO 2
GPIO 3 BTN_A Bus GPIO 3
GPIO 4 Bus Bus GPIO 4
GPIO 5 Bus Bus GPIO 5
GPIO 6 Bus Bus GPIO 6
GPIO 7 Bus Bus GPIO 7
GPIO 8 Bus Bus GPIO 8
GPIO 9 --- BTN_A GPIO 9
GPIO10 Bus Bus GPIO10
GPIO18
USB
PORT.U
D-
USB
PORT.U
D-
GPIO18
USB
GPIO19
USB
PORT.U
D+
USB
PORT.U
D+
GPIO19
USB
GPIO20 USB
Serial
Bus
GPIO20
GPIO21 USB
Serial
Bus
GPIO21
M5Stamp
C3
M5Stamp
C3U

ESP32S3 GPIO list

M5Stack
CoreS3
M5ATOMS3
/ S3Lite
M5ATOMS3U M5STAMPS3 M5Dial M5Capsule M5Cardputer
GPIO 0 M-Bus
SPK_LRCK
--- --- Bus
BTN_A
--- --- BTN_A GPIO 0
GPIO 1 PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
Bus PORT.B --- PORT.A
I2C0_SCL
GPIO 1
GPIO 2 PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
Bus PORT.B Beep PORT.A
I2C0_SDA
GPIO 2
GPIO 3 LCD_CS vdd3v3 vdd3v3 Bus Beep --- KEY_MATRIX GPIO 3
GPIO 4 TF_CS InfraRed --- Bus LCD_RS InfraRed KEY_MATRIX GPIO 4
GPIO 5 M-Bus Bus --- Bus LCD_MOSI --- KEY_MATRIX GPIO 5
GPIO 6 M-Bus Bus --- Bus LCD_SCK BAT_ADC KEY_MATRIX GPIO 6
GPIO 7 M-Bus Bus --- Bus LCD_CS --- KEY_MATRIX GPIO 7
GPIO 8 M-Bus
PORT.B
Bus --- Bus LCD_RST I2C1_SDA KEY_MATRIX GPIO 8
GPIO 9 M-Bus
PORT.B
--- --- Bus LCD_BL --- KEY_MATRIX GPIO 9
GPIO10 M-Bus --- --- Bus RFID_INT I2C1_SCL BAT_ADC GPIO10
GPIO11 I2C1_SCL --- --- Bus I2C1_SDA TF_CS KEY_MATRIX GPIO11
GPIO12 I2C1_SDA --- InfraRed Bus I2C1_SCL TF_MOSI TF_CS GPIO12
GPIO13 M-Bus
SPK_D
--- --- Bus
PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
PORT.A
I2C0_SDA
KEY_MATRIX GPIO13
GPIO14 M-Bus
MIC_IN
--- Bus Bus TP_INT TF_CLK TF_MOSI GPIO14
GPIO15 CAM_D6 LCD_CS --- Bus
PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
PORT.A
I2C0_SCL
KEY_MATRIX GPIO15
GPIO16 CAM_D7 LCD_BL --- FPC --- --- --- GPIO16
GPIO17 M-Bus
PORT.C
LCD_SCLK Bus FPC --- --- --- GPIO17
GPIO18 M-Bus
PORT.C
--- --- FPC --- --- --- GPIO18
GPIO19
USB
USB
D--
USB
D--
USB
D--
USB
D--
USB
D--
USB
D--
USB
D--
GPIO19
USB
GPIO20
USB
USB
D++
USB
D++
USB
D++
USB
D++
USB
D++
USB
D++
USB
D++
GPIO20
USB
GPIO21 I2C_INT LCD_MOSI --- RGB LED RGB LED RGB LED RGB_LED GPIO21
GPIO33 SPK_WCK LCD_DC --- FPC --- --- LCD_RST GPIO33
GPIO34 SPK_BCK LCD_RST --- FPC --- --- LCD_RS GPIO34
GPIO35 M-Bus
SPI_MISO
LCD DC
RGB LED RGB LED FPC --- --- LCD_DAT GPIO35
GPIO36 M-Bus
SPI_SCLK
--- --- FPC --- --- LCD_SCK GPIO36
GPIO37 M-Bus
SPI_MOSI
--- --- FPC --- --- LCD_CS GPIO37
GPIO38 CAM_HREF Bus
I2C1_SDA
PDM_DAT FPC --- --- LCD_BL GPIO38
GPIO39 CAM_D2 Bus
I2C1_SCL
PDM_CLK Bus --- TF_MISO TF_MISO GPIO39
GPIO40 CAM_D3 --- Bus Bus ENCODER_B MIC_CLK TF_CLK GPIO40
GPIO41 CAM_D4 BTN_A BTN_A Bus ENCODER_A MIC_DAT SPK_BCLK GPIO41
GPIO42 CAM_D5 --- Bus Bus BTN_A BTN_A SPK_SDATA GPIO42
GPIO43 M-Bus
SerialTX
--- --- Bus --- --- I2S_LRCLK GPIO43
GPIO44 M-Bus
SerialRX
--- --- Bus --- --- InfraRed GPIO44
GPIO45 CAM_PCLK --- --- --- --- --- --- GPIO45
GPIO46 CAM_VSYNC --- --- Bus HOLD HOLD MIC_DAT GPIO46
GPIO47 CAM_D9 --- --- --- --- --- --- GPIO47
GPIO48 CAM_D8 --- --- --- --- --- --- GPIO48
M5Stack
CoreS3
M5ATOMS3
/ S3Lite
M5ATOMS3U M5STAMPS3 M5Dial M5Capsule M5Cardputer

AXP192 power management IC connections

M5Stack
Core2
M5Stack
Tough
M5Stick
C
M5Stick
CPlus
M5Station
GPIO0
LDO0
BUS PW EN BUS PW EN MIC VCC MIC VCC PortA1.A2 EN GPIO0
LDO0
GPIO1 SYS LED TP RST --- --- PortB1 EN GPIO1
GPIO2 SPK EN SPK EN --- --- PortB2 EN GPIO2
GPIO3 --- --- --- --- PortC1 EN GPIO3
GPIO4 LCD RST
TP RST
LCD RST --- --- PortC2 EN GPIO4
EXTEN PORT 5V EN PORT 5V EN PORT 5V EN PORT 5V EN PORT 5V EN EXTEN
BACKUP RTC BAT RTC BAT RTC BAT RTC BAT --- BACKUP
LDO1 RTC VDD RTC VDD RTC VDD RTC VDD RTC VDD LDO1
LDO2 LCD PW
Periph PW
LCD PW
Periph PW
LCD BL LCD BL --- LDO2
LDO3 VIB MOTOR LCD BL LCD PW LCD PW LCD BL LDO3
DCDC1 ESP32 VDD ESP32 VDD ESP32 VDD ESP32 VDD ESP32 VDD DCDC1
DCDC2 --- --- --- --- --- DCDC2
DCDC3 LCD BL --- --- --- --- DCDC3

AXP2101 usage

M5Stack
Core2v1.1
M5Stack
CoreS3
ALDO1 --- VDD 1v8 ALDO1
ALDO2 LCD RST VDDA 3v3 ALDO2
ALDO3 SPK EN CAM 3v3 ALDO3
ALDO4 Periph PW
TF,TP,LCD
TF 3v3 ALDO4
BLDO1 LCD BL AVDD BLDO1
BLDO2 PORT 5V EN DVDD BLDO2
DLDO1/DC1 VIB MOTOR LCD BL DLDO1/DC1
DLDO2/DC2 --- --- DLDO2/DC2
BACKUP RTC BAT RTC BAT BACKUP

PinMap

M5Stack
BASIC/GRAY
GO/FIRE
FACES II
M5Stack
Core2
Core2AWS
TOUGH
M5Stack
CoreS3
Bus
M-Bus

M-Bus

M-Bus
※ HPWR=not connected to the ESP32. Used by modules capable of supplying 12V power.
M5Stack
BASIC/GRAY
GO/FIRE
FACES II
M5Stack
Core2
Core2AWS
TOUGH
M5Stack
CoreS3
M5Paper M5Station
PortA
PortA

PortA

PortA

PortA

PortA
PortB
PortB

PortB

PortB

PortB

PortB1

PortB2
PortC
PortC

PortC

PortC

PortC

PortC1

PortC2
PortD
PortD

PortD
PortE
PortE

PortE / 485
TOUGH485:12V
M5Stick
C
M5Stick
C Plus
M5Stack
CoreInk
M5Stamp
PICO
M5Stamp
C3
M5Stamp
C3U
PortA
HAT
Bus
MI-Bus
ATOM
Lite
ATOM
Matrix
ATOM
ECHO
ATOM
PSRAM
ATOM
U
PortA
Bus
ATOMS3
/S3Lite
NanoC6
PortA
Bus

SPI device

M5Stack
BASIC
GRAY
GO/FIRE
M5Stack
Core2
Tough
M5Stick
C
M5Stick
CPlus
M5Stack
CoreInk
M5Paper
Display ILI9342C
320×240
CS:G14
ILI9342C
320×240
CS:G5
ST7735S
80×160
CS:G5
ST7789V2
135×240
CS:G5
GDEW0154M09
200×200
CS:G9
IT8951
960×540
CS:G15
Display
TF Card CS:4 CS:4 --- --- --- CS:4 TF Card

I2C device

M5Stack
BASIC/GRAY
GO/FIRE
M5Stack
Core2
M5Stack
Tough
M5Stack
CoreS3
M5Stick
C
CPlus
M5Stack
CoreInk
M5Paper ATOM
Matrix
M5Station
Touch
Panel
--- FT6336U
38h
CHSC6540
2Eh
FT5xxx
38h
--- --- GT911
14h or 5Dh
--- --- Touch
Panel
RTC --- BM8563
51h
BM8563
51h
BM8563
51h
BM8563
51h
BM8563
51h
BM8563
51h
--- BM8563
51h
RTC
Power
Manage
IP5306
75h
AXP192
34h
AXP192
34h
AXP2101
34h
AXP192
34h
--- --- --- AXP192
34h
Power
Manage
IMU MPU6886
68h
MPU6886
68h (Ext)
--- BMI270
69h
MPU6886
68h
--- --- MPU6886
68h
MPU6886
68h (opt)
IMU
IMU
(old lot)
SH200Q
6Ch
--- --- --- SH200Q
6Ch
--- --- --- --- IMU
(old lot)
ENV --- --- --- LTR553ALS
23h
--- --- SHT30
44h
--- --- ENV
EEPROM --- --- --- --- --- --- FM24C02
50h
--- --- EEPROM
Camera --- --- --- GC0308
21h
--- --- --- --- --- Camera
Speaker --- --- --- AW88298
36h
--- --- --- --- --- Speaker
Microphone --- --- --- ES7210
40h
--- --- --- --- --- Microphone
GPIO Expander --- --- --- AW9523B
58h
--- --- --- --- --- GPIO Expander
Current
Voltage
Monitor
--- --- --- --- --- --- --- --- INA3221
40h/41h
(opt)
Current
Voltage
Monitor

m5unified's People

Contributors

bbgott avatar chipguyhere avatar gob52 avatar hollyhockberry avatar hypersupermetactrl avatar imliubo avatar lovyan03 avatar mayopan avatar mongonta0716 avatar pguyot avatar sallocs avatar tanakamasayuki avatar tobozo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

m5unified's Issues

Unit Mini OLED display does not work with M5Stamp-Pico

Using the M5Unified library and the Displays.ino example, I've been able to easily get my Unit Mini OLED display to work with an M5 Atom Lite and an M5 Atom S3. But when I try the same display and the same code with my M5Stamp-Pico, the screen is blank.

I've been able to get several other i2c devices to work with my M5Stamp-Pico, so I know the header is soldered properly. Is there a special incantation I need to perform to get this display to work with the stamp?

(I've also tried this sample code but that also doesn't work.)

CoreInk display fades after some time in use

Hi there,

After some time with the display on, something makes it fade. I am using a repeating cycle of wake from deep sleep, clear display, update display with sensor data, wait for user input for 10 seconds, then go to deep sleep for 60 seconds and repeat. After a few hours the ePaper display fades (sorry I don't know exactly how long, but some time).

No amount of my powering down, or resetting, or clearing the display helps unfortunately.

This photo doesn't show it very well, the humidity 41.8% has not faded much, but the battery "Batt: 100%" has faded quite a lot.
2023-08-06 16 16 01 Also if you look closely the background still has some grey which hasn't been cleared properly.

I did some searching, and there is some feature called HV on and HV off for the SPI connection to the ePaper display. This issue is discussed on the M5Stack forum here. Apparently it solves this display fade issue.

I also see the M5Stack library has this HV on and off function for Arduino here and here.

I would like to try using HV on and off using M5Unified but I don't think those functions are currently available. How hard would it be to implement this? I would be happy to test if you need. Maybe I will try using the M5stack library and see if this solves my problem.

Thank you!

adc_power_acquireがM5Stack1.0.9に存在していない

C:\Users\tanaka\Documents\Arduino\libraries\M5Unified-0.0.1\src\M5Unified.cpp: In member function 'void m5::M5Unified::begin()':
C:\Users\tanaka\Documents\Arduino\libraries\M5Unified-0.0.1\src\M5Unified.cpp:162:25: error: 'adc_power_acquire' was not declared in this scope
       adc_power_acquire(); /// for GPIO 36,39 Chattering prevention.
                         ^

上記のコンパイルエラーが出ました

Double register of BtnA.pressedFor()

Hi there, I'm not sure if this is the correct library to report this, please advise if not.

When BtnA.pressedFor(1000) is true, I run some code which takes a few seconds to complete, and in this time, I release touch button A, wait for the Wifi to connect, sync RTC to NTP service. On the next loop, this code executes again, i.e. BtnA.pressedFor(1000) is true a second time, even though I am not touching the button.

I found by inserting an extra M5.update() the flag is cleared. Can you please advise if this is a bug or not?

void loop(void) {

  // Update M5 object
  M5.update();

  clock_display.update();

  if (M5.BtnA.pressedFor(1000)) {
    M5.Lcd.clear();
    clock_display.pause();
    // Connect to WiFi
    if (connect_wifi()) {
      delay(500);
      sync_rtc_to_ntp(true);
      WiFi.disconnect(true);  // Disconnect wifi
      WiFi.mode(WIFI_OFF);    // Set the wifi mode to off
    }
    delay(2000); // Give user time to read the Wifi and NTP success / failure message
    init_main_display();
    M5.update();  // Needed otherwise another pressed event occurs on next loop
    clock_display.resume();
  }
  // other code ...
}

S3 family compilation error: unused variable when compiler_warnings=all

Hi and thanks for this awesome project 👍

This line triggers a compilation error when the compiler warnings are at the maximum level in Arduino IDE:

static constexpr const uint32_t port0_bitmask = 0b00100000; // USB OTG EN

~/Arduino/libraries/M5Unified/src/utility/Power_Class.cpp: In member function 'bool m5::Power_Class::getUsbOutput()':
~/Arduino/libraries/M5Unified/src/utility/Power_Class.cpp:527:62: error: unused variable 'port0_bitmask' [-Werror=unused-variable]
         static constexpr const uint32_t port0_bitmask = 0b00100000; // USB OTG EN
                                                              ^~~~~~~~~~~~~
cc1plus: some warnings being treated as errors

looks like dead code, removing this line doesn't seem to break anything, prefixing [[maybe_unused]] works too.

Wrong week of day from RTC

M5.Rtc.getDateTime() returns wrong week of day since January. I compiled Rtc.ino from the examples on Core2 with M5Unified 0.12 on PlatformIO, and it returns Thursday on Feb 5th (which is Sunday actually). localtime() or gmtime() works without problems, so it looks like only RTC is returning a strange value.

I found the similar report on Twitter as well.
https://twitter.com/hhajime0101/status/1612371508843941889

How to make audio tone from Core2 speaker

Hi there, I would like to create a simple tone at a specific frequency from the Core2 speaker. I saw M5 stack API has this:

  M5.Speaker.begin(); //Initialize the speaker
  M5.Speaker.tone(661, 1000);    //Set the speaker to tone at 661Hz for 1000ms

But it is not in M5Unified as far as I can tell. Or do I need to do a full I2S implementation like in this example
https://github.com/m5stack/M5-ProductExampleCodes/blob/master/Core/M5Core2/Arduino/speak/speak.ino

Thanks for your help!

channel default volume is unusual

I was surprised that the channel default volume is 64. In audio designs, usually channel volume is attenuation only. So I'd expect the default to be the maximum (255).

Otherwise, the master volume doesn't really mean the "maximum volume", and some channels may have a volume equivalent to a master volume of 1024...

volatile uint8_t volume = 64; // channel volume (not master volume)

ATOM QR-CODE Kit

Dear M5Stack team.
we have selected M5Stack technology with nanoFramework as strategy technology for our smart devices.
We have started developing and we have found the first critical point. We need to use the ATOM QR-CODE Kit on the nanoFramework image, but the only place that I have found until now to read QR code is downloading and burd directly with your tool, but that is not the solution.
I need a wrapper solution in C# language to access the QR reader information.
Could you help me?

Thanks it is so important at that moment take the right decision.

Unified and Timers

We have no longer have access to M5 Timers, how this should be handle?

Thanks

Touch get wrong values more you go away from display center

M5.Touch get wrong X and Y values more you go away from display center. The same problem there is with M5Core2.
How to fix it? With this type of issue the display touch is compliteli useless. X and Y are not centered with the touch point.

P_VID_20220615_144010.mp4

Deep sleep on CoreInk

Using tag 0.1.6.

Calling M5.Power.timerSleep(int) puts a CoreInk to deep sleep, but when it wakes up, if it is running on battery, the reboot reason (result of esp_reset_reason()) is not ESP_RST_DEEPSLEEP but ESP_RST_WDT or ESP_RST_POWERON and any RTC Slow memory variable (RTC_NOINIT_ATTR) is lost.

The problem doesn't happen if the CoreInk is plugged on USB.
The problem doesn't happen if the following two lines are commented:

  void Power_Class::timerSleep( int seconds )
  {
-    M5.Rtc.clearIRQ();
-    M5.Rtc.setAlarmIRQ(seconds);
+//    M5.Rtc.clearIRQ();
+//    M5.Rtc.setAlarmIRQ(seconds);
    esp_sleep_enable_timer_wakeup(seconds * 1000000ULL);
    _timerSleep();
  }

Also, I haven't been able to get M5.Power.timerSleep(const rtc_time_t&) on the CoreInk to work at all.

こんな表があってもいいかも?

I2C GPIO

M5Stack
BASIC/GRAY
GO/FIRE
M5Stack
Core2/Tough
M5Stick
C/Cplus
M5Stack
CoreInk
M5Paper M5Station M5ATOM
Lite/Matrix
ECHO/U
PSRAM
M5STAMP
PICO
M5Stamp
C3/C3U
M5Stack
CoreS3
M5ATOMS3
/ S3Lite
PORT.A
I2C_SDA
21 32 32 32 25 32 26 32 1 2 2
PORT.A
I2C_SCL
22 33 33 33 32 33 32 33 0 1 1
I2C1_SDA 21 21 21 21 21 22 12 38
I2C1_SCL 22 22 22 22 22 25 11 39
|                         | M5Stack<BR>BASIC/GRAY<BR>GO/FIRE | M5Stack<BR>Core2/Tough | M5Stick<BR>C/Cplus | M5Stack<BR>CoreInk | M5Paper | M5Station | M5ATOM<BR>Lite/Matrix<BR>ECHO/U<BR>PSRAM | M5STAMP<BR>PICO | M5Stamp<BR>C3/C3U | M5Stack<BR>CoreS3 | M5ATOMS3 <BR>/ S3Lite |
|-------------------------|:--------------------------------:|:----------------------:|:------------------:|:------------------:|:-------:|:---------:|:----------------------------------------:|:---------------:|:-----------------:|:-----------------:|:---------------------:|
| `PORT.A`<BR>**I2C_SDA** | 21                               | 32                     | 32                 | 32                 | 25      | 32        | 26                                       | 32              | 1                 | 2                 | 2                     |
| `PORT.A`<BR>**I2C_SCL** | 22                               | 33                     | 33                 | 33                 | 32      | 33        | 32                                       | 33              | 0                 | 1                 | 1                     |
| **I2C1_SDA**            |                                  | 21                     | 21                 | 21                 | 21      | 21        | 22                                       |                 |                   | 12                | 38                    |
| **I2C1_SCL**            |                                  | 22                     | 22                 | 22                 | 22      | 22        | 25                                       |                 |                   | 11                | 39                    |

M5Stamp C3でM5Unifiedをincludeできない

スケッチのUpload中に以下のようなエラーが発生します

c:\Users\■■■■\Documents\Arduino\libraries\M5Unified\src\utility\Power_Class.cpp: In member function 'void m5::Power_Class::_powerOff(bool)':
c:\Users\■■■■\Documents\Arduino\libraries\M5Unified\src\utility\Power_Class.cpp:588:21: error: 'esp_sleep_enable_ext0_wakeup' was not declared in this scope
       if (ESP_OK != esp_sleep_enable_ext0_wakeup( pin, false))
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\■■■■\Documents\Arduino\libraries\M5Unified\src\utility\Power_Class.cpp:588:21: note: suggested alternative: 'esp_sleep_enable_wifi_wakeup'
       if (ESP_OK != esp_sleep_enable_ext0_wakeup( pin, false))
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     esp_sleep_enable_wifi_wakeup

Using library M5Unified at version 0.1.9 in folder: C:\Users\■■■■\Documents\Arduino\libraries\M5Unified 
Using library M5GFX at version 0.1.9 in folder: C:\Users\■■■■\Documents\Arduino\libraries\M5GFX 
exit status 1

Compilation error: exit status 1

使用デバイスは
M5Stamp C3 でIDEは ArduinoIDE 2.2.1です

SD Card doesn't get mounted from the M5Unified Library [Core2]

Hi there

When changing from the Core2 Library to the M5Unified library, since it allows to create sin-waves via speaker, the SD-Card isn't recognized, probably by <SPIFFS.h> or <SD.h>.

#include <M5Unified.h>
#include <SPIFFS.h>
#include <SD.h>

I thought it might be a problem with the format of the SD-Card being on FAT32, but changing it to NTFS didn't solve the problem.

Monitoring Error Code: [ 10910][E][vfs_api.cpp:24] open(): File system is not mounted

Example "Display_Unicode" doesn't compile with M5Unified

Hello,
first of all cudos to the developer(s) of M5Unified - excellent work!

After modifing <m5stack path>/src/utility/In_eSPI_Setup.h, At the end of the file add "#define USE_M5_FONT_CREATOR", as per README.md, the sketch "Examples -> M5Stack -> Advanced -> Display -> Display_Unicode" runs without any problems on Core1 (V2.7) and Core2.

If I'm now "porting" this example to M5Unified by

// #include <M5Stack.h>
#include <M5Unified.h>
...
void setup() {
  // M5.begin();        // Init M5Stack.  初始化M5Stack
  auto cfg = M5.config();
  M5.begin(cfg);

I got the following compilation error:

In file included from C:\ <...> \Display_Unicode\Display_Unicode.ino:20:
C:\ <...> \Display_Unicode\CUF_24px.h:64274:7: error: 'EncodeRange' does not name a type
 const EncodeRange unicode_24pxEncodeRange[] PROGMEM = {
       ^~~~~~~~~~~
C:\ <...> \Display_Unicode\CUF_24px.h:66327:32: error: 'EncodeRange' was not declared in this scope
                               (EncodeRange *)unicode_24pxEncodeRange};
                                ^~~~~~~~~~~
C:\ <...> \Display_Unicode\CUF_24px.h:66327:32: note: suggested alternative:
In file included from c:\ <...> \Documents\Arduino\libraries\M5GFX\src/lgfx/v1/LGFXBase.hpp:32,
                 from c:\<...> \Documents\Arduino\libraries\M5GFX\src/M5GFX.h:21,
                 from c:\<...> \Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:19,
                 from c:\<...> \Documents\Arduino\libraries\M5Unified\src/M5Unified.h:5,
                 from C:\ <...> \Display_Unicode\Display_Unicode.ino:18:
c:\<...> \Arduino\libraries\M5GFX\src/lgfx/v1/lgfx_fonts.hpp:126:10: note:   'lgfx::v1::EncodeRange'
   struct EncodeRange {
          ^~~~~~~~~~~
In file included from C:\ <...> \Display_Unicode\Display_Unicode.ino:20:
C:\ <...> \Display_Unicode\CUF_24px.h:66327:45: error: expected primary-expression before ')' token
                               (EncodeRange *)unicode_24pxEncodeRange};
                                             ^
C:\ <...> \Display_Unicode\CUF_24px.h:66327:46: error: expected '}' before 'unicode_24pxEncodeRange'
                               (EncodeRange *)unicode_24pxEncodeRange};
                                              ^~~~~~~~~~~~~~~~~~~~~~~
C:\ <...> \Display_Unicode\CUF_24px.h:66321:30: note: to match this '{'
 const GFXfont unicode_24px = {(uint8_t *)unicode_24pxBitmaps,
                              ^
C:\ <...> \Display_Unicode\CUF_24px.h:66327:46: error: could not convert '{((uint8_t*)((const uint8_t*)(& unicode_24pxBitmaps))), ((GFXglyph*)((const GFXglyph*)(& unicode_24pxGlyphs))), 32, 65439, 25, 4090, <expression error>}' from '<brace-enclosed initializer list>' to 'const GFXfont' {aka 'const lgfx::v1::GFXfont'}
                               (EncodeRange *)unicode_24pxEncodeRange};
                                              ^~~~~~~~~~~~~~~~~~~~~~~
C:\ <...> \Display_Unicode\CUF_24px.h:66327:69: error: expected declaration before '}' token
                               (EncodeRange *)unicode_24pxEncodeRange};
                                                                     ^

exit status 1

Compilation error: 'EncodeRange' does not name a type

Which is the same also on a Core2.

As an Austrian, I depend on Unicode (äöüßÄÖÜ°)

Thank you,
Marcus

P.S.: I am looking forward to when M5.getPin() will be available.

Trouble using SmartConfig

Hi. Thank you very much for releasing such a useful library. 🙇

I have been trying to migrate from the M5Stack library to the M5Unified library and found a problem regarding SmartConfig. The following example works fine when M5Stack.h is selected. However, I can't configure Wi-Fi when M5Unified.h is selected. I confirmed with an M5Stack FIRE.

#include <WiFi.h>

#if 1
#include <M5Unified.h>
#else
#include <M5Stack.h>
#endif

void setup(void) {
  M5.begin();

  WiFi.mode(WIFI_AP_STA);
  WiFi.beginSmartConfig();

  M5.Lcd.println("Waiting for SmartConfig");
  while (!WiFi.smartConfigDone()) {
    delay(500);
    M5.Lcd.print(".");
  }

  M5.Lcd.println();

  M5.Lcd.println("Waiting for Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    M5.Lcd.print(".");
  }

  M5.Lcd.println();

  M5.Lcd.print("IP Address: ");
  M5.Lcd.println(WiFi.localIP());
}

void loop(void) {
  vTaskDelay(1);
  M5.update();
}

I'm sorry if this is a false alarm, but I want to report to make sure. Thank you very much.

M5Stack.h and M5Unified.h

Hi, I recently modified a Mini Proto Unit to read two analog sensors (2 FSR) with GPIO 26 and 36 at Port B. It works perfectly with M5Stack.h, both sensors read 0 to 4095 responsively. However, when I kept the same code but changed to M5Unified.h, one of them (GPIO 26) stop working correctly. Is there a work around to this? Many thanks!

I use a M5Stack Fire.

white noise from SPK HAT

Hello, I'm try to test audio on M5StickC Plus with SPK HAT, using [WebRadio_with_ESP8266Audio.ino] example.

How can I avoid the white noise ? or is it expected from design ?

392_1669973097.mp4

Web Radio sample compile error

いつもお世話になっています。
WebRadioのサンプルコードですが
コンパイルすると下記のエラーになります。
ESP8266Audioも他のライブラリ、ボードライブラリもArduinoIDE全て最新にしています。

ESP32 Coreを使っています。(M5Stick-Cも試しましたが同じエラーでした)

In file included from /Users/demo/Documents/Arduino/libraries/ESP8266Audio/src/AudioGeneratorMIDI.cpp:65:
/Users/demo/Documents/Arduino/libraries/ESP8266Audio/src/libtinysoundfont/tsf.h: In function 'void tsf_channel_midi_control(tsf*, int, int, int)':
/Users/demo/Documents/Arduino/libraries/ESP8266Audio/src/libtinysoundfont/tsf.h:2100:1: error: insn does not satisfy its constraints:
 }
 ^
(insn 858 343 344 51 (set (reg:SF 19 f0 [407])
        (mem/u/c:SF (symbol_ref/u:SI ("*.LC248") [flags 0x2]) [0  S4 A32])) "/Users/demo/Documents/Arduino/libraries/ESP8266Audio/src/libtinysoundfont/tsf.h":2053 47 {movsf_internal}
     (nil))
during RTL pass: postreload

Button Events

How can we get our own custom callbacks for buttons as we issued to have with Core2?

` int16_t xx=elem["xx"].as<int16_t>();

      int16_t yy=elem["yy"].as<int16_t>();

      int16_t ww=elem["ww"].as<int16_t>();

      int16_t hh=elem["hh"].as<int16_t>();

      int16_t id=elem["id"].as<int16_t>();

      if(elem["manualOpen"].as<bool>()==true){

        bAcceso = new Button(xx, yy, ww, hh, false, text, onCol, offCol);

        bAcceso->addHandler(eventDisplay, E_RELEASE);

      }else{

        bAcceso = new Button(xx, yy, ww, hh, false, text, onColD, onColD);

      }
      bAcceso->userData=elem["id"].as<int16_t>();`

M5 Stack Core2 crash during create sprite

Hi there,

I have been developing on M5 Stack Core2 with this library for a couple of weeks now and all has been good! Yesterday I noticed that I was still on v0.0.1 so I upgraded to v0.0.3, however now the Core2 crashes during setup(). I have narrowed this down to the createSprite() call. I have tried to debug this but I quickly get lost in the M5GFX code.

Here is a shortened version of my code:

#include <M5Unified.h>

... many other includes

#define batt_spr_wdth    190  // Battery sprite width
#define batt_spr_ht      20   // Battery sprite height

M5Canvas batt_sprite(&M5.Lcd);                        // Sprite for battery icon and percentage text

void setup(void) {
  Serial.begin(115200);
  M5.begin();
  M5.Power.setExtPower(true);  // Enable 5V output on external port

  // Create battery icon sprite
  batt_sprite.createSprite(batt_spr_wdth, batt_spr_ht);  // <== crashes here :(

  while (true); // prevent subsequent setup code from being compiled

... other code
}

and here is the ESP32 exception decoder output (just core 1 output). If I'm reading this correctly, the problem seems to be related to a palette colour type, as per decoder lines 6 and 5.

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x40091c75  PS      : 0x00060f34  A0      : 0x80093cae  A1      : 0x3ffb1e80  
A2      : 0x37735220  A3      : 0x0000abab  A4      : 0xb33fffff  A5      : 0x00000001  
A6      : 0x00060320  A7      : 0x0000cdcd  A8      : 0x400fad7c  A9      : 0x3ffb1f70  
A10     : 0x3f429568  A11     : 0x00000069  A12     : 0x3f42989c  A13     : 0x3f4295f4  
A14     : 0x00000003  A15     : 0x00060a23  SAR     : 0x0000000a  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x400dbf68  LEND    : 0x400dbf72  LCOUNT  : 0x00000000  

ELF file SHA256: 0000000000000000

Backtrace: 0x40091c75:0x3ffb1e80 0x40093cab:0x3ffb1eb0 0x400942e5:0x3ffb1ed0 0x4008203d:0x3ffb1ef0 0x400d724b:0x3ffb1f10 0x400d6a39:0x3ffb1f30 0x400d1f39:0x3ffb1f50 0x400d3a35:0x3ffb1f70 0x400e1322:0x3ffb1fb0 0x40090c42:0x3ffb1fd0
  #0  0x40091c75:0x3ffb1e80 in vPortCPUAcquireMutexIntsDisabledInternal at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
      (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.h:98
      (inlined by) vTaskEnterCritical at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:4201
  #1  0x40093cab:0x3ffb1eb0 in multi_heap_internal_lock at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap.c:380
  #2  0x400942e5:0x3ffb1ed0 in multi_heap_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c:321
  #3  0x4008203d:0x3ffb1ef0 in heap_caps_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:232
  #4  0x400d724b:0x3ffb1f10 in lgfx::v1::SpriteBuffer::reset(unsigned int, lgfx::v1::AllocationSource) at .pio/libdeps/Core2_SCD30/M5GFX/src/lgfx/v1/misc/SpriteBuffer.cpp:106
      (inlined by) lgfx::v1::SpriteBuffer::reset(unsigned int, lgfx::v1::AllocationSource) at .pio/libdeps/Core2_SCD30/M5GFX/src/lgfx/v1/misc/SpriteBuffer.cpp:131
  #5  0x400d6a39:0x3ffb1f30 in lgfx::v1::Panel_Sprite::createSprite(int, int, lgfx::v1::color_conv_t*, bool) at .pio/libdeps/Core2_SCD30/M5GFX/src/lgfx/v1/misc/colortype.hpp:585
  #6  0x400d1f39:0x3ffb1f50 in lgfx::v1::LGFX_Sprite::createSprite(int, int) at .pio/libdeps/Core2_SCD30/M5GFX/src/lgfx/v1/misc/colortype.hpp:827
  #7  0x400d3a35:0x3ffb1f70 in setup() at src/main.cpp:182
  #8  0x400e1322:0x3ffb1fb0 in loopTask(void*) at /Users/patrickfelstead/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:18
  #9  0x40090c42:0x3ffb1fd0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

I haven't tried the devlop branch to see if this fixes the problem yet. Please let me know if I've done something wrong, or what I can try to fix this. Thanks.

General questions

Hi there @lovyan03 this looks very promising. Is it ready for people to start using?

I have been using @tobozo's ESP32-Chimera-Core because I want an up to date TFT_eSPI library for use with M5 Stack Core2. However the 3 touch buttons at the bottom of the LCD were not working properly (.pressedFor(1000) specifically) and tobozo told me about M5Unified.

I tried this library today and found the following issues:

  • I couldn't find a way to control the Core2 green LED which is done via the AXP192 "Sys_LED" on GPIO1. M5Stack's library has M5.Axp.SetLed(0); to turn the LED off.
  • I use the FastLED library to control a single WS2812 RGB LED with data pin on ESP32 GPIO27. This was working on Chimera-Core but now the LED does not turn on. Not sure what's happening here.
  • I have a I2C sensor with SDA on pin 32, SCL pin 33 however I don't seem to be able to communicate with it any more. I initialise it in Wire.begin(32, 33);. I then tried M5.Ex_I2C.begin(I2C_NUM_1, 32, 33); but this also doesn't seem to work.

I'd appreciate your thoughts / ideas on these issues, thank you.

[CoreS3] Ersatz for M5.update() to support M5.BtnX using touch

Unlike M5Core2 where the touch surface is bigger than the display, the CoreS3 touch surface is limited to the inner display area.

There are many valid reasons why touch buttons emulation is not activated with CoreS3, but in some projects there is is also a need for a transparent solution.

This snippet enables BtnA, BtnB and BtnC on CoreS3 using modified logic from M5Core2 buttons emulation, without breaking the Unified in M5Unified.

// 1) optionnally draw three buttons at the bottom of the screen (20px max)
// 2) use `M5Update()` instead of `M5.update()`

void M5Update()
{
  if( M5.getBoard()==lgfx::boards::board_M5StackCoreS3 && M5.Touch.isEnabled() ) {
    // M5Unified doesn't handle Touch->M5.BtnX translation for CoreS3, give it a little help
    uint8_t edge = 220; // spoil 20px out from the touch zone
    auto ms = m5gfx::millis();
    M5.Touch.update(ms);
    uint_fast8_t btn_bits = 0;
    int i = M5.Touch.getCount();
    if( i>0 ) {
      while (--i >= 0) {
        auto raw = M5.Touch.getTouchPointRaw(i);
        if (raw.y > edge) {
          auto det = M5.Touch.getDetail(i);
          if (det.state & m5::touch_state_t::touch) {
            if (M5.BtnA.isPressed()) { btn_bits |= 1 << 0; }
            if (M5.BtnB.isPressed()) { btn_bits |= 1 << 1; }
            if (M5.BtnC.isPressed()) { btn_bits |= 1 << 2; }
            if (btn_bits || !(det.state & m5::touch_state_t::mask_moving)) {
              btn_bits |= 1 << ((raw.x - 2) / 107);
            }
          }
        }
      }
    }
    M5.BtnA.setRawState(ms, btn_bits & 1);
    M5.BtnB.setRawState(ms, btn_bits & 2);
    M5.BtnC.setRawState(ms, btn_bits & 4);
  } else { // trust M5Unified
    M5.update();
  }
}

Button_ClassのwasHoldがtrueでもisHoldingがfalse

概要

isHoldingは前回と今回の両方がホールドである必要がある。
wasHoldは今回がホールドであるとtrueになるので結果がずれる。
意図している or 仕様であれば問題ありません

isHoldingの実装

bool isHolding(void)   const { return _oldPress == 2 && _press == 2; }

wasHoldの実装

    /// Returns true when the button has been held pressed for a while.
    bool wasHold(void)     const { return _currentState == state_hold; }

検証コード

#include <M5Unified.h>

void setup(void) {
  M5.begin();
}

void loop(void) {
  String printStr = "";
  static String oldStr = "";

  delay(1);
  M5.update();

  printStr += String(",isPressed:") + String(M5.BtnA.isPressed() ? "X" : " ");
  printStr += String(",isHolding:") + String(M5.BtnA.isHolding() ? "X" : " ");
  printStr += String(",isReleased:") + String(M5.BtnA.isReleased() ? "X" : " ");

  printStr += String(",wasPressed:") + String(M5.BtnA.wasPressed() ? "X" : " ");
  printStr += String(",wasHold:") + String(M5.BtnA.wasHold() ? "X" : " ");
  printStr += String(",wasReleased:") + String(M5.BtnA.wasReleased() ? "X" : " ");
  printStr += String(",wasClicked:") + String(M5.BtnA.wasClicked() ? "X" : " ");

  printStr += String(",wasSingleClicked:") + String(M5.BtnA.wasSingleClicked() ? "X" : " ");
  printStr += String(",wasDoubleClicked:") + String(M5.BtnA.wasDoubleClicked() ? "X" : " ");
  printStr += String(",wasDecideClickCount:") + String(M5.BtnA.wasDecideClickCount() ? "X" : " ");
  printStr += String(",wasChangePressed:") + String(M5.BtnA.wasChangePressed() ? "X" : " ");
  printStr += String(",wasReleasedAfterHold:") + String(M5.BtnA.wasReleasedAfterHold() ? "X" : " ");

  printStr += String(",getClickCount:") + String(M5.BtnA.getClickCount());

  if (oldStr != printStr) {
    Serial.println(printStr);
    oldStr = printStr;
  }
}

結果

,isPressed:X,isHolding: ,isReleased: ,wasPressed:X,wasHold: ,wasReleased: ,wasClicked: ,wasSingleClicked: ,wasDoubleClicked: ,wasDecideClickCount: ,wasChangePressed:X,wasReleasedAfterHold: ,getClickCount:0
,isPressed:X,isHolding: ,isReleased: ,wasPressed: ,wasHold: ,wasReleased: ,wasClicked: ,wasSingleClicked: ,wasDoubleClicked: ,wasDecideClickCount: ,wasChangePressed: ,wasReleasedAfterHold: ,getClickCount:0
,isPressed:X,isHolding: ,isReleased: ,wasPressed: ,wasHold:X,wasReleased: ,wasClicked: ,wasSingleClicked: ,wasDoubleClicked: ,wasDecideClickCount: ,wasChangePressed: ,wasReleasedAfterHold: ,getClickCount:0
,isPressed:X,isHolding:X,isReleased: ,wasPressed: ,wasHold: ,wasReleased: ,wasClicked: ,wasSingleClicked: ,wasDoubleClicked: ,wasDecideClickCount: ,wasChangePressed: ,wasReleasedAfterHold: ,getClickCount:0
,isPressed: ,isHolding: ,isReleased:X,wasPressed: ,wasHold: ,wasReleased:X,wasClicked: ,wasSingleClicked: ,wasDoubleClicked: ,wasDecideClickCount: ,wasChangePressed:X,wasReleasedAfterHold:X,getClickCount:0
,isPressed: ,isHolding: ,isReleased:X,wasPressed: ,wasHold: ,wasReleased: ,wasClicked: ,wasSingleClicked: ,wasDoubleClicked: ,wasDecideClickCount: ,wasChangePressed: ,wasReleasedAfterHold: ,getClickCount:0

What is syntax to create sprite?

Apologies for all the issues. What's the preferred way to create a sprite object? Before setup() declare:

M5Canvas BattSprite; or
M5Canvas BattSprite(&M5.Lcd); or even
LGFX_Sprite BattSprite;

They all seem to work. Obviously then in setup():

BattSprite.createSprite(batt_spr_wdth, batt_spr_ht); etc

Thank you.

How to reconfigure pins on second I2C channel

Hi there, for reasons I won't go into here, I'm trying to initialise the second I2C port as follows:

SDA = GPIO26
SCL = GPIO36

The first thing I do is:

void setup(void) {
  auto cfg = M5.config();
  cfg.serial_baudrate = 115200;  // default=115200. if "Serial" is not needed, set it to 0.
  cfg.clear_display = true;      // default=true. clear the screen when begin.
  cfg.output_power = true;       // default=true. use external port 5V output.
  cfg.internal_imu = true;      // default=true. use internal IMU.
  cfg.internal_rtc = true;       // default=true. use internal RTC.
  cfg.external_imu = false;      // default=false. use Unit Accel & Gyro.
  cfg.external_rtc = false;      // default=false. use Unit RTC.
  cfg.led_brightness = 0;        // default= 0. Green LED brightness (0=off / 255=max) (※ not NeoPixel)

  M5.begin(cfg);
...

and then a short while later, I call

begin_ok = Wire.begin(26, 36);

However my I2C sensor on pins 26, 36 is not being found. I think this should be possibe, but the M5Unified begin code is a little hard for me to follow. It appears to me that you use I2C channel 1 (I2C_NUM_1) pins 21 and 22 for the PMU and internal RTC etc. So I2C channel 0 should be available for me to use given I'm not using external RTC or external IMU.

Is there an easy way for me to configure the unused I2C port with pins 26 and 36?

Thanks in advance!

Question about LovyanGFX vs M5GFX

Hi Lovyan. I am curious. I seem to recall that M5Unified included LovyanGFX library, however it now looks like it uses M5GFX, which looks like a branch of LovyanGFX. Can I ask why you did this, doesn't it mean you need to duplicate library maintenance? i.e. you need to make the same changes to LovyanGFX and also M5GFX - or do I misunderstand.

Thanks in advance.

esp_idf_version.h がM5Stack1.0.9系には入っていない

Arduino1.0.5(ESP-IDF3.3)から追加されたファイルのため、1.0.4(ESP-IDF3.2)ベースのM5Stack1.0.9には存在していません

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)

の部分がM5Stack1.0.9でエラーになります。

C:\Users\tanaka\Documents\Arduino\libraries\M5Unified-0.0.1\src\M5Unified.cpp:14:43: error: missing binary operator before token "("
 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
                                           ^

ESP_IDF_VERSIONが未定義の場合はESP-IDF3.2未満と判定する必要があります。

M5GO2 (for CORE2, AWS)

Hi,

Thank you for your incredible work.
The leds from M5GO2 module seem to don't work (GPIO 25) with M5Stack CORE2 or AWS.
It works like a charm with M5GO module on BASIC (GPIO 15).
Do you confirm ?

Armel.

M5Core2 issues when Battery/Screen removed.

I'm having an issue, the M5core2 is the near perfect ready made system for my application. I have tried to use just the bare board with no screen/touch sensor or battery connected and I have found that the internal I2c bus seams to not be responding. I see no i2c traffic using a scope after calling M5.begin , subsequent attempts to read the AXP192 all return 0 the, 5v boost will not turn on... Is there a quick easy i can disable using the primary display/touch sensor so i can start to narrow this down? I'm kind of new to using the ESP32, and i see there is some logging built into the code, how can i enable its output so i can see whats happening at startup?
The external I2c Bus still functions and the program itself is not hung up.
Thank You!

SD-Card (GPIO_NUM_4) interferes with DAC Output

Hi there

When starting the implementation of the SD-Card with SD.begin(GPIO_NUM_4, SPI, 25000000), the DAC Output of G25 and G26
aren't giving any signals out.

I tested it with an Oscilloscope which is able to detect Frequency's.
The DAC Output normally works when the SD-Card isn't implemented, so it seems that GPIO_NUM_4 interferes with DAC in some way.

Is there a way to set the GPIO_NUM_4 back to it's origin settings after the Data has been downloaded and loaded from the SD-Card, or is there another solution to it?

The settings of Speaker_Class Config is:

struct speaker_config_t
  {
    /// i2s_data_out (for spk)
    int pin_data_out = I2S_PIN_NO_CHANGE;

    /// i2s_bck
    int pin_bck = I2S_PIN_NO_CHANGE;

    /// i2s_ws (lrck)
    int pin_ws = I2S_PIN_NO_CHANGE;

    /// output sampling rate (Hz)
    uint32_t sample_rate = 254000;

    /// use stereo output
    bool stereo = false;

    /// use single gpio buzzer, ( need only pin_data_out )
    bool buzzer = false;

    /// use DAC speaker, ( need only pin_data_out ) ( only GPIO_NUM_25 or GPIO_NUM_26 )
    bool use_dac = true;

    /// Zero level reference value when using DAC ( 0=Dynamic change )
    uint8_t dac_zero_level = 0;

    /// multiplier for output value
    uint8_t magnification = 128;

    /// for I2S dma_buf_len
    size_t dma_buf_len = 128;

    /// for I2S dma_buf_count
    size_t dma_buf_count = 8;

    /// background task priority
    UBaseType_t task_priority = 2;

    /// background task pinned core
    BaseType_t task_pinned_core = -1;

    /// I2S port
    i2s_port_t i2s_port = i2s_port_t::I2S_NUM_0;
  };

ATOM MatrixのIMUだけ方向が違う

M5StickC(or他のボード)とATOM MatrixをUSBポートを手前にして、画面orマトリクスを上にした状態で動かした場合にIMUの数値がATOM Matrixのみ違う
おそらくセンサーの向きが違うので、できれば同じ方向に揃えてほしい

M5Unified - sprite doesn't work

Hi, if I use the sprite class, I get this error:
C:\Users\ftens\Sviluppo SW\Arduino\M5Stack-core2_display\Sprite_drawPixel\Sprite_drawPixel.ino:39:1: error: 'TFT_eSprite' does not name a type
TFT_eSprite spr = TFT_eSprite(&M5.Lcd);

If I use the M5Core.h library it works..

speaker streaming and playRaw()

Naively, I thought that repeated calls to Speaker.playRaw() on the same channel with stop_current_sound=false would connect exactly, without a gap. But I tried it and there seems to be clicking artifacts due to a gap.

We could use it to simply stream from an audio file or real-time generated waveform.

Since Speaker has multiple channels and various functionality, it would be nice to combine streaming on one channel with one-shot sounds on other channels under a single API.

Do I understand it correctly? 🙏 @lovyan03

非同期のaquestalkのexampleありませんか?

いつも使いやすいライブラリ提供ありがとうございます。
lovyangfxとaquestalkを組み合わせてm5stackcore2のコード書いてましたが、タッチ操作も追加したくなり、ちょうどm5の機能が統合されたm5unifiedが使えそうなので試しました。
setup内での再生はうまくいくのですが、loop内で非同期再生しようとaquesTTSを修正して試しましたが、うまく行きません。
音は出ますが細切れの超スロー再生のような感じになってしまいます。
非同期バージョンのexampleがあると嬉しいです。

M5Stack Core 2 AWS Edukit - ATEECCX08 supported?

I have this code which worked with the m5core2 library:

void atecc608Init(){
  Wire.begin(21, 22);
  if (!ECCX08.begin(0x35)) {
    Serial.println("ATECC608 secure element failed to start.");
    while (1);
  }
  Serial.print("ATECC608 serial number: ");
  Serial.println(ECCX08.serialNumber());
}

Wakes up the ECCX08 chip and prints the serial number. But when I try with the M5 Unified library instead, it fails to start.

Any ideas how to make this work? Or maybe it's not supported with this library?

Missing IMU_Class::getTemp() function declaration

IMU_Class::getTemp() is defined in IMU_Class.hpp, but not implemented in IMU_Class.cpp which leads to a link error when attempting to leverage the function.

Here is a possible implementation for IMU_Class.cpp:

bool IMU_Class::getTemp(float *t) {
  bool res = false;

  switch (_imu) {
    case imu_t::imu_sh200q:
      res = Sh200q.getTemp(t);
      break;
    case imu_t::imu_mpu6050:
    case imu_t::imu_mpu9250:
    case imu_t::imu_mpu6886:
      res = Mpu6886.getTemp(t);
      break;
    case imu_t::imu_unknown:
    default:
      break;
  }

  return res;
}

I hope this helps!

PS: Working on an ESPHome wrapper for m5unified.

Panic on M5Tough (won't fix)

The M5Tough is crashing with the following panic during the Arduino setup() function:

I (0) cpu_start: Starting scheduler on APP CPU.
Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x00000040  PS      : 0x00060030  A0      : 0x800d5fa5  A1      : 0x3ffb9eb0  
A2      : 0x3ffb2cf4  A3      : 0x00000040  A4      : 0x000000a4  A5      : 0x00000000  
A6      : 0x00010101  A7      : 0x00060823  A8      : 0x800d6aa7  A9      : 0x3ffb9ea0  
A10     : 0x3ffb2cf4  A11     : 0x00000000  A12     : 0x00000000  A13     : 0x3ffb32da  
A14     : 0x00000000  A15     : 0x01000101  SAR     : 0x00000000  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000040  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  


Backtrace:0x0000003d:0x3ffb9eb00x400d5fa2:0x3ffb9f50 0x400894e5:0x3ffb9f70 
0x400d5fa2: loopTask(void*) at /home/max/projects/hardware/esp32-temp/tough/build/../components/arduino-esp32/cores/esp32/main.cpp:42

0x400894e5: vPortTaskWrapper at /home/max/esp/esp-idf-v4.4/components/freertos/port/xtensa/port.c:131

I'm trying to run the HowToStart example.

I was able to draw to the LCD using the M5Tough library.

Used Software

M5Unified: Latest as of today
ESP-IDF: 4.4
arduino-esp32: Latest as of today (master branch)

Cannot compile RTC.ino example

Hi there, thanks for your great library. My question is related to PR #20

I cannot get the basic RTC.ino example to compile when I uncomment these lines to sync Core2 RTC with NTP

/* /// setup RTC ( NTP auto setting )
M5.Display.print("WiFi:");
WiFi.begin( WIFI_SSID, WIFI_PASSWORD );
configTzTime(NTP_TIMEZONE, NTP_SERVER1, NTP_SERVER2, NTP_SERVER3);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print('.');
delay(500);
}
Serial.println("\r\n WiFi Connected.");
M5.Display.print("Connected.");
while (sntp_get_sync_status() != SNTP_SYNC_STATUS_COMPLETED)
{
Serial.print('.');
delay(1000);
}
Serial.println("\r\n NTP Connected.");
time_t t = time(nullptr)+1; // Advance one second.
while (t > time(nullptr)); /// Synchronization in seconds
M5.Rtc.setDateTime( localtime( &t ) );
//*/

It is failing on line 55. I'm unsure how this can compile when it is an IDF framework function, not an Arduino framework function?
while (sntp_get_sync_status() != SNTP_SYNC_STATUS_COMPLETED)

I acknowledge this is not a M5 Unified issue, but any help would be appreciated because I get inconsistent results using a 1sec delay after calling sync with NTP. Sometimes it works, other times it syncs to an incorrect time.

Thankyou.

M5Tough - charging backup battery (RTC) is disabled by default in stock firmware loaded in the factory

Hi guys

is there any particular reason the backup battery (RTC) charging is disabled by default on M5Core2, M5Tough and M5StickCPlus?

I only noticed this since the backup battery in my M5Tough was flat when the device arrived and the RTC time restarted at 00:00:00 every time I powered M5Tough via USB and it did not improve even after letting it run with USB plugged in. Then looking through the code I noticed this function Axp192.setBACKUP(); but it isn't called from anywhere.

Thanks
Felix

GoPlus2 problem

Hi, I tried the library with two samples and and when I run the programs in a Core2 with a GoPlus2 attached, the servo connected to SERVO1 out start to run.

The examples I tried are the bluetooth speaker and the "HowToUse.ino" demo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.