I posted this question on Stack Overflow first because it is not really a Particle issue but a simple programming issue, but Stack Overflow closed my post because it "needs clarity" (???).
My application running on a Photon2 needs to get an integer to appear on an LCD display without decimals. Specifically, I have a variable of type double - 'Percent' - that is calculated by diividing the number of 'Gallons' (also a double) in a water tank by the capacity of the tank times 100, as follows:
Percent = (Gallons/1771*100)+.5; // Calculate percent full; .5 added to assure proper rounding
Next, I try to convert Percent to an integer and then convert the integer to a string:
int y = static_cast<int>(Percent);
std::string myString = std::to_string(y);
Then my code tries to send the resulting string to an OLED display, as follows:
display.getTextBounds((myString + "% Full"), 0, 0, &x1, &y1, &w, &h);
display.setCursor((128 - w) / 2, 46);
display.println(myString + "% Full");
display.display();
Unfortunately, the code associated with the display won't compile (error = "no matching function for call to 'Adafruit_SSD1306::getTextBounds(std::__cxx11::basic_string)'".
How can I display only the integer component of the resulting myString value?
