Difference between revisions of "PRO Display"

From meteobridge
Jump to: navigation, search
Line 77: Line 77:
  
 
==Examples==
 
==Examples==
These examples are unquoted one level, so that each display command has its own line. When filling these definitions into the one line displays definition of Meteobridge PRO, each line feed needs to be converted int "\n" and each quoted line feed (used inside loop screen definitions) needs to be double quoted "\\n".
+
These examples illustrate how to use Meteobridge PRO's displays capabilities in real world examples.  
  
 
===Boot screen===
 
===Boot screen===
 
This definition shows boot screen with smartbedded logo, "meteobridge PRO" text and progress bar during boot
 
This definition shows boot screen with smartbedded logo, "meteobridge PRO" text and progress bar during boot
<pre>#clear
+
<pre>#clear\n
#sblogo 0 0
+
#sblogo 0 0\n
#font helvR10
+
#font helvR10\n
#string 6 44 meteobridge PRO
+
#string 6 44 meteobridge PRO\n
*startfbar 4 56 116 6 right 4
+
*startfbar 4 56 116 6 right 4\n
#show</pre>
+
#show\n</pre>
  
 
===Loop on Weather Data===
 
===Loop on Weather Data===
This more complex definition holds 6 screens to flip through. In order to make it better readable some line breaks are included, that are not allowed to be there if the example is pasted into the Meteobridge display definition field. Above commands clear the internal structures and visible screen and start loop operation.
+
This more complex definition holds 2 screens to flip through. In order to make it better readable some line breaks are included, that are not allowed to be there if the example is pasted into the Meteobridge display definition field. Above commands clear the internal structures and visible screen and start loop operation.
  
 
First section just resets data structures and starts loop operation.
 
First section just resets data structures and starts loop operation.
<pre>#new
+
<pre>#new\n
#clear
+
#clear\n
*clearloop
+
*clearloop\n
*startloop</pre>
+
*startloop\n</pre>
  
 
Commands below add a screen named "a0" to the loop, with screen duration of 5 seconds and a maximum lifetime of 300 seconds. As data is regarded outdated after 5 minutes, it is better to drop the screen instead of showing old content. The commands in the screen definition  
 
Commands below add a screen named "a0" to the loop, with screen duration of 5 seconds and a maximum lifetime of 300 seconds. As data is regarded outdated after 5 minutes, it is better to drop the screen instead of showing old content. The commands in the screen definition  
Line 106: Line 106:
 
* Next row is filled with current cpuload for last 15, 5 and 1 minute. As cpu load comes as a decimal where 1.0 represents 100% this needs to be multiplied by 100 to show percent. Furthermore the decimals from the conversion are cut. This math is also done by the math operators that are provided by generic Meteobridge template replacement.  
 
* Next row is filled with current cpuload for last 15, 5 and 1 minute. As cpu load comes as a decimal where 1.0 represents 100% this needs to be multiplied by 100 to show percent. Furthermore the decimals from the conversion are cut. This math is also done by the math operators that are provided by generic Meteobridge template replacement.  
 
* Next and last row shows system uptime. Variable "mbsystem-uptime" reports number of seconds since start of the system. As this is hard to work with the formula above derives number of days, hours and minutes from the numbers. Again, this is done with Meteobridge's math functions inside template replacement engine. To get number of days, seconds are divided by seconds of a day (86400) and result is not rounded by truncated to an integer. Hours is computed similar, but his time seconds remaining in the day are first extracted by modulus 86400 and minutes later on are handled accordingly.
 
* Next and last row shows system uptime. Variable "mbsystem-uptime" reports number of seconds since start of the system. As this is hard to work with the formula above derives number of days, hours and minutes from the numbers. Again, this is done with Meteobridge's math functions inside template replacement engine. To get number of days, seconds are divided by seconds of a day (86400) and result is not rounded by truncated to an integer. Hours is computed similar, but his time seconds remaining in the day are first extracted by modulus 86400 and minutes later on are handled accordingly.
<pre>*addloop a0 5 300 #clear\n
+
<pre>*addloop a0 5 300 #clear\\n
   #font helvB12\n
+
   #font helvB12\\n
   #color 1\n
+
   #color 1\\n
   #rbox 0 0 126 14 4\n
+
   #rbox 0 0 126 14 4\\n
   #color 0\n
+
   #color 0\\n
   #string 30 13 SYSTEM\n
+
   #string 30 13 SYSTEM\\n
   #color 1\n
+
   #color 1\\n
   #string 0 30 [mbsystem-ip:--]\n
+
   #string 0 30 [mbsystem-ip:--]\\n
 
   #string 0 47 {*[mbsystem-cpuload1m.2:0]*100*0}%  
 
   #string 0 47 {*[mbsystem-cpuload1m.2:0]*100*0}%  
 
               {*[mbsystem-cpuload5m.2:0]*100*0}%  
 
               {*[mbsystem-cpuload5m.2:0]*100*0}%  
Line 119: Line 119:
 
   #string 0 64 {*[mbsystem-uptime.0:0]/86400*t}d  
 
   #string 0 64 {*[mbsystem-uptime.0:0]/86400*t}d  
 
               {*([mbsystem-uptime.0:0]%86400)/3600*t}h  
 
               {*([mbsystem-uptime.0:0]%86400)/3600*t}h  
               {*([mbsystem-uptime.0:0]%3600)/60*t}m
+
               {*([mbsystem-uptime.0:0]%3600)/60*t}m\n</pre>
</pre>
+
  
*addloop a1 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 40 13 WIND\\n#color 1\\n#font helvR14\\n#string 0 30 gust\\n#string 50 30 [wind0wind-max5.1:--] m/s\\n#string 0 47 avg\\n#string 50 47 [wind0avgwind-act.1:--] m/s\\n#string 0 64 dir\\n#string 50 64 [wind0dir-act=endir:]\n*addloop a2 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 20 13 OUTDOOR\\n#color 1\\n#font helvR14\\n#string 0 30 temp\\n#string 50 30 [th0temp-act.1:--] \xb0C\\n#string 0 47 hum\\n#string 50 47 [th0hum-act.0:--] %\\n#string 0 64 dew\\n#string 50 64 [th0dew-act.1:--] \xb0C\n*addloop a3 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 30 13 INDOOR\\n#color 1\\n#font helvR14\\n#string 0 30 press\\n#string 50 30 [thb0seapress-act.0:--] mb\\n#string 0 47 temp\\n#string 50 47 [thb0temp-act.1:--] \xb0C\\n#string 0 64 hum\\n#string 50 64 [thb0hum-act.0:--] %\n*addloop a4 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 40 13 RAIN\\n#color 1\\n#font helvR14\\n#string 0 30 hour\\n#string 50 30 [rain0total-sum60.1:--] mm\\n#string 0 47 day\\n#string 50 47 [rain0total-sumday.1:--] mm\\n#string 0 64 24h\\n#string 50 64 [rain0total-sum24h.1:--] mm\n*addloop a5 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 30 13 POWER\\n#color 1\\n#font helvR14\\n#string 0 30 temp\\n#string 50 30 [mbsystem-temp.1:--] \xb0C\\n#string 0 47 pwr\\n#string 50 47 [mbsystem-watt.2:--] W\\n#string 0 64 volt\\n#string 50 64 [mbsystem-volt.2:--] V\n#show  
+
Next screen definition named "a1" starts with
 +
* drawing a rounded box n the top labled with "WIND"
 +
* prints maximum gust value of last 5 minutes in m/s into second row
 +
* prints current avarage wind speed into third row
 +
* and wind direction in English abbreviations into the last row.
 +
<pre>*addloop a1 5 300 #clear\\n
 +
  #font helvB12\\n
 +
  #color 1\\n
 +
  #rbox 0 0 126 14 4\\n
 +
  #color 0\\n
 +
  #string 40 13 WIND\\n
 +
  #color 1\\n
 +
  #font helvR14\\n
 +
  #string 0 30 gust\\n
 +
  #string 50 30 [wind0wind-max5.1:--] m/s\\n
 +
  #string 0 47 avg\\n
 +
  #string 50 47 [wind0avgwind-act.1:--] m/s\\n
 +
  #string 0 64 dir\\n
 +
  #string 50 64 [wind0dir-act=endir:]\n</pre>
 +
 
 +
