display big numbers



  • 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



  • 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?



  • 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 ...



  • hello, you can test

    M5.Lcd.fillScreen(uint16_t color)
    

    to replace clear


  • M5Stack

    M5.Lcd.fillScreen(BLACK)