Label fmt_string

Visualization and Recording of CAN Data
Post Reply
SDOHFE
Posts: 4
Joined: Fri 16. Sep 2022, 22:42

Label fmt_string

Post by SDOHFE » Thu 6. Oct 2022, 08:12

I seem to be having some difficulties with the string formatters. Is there a better description of the formatters that are supported?

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Label fmt_string

Post by PEAK-Support » Thu 6. Oct 2022, 15:04

The String Format worked in the same way as the using of printf in C or C++
MiniDisplay_String_Format_Manual.JPG
MiniDisplay_String_Format_Manual.JPG (29.91 KiB) Viewed 5769 times
Please see here or here for more information (you will find x-thousend pages on the WEB)
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

SDOHFE
Posts: 4
Joined: Fri 16. Sep 2022, 22:42

Re: Label fmt_string

Post by SDOHFE » Fri 7. Oct 2022, 00:43

OK, thats how I thought it was based off of and I believe I have that correct.

Under the [VARIABLE] section, is there a better explanation of vartype and datatype?

For testing, I am just trying to display battery voltage.

This is what I have pertaining to that message, variable, and label:

Code: Select all

// =======================================================================================================================
// Global Settings
// =======================================================================================================================
[global]
format=1
compress=0
messages=3
variables=3
labels=3
fonts=2

[font1]
font="century_16_18_numbers.fon"
name="Font1"
type=0

[font2]
font="Palatino_Linotype_24_28.fon"
name="Font2"
type=0

//-------------Messages-----------------------

[message1]
enable=1
name="EEC1"
canid=0x0CF00400
frametype=1
channel=0
timeout=0

[message2]
enable=1
name="CCVS1"
canid=0x18FEF100
frametype=1
channel=0
timeout=0

[message3]
enable=1
name="VEP1"
canid=0x18FEF700
frametype=1
channel=0
timeout=0

//----------------Variables---------------------

[variable1]
name="RPM"
messagename="EEC1"
position=32,16
byteorder=1
muxtype=0
muxval=0
scale=0.125
offset=0
vartype=2
datatype=2

[variable2]
name="SPEED"
messagename="CCVS1"
position=16,16
byteorder=1
muxtype=0
muxval=0
scale=0.00390625
offset=0
vartype=2
datatype=2

[variable3]
name="VOLTS"
messagename="VEP1"
position=40,16
byteorder=1
muxtype=0
muxval=0
scale=.05
offset=0
vartype=2
datatype=2

//-------------Labels----------------------

[label1]
position=10,10
name="label1"
font_name="Font2"
fmt_string="%4.1f RPM"
var_name="RPM"
length=10
initval="--- RPM"
fontcolor=255,0,0
bgcolor=0,0,0
update_rate=0

[label2]
position=10,40
name="label2"
font_name="Font2"
fmt_string="%4.1f KPH"
var_name="SPEED"
length=10
initval="--- KPH"
fontcolor=0,255,0
bgcolor=0,0,0
update_rate=0

[label3]
position=10,70
name="label3"
font_name="Font2"
fmt_string="%3.2f Volts"
var_name="VOLTS"
length=10
initval="--- VOLTS"
fontcolor=0,0,255
bgcolor=0,0,0
update_rate=0

All I get is 0.000000

(Changed by Admin - consulidate both post to one & format source code / ini file)

G.Bohlen
Hardware Development
Hardware Development
Posts: 66
Joined: Wed 22. Sep 2010, 21:38

Re: Label fmt_string

Post by G.Bohlen » Fri 7. Oct 2022, 08:57

Hello,

label3 is used to dispaly the voltage, and uses variable "VOLTS".
fmt_string="%3.2f Volts" indicates that the variable has to be float type.
Variable "VOLTS" has got vartype=2 which is float (correct)
datatype is also set to 2 (float) which means that the value on the CAN-Bus is a float value. A float-value on the CAN-bus is very unusual, usually unsigned or signed integer is used.
position=40,16 shows that on the CAN-Bus this is a 16bit value, and I would assume it is an integer value.
Please set datatype to 0 (unsigned) or 1 (signed), this depends on how the vaylue is transmitted.

Regards,
Gunnar Bohlen

Post Reply