*addloop a2 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 20 13 OUTDOOR\\n#color 1\\n#font helvR14\\n#string 0 30 temp\\n#string 50 30 [th0temp-act.1:--] \xb0C\\n#string 0 47 hum\\n#string 50 47 [th0hum-act.0:--] %\\n#string 0 64 dew\\n#string 50 64 [th0dew-act.1:--] \xb0C\n*addloop a3 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 30 13 INDOOR\\n#color 1\\n#font helvR14\\n#string 0 30 press\\n#string 50 30 [thb0seapress-act.0:--] mb\\n#string 0 47 temp\\n#string 50 47 [thb0temp-act.1:--] \xb0C\\n#string 0 64 hum\\n#string 50 64 [thb0hum-act.0:--] %\n*addloop a4 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 40 13 RAIN\\n#color 1\\n#font helvR14\\n#string 0 30 hour\\n#string 50 30 [rain0total-sum60.1:--] mm\\n#string 0 47 day\\n#string 50 47 [rain0total-sumday.1:--] mm\\n#string 0 64 24h\\n#string 50 64 [rain0total-sum24h.1:--] mm\n*addloop a5 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 30 13 POWER\\n#color 1\\n#font helvR14\\n#string 0 30 temp\\n#string 50 30 [mbsystem-temp.1:--] \xb0C\\n#string 0 47 pwr\\n#string 50 47 [mbsystem-watt.2:--] W\\n#string 0 64 volt\\n#string 50 64 [mbsystem-volt.2:--] V\n#show  
 
#  
 
#  
  
  
 
</translate>
 
</translate>

Revision as of 18:41, 6 December 2015

<languages /><translate>
This page explains how to control the Meteobridge PRO display.

Display Commands

Display commands are lined up in sequence, where each command is terminated by a "\n" (quoted line feed). Commands are executed from left to right. Each Display command starts with a "#".

Control Commands

The control flow when using the display is to

  1. Clear the previously used data structures and to prepare the display driver for a new screen.
  2. build the new screen with a set of drawing/writing commands in the background (framebuffer)
  3. when done show the content prepared in the background

This is done by these commands:

  • #new prepares the display frame buffer collect new content.
  • #show makes the content prepared in the framebuffer visible.

Draw Commands

Between these commands a lot of drawing commands can be used to design the screen. The screen has size 128 x 64. Origin is located in the upper left. Items are drawn upright at the given coordinates. The commands are mostly 1:1 mappings to the list of u8g drawing commands ([1] u8g command reference). With Meteobridge PRO you can use these commands:

  • #sblogo x y draws the smartbedded logo (shown when unit starts) at position x,y.
  • #clear sets complete screen area to background color.
  • #clearall does as #clear does but also clears active progress bars (if any).
  • #box x y w h draws a solid box at position x,y with width w and height h in foreground color.
  • #rbox x y w h r draws a rounded box with radius r at the corners
  • #circle x y r s draws a circle at x,y with radius r. s is optional parameter that can define which segment of the circle to draw: ur = upper right, ul = upper left, lr = lower right, ll = lower left
  • #disc x y r s draws a circle filled with foreground color, parameters are as with #circle.
  • #ellipse x y rx ry s draws an ellipse at position x,y with vertical radius ry and horizontal radius rx. s has same meaning as with #circle.
  • #filledellipse x y rx ry s draws an elllipse filled with foreground color, parameters are as with #ellipse.
  • #frame x y w h draws a rectangular frame. Meaning of parameters is as with #box.
  • #rframe x y w h r draws a rounded frame, r defined the radius of the corner.
  • #hline x y w draws a horizontal line beginning from position x,y with length w.
  • #vline x y h draws a vertical line beginning at position x,y with length h.
  • #line x1 y1 x2 y2 draws a straight line from position x1,y1 to position x2,y2.
  • #pixel x y sets pixel at position x,y to foreground color.
  • #string x y text prints text starting at position x,y.
  • #string90 x y text prints text starting at position x,y 90 degrees counter-clockwise oriented.
  • #string180 x y text prints text starting at position x,y 180 degrees counter-clockwise oriented.
  • #string270 x y text prints text starting at position x,y 270 degrees counter-clockwise oriented.
  • #triangle x1 y1 x2 y2 x3 y3 prints a triangle through positions x1,y1 and x2,y2 and x3,y3.
  • #color c sets color c as foreground color, c = 0 is black, c = 1 is white.
  • #font name defined font "name" to be used for string commands. List of fonts sorted by size and also providing information about the supported character sets can be found here. Fonts supported by Meteobridge PRO are:
    • generic: u8glib_4, m2icon_5, m2icon_7, m2icon_9, cursor, micro
    • X11 types: 4x6, 5x7, 5x8, 6x10, 6x12, 6x12_67_75, 6x12_78_79, 6x13, 6x13B, 7x13, 7x13B, 7x13O, 7x13_67_75, 7x14, 7x14B, 8x13, 8x13B, 8x13O, 8x13_67_75, 9x15, 9x15B, 9x15_67_75, 9x15_78_79, 9x18, 9x18B, 9x18_67_75, 9x18_78_79, 10x20, 10x20_67_75, 10x20_78_79
    • cursor types: cu12_67_75, cu12
    • free universal bold: fub11, fub14, fub17, fub20, fub25, fub30
    • free universal regular: fur11, fur14, fur17, fur20, fur25, fur30
    • gentium bold: gdb11, gdb12, gdb14, gdb17, gdb20, gdb25, gdb30
    • gentium regular: gdr9, gdr10, gdr11, gdr12, gdr14, gdr17, gdr20, gdr25, gdr30
    • old standard bold: osb18, osb21, osb26, osb29, osb35
    • old standard regular: osr18, osr21, osr26, osr29, osr35
    • gnu unifont: unifont_18_89, unifont_72_73, unifont_67_75, unifont_76, unifont_77, unifont_78_79, unifont_86, unifont, unifont_0_8, unifont_2_3, unifont_4_5, unifont_8_9, unifont_12_13
    • orgdot fonts: orgv01, fixed_v0, tpssb, tpss
    • contributed: freedoomr25n, freedoomr10r
    • Adobe X11: courB08, courB10, courB12, courB14, courB18, courB24, courR08, courR10, courR12, courR14, courR18, courR24, helvB08, helvB10, helvB12, helvB14, helvB18, helvB24, helvR08, helvR10, helvR12, helvR14, helvR18, helvR24, ncenB08, ncenB10, ncenB12, ncenB14, ncenB18, ncenB24, ncenR08, ncenR10, ncenR12, ncenR14, ncenR18, ncenR24, symb08, symb10, symb12, symb14, symb18, symb24, timB08, timB10, timB12, timB14, timB18, timB24, timR08, timR10, timR12, timR14, timR18, timR24
    • fontstruct: p01type, Lucasfont_alternate, chikita, pixelle_micro, trixel_square, robot_de_niro, baby, blipfest_07
    • profont: profont10, profont11, profont12, profont15, profont17, profont22, profont29
  • #linespacing s defines line spacing, default is 1.0.
  • #flip n rotates text 180 degrees, if n = 1. no rotation is n = 0.

