Git Product home page Git Product logo

m5tough's Introduction

M5Tough Library

English | 中文

M5Tough_P1

  • For the Detailed documentation of M5Tough, please Click here

  • In order to buy M5Tough,please Click here

Description

M5Tough is the second generation core device in the M5Stack development kit series, which further enhances the functions of the original generation of cores.

The MCU is an ESP32 model D0WDQ6-V3 and has dual core Xtensa® 32-bit 240Mhz LX6 processors that can be controlled separately. WiFi and Bluetooth are supported as standard and it includes an on board 16MB Flash and 8MB PSRAM, USB TYPE-C interface for charging, downloading of programs and serial communication, a 2.0-inch integrated capacitive touch screen, and a built-in vibration motor.

M5Tough also features a built-in RTC module which can provide accurate timing. The power supply is managed by an AXP192 power management chip, which can effectively control the power consumption of the base and a built-in green LED power indicator helps to notify the user of battery level. The battery capacity has been upgraded to 390mAh, which can power the core for much longer than the previous model.

The M5Tough retains the SD card slot and speakers. However, in order to ensure higher quality sound output, the I2S digital audio interface power amplifier chip is used to effectively prevent signal distortion. There are independent power and reset buttons on the left side and bottom of the base.

The 3 icons on the front of the screen are capacitive buttons which are programmable.

PinMap

LCD & TF card

LCD :320x240 TF card Maximum size 16GB

ESP32 Chip GPIO38 GPIO23 GPIO18 GPIO5 GPIO15
AXP192 Chip AXP_IO4 AXP_LDO3 AXP_LDO2
ILI9342C MISO MOSI SCK CS DC RST BL PWR
ESP32 Chip GPIO38 GPIO23 GPIO18 GPIO4
TF Card MISO MOSI SCK CS

CAP.TOUCH

ESP32 chip GPIO21 GPIO22 GPIO39
AXP192 AXP_IO4
CHSC6540 SDA SCL INT RST

NS4168

ESP32 Chip GPIO12 GPIO0 GPIO2 AXP_IO2
NS4168 BCLK LRCK DATA SPK_EN

AXP Control

AXP192 AXP_IO1 AXP_IO2 AXP_IO4 AXP_LDO3
TouchPanel RST
SPEAKER EN
LCD RST backright

RTC

ESP32 Chip GPIO21 GPIO22
AXP192 AXP_PWR
BM8563 SDA SCL INT

USB to serial chip

ESP32 Chip GPIO1 GPIO3
CP2104 RXD TXD

Internal I2C connection

ESP32 Chip GPIO21 GPIO22
AXP192 SDA SCL
BM8563 SDA SCL
CHSC6540 SDA SCL

M5Tough M-BUS Schematic diagram

M5PORT EXPLAIN

PORT PIN Note:
PORT-A(Red) G32/33 I2C

More Information

Product docs

m5tough's People

Contributors

forairaaaaa avatar gitshaoxiang avatar lovyan03 avatar tinyu-zhao avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

m5tough's Issues

MPU6886 example not compilling

In the examples folder, there's an example for the MPU6886 imu. Unfortunately, it does not compile, because 'class M5Tough' has no member named 'IMU'. Looking at the code, that is correct, there's no reference whatsoever to an IMU in the declaration of the M5 class. According to the documentation, I'm not even sure the M5Though does have an IMU/MPU.

Can you clearify whether that example is supposed to work? Is there an IMU in the M5Though, and if so, what type is it?

Question: Difference to M5Unified

I'm currently building a project on the Tough. I'm unsure which library to use though to draw on the LCD and access GPIOs.

Is the M5Tough the legacy project which supports more right now but will be deprecated eventually?

Can I run M5Tough without Arduino using just esp-idf?

Factorytest.ino warnings and errors when trying to build in Arduino IDE

I encountered various errors/problems when trying to build/flash the ..\examples\core2_for_aws\FactoryTest\FactoryTest.ino, on a desktop PC with MS Windows 11 Pro and running Arduino IDE 1.8.19. A part of the errors have the same origin as discussed in issue #3: the lack of an IMU in the M5Stack TOUGH.

Starting with the following warning:

                 from C:\Users\pauls2\Documenten\Arduino\2022-03-03_M5Stack_TOUGH_FactoryTest\2022-03-03_M5Stack_TOUGH_FactoryTest.ino:21:
C:\Users\<Username>\Documents\Arduino\libraries\FastLED\src/fastspi.h:145:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output
 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

I did not do anything to solve this warning.

Then Errors related to a non existant IMU:

