Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: compile options affects snprintf()--and in a bad way

  1. #1
    Senior Member
    Join Date
    Apr 2017
    Posts
    214

    compile options affects snprintf()--and in a bad way

    All,

    I wrote a very helpful library that will let you print numbers but mask only the digits that have changed. My need was to update a number and not have the flicker problem with painting a box before drawing the text. It works with ints and floats.

    However....I'm using he snprintf to do the formatting but works only if I compile with fastest options. Have a try...

    // compile with fastest snprintf will return "0.1234"
    // compile with smallest snprintf will return ""

    float Data = 0.1234;

    Serial.print("S"); // just so you can see start
    snprintf(buf, sizeof buf, "%.4f", Data);
    Serial.print(buf);
    Serial.print("E"); // just so you can see end


    Anyone know a remedy?

    I hate have to resort back to dissecting a number to get individual digits and such.

  2. #2
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    330

  3. #3
    Senior Member
    Join Date
    Apr 2017
    Posts
    214
    @jonr Any pointers as to what I do with that file?

  4. #4
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    330
    Strip the line numbers, #define NO_CONFIG_H and include it in your program. It worked when I tried it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •