Git Product home page Git Product logo

m5tough's Issues

M5Tough.h:134:12: error: extended character “ is not valid

/home/runner/Arduino/libraries/CustomLibrary_M5Tough/src/M5Tough.h:134:12: error: extended character “ is not valid in an identifier
134 | #error “This library only supports boards with ESP32 processor.”
| ^
/home/runner/Arduino/libraries/CustomLibrary_M5Tough/src/M5Tough.h:134:68: error: extended character ” is not valid in an identifier
134 | #error “This library only supports boards with ESP32 processor.”
| ^

Error compiling FactoryTest.ino

hi,

I just bought this M5Stack Tough, and I'm trying to understand its components, but the example doesn't compile.

IDE: 2.3.2 ESP32: 3.0.0

In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Power_Class.hpp:17,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:55,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.h:5,
from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\ft6336_fw_updater.cpp:2:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
| ^~~~~~~
In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Speaker_Class.hpp:13,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:56:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/driver/deprecated/driver/i2s.h:27:2: warning: #warning "This set of I2S APIs has been deprecated, please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. if you want to keep using the old APIs and ignore this warning, you can enable 'Suppress leagcy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" [-Wcpp]
27 | #warning "This set of I2S APIs has been deprecated,
| ^~~~~~~
In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Power_Class.hpp:17,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:55,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.h:5,
from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\main.hpp:7,
from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\FactoryTest.ino:17:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
| ^~~~~~~
In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Speaker_Class.hpp:13,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:56:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/driver/deprecated/driver/i2s.h:27:2: warning: #warning "This set of I2S APIs has been deprecated, please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. if you want to keep using the old APIs and ignore this warning, you can enable 'Suppress leagcy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" [-Wcpp]
27 | #warning "This set of I2S APIs has been deprecated,
| ^~~~~~~
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\main.hpp: In function 'void setSpeaker(int)':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\main.hpp:53:22: warning: missing initializer for member 'i2s_driver_config_t::mclk_multiple' [-Wmissing-field-initializers]
53 | .fixed_mclk = 0};
| ^
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\main.hpp:53:22: warning: missing initializer for member 'i2s_driver_config_t::bits_per_chan' [-Wmissing-field-initializers]
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\main.hpp:63:3: warning: missing initializer for member 'i2s_pin_config_t::mck_io_num' [-Wmissing-field-initializers]
63 | };
| ^
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\main.hpp:55:8: warning: variable 'res' set but not used [-Wunused-but-set-variable]
55 | auto res = i2s_driver_install(Speak_I2S_NUMBER, &i2s_config, 0, nullptr);
| ^~~
In file included from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\FactoryTest.ino:23:
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageWiFi.hpp: In member function 'virtual void PageWiFi::loop()':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageWiFi.hpp:33:23: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' {aka 'long int'} [-Wformat=]
33 | M5.Lcd.printf("%d. %s : (%d)", i + 1, WiFi.SSID(i).c_str(), WiFi.RSSI(i));
| ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~
| |
| int32_t {aka long int}
In file included from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\FactoryTest.ino:24:
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageTOUCH.hpp: In member function 'void PageTOUCH::startEspNow()':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageTOUCH.hpp:54:29: error: invalid conversion from 'void ()(const uint8_t, const uint8_t*, int)' {aka 'void ()(const unsigned char, const unsigned char*, int)'} to 'esp_now_recv_cb_t' {aka 'void ()(const esp_now_recv_info, const unsigned char*, int)'} [-fpermissive]
54 | esp_now_register_recv_cb(OnDataRecv);
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
| |
| void ()(const uint8_t, const uint8_t*, int) {aka void ()(const unsigned char, const unsigned char*, int)}
In file included from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageTOUCH.hpp:5:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/esp_wifi/include/esp_now.h:157:54: note: initializing argument 1 of 'esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t)'
157 | esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t cb);
| ~~~~~~~~~~~~~~~~~~^~
In file included from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\FactoryTest.ino:27:
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp: In member function 'virtual void PageUART::setup()':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp:171:23: error: 'ESP_MAC_BT' was not declared in this scope
171 | esp_read_mac(mac, ESP_MAC_BT);
| ^~~~~~~~~~
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp:171:5: error: 'esp_read_mac' was not declared in this scope
171 | esp_read_mac(mac, ESP_MAC_BT);
| ^~~~~~~~~~~~
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp:182:23: error: 'ESP_MAC_WIFI_STA' was not declared in this scope; did you mean 'ESP_IF_WIFI_STA'?
182 | esp_read_mac(mac, ESP_MAC_WIFI_STA);
| ^~~~~~~~~~~~~~~~
| ESP_IF_WIFI_STA
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp: In constructor 'PageUART::ESPNOWSerial::ESPNOWSerial()':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp:337:31: error: invalid conversion from 'void ()(const uint8_t, const uint8_t*, int)' {aka 'void ()(const unsigned char, const unsigned char*, int)'} to 'esp_now_recv_cb_t' {aka 'void ()(const esp_now_recv_info, const unsigned char*, int)'} [-fpermissive]
337 | esp_now_register_recv_cb(OnDataRecv);
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
| |
| void ()(const uint8_t, const uint8_t*, int) {aka void ()(const unsigned char, const unsigned char*, int)}
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/esp_wifi/include/esp_now.h:157:54: note: initializing argument 1 of 'esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t)'
157 | esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t cb);
| ~~~~~~~~~~~~~~~~~~^~
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp: In member function 'virtual void PageUART::BLESerial::MyCallbacks::onWrite(BLECharacteristic*)':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PageUART.hpp:419:54: error: conversion from 'String' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string'} requested
419 | std::string rxValue = pCharacteristic->getValue();
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\FactoryTest.ino:30:
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PagePWR.hpp: In member function 'void PagePWR::setExtEn(bool)':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PagePWR.hpp:42:25: warning: 'void m5::Power_Class::setExtPower(bool, m5::ext_port_mask_t)' is deprecated: Change to setExtOutput [-Wdeprecated-declarations]
42 | M5.Power.setExtPower(flg);
| ~~~~~~~~~~~~~~~~~~~~^~~~~
c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Power_Class.hpp:64:10: note: declared here
64 | void setExtPower(bool enable, ext_port_mask_t port_mask = (ext_port_mask_t)0xFF) { setExtOutput(enable, port_mask); }
| ^~~~~~~~~~~
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PagePWR.hpp: In member function 'virtual void PagePWR::loop()':
C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\PagePWR.hpp:221:54: warning: 'float m5::AXP192_Class::getACINVolatge()' is deprecated: use getACINVoltage() [-Wdeprecated-declarations]
221 | drawFloat(122, 66, M5.Power.Axp192.getACINVolatge(), 1, 2);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:52:
c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/AXP192_Class.hpp:92:18: note: declared here
92 | inline float getACINVolatge(void) { return getACINVoltage(); }
| ^~~~~~~~~~~~~~
In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Power_Class.hpp:17,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:55,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.h:5,
from C:\Users\science\AppData\Local\Temp.arduinoIDE-unsaved2024430-5008-1n26240.k446\FactoryTest\tlsc6x_updater.cpp:2:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/driver/deprecated/driver/adc.h:19:2: warning: #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively" [-Wcpp]
19 | #warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
| ^~~~~~~
In file included from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/utility/Speaker_Class.hpp:13,
from c:\Users\science\Documents\Arduino\libraries\M5Unified\src/M5Unified.hpp:56:
C:\Users\science\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-442a798083/esp32/include/driver/deprecated/driver/i2s.h:27:2: warning: #warning "This set of I2S APIs has been deprecated, please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. if you want to keep using the old APIs and ignore this warning, you can enable 'Suppress leagcy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" [-Wcpp]
27 | #warning "This set of I2S APIs has been deprecated,
| ^~~~~~~
Multiple libraries were found for "SD.h"
Used: C:\Users\science\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.0\libraries\SD
Not used: C:\Users\science\AppData\Local\Arduino15\libraries\SD
Not used: C:\Users\science\Documents\Arduino\libraries\SD
exit status 1

