mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 20:17:30 +02:00
ubb-la/gui.c: display a small map of buffer and view
This commit is contained in:
parent
f99b62636f
commit
e1be0f242b
35
ubb-la/gui.c
35
ubb-la/gui.c
@ -35,10 +35,19 @@
|
||||
#define XRES 320 /* canvas width */
|
||||
#define YRES 240 /* canvas height */
|
||||
|
||||
#define MAP_BUF_RGBA 0x808080ff /* buffer in the map */
|
||||
#define MAP_VIEW_RGBA 0xffffffff /* current view in the map */
|
||||
#define LEVEL_RGBA 0xffff00ff /* constant level or single change */
|
||||
#define BOUNCE_RGBA 0xff8080ff /* bouncing signal */
|
||||
#define LABEL_RGBA 0xffffffff /* channel label */
|
||||
|
||||
#define XCENTER ((XRES+CH_XOFF)/2)
|
||||
|
||||
#define MAP_BUF_Y0 2
|
||||
#define MAP_BUF_Y1 8
|
||||
#define MAP_VIEW_Y0 0
|
||||
#define MAP_VIEW_Y1 10
|
||||
|
||||
#define CH_XOFF 30
|
||||
#define CH_YOFF 30
|
||||
#define CH_SKIP 16
|
||||
@ -122,6 +131,26 @@ static void textf(int x, int y, uint32_t color, const char *fmt, ...)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Map of buffer and view -------------------------------------------- */
|
||||
|
||||
|
||||
static void show_map(int skip, int nibbles, int s0, int s1)
|
||||
{
|
||||
int w = nibbles-skip;
|
||||
int m = (nibbles+skip) >> 1;
|
||||
int scale = 0;
|
||||
|
||||
while (w >= (XRES-CH_XOFF)/2) {
|
||||
w >>= 1;
|
||||
scale++;
|
||||
}
|
||||
boxColor(surf, XCENTER-(w >> 1), MAP_BUF_Y0,
|
||||
XCENTER+(w >> 1), MAP_BUF_Y1, MAP_BUF_RGBA);
|
||||
rectangleColor(surf, (s0-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y0,
|
||||
(s1-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y1, MAP_VIEW_RGBA);
|
||||
}
|
||||
|
||||
|
||||
/* ----- Waveform elements ------------------------------------------------- */
|
||||
|
||||
|
||||
@ -227,12 +256,14 @@ static void show_buffer_zoom_out(const uint8_t *buf, int skip, int nibbles,
|
||||
static void show_buffer(const uint8_t *buf, int skip, int nibbles,
|
||||
int x0, int x1, int zoom, int pos)
|
||||
{
|
||||
int xm, w, p0, p1;
|
||||
int xm, w, s, p0, p1;
|
||||
int d, dp;
|
||||
|
||||
xm = (x0+x1) >> 1;
|
||||
dp = pos-((nibbles+skip) >> 1);
|
||||
if (zoom < 0) {
|
||||
s = (x1-x0) << -zoom;
|
||||
show_map(skip, nibbles, pos-s/2, pos+s/2);
|
||||
w = (nibbles-skip) >> -zoom;
|
||||
p0 = xm-(w >> 1)-(dp >> -zoom);
|
||||
p1 = xm+((w+1) >> 1)-(dp >> -zoom);
|
||||
@ -246,6 +277,8 @@ static void show_buffer(const uint8_t *buf, int skip, int nibbles,
|
||||
}
|
||||
show_buffer_zoom_out(buf, skip, nibbles, p0, p1);
|
||||
} else {
|
||||
s = (x1-x0) >> zoom;
|
||||
show_map(skip, nibbles, pos-s/2, pos+s/2);
|
||||
w = (nibbles-skip) << zoom;
|
||||
p0 = xm-(w >> 1)-(dp << zoom);
|
||||
p1 = xm+((w+1) >> 1)-(dp << zoom);
|
||||
|
Loading…
Reference in New Issue
Block a user