PRO Display

From meteobridge
Revision as of 11:24, 5 October 2023 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page explains how to control the Meteobridge PRO display.

Display Commands

Display definitions can be given directly in the one line text field when defining the service (which might be a bit uncomfortable on larger definitions) or in a template file in folder "templates", where filename extension is ".dsp". When using the text input field, each command is terminated by "\n" (quoted line feed). When using a template file commands are separated by line breaks. Commands are executed from left to right. Each Display command starts with a "#".

Control Commands

The control flow when using the display is:

  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 frame buffer 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.
  • #pline x1 y1 r alpha draws a straight line from position x1,y1 with length r in direction alpha.
  • #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, numbers only: fub35n, fub42n, fub49n
    • free universal regular: fur11, fur14, fur17, fur20, fur25, fur30, numbers only: fur35n, fur42n, fur49n
    • 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 n1 n2 ... erases the current loop definitions completely. Optional parameters n1, n2, ... are names of screens that should not be erased.
  • *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. When lt is a negative number it indicates how often the loop should be executed (-2 means two times). 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" (when using the text input filed) or single quoted line feeds "\n" (when doing definition in a template file). If a screen with name n is already defined, the new definition will replace the old one. To avoid long lines with multiple "\n" separated commands, you can break the line with a "\" character at the end of the line, which we call "transparent line break". Parsing process of the template file ignores the "\" character and the following line feed and continues at the beginning of the next line.
  • *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 template definition shows boot screen with smartbedded logo, "meteobridge PRO" text and progress bar during boot.

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

Same definition will look a bit different when not stored in a template file but directly specified on the text input field. Now line feeds need quoting.

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

Loop on Weather Data

This more complex definition holds 6 screens of rather detailed data to flip through. Definition is in the template file format and makes uses of transparent line breaks with the "/" at the line ends. This makes reading the file much more easy. Please have a look at the video on the right to have an impression how screens change. Please ignore the flicker and blueish color as these are just camera artifacts. In reality there is no flicker and letters are bright white.

First section just resets data structures except the screens (a0, a1, .., a5) used in this definition. As a result all screens defined previously are erased, but the ones used in this definition are kept untouched. This is useful as this template will be invoked again and again to show updated data. If the screens were cleared before updated, the display will show temporarily blank pages, which is not intended. Second command starts loop operation.

*clearloop a0 a1 a2 a3 a4 a5
*startloop
Oled-SYSTEM.png
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 Helvetica
  • 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
Oled-WIND.png
Second screen definition named "a1" starts with
  • drawing a rounded box n the top labeled with "WIND"
  • prints maximum gust value of last 5 minutes in m/s into second row
  • prints current average 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:]
Oled-OUTDOOR.png
Third screen definition named "a2" starts with
  • drawing a rounded box n the top labeled with "OUTDOOR"
  • prints current outdoor temperature in degrees Celsius ("\xb0" is the degree symbol of the chosen font "helvR14")
  • prints current humidity without decimals into third row
  • and prints dew point into the last row.
*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
Oled-INDOOR.png
Fourth screen definition is named "a3" and draws a screen for "INDOOR" data, where
  • current sea level pressure is reported without decimals in the second row
  • current outdoor temperature is reported in the third row
  • and outdoor humidity is reported in the last row
*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:--] %
Oled-RAIN.png
Fifth screen definition is named "a4" and reports "RAIN" data, where
  • rain fall in last 60 minutes is reported in second row
  • rain fall of today is reported in third row
  • and rain fall of last 24 hours is reported in last row
*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
Oled-POWER.png
Last screen definition is named "a5" and reports "POWER" data, where
  • internal system temperature is reported in second row
  • power consumption of the Meteobridge PRO (including USB connected devices) is reported in third row
  • and USB voltage the Meteobridge PRO is driven with is reported in last row.
*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

At the end of all "*addloop" statements the screen show is started with the "#show" command.

#show