widget_gpo

GPO Widget / GPIO driver

The GPO widget is used to control the so called General Purpose Output signals your display may have. Such GPO's may be used to connect a LED, a buzzer, a relay, … Some displays may have graphic symbols (especially when they come from telephones), these symbols can be controlled by GPO's, too.

The GPIO driver provides not only the GPO widget, but also support for GPI's (General Purpose Inputs). These Inputs may be logical (0/1) or analogue, providing a real value (like a fan RPM, temerature, voltage, …)

GPO's may be digital (having only a on/off state) or analog (having a range of states). It's up to the display driver how this is handled, but in general a digital GPO interprets everything less or equal zero as off, and greater zero as on.

The mapping between GPO widgets and output lines is done in the Layout section: Just as you would place other widgets with Row*.Col* lines, you can map a GPO widget to an actual GPO line on a display using a 'GPO*' layout line. The widget's expression is what will eventually be sent over the GPO line.

Here's the definition of a GPO widget:

Widget <widget_name> {
    class      'GPO'
    expression <string>
    update     <number>
}

And here is how the widget's value (expression) is linked to a GPO line:

Layout <layout_name> {
    GPO<num>      '<widget_name>'
}

Note that the GPO widget and the LCD::GPO() plugin are available only if your display supports GPO's (and you did configure the driver to actually use them)!


expressionexpression delivering the value of the GPO
updateupdate interval (msec)

The GPIO driver provides the following functions

LCD::GPI(num)returns the value of GPI num
LCD::GPO(num)returns the actual value of GPO num
LCD::GPO(num, val)set GPO num to val, returns the actual value

A simple GPO example. Here, the system load average will be calculated in the GPO_Test widget, and sent over the display's first GPO line (GPO1.) The GPO will be high when the load is above zero, and low when the load is exactly zero.

Widget GPO_Test {
    class 'GPO'
    expression loadavg(1) > 0
    update 1000
}

Layout TestGPO {
    Row1.Col1 'AnyWidget'
    GPO1      'GPO_Test'
}

more sophisticated example using GPI: (tested on a MatrixOrbital LK202)

Widget Fan_Set {
    class 'GPO'
    expression test::bar(0,255, 0, 1)
    update 100
}

Widget Fan_PWM {
    class 'Text'
    expression LCD::GPO(1)
    prefix 'PWM'
    width 8
    precision 0
    align 'R'
    update 100
}

Widget Fan_RPM {
    class 'Text'
    expression LCD::GPI(1)
    prefix 'RPM'
    width 8
    precision 0
    align 'R'
    update 100
}

Layout FanDemo {
    Row1.Col1  'Fan_PWM'
    Row1.Col10 'Fan_RPM'
    GPO1       'Fan_Set'
}

The Fan PWM value goes from zero up to 255 and back to zero, the actual PWM value and the resulting fan speed is printed on the display.


  • widget_gpo.txt
  • Last modified: 2020/07/17 18:33
  • (external edit)