Skip to content
Chris Petersen edited this page Oct 16, 2014 · 1 revision

glgui-trace creates a widget that plots waveform data.

Parameter Description
g Graphical User Interface (GUI) for this widget
x Lower left corner along the x-axis in pixels
y Lower left corner along the y-axis in pixels
w Width of the element in pixels
h Height of the element in pixels
trace The data of the waveform to be traced
color The waveform color
lim Optional: 'limfnt specifies the character-encoding scheme of waveform graph, 'limcol specifies the font color, and 'limscale is used to scale the numbers

Example

Example 1: Trace a fake waveform. First define the trace with its boundaries. Then place a trace-widget on the screen. Finally, clear the trace, load some data and update the trace. In a real world application the gltrace-add and gltrace-update would happen in a loop elsewhere, whenever new data are received.

(set! VAL_min 0)(set! VAL_max 10)
(set! val-trace (make-gltrace 101 30 GLTRACE_OVERWRITE VAL_min VAL_max VAL_min VAL_max))
(gltrace:clear val-trace)
(set! val-wave (glgui-trace gui 5 (- (glgui-height-get) 44 110) 200 40 val-trace Orange))
(set! values (list 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5 6 7 7 9 5 4 3 2 1 3 4 5 6 4 4 3 3 2 2 1 1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 0 0 1 1 2 2 3 3 4 4 5 5))
(let loop ((i 0))
  (if (< i (length values))
    (begin
      (gltrace-add val-trace (list-ref values i))
      (loop (+ i 1))
  )))
...
(gltrace-update val-trace)  ;; this must be called in the event loop
Clone this wiki locally