fosphor: Add a color intensity scale on the right side
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
720e702ee9
commit
11f27973a9
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue