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

    M5Paper Line Break in text

    Scheduled Pinned Locked Moved General
    3 Posts 1 Posters 5.4k Views 1 Watching
    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.
    • D Offline
      DiWa
      last edited by

      I am trying to display a longer text received from Telegram on the M5Paper display. The text includes \n for line breaks, however I am unable to display it properly. This is the snippit from the Arduino code:

      String Rezept = "Line 1 \n Line 2";

      void setup() {
      Serial.begin(115200);
      M5.begin();
      M5.EPD.SetRotation(90);
      M5.EPD.Clear(true);

      canvas.createCanvas(540, 960);
      canvas.setTextSize(3);
      canvas.setTextArea(0, 0, 760, 390);
      canvas.setTextWrap(true, false);
      canvas.printf(Rezept, 35, 350);
      canvas.printf("Line 1 \n Line 2", 35, 350);
      canvas.drawString("Line 1 \n Line 2", 35, 350);
      canvas.pushCanvas(0,0,UPDATE_MODE_DU4);

      I tried different methods, but none works:
      canvas.printf(Rezept, 35, 350); --> no matching function for call to 'M5EPD_Canvas::println(String&, int, int)'
      canvas.printf("Line 1 \n Line 2", 35, 350); --> This works well, but I hard coded text
      canvas.drawString("Line 1 \n Line 2", 35, 350); --> does not recognize the \n

      Any idea what I can do? Thanks a lot!

      1 Reply Last reply Reply Quote 0
      • D Offline
        DiWa
        last edited by

        Solved, this works fine:

        char Rezept[50] = "Line 1 \n Line 2";

        and

        canvas.print(Rezept);

        1 Reply Last reply Reply Quote 0
        • D Offline
          DiWa
          last edited by

          In case you are interested about the final result: https://youtu.be/hrmYldbOStQ

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post