SSD1306 Library

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
tomcat
 
Posts: 30
Joined: Thu Jan 26, 2012 9:50 am

Re: SSD1306 Library

Post by tomcat »

The orientation is not so important, I plan to use the larger 128 x 64 display once they become available.
I am however having a problem with conversion. It's something basic, I know, but I'm not well versed in C/C++ so I need a little help.

In the following function, I need the 3rd parameter to be variable, based on a number from 0 to 1023, which will then be scaled to feet, inches, and fractions of an inch.
oled.drawstring(0, 0, "3' 1-1/2''");

So, for example, say 512 converts to an arbitrary distance of 3' 1-1/2", my conversion constant would be .07324219. I would then take the result (37.5) and divide by 12 (inches per foot). If there's a remaining decimal, I convert that to inches and fractions of an inch.

My question is how do I change the third parameter dynamically with a numeric value that, I assume would need to be converted to a string.

Thanks

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: SSD1306 Library

Post by adafruit »

the itoa() function can convert a number to a string and you can then draw that string using drawstring(), google around for more information on how to use itoa() - we don't have any example or tutorial code for it at this time.

https://www.google.com/search?q=itoa+arduino

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”