FactoryTest:448:12: error: 'class M5Tough' has no member named 'IMU'
    if (M5.IMU.Init() == 0) {
FactoryTest:612:8: error: 'class M5Tough' has no member named 'IMU'
     M5.IMU.getAccelData(&accX, &accY, &accZ);
        ^~~
C:\Users\<Username>\Documents\Arduino\libraries\M5Tough-master\examples\core2_for_aws\FactoryTest\FactoryTest.ino: In function 'void MPU6886Page()':
FactoryTest:1755:12: error: 'class M5Tough' has no member named 'IMU'
         M5.IMU.getAccelData(&accX, &accY, &accZ);

For this fact I removed: a) the checkIMUInit() function; b) the checkIMUInit() function; c) the MPU6886Page() function.

Then:

FactoryTest:473:31: error: call of overloaded 'begin(int, int, int)' is ambiguous
     Wire1.begin(21, 22, 100000);
                               ^
In file included from C:\Users\<Username>\Documenten\Arduino\libraries\ArduinoECCX08\src/ECCX08.h:24,
                 from C:\Users\<Username>\Documenten\Arduino\libraries\ArduinoECCX08\src/ArduinoECCX08.h:23,
                 from C:\Users\<Username>\Documenten\Arduino\libraries\M5Tough-master\examples\core2_for_aws\FactoryTest\FactoryTest.ino:13:
C:\Users\<Username>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\Wire\src/Wire.h:79:10: note: candidate: 'bool TwoWire::begin(int, int, uint32_t)'
     bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus
          ^~~~~
C:\Users\<Username>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\Wire\src/Wire.h:80:10: note: candidate: 'bool TwoWire::begin(uint8_t, int, int, uint32_t)'
     bool begin(uint8_t slaveAddr, int sda=-1, int scl=-1, uint32_t frequency=0);

To solve this ambiguity error:
In line 478 I changed: Wire1.begin(21, 22, 10000); into: Wire1.begin((uint8_t)21, 22, 10000); . The same in line 1947.

Then:
../FactoryTest.ino:466:49: warning: control reaches end of non-void function [-Wreturn-type]
int checkAETCC608AInit() causes a warning because the function does not return anything.
I changed it into: void checkAETCC608AInit().

After all these corrections the sketch built and flashed to my M5Stack TOUGH, but the unit switched off immediately after only showing the text "motor test" at the bottom of the display and sounding a dualtone bleep.

A next build failed with the error that the dynaming memory was full (102%).
The sketch uses 1344717 bytes of the program storage. The maximum is 1310720 bytes.
In an attempt to solve this I changed, where possible, Serial.print() commands with static texts into Serial.print(F("...")); however there were not that many of these commands. More in number were combined Serial.printf() commands.

I didn't find yet a solution to the memory full error.

Initialization and finalization issues related to M5Button class

While using the soft Buttons on M5Tough in a more dynamic way (not just as global objects, but rather as local variables in functions with a loop), the following issues were seen:

  1. When a Button object is deleted, pointers to it may remain in two locations (M5Buttons::event.button and M5Buttons::_finger[i].button) and may lead to overwriting free memory (or the stack) via M5.update().

A possible fix may be to add the following to the end of the method M5Buttons::delHandlers (which is called by the Button destructor with nullptr for fn):

  if (button && !fn) { // when deleting a button
   if (event.button == button) {
     event.button = nullptr;
   }
   for(int fIdx = 0; fIdx < 2; ++fIdx) {
     if (_finger[fIdx].button == button) {
       _finger[fIdx].button = nullptr;
     }
   }
 }

 
There is a similar problem with Gestures, but this was not used by us and the following fix (also for M5Buttons::delHandlers) was not tested:

  if (gesture && !fn) { // when deleting a gesture
   if (event.gesture == gesture) {
     event.gesture = nullptr;
   }
 }

 

  1. Some members of Button are not explicitly initialized. This can obviously be a problem if the object is not global/static. An error was observed in a program with several buttons on the stack: on the first M5.update(), a fake event with partially random data was reported to one handler function.
    The following statements may be added to the beginning of Button::init() to make the initialization at least equivalent to global/static default initialization:
  _changed = false;
 _longPressing = _cancelled = _manuallyRead = false;
 _setState = 0;
 _lastRepeat = _lastLongPress = 0;
 _finger = 0;
 _hidden = false;
 _name[sizeof(_name) - 1] = 0; // for safety if input was too long

 

Furthermore, the struct Finger should have a constructor:

in M5Button.h, add constructor declaration in “struct Finger {..”:

struct Finger {
  Finger();

 

and in M5Button.cpp, add:

#ifdef _M5TOUCH_H_
Finger::Finger() {
  startTime = 0;
  tapTime = 0;
  button = nullptr;
}
#endif

 

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.