Progress Bar Commands

Apart from constructing a screen and displaying it with the "#show" command, Meteobridge PRO also supports progress bars, which automatically increase while time is passing by. Progress bar definitions start with a "*" instead of the "#" used with direct draw commands.

  • *startfbar x1 y1 x2 y2 d s c defines a progress bar that has lower left corner x1,y1 and upper right corner x2,y2 and fills up in direction d, where valid values are "up", "down", "left", "right". s defines the speed of the progress bar in terms of percent of the bar that should be passed each second. Example: A progress bar with a speed of 5 will approximately need 20 seconds to run through. optional parameter c can depict a shell script or program to start when progress bar has finished.
  • *stopfbar terminates progress bar processing and removes the progress bar from the display.

Display Loop Commands

Another type of commands are so called loop commands, that allow to automatically run through a sequence of screens to be displayed. These commands also start with "*".

  • *clearloop erases the current loop definitions completely.
  • *addloop n d lt cmds adds a screen with name n and display duration of d seconds and an overall lifetime of lt seconds to the display loop. Commands that make up the screen follows as a command list "cmds". Draw commands in the command list are separated by double quoted line feeds "\\n" in order to be distinguished from the quote line feed "\n" that indicates the end of the current display loop command. If a screen with name n is already defined, the new deinition will replace the old one.
  • *remloop n removes screen with name n from loop.
  • *startloop starts endless playback of the defined screens, where each screen rests for the duration defined for the screen. A screen is removed from the loop list, when the lifetime of the screen has been reached.
  • *stoploop stops playing the loop of screens.

Loop command "*addloop" tends to look a bit complicated as it includes draw command definitions.

Inserting Weather Data

Inserting sensor data into the screen sis easy, as the same template replacement mechanism is used on display definitions as with all the other functions in Meteobridge.

Examples

These examples illustrate how to use Meteobridge PRO's displays capabilities in real world examples.

Boot screen

This definition shows boot screen with smartbedded logo, "meteobridge PRO" text and progress bar during boot

#clear\n
#sblogo 0 0\n
#font helvR10\n
#string 6 44 meteobridge PRO\n
*startfbar 4 56 116 6 right 4\n
#show\n

Loop on Weather Data

This more complex definition holds 2 screens to flip through. In order to make it better readable some line breaks are included, that are not allowed to be there if the example is pasted into the Meteobridge display definition field. Above commands clear the internal structures and visible screen and start loop operation.

First section just resets data structures and starts loop operation.

#new\n
#clear\n
*clearloop\n
*startloop\n

