🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Drawing an icon on the M5Paper from an array

    Arduino
    3
    4
    1.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Steve1
      last edited by

      On the M5Paper how can I draw an icon using a function with drawPixel() from an array of the form;

      static const uint8_t SUNRISE64x64[8192] = {
      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff........};

      1 Reply Last reply Reply Quote 0
      • M
        Meldrak
        last edited by

        There is an M5Paper weather display that uses that very code. Maybe looking at it will help you figure it out. I am just getting started coding, but I compiled that weather project yesterday and remember seeing that code.

        https://github.com/Bastelschlumpf/M5PaperWeather/blob/master/weather/Icons.h

        1 Reply Last reply Reply Quote 0
        • S
          Steve1
          last edited by

          Yes indeed, that's the very code I'm using at the moment. The problem is the people over at the Arduino Forum insist that the code is "not allowed" and bad C/C++ coding because the icon arrays are uint8_t and the DrawIcon function uses uint16_t. Here is a link to the discussions this issue appears towards the end of the discussion from post 20/38. Also it is very difficult for me to understand eactly how the DrawIcon function works, even though it most certainly does work. I have tried changing the uint16_t references in the function to uint8_t and the arrays to uint16_t but all I get with both changes is a black square instead of an icon.

          1 Reply Last reply Reply Quote 0
          • felmueF
            felmue
            last edited by felmue

            Hello @Steve1

            I had success with the following converter settings.

            0_1704017737289_IconConvert1_20231231.png

            0_1704017750382_IconConvert2_20231231.png

            This creates a array size of 8192 - same as the stock icons and displays correctly using the DrawIcon() function from the Weather app.

            // array size is 8192
            static const uint16_t IconCloud64x64[]  = {
              0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
            

            Note: I had best results converting jpg using above converter. (png did not work for me and always created an all zero array.)

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • First post
              Last post