Date:2013-01-31 07:52:24 (6 years 4 months ago)
Author:Werner Almesberger
Commit:db133f2cb617ae1934dabc1246101034fb476767
Message:ubb-la/gui.c: display time of center (from start of buffer)

Files: ubb-la/gui.c (5 diffs)

Change Details

ubb-la/gui.c
7474
7575#define UNIT_GAP 2 /* space between number and unit */
7676
77#define POS_X 168
78#define POS_Y (MEAS_DIV_Y-8-3)
79
80#define MEAS_DIV_Y (FREQ_Y-3-1)
81
7782#define FREQ_X 0
78#define FREQ_Y 220
83#define FREQ_Y 222
7984#define INTERVAL_X 0
80#define INTERVAL_Y 230
85#define INTERVAL_Y (FREQ_Y+8+2)
8186#define DIV_SAMP_X (DIV_INT_X-8)
8287#define DIV_SAMP_Y FREQ_Y
8388#define DIV_INT_X 80
...... 
333338/* ----- Display the sample frequency -------------------------------------- */
334339
335340
336static void si_text(int x, int y, double v, const char *unit)
341static void si_text(int x, int y, double v, const char *unit, int digits)
337342{
338343    const char *pfx;
339344
...... 
355360        v *= 1e9;
356361        pfx = "n";
357362    }
358    if (v >= 10)
363    if (v >= 10 && digits == 3)
359364        textf(x, y, TEXT_RGBA, "%3d", (int) (v+0.5));
365    else if (v >= 100 && digits == 4)
366        textf(x, y, TEXT_RGBA, "%4d", (int) (v+0.5));
367    else if (v >= 100)
368        textf(x, y, TEXT_RGBA, "%*.*f", digits, digits-4, v);
369    else if (v >= 10)
370        textf(x, y, TEXT_RGBA, "%*.*f", digits, digits-3, v);
360371    else
361        textf(x, y, TEXT_RGBA, "%3.1f", v);
362    textf(x+3*8+UNIT_GAP, y, UNIT_RGBA, "%s%s", pfx, unit);
372        textf(x, y, TEXT_RGBA, "%*.*f", digits, digits-2, v);
373    textf(x+digits*8+UNIT_GAP, y, UNIT_RGBA, "%s%s", pfx, unit);
363374}
364375
365376
...... 
367378{
368379    int div;
369380
370    si_text(FREQ_X, FREQ_Y, freq, "Sa/s");
371    si_text(INTERVAL_X, INTERVAL_Y, 1/freq, "s/Sa");
381    si_text(FREQ_X, FREQ_Y, freq, "Sa/s", 3);
382    si_text(INTERVAL_X, INTERVAL_Y, 1/freq, "s/Sa", 3);
372383    div = (DIV_X >> MAX_ZOOM) << (MAX_ZOOM-zoom);
373384    textf(DIV_SAMP_X, DIV_SAMP_Y, TEXT_RGBA, "%4d", div);
374385    textf(DIV_SAMP_X+4*8+UNIT_GAP, DIV_SAMP_Y, UNIT_RGBA, "Sa/div", div);
375    si_text(DIV_INT_X, DIV_INT_Y, div/freq, "s/div");
386    si_text(DIV_INT_X, DIV_INT_Y, div/freq, "s/div", 3);
376387}
377388
378389
...... 
421432            XCENTER+CENTER_W/2, CENTER_Y0, CENTER_RGBA);
422433        show_buffer(buf, skip, nibbles, CH_XOFF, XRES, zoom, pos);
423434        show_freq(freq, zoom);
435        si_text(POS_X, POS_Y, pos/freq, "s", 7);
436        hlineColor(surf, 0, XRES-1, MEAS_DIV_Y, DIV_RGBA);
424437        update();
425438
426439        while (1) {

Archive Download the corresponding diff file

Branches:
master



interactive