m5stack-avatar icon indicating copy to clipboard operation
m5stack-avatar copied to clipboard

face-and-color example compile error solved

Open PaulskPt opened this issue 2 years ago • 0 comments

Using a M5Stack Core2 device.

To solve a reference to 'JPEG_DIV_NONE' is ambiguous and reference to 'jpeg_div_t' is ambiguous. errors, I changed the following file:

In file: libraries/M5Core2/src/M5Display.h, from line 13:

  typedef enum {
    JPEG_DIV_NN,  // name changed. Original JPEG_DIV_NONE 
    JPEG_DIV_2,
    JPEG_DIV_4,
    JPEG_DIV_8,
    JPEG_DIV_MAX
  } jpeg_div_disp_t; // name changed. Original jpeg_div_t 

I had to change both name definitions 'JPEG_DIV_NONE' and 'jpeg_div_t'.

Then, in file: libraries/M5Core2/src/M5Display.cpp,

a) Line 233:

  jpeg_div_disp_t scale;  // name changed by @PaulskPt. original jpeg_div_t resulted in an error: reference to 'jpeg_div_t' is ambiguous. I had to change both the names 

b) Lines 370-372:

void M5Display::drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x,
                        uint16_t y, uint16_t maxWidth, uint16_t maxHeight,
                        uint16_t offX, uint16_t offY, jpeg_div_disp_t scale) 

c) Lines 402-404:

void M5Display::drawJpgFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y,
                            uint16_t maxWidth, uint16_t maxHeight, uint16_t offX,
                            uint16_t offY, jpeg_div_disp_t scale) {

After these changes these errors did not repeat, but a class Button redefined error. To solve performed the following change:

// Following if...else...endif block added because of error redefinition of 'class Button' ( a) in class M5Stack Button.h; b) in Core2 M5Button.h)

# if defined(ARDUINO_M5STACK_Core2) || defined(M5AVATAR_CORE2) || defined(_M5Core2_H_)
  #include <M5Core2.h>
# else
  #include <M5Stack.h>
# endif

Finally I did the following change:

then I changed:
#include <Avatar.h>
#include <faces/DogFace.h>

into:
#include "Avatar.h"
#include "faces/DogFace.h"

After these changes this example built OK

PaulskPt avatar Mar 26 '22 20:03 PaulskPt