Example #1
0
File: bandmap.c Project: patlc/tlf
void bandmap_show() {
/*
 * display depending on filter state
 * - all bands on/off
 * - all mode  on/off
 * - dupes     on/off
 *
 * If more entries to show than place in window, show around current frequency
 *
 * mark entries according to age, source and worked state. Mark new multis
 * - new 	brigth blue
 * - normal	blue
 * - aged	black
 * - worked	small caps
 * - new multi	underlined
 * - self announced stations
 *   		small preceeding letter for reporting station
 *
 * maybe show own frequency as dashline in other color 
 * (maybee green highlighted)
 * - highligth actual spot if near its frequency 
 *
 * Allow selection of one of the spots (switches to S&P)
 * - Ctrl-G as known
 * - '.' and cursor plus 'Enter'
 * - Test mouseclick...
 *
 * '.' goes into map, shows help line above and supports
 * - cursormovement
 * - 'ESC' leaves mode
 * - 'Enter' selects spot
 * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off.
 */

    GList *list;
    spot *data;
    int cols = 0;
    int curx, cury;
    int bm_x, bm_y;
    int i,j;
    short dupe;

    if (!bm_initialized) {
	bm_init();
	bm_initialized = 1;
    }

    /* acquire mutex 
     * do not add new spots to allspots during
     * - aging and
     * - filtering
     * furthermore do not allow call lookup as long as
     * filter array is build anew */
    pthread_mutex_lock( &bm_mutex );

    bandmap_age();			/* age entries in bandmap */

    /* make array of spots to display
     * filter spotlist according to settings */

    if (spots) 
	g_ptr_array_free( spots, TRUE);		/* free array */

    spots = g_ptr_array_sized_new( 128 );	/* allocate new one */

    list = allspots;

    while (list) {
	data = list->data;

	/* if spot is allband or allmode is set or band or mode matches
	 * actual one than add it to the filtered 'spot' array
	 */

	dupe = bm_isdupe(data->call, data->band);

	if ((bm_config.allband || (data->band == bandinx)) && 
		(bm_config.allmode || (data->mode == trxmode)) &&
		(bm_config.showdupes || !dupe)) {
	
	    data -> dupe = dupe;
	    g_ptr_array_add( spots, data );
	}

	list = list->next;
    }

    pthread_mutex_unlock( &bm_mutex );


    /* afterwards display filtered list around own QRG +/- some offest 
     * (offset gets resest if we change frequency */

    /** \todo Auswahl des Display Bereiches */
    getyx( stdscr, cury, curx);		/* remember cursor */

    /* start in line 14, column 0 */
    bm_y = 14;
    bm_x = 0;

    /* clear space for bandmap */
    attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);

    move(bm_y,0);			/* do not overwrite # frequency */
    for (j = 0; j < 67; j++)
	addch(' ');

    for (i = bm_y + 1; i < bm_y + 10; i++) {
	move (i,0);
	for (j = 0; j < 80; j++)
	    addch (' ');
    }

    bm_show_info();
    /** \fixme Darstellung des # Speichers */

    for (i = 0; i < spots->len; i++) 
    {
	data = g_ptr_array_index( spots, i );

	attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);
	mvprintw (bm_y, bm_x, "%7.1f %c ", (float)(data->freq/1000.), 
		(data->node == thisnode ? '*' : data->node));

	if (data -> timeout > SPOT_NORMAL) 
	    attrset(COLOR_PAIR(CB_NEW)|A_BOLD);

	else if (data -> timeout > SPOT_OLD)
	    attrset(COLOR_PAIR(CB_NORMAL));

	else
	    attrset(COLOR_PAIR(CB_OLD));

	if (bm_ismulti(data->call))
	    attron(A_STANDOUT);

       if (data->dupe) {
	   if (bm_config.showdupes) {
	       attrset(COLOR_PAIR(CB_DUPE)|A_BOLD);
	       attroff(A_STANDOUT);
	       printw ("%-12s", g_ascii_strdown(data->call, -1));
	   }
	}
	else {
	    printw ("%-12s", data->call);
	}

	attroff (A_BOLD);

	bm_y++;
	if (bm_y == 24) {
	    bm_y = 14;
	    bm_x += 22;
	    cols++;
	    if (cols > 2)
		break;
	}
    }
    
    move(cury, curx);			/* reset cursor */

    refreshp();
}
Example #2
0
void time_update(void)
{
    extern struct tm *time_ptr;
    extern char qsonrstr[];
    extern int bandinx;
    extern int this_second;
    extern int system_secs;
    extern int miniterm;

    char time_buf[11];
    int currentterm = 0;
    static int s = 0;
    static int m = 0;
    static int bm_timeout = 0;
    static int oldsecs = -1;  	/* trigger immediate update */

    get_time();
    this_second = time_ptr->tm_sec;		/* seconds */
    system_secs = time_ptr->tm_min * 60 + time_ptr->tm_sec;

    if (this_second != oldsecs) {
	/* do it every second */
	oldsecs = this_second;

	if (wpx == 1) {
	    if (minute_timer > 0)
		minute_timer--;
	}

	show_freq();

	bandmap_age();		/* age bandmap spots every second */
	clusterinfo();		/* update cluster and bandmap display */

				/* write bandmap spots to file every 10s */
	bm_timeout = (bm_timeout + 1) % 10;
	if (bm_timeout == 0) {

	    bmdata_write_file();
	}

	s = (s + 1) % 2;
	if (s > 0) {		/* every 2 seconds */

	    strftime(time_buf, 10, "%H:%M:%S", time_ptr);
	    time_buf[5] = '\0';

	    if ((time_buf[6] == '1') && (m >= 30)) {

		m = 0;
		getwwv();

	    } else {
		m++;
	    }

	    currentterm = miniterm;
	    miniterm = 0;

	    broadcast_lan();
	    update_line(time_buf);

	    attron(COLOR_PAIR(C_LOG) | A_STANDOUT);

	    mvprintw(7, 0, logline0);
	    mvprintw(8, 0, logline1);
	    mvprintw(9, 0, logline2);
	    mvprintw(10, 0, logline3);
	    mvprintw(11, 0, logline4);
	    mvprintw(13, 0,
		    "                                                                    ");
	    attron(COLOR_PAIR(C_WINDOW));
	    mvprintw(12, 23, qsonrstr);
	    printcall();

	    showscore();	/* update  score  window every 2 seconds */
	    show_zones(bandinx);
	    miniterm = currentterm;
	}
    }
}