Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. makingwaves
    M
    • Continue chat with makingwaves
    • Start new chat with makingwaves
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    makingwaves

    @makingwaves

    0
    Reputation
    8
    Posts
    388
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    makingwaves Follow

    Posts made by makingwaves

    • RE: esp32_adc2gpio not declared in pins_arduino.h for M5StickCPlus

      I replaced the macro analogInputToDigitalPin(p) in the file packages\m5stack\hardware\esp32\2.0.5\variants\m5stick_c_plus\pins_arduino.h and it seemed to work:

      //#define analogInputToDigitalPin(p)  (((p)<20)?(esp32_adc2gpio[(p)]):-1)
      #define analogInputToDigitalPin(p)  (((p)<20)?(analogChannelToDigitalPin(p)):-1)
      

      I tested it with the following sketch, which printed the correct sequence of mappings (36, 37, 38, 39, 32, 33, 34, 35, -1, -1, 4, 0, 2, 15, 13, 12, 14, 27, 25, 26):

      #include <M5StickCPlus.h>
      void setup() {
        M5.begin();
        M5.Lcd.fillScreen(RED);
        for (uint8_t i = 0;  i < 20;  i++) {
          Serial.println(analogInputToDigitalPin(i));
        }
      }
      
      void loop() {
      }
      

      With this change, I was able to get the Blynk Quickstart example working with my M5StickCPlus, which is what led me down this rabbit hole in the first place!

      posted in Arduino
      M
      makingwaves
    • esp32_adc2gpio not declared in pins_arduino.h for M5StickCPlus

      The file pins_arduino.h in the 2.0.5 board files for the M5Stick-C-Plus contains a macro definition that refers to an array esp32_adc2gpio that appears to be undefined and causes a compile error. I first ran into the problem when trying to compile a Blynk Quickstart example.

      Comparing this with the pins_arduino.h files for other M5Stack devices including Atom, Stick-C, and Core2, I noticed that they do not refer to esp32_adc2gpio, but instead call a function analogChannelToDigitalPin that compiles properly. Is this a bug for Stick-C-Plus and should it call the same function as the Stick-C and other devices? Any insights/comments would be appreciated!

      Here's a bunch more detail on what I've found.

      Here's the macro definition from the file packages\m5stack\hardware\esp32\2.0.5\variants\m5stick_c_plus\pins_arduino.h

      #define analogInputToDigitalPin(p)  (((p)<20)?(esp32_adc2gpio[(p)]):-1)
      

      Note that the same macro is also used in the pins_arduino.h files for several other device variants, including m5stack_paper and m5stack_tough.

      Here's a simple sketch that causes a compile error related that uses the macro:

      void setup() {
        analogInputToDigitalPin(5);
      }
      
      void loop() {
      }
      

      Here's the error I get:

      C:\Users\xxx\AppData\Local\Arduino15\packages\m5stack\hardware\esp32\2.0.5\variants\m5stick_c_plus/pins_arduino.h:10:48: error: 'esp32_adc2gpio' was not declared in this scope
       #define analogInputToDigitalPin(p)  (((p)<20)?(esp32_adc2gpio[(p)]):-1)
      

      When I searched the entire m5stack for esp32_adc2gpio using grep -r, it wasn't anywhere to be found.

      If I change the device to M5Stack-Atom, it compiles fine.

      I looked at the pins_arduino.h files for a few other device variants and saw that they use a different definition for the macro. For variants m5stack_atom and m5stick_c, the macro analogInputToDigitalPin is defined as:

      #define analogInputToDigitalPin(p)  (((p)<20)?(analogChannelToDigitalPin(p)):-1)
      

      The function analogChannelToDigitalPin is defined in packages\m5stack\hardware\esp32\2.0.5\cores\esp32\esp32-hal-gpio.c This function refers to another array called adc_channel_io_map that does appear to be defined in the esp32 library archive files according to grep:

      (base) PS C:\Users\xxx\Downloads\m5stack-2.0.5\m5stack-2.0.5> grep -r adc_channel_io_map .
      ./cores/esp32/esp32-hal-gpio.c:                if (adc_channel_io_map[i][j] == pin) {
      ./cores/esp32/esp32-hal-gpio.c:    return adc_channel_io_map[adc_unit][adc_chan];
      ./tools/sdk/esp32/include/soc/include/soc/adc_periph.h:extern const int adc_channel_io_map[SOC_ADC_PERIPH_NUM][SOC_ADC_MAX_CHANNEL_NUM];
      Binary file ./tools/sdk/esp32/lib/libdriver.a matches
      Binary file ./tools/sdk/esp32/lib/libhal.a matches
      Binary file ./tools/sdk/esp32/lib/libsoc.a matches
      

      Perhaps the version of the macro analogInputToDigitalPin for the Stick-C-Plus is obsolete and should replaced with the version that calls analogChannelToDigitalPin? Or maybe I'm missing something else?

      posted in Arduino
      M
      makingwaves
    • Error compiling for ArduinoIoTCloud with M5StickCPlus

      I have been using Arduino IoT Cloud successfully with an M5Atom for a while, creating Things with cloud variables controlled by Dashboards, such as using a button on a Dashboard change the color of the LED. I tried doing something similar with an M5StickCPlus with a simple sketch using the template provided by IoT Cloud to change the color of the LCD display:

      #include "arduino_secrets.h"
      /* 
        Sketch generated by the Arduino IoT Cloud Thing "Untitled"
        https://create.arduino.cc/cloud/things/e393cc1c-d5b7-48bb-8a27-521dxxxxxxx
      
        Arduino IoT Cloud Variables description
      
        The following variables are automatically generated and updated when changes are made to the Thing
      
        bool button;
      
        Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
        which are called when their values are changed from the Dashboard.
        These functions are generated with the Thing and added at the end of this sketch.
      */
      
      #include "thingProperties.h"
      #include "M5StickCPlus.h"
      
      void setup() {
        M5.begin();
      
        // Defined in thingProperties.h
        initProperties();
      
        // Connect to Arduino IoT Cloud
        ArduinoCloud.begin(ArduinoIoTPreferredConnection);
        
      void loop() {
        ArduinoCloud.update();
        // Your code here 
      }
      
      /*
        Since Button is READ_WRITE variable, onButtonChange() is
        executed every time a new value is received from IoT Cloud.
      */
      void onButtonChange()  {
        // Add your code here to act upon Button change
        if (button)
          M5.Lcd.fillScreen(RED);
        else
          M5.Lcd.fillScreen(BLUE);
      }
      

      When I compile this, I get the following error:

      c:\Users\xxx\Documents\Arduino\libraries\M5StickCPlus\src/utility/In_eSPI.h:952:52: error: macro "setAttribute" passed 2 arguments, but takes just 1
      			     void setAttribute(uint8_t id = 0, uint8_t a = 0);
      

      The problem is that ArduinoIoTCloud.h includes a file property/Property.h that defines three macros, including setAttribute

      #define appendAttributesToCloud() appendAttributesToCloudReal(CborEncoder *encoder)
      #define appendAttribute(x) appendAttributeReal(x, getAttributeName(#x, '.'), encoder)
      #define setAttribute(x) setAttributeReal(x, getAttributeName(#x, '.'))
      

      Unfortunately, there is a class member function called setAttribute in the library file M5StickCPlus/src/utility/In_eSPI.h

      // Set or get an arbitrary library attribute or configuration option
          void setAttribute(uint8_t id = 0, uint8_t a = 0);
          uint8_t getAttribute(uint8_t id = 0);
      

      Because the macro from the ArduinoIoTCloud library is included globally, it ends up getting used in place of the correct function (which has 2 arguments).

      Whose "fault" is this and what should be the fix? In general, I think it's not good form to include a global macro in a library, especially one with a name like setAttribute that could easily match something in user code that includes that library. So I decided to change my local copy of the ArduinoIoTCloud library and replace the macro name with AIOTC_setAttribute (as well as prefixing the other two macros with AIOTC_), and then modify all of the files in property/types that use this macro to match.

      Hopefully someone finds this helpful. I'm going to post this over on the Arduino forum as well, as I think these global macros should be replaced by something safer.

      posted in Arduino
      M
      makingwaves
    • RE: esptool write_flash: error: argument : Address "{upload.erase_cmd}" must be a number

      Hi @veryalien,

      For the record, I was getting this error with the M5StickC PLUS and your suggested edits to boards.txt fixed the problem. Thanks! Note that for whatever reason, I was not getting this error with an M5Atom.

      Do you know how/when M5Stack does new releases that incorporates bug fixes such as these? Do we need to somehow notify them or do they regularly read the community forum? I'm aware of at least one library bug that someone has found a fix for in the forum. In that case, the user did a pull request on GitHub and the fix was pulled into the repository, but a new version of the library has not been released.

      posted in Arduino
      M
      makingwaves
    • RE: M5StickC Plus arduino 8Servos HAT v1.1 example missing in repository

      Hi @felmue,

      I see on GitHub that your pull request has been merged, but it hasn't yet been published as a new version release of the Arduino library (which I confirmed by uninstalling and reinstalling the library). The latest library version is still set as release 0.0.2 from July 24, which indicates that there are 2 commits that have been made (yours and Tinyu's) since the release. Not sure what M5Stack's process is for releasing new versions of libraries, but it is interesting to see how sausage is made.

      posted in M5 Stick/StickC
      M
      makingwaves
    • RE: M5StickC Plus arduino 8Servos HAT v1.1 example missing in repository

      Hi @felmue,

      Thanks for pointing out the pull request. Does this mean that the change would show up as a library update in the Arduino library manager once the pull request is processed?

      I also will be taking a closer look at the info you've put on your website on M5Stack resources. I'm fairly new in working with M5Stack and ESP32 in general, and have been using a mix of IDE 2.0 and the Web Editor. Both platforms seem to have their pros and cons. I'm also using Arduino IoT Cloud to create "Things" that support shared variables in the cloud, which simplifies the development for a lot of basic applications. To use this, however, you have to initiate projects in IoT Cloud, which you can then pull and push to IDE 2.0. At present, you can't create new IoT Cloud "Things" from the IDE.

      Thanks,

      Jay

      posted in M5 Stick/StickC
      M
      makingwaves
    • RE: M5StickC Plus arduino 8Servos HAT v1.1 example missing in repository

      @felmue, It worked!!! Thanks! If I had a way to use this device to pour you a beer over the cloud, I would do so.

      Regards,

      Jay

      posted in M5 Stick/StickC
      M
      makingwaves
    • RE: M5StickC Plus arduino 8Servos HAT v1.1 example missing in repository

      @kjaern did you ever get the 8Servos HAT v1.1 working? I just purchased one and was able to compile the code, but also never get past "Connect Error". I've also tried this with 2 different hats.

      Regards,

      Jay

      posted in M5 Stick/StickC
      M
      makingwaves