Commands below add a screen named "a0" to the loop, with screen duration of 5 seconds and a maximum lifetime of 300 seconds. As data is regarded outdated after 5 minutes, it is better to drop the screen instead of showing old content. The commands in the screen definition

  • start with clearing the screen
  • setting font to 12pt bold Hevetica
  • setting foreground color to white
  • drawing a rounded, filled white box into the top of the screen
  • setting draw color to black and writing "SYSTEM" in black color into the white box.
  • Next thing is to change draw color to white again and the write system variable "mbsystem-ip" (IP of the system) into the first row below the header.
  • Next row is filled with current cpuload for last 15, 5 and 1 minute. As cpu load comes as a decimal where 1.0 represents 100% this needs to be multiplied by 100 to show percent. Furthermore the decimals from the conversion are cut. This math is also done by the math operators that are provided by generic Meteobridge template replacement.
  • Next and last row shows system uptime. Variable "mbsystem-uptime" reports number of seconds since start of the system. As this is hard to work with the formula above derives number of days, hours and minutes from the numbers. Again, this is done with Meteobridge's math functions inside template replacement engine. To get number of days, seconds are divided by seconds of a day (86400) and result is not rounded by truncated to an integer. Hours is computed similar, but his time seconds remaining in the day are first extracted by modulus 86400 and minutes later on are handled accordingly.
*addloop a0 5 300 #clear\\n
  #font helvB12\\n
  #color 1\\n
  #rbox 0 0 126 14 4\\n
  #color 0\\n
  #string 30 13 SYSTEM\\n
  #color 1\\n
  #string 0 30 [mbsystem-ip:--]\\n
  #string 0 47 {*[mbsystem-cpuload1m.2:0]*100*0}% 
               {*[mbsystem-cpuload5m.2:0]*100*0}% 
               {*[mbsystem-cpuload15m.2:0]*100*0}%\n
  #string 0 64 {*[mbsystem-uptime.0:0]/86400*t}d 
               {*([mbsystem-uptime.0:0]%86400)/3600*t}h 
               {*([mbsystem-uptime.0:0]%3600)/60*t}m\n

Next screen definition named "a1" starts with

  • drawing a rounded box n the top labled with "WIND"
  • prints maximum gust value of last 5 minutes in m/s into second row
  • prints current avarage wind speed into third row
  • and wind direction in English abbreviations into the last row.
*addloop a1 5 300 #clear\\n
  #font helvB12\\n
  #color 1\\n
  #rbox 0 0 126 14 4\\n
  #color 0\\n
  #string 40 13 WIND\\n
  #color 1\\n
  #font helvR14\\n
  #string 0 30 gust\\n
  #string 50 30 [wind0wind-max5.1:--] m/s\\n
  #string 0 47 avg\\n
  #string 50 47 [wind0avgwind-act.1:--] m/s\\n
  #string 0 64 dir\\n
  #string 50 64 [wind0dir-act=endir:]\n
  • addloop a2 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 20 13 OUTDOOR\\n#color 1\\n#font helvR14\\n#string 0 30 temp\\n#string 50 30 [th0temp-act.1:--] \xb0C\\n#string 0 47 hum\\n#string 50 47 [th0hum-act.0:--] %\\n#string 0 64 dew\\n#string 50 64 [th0dew-act.1:--] \xb0C\n*addloop a3 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 30 13 INDOOR\\n#color 1\\n#font helvR14\\n#string 0 30 press\\n#string 50 30 [thb0seapress-act.0:--] mb\\n#string 0 47 temp\\n#string 50 47 [thb0temp-act.1:--] \xb0C\\n#string 0 64 hum\\n#string 50 64 [thb0hum-act.0:--] %\n*addloop a4 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 40 13 RAIN\\n#color 1\\n#font helvR14\\n#string 0 30 hour\\n#string 50 30 [rain0total-sum60.1:--] mm\\n#string 0 47 day\\n#string 50 47 [rain0total-sumday.1:--] mm\\n#string 0 64 24h\\n#string 50 64 [rain0total-sum24h.1:--] mm\n*addloop a5 5 300 #clear\\n#font helvB12\\n#color 1\\n#rbox 0 0 126 14 4\\n#color 0\\n#string 30 13 POWER\\n#color 1\\n#font helvR14\\n#string 0 30 temp\\n#string 50 30 [mbsystem-temp.1:--] \xb0C\\n#string 0 47 pwr\\n#string 50 47 [mbsystem-watt.2:--] W\\n#string 0 64 volt\\n#string 50 64 [mbsystem-volt.2:--] V\n#show


</translate>