Skip to content

Commit

Permalink
Draw partial signal dot for no amplitude
Browse files Browse the repository at this point in the history
Previously max signal level (4 dots) but with no amplitude measured was
counted as signal level 3.  But level 3 or lower with no amplitude sill
counts as the same level.

Have compute_update() no longer do this signal level adjustment and just
report the level used, which indicates the averaging interval.

The dot graphic will now indicate "no amplitude" by using a hollow dot
for the final signal level's dot.

This way the number of dots always shows the averaging interval and a
hollow dot always shows that the signal is too poor to measure
amplitude.
  • Loading branch information
xyzzy42 committed Apr 2, 2021
1 parent fc66375 commit e199e2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/computer.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void compute_update(struct computer *c)
c->actv->pb = pb_clone(&ps[step]);
c->actv->is_old = 0;
/* Signal's range is 0 to NSTEPS, while step is -1 to NSTEPS-1, i.e. signal = step+1 */
c->actv->signal = step == NSTEPS-1 && ps[step].amp < 0 ? step : step+1;
c->actv->signal = step+1;
} else {
debug("---\n");
c->actv->is_old = 1;
Expand Down
24 changes: 17 additions & 7 deletions src/output_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,20 @@ static double amplitude_to_time(double lift_angle, double amp)
return asin(lift_angle / (2 * amp)) / M_PI;
}

static double draw_watch_icon(cairo_t *c, int signal, int happy, int light)
/** Draw the watch graphic that has status info.
*
* @param[in,out] c Cairo context to use.
* @param signal Signal level, i.e. dots, 0 to NSTEPS inclusive.
* @param partial Specified signal level is only partially achieved.
* @param happy Green happy face or red frowny face.
* @param light Indicate light sampling mode.
* @return Y coodinate of top margin.
*/

static double draw_watch_icon(cairo_t *c, int signal, bool partial, bool happy, bool light)
{
happy = !!happy;
cairo_set_line_width(c,3);
cairo_set_source(c,happy?green:red);
cairo_set_line_width(c, 3);
cairo_set_source(c, happy ? green : red);
cairo_move_to(c, OUTPUT_WINDOW_HEIGHT * 0.5, OUTPUT_WINDOW_HEIGHT * 0.5);
cairo_line_to(c, OUTPUT_WINDOW_HEIGHT * 0.75, OUTPUT_WINDOW_HEIGHT * (0.75 - 0.5*happy));
cairo_move_to(c, OUTPUT_WINDOW_HEIGHT * 0.5, OUTPUT_WINDOW_HEIGHT * 0.5);
Expand All @@ -126,15 +135,15 @@ static double draw_watch_icon(cairo_t *c, int signal, int happy, int light)
cairo_stroke(c);
int l = OUTPUT_WINDOW_HEIGHT * 0.8 / (2*NSTEPS - 1);
int i;
cairo_set_line_width(c,1);
cairo_set_line_width(c, 1);
for(i = 0; i < signal; i++) {
cairo_move_to(c, OUTPUT_WINDOW_HEIGHT + 0.5*l, OUTPUT_WINDOW_HEIGHT * 0.9 - 2*i*l);
cairo_line_to(c, OUTPUT_WINDOW_HEIGHT + 1.5*l, OUTPUT_WINDOW_HEIGHT * 0.9 - 2*i*l);
cairo_line_to(c, OUTPUT_WINDOW_HEIGHT + 1.5*l, OUTPUT_WINDOW_HEIGHT * 0.9 - (2*i+1)*l);
cairo_line_to(c, OUTPUT_WINDOW_HEIGHT + 0.5*l, OUTPUT_WINDOW_HEIGHT * 0.9 - (2*i+1)*l);
cairo_line_to(c, OUTPUT_WINDOW_HEIGHT + 0.5*l, OUTPUT_WINDOW_HEIGHT * 0.9 - 2*i*l);
cairo_stroke_preserve(c);
cairo_fill(c);
if (i < signal-1 || !partial) cairo_fill(c);
}
if(light) {
int l = OUTPUT_WINDOW_HEIGHT * 0.15;
Expand Down Expand Up @@ -194,7 +203,8 @@ static gboolean output_draw_event(GtkWidget *widget, cairo_t *c, struct output_p
struct processing_buffers *p = snst->pb;
int old = snst->is_old;

double x = draw_watch_icon(c,snst->signal,snst->calibrate ? snst->signal==NSTEPS : snst->signal, snst->is_light);
double x = draw_watch_icon(c, snst->signal, snst->amp <= 0,
snst->signal >= (snst->calibrate ? NSTEPS : 1), snst->is_light);

cairo_text_extents_t extents;

Expand Down

0 comments on commit e199e2d

Please sign in to comment.