mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 21:14:04 +02:00
ubb-la/gui.c: display time of center (from start of buffer)
This commit is contained in:
parent
b0a576dd64
commit
db133f2cb6
31
ubb-la/gui.c
31
ubb-la/gui.c
@ -74,10 +74,15 @@
|
|||||||
|
|
||||||
#define UNIT_GAP 2 /* space between number and unit */
|
#define UNIT_GAP 2 /* space between number and unit */
|
||||||
|
|
||||||
|
#define POS_X 168
|
||||||
|
#define POS_Y (MEAS_DIV_Y-8-3)
|
||||||
|
|
||||||
|
#define MEAS_DIV_Y (FREQ_Y-3-1)
|
||||||
|
|
||||||
#define FREQ_X 0
|
#define FREQ_X 0
|
||||||
#define FREQ_Y 220
|
#define FREQ_Y 222
|
||||||
#define INTERVAL_X 0
|
#define INTERVAL_X 0
|
||||||
#define INTERVAL_Y 230
|
#define INTERVAL_Y (FREQ_Y+8+2)
|
||||||
#define DIV_SAMP_X (DIV_INT_X-8)
|
#define DIV_SAMP_X (DIV_INT_X-8)
|
||||||
#define DIV_SAMP_Y FREQ_Y
|
#define DIV_SAMP_Y FREQ_Y
|
||||||
#define DIV_INT_X 80
|
#define DIV_INT_X 80
|
||||||
@ -333,7 +338,7 @@ static void show_buffer(const uint8_t *buf, int skip, int nibbles,
|
|||||||
/* ----- Display the sample frequency -------------------------------------- */
|
/* ----- Display the sample frequency -------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
static void si_text(int x, int y, double v, const char *unit)
|
static void si_text(int x, int y, double v, const char *unit, int digits)
|
||||||
{
|
{
|
||||||
const char *pfx;
|
const char *pfx;
|
||||||
|
|
||||||
@ -355,11 +360,17 @@ static void si_text(int x, int y, double v, const char *unit)
|
|||||||
v *= 1e9;
|
v *= 1e9;
|
||||||
pfx = "n";
|
pfx = "n";
|
||||||
}
|
}
|
||||||
if (v >= 10)
|
if (v >= 10 && digits == 3)
|
||||||
textf(x, y, TEXT_RGBA, "%3d", (int) (v+0.5));
|
textf(x, y, TEXT_RGBA, "%3d", (int) (v+0.5));
|
||||||
|
else if (v >= 100 && digits == 4)
|
||||||
|
textf(x, y, TEXT_RGBA, "%4d", (int) (v+0.5));
|
||||||
|
else if (v >= 100)
|
||||||
|
textf(x, y, TEXT_RGBA, "%*.*f", digits, digits-4, v);
|
||||||
|
else if (v >= 10)
|
||||||
|
textf(x, y, TEXT_RGBA, "%*.*f", digits, digits-3, v);
|
||||||
else
|
else
|
||||||
textf(x, y, TEXT_RGBA, "%3.1f", v);
|
textf(x, y, TEXT_RGBA, "%*.*f", digits, digits-2, v);
|
||||||
textf(x+3*8+UNIT_GAP, y, UNIT_RGBA, "%s%s", pfx, unit);
|
textf(x+digits*8+UNIT_GAP, y, UNIT_RGBA, "%s%s", pfx, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -367,12 +378,12 @@ static void show_freq(double freq, int zoom)
|
|||||||
{
|
{
|
||||||
int div;
|
int div;
|
||||||
|
|
||||||
si_text(FREQ_X, FREQ_Y, freq, "Sa/s");
|
si_text(FREQ_X, FREQ_Y, freq, "Sa/s", 3);
|
||||||
si_text(INTERVAL_X, INTERVAL_Y, 1/freq, "s/Sa");
|
si_text(INTERVAL_X, INTERVAL_Y, 1/freq, "s/Sa", 3);
|
||||||
div = (DIV_X >> MAX_ZOOM) << (MAX_ZOOM-zoom);
|
div = (DIV_X >> MAX_ZOOM) << (MAX_ZOOM-zoom);
|
||||||
textf(DIV_SAMP_X, DIV_SAMP_Y, TEXT_RGBA, "%4d", div);
|
textf(DIV_SAMP_X, DIV_SAMP_Y, TEXT_RGBA, "%4d", div);
|
||||||
textf(DIV_SAMP_X+4*8+UNIT_GAP, DIV_SAMP_Y, UNIT_RGBA, "Sa/div", div);
|
textf(DIV_SAMP_X+4*8+UNIT_GAP, DIV_SAMP_Y, UNIT_RGBA, "Sa/div", div);
|
||||||
si_text(DIV_INT_X, DIV_INT_Y, div/freq, "s/div");
|
si_text(DIV_INT_X, DIV_INT_Y, div/freq, "s/div", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -421,6 +432,8 @@ void gui(const uint8_t *buf, int skip, int nibbles, double freq)
|
|||||||
XCENTER+CENTER_W/2, CENTER_Y0, CENTER_RGBA);
|
XCENTER+CENTER_W/2, CENTER_Y0, CENTER_RGBA);
|
||||||
show_buffer(buf, skip, nibbles, CH_XOFF, XRES, zoom, pos);
|
show_buffer(buf, skip, nibbles, CH_XOFF, XRES, zoom, pos);
|
||||||
show_freq(freq, zoom);
|
show_freq(freq, zoom);
|
||||||
|
si_text(POS_X, POS_Y, pos/freq, "s", 7);
|
||||||
|
hlineColor(surf, 0, XRES-1, MEAS_DIV_Y, DIV_RGBA);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user