]> sigrok.org Git - libsigrok.git/commit - src/output/ascii.c
output/ascii: add support for user configurable character set
authorGerhard Sittig <redacted>
Sun, 16 Oct 2016 16:25:23 +0000 (18:25 +0200)
committerUwe Hermann <redacted>
Wed, 2 Nov 2016 18:09:55 +0000 (19:09 +0100)
commit0150fdca549411e2d5111629c786e4e53c6208cc
treecfbda1a44524cb4959655cfd79052baf9ff70efd
parent6c23b710ec21b6937be059aa7cb14313e929ec7c
output/ascii: add support for user configurable character set

Since tastes and requirements might differ, introduce support for a
user specified character set in the construction of ASCII art graphs
of signal levels. The syntax is "charset=<low><high>[<fall><rise>]",
the default remains backwards compatible with existing consumers.

In comparison to assuming a fixed character set, this change addresses
several distinct aspects:

Users can adjust the output for "higher visual contrast", or "straight
lines" instead of dotted patterns, or "increased difference in height"
for low and high signal levels, or "filled" (block like, "wall of text")
appearance of periods with high levels. User adjustable characters are
needed, as no single fixed set can satisfy the differing expectations.
Perception of the output heavily depends on specific terminals and fonts
in use.

Then there is the issue of levels versus edges, and how their timing
relates. By default edges are drawn at a point in time where the signal
was sampled and was deteremined to already _have_ changed and have
settled to the new level, which means that the position of edges in the
resulting graph might be off by up to one sample period. Strictly
speaking, the available set of samples only contains levels, and does
not hint where exactly an edge might have occured. Though this might be
considered rather nitpicky, representing the graph without edges does
better reflect the input data, and might simplify postprocessing.

Compare the previously only supported format (still the default, -O ascii):

  1:...................................................../""""""""""""""""""""
  1:""""""""""""""""""""""""""""""""\.........................................
  1:..........................................................................

to those example alternatives:

  $ sigrok-cli -i file.sr -O ascii:charset=_\"\\/
  1:_____________________________________________________/""""""""""""""""""""
  1:""""""""""""""""""""""""""""""""\_________________________________________
  1:__________________________________________________________________________

  $ sigrok-cli -i file.sr -O ascii:charset=_\"
  1:_____________________________________________________"""""""""""""""""""""
  1:""""""""""""""""""""""""""""""""__________________________________________
  1:__________________________________________________________________________

  $ sigrok-cli -i file.sr -O ascii:charset=_^
  1:_____________________________________________________^^^^^^^^^^^^^^^^^^^^^
  1:^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^__________________________________________
  1:__________________________________________________________________________

  $ sigrok-cli -i file.sr -O ascii:charset=_M
  1:_____________________________________________________MMMMMMMMMMMMMMMMMMMMM
  1:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM__________________________________________
  1:__________________________________________________________________________

  $ sigrok-cli -i file.sr -O ascii:charset=_X
  1:_____________________________________________________XXXXXXXXXXXXXXXXXXXXX
  1:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX__________________________________________
  1:__________________________________________________________________________

Signed-off-by: Gerhard Sittig <redacted>
src/output/ascii.c