aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2015-01-19 13:57:04 +0100
committerSylvain Munaut <tnt@246tNt.com>2015-01-19 14:16:25 +0100
commit11f27973a948531283fbb42f6dc54bd42032762f (patch)
treef7003dadd8936a61cf7c58c1551393f000df183b
parent720e702ee9e13b5427d1b07d075e91a22193933b (diff)
fosphor: Add a color intensity scale on the right side
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--lib/fosphor/fosphor.c19
-rw-r--r--lib/fosphor/fosphor.h1
-rw-r--r--lib/fosphor/gl.c8
-rw-r--r--lib/fosphor/gl_cmap.c23
-rw-r--r--lib/fosphor/gl_cmap.h3
-rw-r--r--lib/fosphor/main.c2
6 files changed, 50 insertions, 6 deletions
diff --git a/lib/fosphor/fosphor.c b/lib/fosphor/fosphor.c
index a887997..f399949 100644
--- a/lib/fosphor/fosphor.c
+++ b/lib/fosphor/fosphor.c
@@ -186,7 +186,8 @@ fosphor_render_defaults(struct fosphor_render *render)
FRO_WATERFALL |
FRO_LABEL_FREQ |
FRO_LABEL_PWR |
- FRO_LABEL_TIME;
+ FRO_LABEL_TIME |
+ FRO_COLOR_SCALE;
render->histo_wf_ratio = 0.5f;
render->freq_n_div = 10;
@@ -199,7 +200,7 @@ void
fosphor_render_refresh(struct fosphor_render *render)
{
int disp_spectrum, disp_waterfall;
- int avail, div, over, rsvd;
+ int avail, div, over, rsvd, rsvd_lr[2];
float y_top, y_bot;
/* Which screen zone ? */
@@ -207,10 +208,16 @@ fosphor_render_refresh(struct fosphor_render *render)
disp_waterfall = !!(render->options & FRO_WATERFALL);
/* Split the X space */
+ rsvd_lr[0] = 10;
+ rsvd_lr[1] = 10;
+
if (render->options & (FRO_LABEL_PWR | FRO_LABEL_TIME))
- rsvd = 50;
- else
- rsvd = 20;
+ rsvd_lr[0] += 30;
+
+ if (render->options & FRO_COLOR_SCALE)
+ rsvd_lr[1] += 10;
+
+ rsvd = rsvd_lr[0] + rsvd_lr[1];
render->freq_n_div = ((int)(render->width - rsvd) / 80) & ~1;
if (render->freq_n_div > 10)
@@ -223,7 +230,7 @@ fosphor_render_refresh(struct fosphor_render *render)
over = avail - (render->freq_n_div * div);
render->_x_div = (float)div;
- render->_x[0] = render->pos_x + (float)(rsvd - 10) + (float)(over / 2);
+ render->_x[0] = render->pos_x + (float)(rsvd_lr[0]) + (float)(over / 2);
render->_x[1] = render->_x[0] + (render->freq_n_div * render->_x_div) + 1.0f;
render->_x_label = render->_x[0] - 5.0f;
diff --git a/lib/fosphor/fosphor.h b/lib/fosphor/fosphor.h
index f245427..2022daf 100644
--- a/lib/fosphor/fosphor.h
+++ b/lib/fosphor/fosphor.h
@@ -69,6 +69,7 @@ struct fosphor_channel
#define FRO_LABEL_PWR (1<<5) /*!< \brief Display power labels */
#define FRO_LABEL_TIME (1<<6) /*!< \brief Display time labels */
#define FRO_CHANNELS (1<<7) /*!< \brief Display channels */
+#define FRO_COLOR_SCALE (1<<8) /*!< \brief Display intensity color scale */
/*! \brief fosphor render options */
struct fosphor_render
diff --git a/lib/fosphor/gl.c b/lib/fosphor/gl.c
index 99bba2d..b87b405 100644
--- a/lib/fosphor/gl.c
+++ b/lib/fosphor/gl.c
@@ -429,6 +429,10 @@ fosphor_gl_draw(struct fosphor *self, struct fosphor_render *render)
glEnd();
fosphor_gl_cmap_disable();
+
+ if (render->options & FRO_COLOR_SCALE)
+ fosphor_gl_cmap_draw_scale(gl->cmap_waterfall,
+ x[1]+2.0f, x[1]+10.0f, y[0], y[1]);
}
/* Draw histogram */
@@ -458,6 +462,10 @@ fosphor_gl_draw(struct fosphor *self, struct fosphor_render *render)
glEnd();
fosphor_gl_cmap_disable();
+
+ if (render->options & FRO_COLOR_SCALE)
+ fosphor_gl_cmap_draw_scale(gl->cmap_waterfall,
+ x[1]+2.0f, x[1]+10.0f, y[0], y[1]);
}
else if (render->options & (FRO_LIVE | FRO_MAX_HOLD))
{
diff --git a/lib/fosphor/gl_cmap.c b/lib/fosphor/gl_cmap.c
index 499efc0..d4b367d 100644
--- a/lib/fosphor/gl_cmap.c
+++ b/lib/fosphor/gl_cmap.c
@@ -272,6 +272,29 @@ fosphor_gl_cmap_disable(void)
glUseProgram(0);
}
+void
+fosphor_gl_cmap_draw_scale(GLuint cmap_id,
+ float x0, float x1, float y0, float y1)
+{
+ /* Enable texture-1D */
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_1D, cmap_id);
+ glEnable(GL_TEXTURE_1D);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ /* Draw QUAD */
+ glBegin( GL_QUADS );
+ glTexCoord1f(0.0f); glVertex2f(x0, y0);
+ glTexCoord1f(0.0f); glVertex2f(x1, y0);
+ glTexCoord1f(1.0f); glVertex2f(x1, y1);
+ glTexCoord1f(1.0f); glVertex2f(x0, y1);
+ glEnd();
+
+ /* Disable texturing */
+ glDisable(GL_TEXTURE_1D);
+}
+
int
fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, int N)
diff --git a/lib/fosphor/gl_cmap.h b/lib/fosphor/gl_cmap.h
index d253fe3..cbb0c40 100644
--- a/lib/fosphor/gl_cmap.h
+++ b/lib/fosphor/gl_cmap.h
@@ -53,6 +53,9 @@ void fosphor_gl_cmap_enable(struct fosphor_gl_cmap_ctx *cmap_ctx,
enum fosphor_gl_cmap_mode mode);
void fosphor_gl_cmap_disable(void);
+void fosphor_gl_cmap_draw_scale(GLuint cmap_id,
+ float x0, float x1, float y0, float y1);
+
typedef void (*gl_cmap_gen_func_t)(uint32_t *rgba, int N);
int fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, int N);
diff --git a/lib/fosphor/main.c b/lib/fosphor/main.c
index 29b2a0a..08b9ec7 100644
--- a/lib/fosphor/main.c
+++ b/lib/fosphor/main.c
@@ -204,6 +204,7 @@ _update_fosphor(void)
g_as->render_main.width = a;
g_as->render_main.height = g_as->h;
+ g_as->render_main.options &= ~FRO_COLOR_SCALE;
g_as->render_zoom.pos_x = a - 10;
g_as->render_zoom.width = g_as->w - a + 10;
@@ -213,6 +214,7 @@ _update_fosphor(void)
{
g_as->render_main.width = g_as->w;
g_as->render_main.height = g_as->h;
+ g_as->render_main.options |= FRO_COLOR_SCALE;
}
g_as->render_main.histo_wf_ratio = g_as->ratio;