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

    display big numbers

    FAQS
    4
    5
    8.7k
    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.
    • C
      cepics
      last edited by

      Hi All,
      I'm using this sketch to display sensor value in four big number on M5 lcd...

      can someone help me to do not display the first "0"?

      es " 222" instead of "0222"
      or " 35" instead of "0035"
      0r " 9" instead of "0009"

      thanks a lot

      1 Reply Last reply Reply Quote 0
      • RopR
        Rop
        last edited by Rop

        Ouch, that is ugly code. But if you absolutely must, replace this bit:

          M5.Lcd.pushRect(80*3,40,80,160,(uint16_t *)(_buf+ c0 * 80 * 160 * 2));
          M5.Lcd.pushRect(80*2,40,80,160,(uint16_t *)(_buf+ c1 * 80 * 160 * 2));
          M5.Lcd.pushRect(80*1,40,80,160,(uint16_t *)(_buf+ c2 * 80 * 160 * 2));
          M5.Lcd.pushRect(80*0,40,80,160,(uint16_t *)(_buf+ c3 * 80 * 160 * 2));
        

        with

          M5.Lcd.pushRect(80*3,40,80,160,(uint16_t *)(_buf+ c0 * 80 * 160 * 2));
          if (count >= 10) M5.Lcd.pushRect(80*2,40,80,160,(uint16_t *)(_buf+ c1 * 80 * 160 * 2));
          if (count >= 100) M5.Lcd.pushRect(80*1,40,80,160,(uint16_t *)(_buf+ c2 * 80 * 160 * 2));
          if (count >= 1000) M5.Lcd.pushRect(80*0,40,80,160,(uint16_t *)(_buf+ c3 * 80 * 160 * 2));
        

        Note that this code will leave 9 digits on the display if the counter wraps around, you might need to put M5.Lcd.clear(WHITE); in there if you want to prevent that, but I didn't do it because it will cause flicker.

        Just out of curiosity: what are you trying to do here?

        1 Reply Last reply Reply Quote 0
        • C
          cepics
          last edited by

          Hi, tanks a lot but since I'm displaying distance with an HC-SR04 your code doesn't work for me... because the sensor can "jump" from a distance with three digit to a distance with two digit (es from 125 cm to 80cm).... and , like you say, I can't use M5.Lcd.clear(WHITE); for flickering issue...
          what I'm looking for is to "clear" only the rectangle where the digit "was"...

          mumble mumble

          thanks a lot anyway ...

          1 Reply Last reply Reply Quote 0
          • H
            heybin
            last edited by

            hello, you can test

            M5.Lcd.fillScreen(uint16_t color)
            

            to replace clear

            1 Reply Last reply Reply Quote 0
            • m5-docsM
              m5-docs
              last edited by

              M5.Lcd.fillScreen(BLACK)

              M5Stack documentation URL

              https://docs.m5stack.com

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