The text method
As great as a spiffy graphical display is, it often makes sense to have some more specific information displayed about a parameter's current value as well. This is where the
text method comes in handy (using the
font definition we drew up earlier). Let's say, for instance, we want to have incoming CPS shown as a numeric value. Then, we would have to add the following section:
[disp5]
value=rx_cps
method=text
font=font1
rect=50,32,80,40
style=d
flags=r
digits=6
decimals=1
unitchar=?
transform1=60,0,0,60,255,255,33,0,0,33,220,255
transform2=0,0,0,10,255,255,225,190,140,226,191,141

What this does is display the
rx_cps parameter of
cFosSpeed, which keeps track of the current CPS reception rate. By setting
method to
text and
font to
font1, we make sure the
disp section uses the font we've already defined in step two.
The
style is set to "d" (=decimal) with one digit after the comma. Setting the "r" flag will have the text right-aligned. Numeric value and measuring unit may take up to 6
digits. Seeing then how our
font definition clearly specifies each digit to have a
width of 5 and a
height of 8 pixels, this would result in a
rect of 30x8 pixels to be placed above the bar defined in
[disp3].
Having the
unitchar point to a "blank" character bitmap will prevent displayed numbers from shifting to the right when there is no measuring unit available. This happens when transfer rates fall outside available (T)era, (G)iga, (M)ega or (K)ilo byte ranges (e.g., when showing bytes only).
While
transform1 shifts the color of the text from yellow to orange,
transform2 decreases the intensity of the drop shadow, which is also part of the font bitmap.
For outgoing CPS, let's now add the following:
[disp6]
value=tx_cps
method=text
font=font1
rect=50,77,80,85
style=d
flags=r
digits=6
decimals=1
unitchar=?
transform1=60,0,0,60,255,255,100,0,0,100,200,220
transform2=0,0,0,10,255,255,225,190,120,226,191,121
It should be obvious by now that this is basically the same as above – just with other
rect coordinates. What's also different here is that the
transform1 key changes the color to green, while
transform2 creates a slightly darker shadow.
Next step:
Adding an LED with the slider methodThe history method The slider method Index