Frequency Readout

freqdisplay2

The most easy way to show the frequency readout is to use a text rather than an image.

gboolean front_panel(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
    int x, y, width, height;
    double color, barlength;
    x = event->area.x;
    y = event->area.y;
    width = event->area.width;
    height = event->area.height;
    cairo_t *cr = gdk_cairo_create(widget->window);
    cairo_rectangle(cr, x, y, width, height);
    cairo_clip(cr);
    barlength = (s_meter/255.0) * (width-20);
    color = 0.0;
    for(int i=0; i<barlength; i+=10) {
     if((i/10)%10 == 0) cairo_set_source_rgb(cr, 0x33/256.0, 0x66/256.0, 0x99/256.0);
     else cairo_set_source_rgb(cr, color, 1.0-color, 0.1);
     cairo_rectangle(cr, x+10+i, y+10, 10, height-20);
     color += 0.020;
     if(color > 1.0) color = 0.0;
     cairo_fill(cr);
    }
    char string[128];
    sprintf(string,"%12.3f",freq_show/1000.0);
    cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
    cairo_select_font_face(cr, "FreeSans", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size(cr, 46.0);
    cairo_move_to(cr, width-270.0, height-8.0);
    cairo_show_text(cr, string);
    cairo_set_source_rgb(cr,0,0,0);
    cairo_destroy(cr);
    return FALSE;
}

This code is very dirty, but it works. The first half is for the S-meter, and the latter half for the Frequency Display.

Drawing an S-meter (2)

s-meter3

This is a prototype version of the front panel. Radio buttons are easy to use, but have less flexibility in design and may have to be avoided to use.

Next thing to do is a frequency display.

Drawing an S-meter

s-meter2

Now some graphics. This is supposed to be an S-meter. The length of the yellow bar shows the signal strength. The refresh rate is 10 frames per second, which means I am inquiring IC-7410 for the S-meter value every 100 mS.

I need to do some calibrations. The only available information from the instruction manual is that 0000=S0, 0120=S9, and 0240=S9+60dB.

CPU2

The CPU load drops significantly when the program is terminated.

With grig there is almost no change in the CPU load, so there is a room for improvement.