Compilation error: invalid conversion from 'void ()(const uint8_t, const uint8_t*, int)' {aka 'void ()(const unsigned char, const unsigned char*, int)'} to 'esp_now_recv_cb_t' {aka 'void ()(const esp_now_recv_info, const unsigned char*, int)'} [-fpermissive]

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?

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?

Example M5Tough/Basic/Speak Only Plays Once

The example Speak, when compiled and loaded into the M5Tough, plays the "dingdong" sound on setup and does nothing further. There are no buttons displayed on the touch screen, and touching the lower left or anywhere else on the screen does nothing. I am trying to get any sound to play more than once when triggered, and thought I could use this example as a template. I really like the M5 platform and products, though!

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.

error in compile example

when i want to test example of tough controller it display this error:
In file included from c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/M5Display.h:10,
from c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/M5Tough.h:76,
from C:\Users\Admin\AppData\Local\Temp.arduinoIDE-unsaved202472-6768-12gh42i.vf28i\Display\Display.ino:13:
c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/M5Display.h: In member function 'void M5Display::startWrite()':
c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/utility/In_eSPI.h:212:26: error: 'GPIO' was not declared in this scope
212 | #define CS_L GPIO.out_w1tc = (1 << TFT_CS);GPIO.out_w1tc = (1 << TFT_CS)
| ^~~~
c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/M5Display.h:46:9: note: in expansion of macro 'CS_L'
46 | CS_L;
| ^~~~
c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/M5Display.h: In member function 'void M5Display::endWrite()':
c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/utility/In_eSPI.h:213:26: error: 'GPIO' was not declared in this scope
213 | #define CS_H GPIO.out_w1ts = (1 << TFT_CS)//;GPIO.out_w1ts = (1 << TFT_CS)
| ^~~~
c:\Users\Admin\Documents\Arduino\libraries\M5Tough\src/M5Display.h:57:9: note: in expansion of macro 'CS_H'
57 | CS_H;
| ^~~~

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.