|
Post by MangyDog on Jul 30, 2017 5:40:31 GMT -8
How are you meant to build dynamic strings for the text element? Ive been having some issues here as im currently testing with Arduino, and this doesnt have the complete standard libraries.
I want to mix some number variables into strings to be displayed in the text command. Some are ints floats doubles... everything...
What is the proper way to do it for this GD?
If i recall correctly the text element in the cmd_text is actually a char array and not a string type. Ive managed to convert some of my numbers and floats to a char and get them to display correctly, but I cant figure out a way to mix this with some text say "X:" floatvar (X:3.823...)
Ive used char sX[10]; dtostrf(x, sizeof(x), 5, sX); to get my float numbers done... x being a float number. So what do I do next?
|
|
|
Post by rayman on Jul 31, 2017 1:37:07 GMT -8
use sprintf ...
|
|
|
Post by MangyDog on Aug 1, 2017 5:01:55 GMT -8
snprintf/sprintf doesnt work with the %f modifier in arduino and possibly not in libmaple core either...
|
|
|
Post by lightcalamar on Aug 1, 2017 13:28:37 GMT -8
Start with the basics
1.- Put used code. 2.- MCU used 3.- Library used
Do not be us fortune tellers. Not being able to help if you do not put the 3 steps.
|
|
|
Post by lightcalamar on Aug 2, 2017 7:34:38 GMT -8
Be clear you do not try ... void STM32() { GD.ColorRGB(0x00ff00); sprintf(TXP,"F_CPU: %d MHz", (F_CPU/1000000)); GD.cmd_text(GD.w - 105, 5, 26, 0, TXP); float RAMFree = (freeRam()/1)*100/ST_RAM; int RAMUsed= 100-RAMFree; GD.ColorRGB(0x00ff00); sprintf(TXP,"RAM: %d/%d", RAMUsed,100); GD.cmd_text(GD.w - 105, 25, 26, 0, TXP); }insert code here - Arduino_STM32 (25/July/2017) (Core)
- MCU STM32F103ZET6
- FT810 screen
- Compiler ARM Linux
- Arduino IDE 1.8.3
|
|
|
Post by MangyDog on Aug 7, 2017 3:47:51 GMT -8
Well its good to know it works on the STM32... Ive only been able to test on arduino for now... Im working on the speedo revision in the next couple of weeks. With the new screen. Ill report back then if it works for me.
|
|