示例#1
0
文件: zoom.c 项目: imincik/pkg-grass
/* Zoom - to region */
int zoom_region(void)
{
    struct Cell_head win;
    char *mapset;

    G_debug(2, "zoom_region()");

    driver_open();

    mapset = G_find_file2("windows", var_getc(VAR_ZOOM_REGION), NULL);
    if (mapset == NULL) {
	G_warning(_("Cannot find window '%s'"), var_getc(VAR_ZOOM_REGION));
	return 0;
    }
    G__get_window(&win, "windows", var_getc(VAR_ZOOM_REGION), mapset);
    G_put_window(&win);
    G_set_window(&win);

    display_redraw();

    driver_close();

    G_debug(3, "zoom_region(): End");

    return 1;
}
示例#2
0
文件: zoom.c 项目: imincik/pkg-grass
int zoom_pan_update(void *closure, int sxn, int syn, int button)
{
    G_debug(2, "button = %d x = %d y = %d", button, sxn, syn);

    if (button == 3)
	return 1;

    if (button == 1) {
	double x = D_d_to_u_col(sxn);
	double y = D_d_to_u_row(syn);
	double dx = (window.east - window.west) / 2;
	double dy = (window.north - window.south) / 2;

	window.north = y + dy;
	window.south = y - dy;
	window.east = x + dx;
	window.west = x - dx;

	G_debug(2, "w = %f e = %f n = %f s = %f", window.west, window.east,
		window.north, window.south);
	G_adjust_Cell_head(&window, 0, 0);
	G_put_window(&window);
	G_set_window(&window);

	display_redraw();
    }

    return 0;
}
示例#3
0
void ICACHE_FLASH_ATTR
display_data(uint8 page, uint8 line, char data[20])
{
    page--;
    switch (line)
    {
        case 1:
            os_memcpy(&_PageData[page].line1, data, 20);
        break; 
        case 2:
            os_memcpy(&_PageData[page].line2, data, 20);
        break; 
        case 3:
            os_memcpy(&_PageData[page].line3, data, 20);
        break; 
        case 4:
            os_memcpy(&_PageData[page].line4, data, 20);
        break;
    }
    if (startup_done == 0 && line == 4) {
        LCD_noBlink();
        display_redraw();
        os_timer_disarm(&refresh_timer);
        os_timer_setfn(&refresh_timer, (os_timer_func_t *)display_refresh, 0);
        os_timer_arm(&refresh_timer, 5000, 1);
        startup_done = 1;
    }
}
示例#4
0
void display_refresh(display_t *d, frame_geometry_t *g)
{
  if ( d == NULL )
    return;
  display_update(d, g);
  display_redraw(d, g->x, g->y, g->width, g->height);
}
示例#5
0
static portBASE_TYPE handle_msg_subscribe_mode(msg_id_t id, msg_data_t *data)
{
	display_mode = data->subscribe_mode;
	display_redraw();

	return pdTRUE;
}
示例#6
0
void ICACHE_FLASH_ATTR 
display_prev_page(void)
{
    display_page--;
    if (display_page == 0) display_page = DISPLAY_PAGE_MAX;
    display_redraw();

    //Reset refresh timer
    os_timer_disarm(&refresh_timer);
    os_timer_setfn(&refresh_timer, (os_timer_func_t *)display_refresh, 0);
    os_timer_arm(&refresh_timer, 5000, 0);
}
示例#7
0
void ICACHE_FLASH_ATTR
display_refresh(uint8 start)
{
    //Refresh the display
    os_timer_disarm(&refresh_timer);
    os_timer_setfn(&refresh_timer, (os_timer_func_t *)display_refresh, 0);
    os_timer_arm(&refresh_timer, 5000, 0);
    if (start == 1) {
        display_redraw();
        return;
    }
    display_next_page();
}
示例#8
0
static gboolean display_event_expose(GtkWidget *widget, GdkEventExpose *event)
{
  display_t *d = display_current;
  if ( d == NULL )
    return TRUE;

  debug(DEBUG_GTK, "EXPOSE x=%u y=%u w=%u h=%u\n", event->area.x, event->area.y, event->area.width, event->area.height);

  display_redraw(d, event->area.x, event->area.y, event->area.width, event->area.height);
  display_selection_show(d);
  display_pattern_show_selection();

  return TRUE;
}
示例#9
0
文件: zoom.c 项目: imincik/pkg-grass
int zoom_window_update(void *closure, int sxn, int syn, int button)
{
    struct zoom_window *zw = closure;

    if (zw->mode == 1) {
	i_prompt_buttons(_("1. corner"), _("2. corner"), _("Quit"));
	zw->next_mode = 2;
    }

    G_debug(2, "button = %d x = %d y = %d", button, sxn, syn);

    if (button == 3)
	return 1;

    if (zw->mode == 2 && button == 2) {
	double x1 = D_d_to_u_col(zw->sxo);
	double y1 = D_d_to_u_row(zw->syo);
	double x2 = D_d_to_u_col(sxn);
	double y2 = D_d_to_u_row(syn);

	G_debug(2, "x1 = %f x2 = %f y1 = %f y2 = %f", x1, x2, y1, y2);

	window.north = y1 > y2 ? y1 : y2;
	window.south = y1 < y2 ? y1 : y2;
	window.west = x1 < x2 ? x1 : x2;
	window.east = x1 > x2 ? x1 : x2;

	G_debug(2, "w = %f e = %f n = %f s = %f", window.west, window.east,
		window.north, window.south);

	G_adjust_Cell_head(&window, 0, 0);
	G_put_window(&window);
	G_set_window(&window);

	display_redraw();

	i_prompt_buttons(_("1. corner"), _("1. corner"), _("Quit"));
	zw->next_mode = 1;
    }

    zw->sxo = sxn;
    zw->syo = syn;
    zw->mode = zw->next_mode;

    set_mode(zw->mode == 2 ? MOUSE_BOX : MOUSE_POINT);
    set_location(zw->sxo, zw->syo);

    return 0;
}
示例#10
0
文件: zoom.c 项目: imincik/pkg-grass
/* Zoom - default region */
int zoom_default(void)
{
    struct Cell_head defwin;

    G_debug(2, "zoom_default()");

    driver_open();

    G_get_default_window(&defwin);
    G_put_window(&defwin);
    G_set_window(&defwin);

    display_redraw();

    driver_close();

    G_debug(3, "zoom_default(): End");

    return 1;
}
示例#11
0
文件: zoom.c 项目: imincik/pkg-grass
/* Zoom - in / out (centre unchanged) */
int zoom_centre(double factor)
{
    double xc, yc, dx, dy;

    G_debug(2, "zoom_centre()");

    driver_open();

    G_debug(2, "1 n = %f s = %f", window.north, window.south);

    dx = (window.east - window.west) / 2;
    dy = (window.north - window.south) / 2;
    xc = (window.east + window.west) / 2;
    yc = (window.north + window.south) / 2;

    G_debug(2, "  yc = %f dy = %f", yc, dy);

    window.north = yc + dy * factor;
    window.south = yc - dy * factor;
    window.east = xc + dx * factor;
    window.west = xc - dx * factor;


    G_debug(2, "2 n = %f s = %f", window.north, window.south);
    G_adjust_Cell_head(&window, 0, 0);
    G_debug(2, "3 n = %f s = %f", window.north, window.south);
    G_put_window(&window);
    G_set_window(&window);

    display_redraw();

    driver_close();

    G_debug(3, "zoom_centre(): End");

    return 1;
}
示例#12
0
文件: select.c 项目: AaronNGray/mtr
void select_loop(void) {
  fd_set readfd;
  fd_set writefd;
  int anyset = 0;
  int maxfd = 0;
  int dnsfd, netfd;
#ifdef ENABLE_IPV6
  int dnsfd6;
#endif
  int NumPing = 0;
  int paused = 0;
  struct timeval lasttime, thistime, selecttime;
  struct timeval startgrace;
  int dt;
  int rv; 
  int graceperiod = 0;

  memset(&startgrace, 0, sizeof(startgrace));

  gettimeofday(&lasttime, NULL);

  while(1) {
    dt = calc_deltatime (WaitTime);
    intervaltime.tv_sec  = dt / 1000000;
    intervaltime.tv_usec = dt % 1000000;

    FD_ZERO(&readfd);
    FD_ZERO(&writefd);

    maxfd = 0;

    if(Interactive) {
      FD_SET(0, &readfd);
      maxfd = 1;
    }

#ifdef ENABLE_IPV6
    if (dns) {
      dnsfd6 = dns_waitfd6();
      if (dnsfd6 >= 0) {
        FD_SET(dnsfd6, &readfd);
        if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
      } else {
        dnsfd6 = 0;
      }
    } else
      dnsfd6 = 0;
#endif
    if (dns) {
      dnsfd = dns_waitfd();
      FD_SET(dnsfd, &readfd);
      if(dnsfd >= maxfd) maxfd = dnsfd + 1;
    } else
      dnsfd = 0;

    netfd = net_waitfd();
    FD_SET(netfd, &readfd);
    if(netfd >= maxfd) maxfd = netfd + 1;

    if (mtrtype == IPPROTO_TCP)
      net_add_fds(&writefd, &maxfd);

    do {
      if(anyset || paused) {
	/* Set timeout to 0.1s.
	 * While this is almost instantaneous for human operators,
	 * it's slow enough for computers to go do something else;
	 * this prevents mtr from hogging 100% CPU time on one core.
	 */
	selecttime.tv_sec = 0;
	selecttime.tv_usec = paused?100000:0; 
      
	rv = select(maxfd, (void *)&readfd, &writefd, NULL, &selecttime);

      } else {
	if(Interactive) display_redraw();

	gettimeofday(&thistime, NULL);

	if(thistime.tv_sec > lasttime.tv_sec + intervaltime.tv_sec ||
	   (thistime.tv_sec == lasttime.tv_sec + intervaltime.tv_sec &&
	    thistime.tv_usec >= lasttime.tv_usec + intervaltime.tv_usec)) {
	  lasttime = thistime;

	  if (!graceperiod) {
	    if (NumPing >= MaxPing && (!Interactive || ForceMaxPing)) {
	      graceperiod = 1;
	      startgrace = thistime;
	    }

	    /* do not send out batch when we've already initiated grace period */
	    if (!graceperiod && net_send_batch())
	      NumPing++;
	  }
	}

	if (graceperiod) {
	  dt = (thistime.tv_usec - startgrace.tv_usec) +
		    1000000 * (thistime.tv_sec - startgrace.tv_sec);
	  if (dt > GRACETIME)
	    return;
	}

	selecttime.tv_usec = (thistime.tv_usec - lasttime.tv_usec);
	selecttime.tv_sec = (thistime.tv_sec - lasttime.tv_sec);
	if (selecttime.tv_usec < 0) {
	  --selecttime.tv_sec;
	  selecttime.tv_usec += 1000000;
	}
	selecttime.tv_usec = intervaltime.tv_usec - selecttime.tv_usec;
	selecttime.tv_sec = intervaltime.tv_sec - selecttime.tv_sec;
	if (selecttime.tv_usec < 0) {
	  --selecttime.tv_sec;
	  selecttime.tv_usec += 1000000;
	}

	if (dns) {
	  if ((selecttime.tv_sec > (time_t)dnsinterval) ||
	      ((selecttime.tv_sec == (time_t)dnsinterval) &&
	       (selecttime.tv_usec > ((time_t)(dnsinterval * 1000000) % 1000000)))) {
	    selecttime.tv_sec = (time_t)dnsinterval;
	    selecttime.tv_usec = (time_t)(dnsinterval * 1000000) % 1000000;
	  }
	}

	rv = select(maxfd, (void *)&readfd, NULL, NULL, &selecttime);
      }
    } while ((rv < 0) && (errno == EINTR));

    if (rv < 0) {
      perror ("Select failed");
      exit (1);
    }
    anyset = 0;

    /*  Have we got new packets back?  */
    if(FD_ISSET(netfd, &readfd)) {
      net_process_return();
      anyset = 1;
    }

    if (dns) {
      /* Handle any pending resolver events */
      dnsinterval = WaitTime;
      dns_events(&dnsinterval);
    }

    /*  Have we finished a nameservice lookup?  */
#ifdef ENABLE_IPV6
    if(dns && dnsfd6 && FD_ISSET(dnsfd6, &readfd)) {
      dns_ack6();
      anyset = 1;
    }
#endif
    if(dns && dnsfd && FD_ISSET(dnsfd, &readfd)) {
      dns_ack();
      anyset = 1;
    }

    /*  Has a key been pressed?  */
    if(FD_ISSET(0, &readfd)) {
      switch (display_keyaction()) {
      case ActionQuit: 
	return;
	break;
      case ActionReset:
	net_reset();
	break;
      case ActionDisplay:
        display_mode = (display_mode+1) % 3;
	break;
      case ActionClear:
	display_clear();
	break;
      case ActionPause:
	paused=1;
	break;
      case  ActionResume:
	paused=0;
	break;
      case ActionMPLS:
	   enablempls = !enablempls;
	   display_clear();
	break;
      case ActionDNS:
	if (dns) {
	  use_dns = !use_dns;
	  display_clear();
	}
	break;
#ifdef IPINFO
      case ActionII:
	if (ipinfo_no >= 0) {
	  ipinfo_no++;
          if (ipinfo_no > ipinfo_max)
            ipinfo_no = 0;
	}
	break;
      case ActionAS:
	if (ipinfo_no >= 0)
          ipinfo_no = ipinfo_no?0:ipinfo_max;
	break;
#endif

      case ActionScrollDown:
        display_offset += 5;
	break;
      case ActionScrollUp:
        display_offset -= 5;
	if (display_offset < 0) {
	  display_offset = 0;
	}
	break;
      }
      anyset = 1;
    }

    /* Check for activity on open sockets */
    if (mtrtype == IPPROTO_TCP)
      net_process_fds(&writefd);
  }
  return;
}
示例#13
0
void on_button_refresh_clicked(GtkButton * button, gpointer user_data)
{
    show_GOP(engine,get_GOP_selected());
    display_redraw(engine);
}
示例#14
0
文件: select.c 项目: ginggs/maemo-mtr
void select_loop(void) {
  fd_set readfd;
  int anyset = 0;
  int maxfd = 0;
  int dnsfd, netfd;
  int NumPing = 0;
  int paused = 0;
  struct timeval lasttime, thistime, selecttime;
  int dt;
  int rv; 

  gettimeofday(&lasttime, NULL);

  while(1) {
    dt = calc_deltatime (WaitTime);
    intervaltime.tv_sec  = dt / 1000000;
    intervaltime.tv_usec = dt % 1000000;

    FD_ZERO(&readfd);

    maxfd = 0;

    if(Interactive) {
      FD_SET(0, &readfd);
      maxfd = 1;
    }

    if (dns) {
      dnsfd = dns_waitfd();
      FD_SET(dnsfd, &readfd);
      if(dnsfd >= maxfd) maxfd = dnsfd + 1;
    } else
      dnsfd = 0;

    netfd = net_waitfd();
    FD_SET(netfd, &readfd);
    if(netfd >= maxfd) maxfd = netfd + 1;

    do {
      if(anyset || paused) {
	selecttime.tv_sec = 0;
	selecttime.tv_usec = 0;
      
	rv = select(maxfd, (void *)&readfd, NULL, NULL, &selecttime);

      } else {
	if(Interactive) display_redraw();

	gettimeofday(&thistime, NULL);

	if(thistime.tv_sec > lasttime.tv_sec + intervaltime.tv_sec ||
	   (thistime.tv_sec == lasttime.tv_sec + intervaltime.tv_sec &&
	    thistime.tv_usec >= lasttime.tv_usec + intervaltime.tv_usec)) {
	  lasttime = thistime;
	  if(NumPing >= MaxPing && (!Interactive || ForceMaxPing))
	    return;
	  if (net_send_batch())
	    NumPing++;
	}

	selecttime.tv_usec = (thistime.tv_usec - lasttime.tv_usec);
	selecttime.tv_sec = (thistime.tv_sec - lasttime.tv_sec);
	if (selecttime.tv_usec < 0) {
	  --selecttime.tv_sec;
	  selecttime.tv_usec += 1000000;
	}
	selecttime.tv_usec = intervaltime.tv_usec - selecttime.tv_usec;
	selecttime.tv_sec = intervaltime.tv_sec - selecttime.tv_sec;
	if (selecttime.tv_usec < 0) {
	  --selecttime.tv_sec;
	  selecttime.tv_usec += 1000000;
	}

	if (dns) {
	  if ((selecttime.tv_sec > (time_t)dnsinterval) ||
	      ((selecttime.tv_sec == (time_t)dnsinterval) &&
	       (selecttime.tv_usec > ((time_t)(dnsinterval * 1000000) % 1000000)))) {
	    selecttime.tv_sec = (time_t)dnsinterval;
	    selecttime.tv_usec = (time_t)(dnsinterval * 1000000) % 1000000;
	  }
	}

	rv = select(maxfd, (void *)&readfd, NULL, NULL, &selecttime);
      }
    } while ((rv < 0) && (errno == EINTR));

    if (rv < 0) {
      perror ("Select failed");
      exit (1);
    }
    anyset = 0;

    /*  Have we got new packets back?  */
    if(FD_ISSET(netfd, &readfd)) {
      net_process_return();
      anyset = 1;
    }

    if (dns) {
      /* Handle any pending resolver events */
      dnsinterval = WaitTime;
      dns_events(&dnsinterval);
    }

    /*  Have we finished a nameservice lookup?  */
    if(dns && FD_ISSET(dnsfd, &readfd)) {
      dns_ack();
      anyset = 1;
    }

    /*  Has a key been pressed?  */
    if(FD_ISSET(0, &readfd)) {
      switch (display_keyaction()) {
      case ActionQuit: 
	return;
	break;
      case ActionReset:
	net_reset();
	break;
      case ActionDisplay:
        display_mode = (display_mode+1) % 3;
	break;
      case ActionClear:
	display_clear();
	break;
      case ActionPause:
	paused=1;
	break;
      case  ActionResume:
	paused=0;
	break;
      case ActionMPLS:
	   enablempls = !enablempls;
	   display_clear();
	break;
      case ActionDNS:
	if (dns) {
	  use_dns = !use_dns;
	  display_clear();
	}
	break;

      case ActionScrollDown:
        display_offset += 5;
	break;
      case ActionScrollUp:
        display_offset -= 5;
	if (display_offset < 0) {
	  display_offset = 0;
	}
	break;
      }
      anyset = 1;
    }
  }
  return;
}
示例#15
0
static void display_redraw_all(display_t *d)
{
  display_redraw(d, 0, 0, d->rgb_width, d->rgb_height);
}