XTempHistory

XTempHistory

XTempHistory is a Monitor widget in LightGUI's XFrame widget set. Temperature history with a threshold line and over-temp colouring.

XTempHistory scrolls a temperature trace and draws a threshold line across it; samples above the threshold are coloured as over-temp, so a hot spike is visible at a glance instead of needing a number read-out.

XTempHistory running under Xvfb
XTempHistory running — screenshot taken from the example below under Xvfb.

Key methods

  • push(temp_c) — append one temperature sample in degrees C
  • set_threshold(t) — the over-temp line, in degrees C

Every widget also gets the shared properties visible, enabled, bounds (x, y, width, height) and style_name, plus the background / foreground colours from the active style.

Example

Set the threshold once; anything over it draws in the over-temp colour.

XTempHistory widget(display, screen, window, gc, &styles, 20, 20, 720, 480);
widget.set_threshold(80.0);  // over-temp line at 80 C
widget.push(63.5);
widget.draw();

The snippet above is the widget part only. As with every XFrame example, the full program opens a display, creates a window and a style manager, then runs the standard event loop — see the complete example in the repo.

Build it from the repo root:

g++ -std=c++17 -Iwidgets/components -Iwidgets examples/XTempHistory.cpp -lX11 -o XTempHistory

Run it under Xvfb or a real X server; close the window to quit.

Example in the repo

The full working example is examples/XTempHistory.cpp in the lightgui repo (C is canonical). The same widget is ported to the Rust and Python repos under the same name — see the links below.

Get the code

These widgets ship in all three LightGUI repos:

See also

Linux Rocks Every Day
Source code: LightGUI (C) · LightGUI (Rust) · LightGUI (Python)