Exemplo n.º 1
0
void godob::handle_time_keys(btnval_e lcd_key)
{
  switch (lcd_key)
    {
    case btnRIGHT:
      if(t_set==true){
	t_idx++;
	t_idx %= 7;
      }
      t_set = true;
      t_adjust=show_adjust(t_idx);
      break;
    case btnLEFT:
      if(t_set==true){
	t_idx+=6;
	t_idx %= 7;
      }
      t_set = true;
      t_adjust=show_adjust(t_idx);
      break;
    case btnUP:
      if(t_set == true){
	//adjustTime(t_adjust); /* doesn't work when t_adjust>0. weird! */
	setTime(now() + t_adjust);
      }
      else{
	handle_main_keys(lcd_key);
      }
      break;
    case btnDOWN:
      if(t_set == true){
	adjustTime(-t_adjust);
      }
      else{
	handle_main_keys(lcd_key);
      }
      break;
    case btnSELECT:
      if(t_set==false){
	handle_main_keys(lcd_key);
      }
      else{
	setRTC();
	LCD->noCursor();
      }
      t_set=false;
      break;
    case btnNONE:
      break;
    }
}
Exemplo n.º 2
0
void godob::run(void)
{
  static unsigned long tmin = 0, tenc=0;
  unsigned long t0 = millis();
  float lst,gmst;
  starpos_s mount;
  float errf;
  
  if(t0-tmin>200){ /* update LCD every 200ms */
    tmin = t0;
    if(connect_time>5)Connected=false;
    connect_time++;

    switch(dstat){
    case ds_time:
      printtime();
      printdate();
      show_adjust(t_idx);    
      if(BTN->poll()){
	handle_time_keys(BTN->lastkey());
      }
      break;
    case ds_lst:
      LCD->setCursor(0, 0);
      LCD->print("LST ");
      gmst = AST->get_GMST(now());
      lst = gmst + AST->last_longitude();
      show_hms(lst);
      LCD->setCursor(0, 1);
      LCD->print(" LT ");
      show_hms( (AST->get_LT(gmst)%86400)*M_PI/43200 );
      if(BTN->poll()){
	handle_main_keys(BTN->lastkey());
      }
      break;
    case ds_loc:
      LCD->setCursor(0, 0);
      LCD->print("Lat  ");
      show_dms(AST->last_latitude());
      LCD->setCursor(0, 1);
      LCD->print("Long ");
      show_dms(AST->last_longitude());
      if(BTN->poll()){
	handle_main_keys(BTN->lastkey());
      }
      break;
    case ds_horz:
      show_altaz();
      if(BTN->poll()){
	handle_main_keys(BTN->lastkey());
      }
      break;
    case ds_eq:
      LCD->setCursor(0, 0);
      mount.az = ItoRad(ENCAz->lastpos());
      mount.alt = ItoRad(ENCAlt->lastpos());
      mount.GMST = AST->get_GMST(now());
      AST->horz_to_eq(mount);
      LCD->print(" RA  ");
      show_hms(mount.RA);
      LCD->setCursor(0, 1);
      LCD->print("Dec");
      show_dms(mount.dec);
      if(BTN->poll()){
	handle_main_keys(BTN->lastkey());
      }
      break;
    case ds_targ:
      LCD->setCursor(0, 0);
      if(!reqPending){
	LCD->print("Designate a star");
      }
      else{
	star[0].GMST=AST->get_GMST(now());
	AST->eq_to_horz(star[0]);
	LCD->print("AltErr:");
	errf = ItoRad(ENCAlt->lastpos()) - star[0].alt;
	if(errf>M_PI)errf-=2*M_PI;
	if(errf<-M_PI)errf+=2*M_PI;
	show_rad(errf);
	LCD->setCursor(0, 1);
	LCD->print(" AzErr:");
	errf = ItoRad(ENCAz->lastpos()) - star[0].az;
	if(errf>M_PI)errf-=2*M_PI;
	if(errf<-M_PI)errf+=2*M_PI;
	show_rad(errf);
      }
      if(BTN->poll()){
	handle_main_keys(BTN->lastkey());
      }
      break;
    case ds_range:
      mount.az = ItoRad(ENCAz->lastpos());
      mount.alt = ItoRad(ENCAlt->lastpos());
      mount.GMST = AST->get_GMST(now());
      star[0].GMST = star[1].GMST = mount.GMST;
      AST->eq_to_horz(star[1]);
      LCD->setCursor(0, 0);
      LCD->print("Targ r=");
      show_rad(AST->eq_range(star[0], star[1]));
      LCD->setCursor(0, 1);
      LCD->print(" Now r=");
      show_rad(AST->horz_range(mount, star[1]));
      if(BTN->poll()){
	handle_main_keys(BTN->lastkey());
      }
      break;
      
    default:
      dstat = ds_time;
      break;
    }/* switch */
  }/*tmin*/
  if(t0-tenc>1){ /* read encoders every ms */
    tenc = 0;
    ENCAlt->readpos();
    ENCAz->readpos();
  }
  handle_serial();
}
Exemplo n.º 3
0
void tex::show_node_list(ptr p)
	{
	int	n;

	if (cur_length() > depth_threshold) {
		if (p > null)
			print(" []");
		return;
	}
	n = 0;
	while (p > null) {
		print_ln();
		print_str();
		incr(n);
		if (n > breadth_max) {
			print("etc.");
			return;
		}
		if (is_char_node(p)) {
			print_font_and_char(p);
		} else {
			switch (type(p))
			{
			case HLIST_NODE:
			case VLIST_NODE:
			case UNSET_NODE:
				show_box1(p);
				break;

			case RULE_NODE:
				show_rule(p);
				break;
			
			case INS_NODE:
				show_insertion(p);
				break;
			
			case WHATSIT_NODE:
				show_whatsit(p);
				break;
			
			case GLUE_NODE:
				show_glue(p);
				break;
			
			case KERN_NODE:
				show_kern(p);
				break;
			
			case MATH_NODE:
				show_math(p);
				break;
			
			case LIGATURE_NODE:
				show_ligature(p);
				break;

			case PENALTY_NODE:
				show_penalty(p);
				break;
		
			case DISC_NODE:
				show_discretionary(p);
				break;
			
			case MARK_NODE:
				show_mark(p);
				break;
			
			case ADJUST_NODE:
				show_adjust(p);
				break;
			
			case STYLE_NODE:
				print_style(subtype(p));
				break;
			
			case CHOICE_NODE:
				show_choice_node(p);
				break;

			case INNER_NOAD:
			case ORD_NOAD:
			case OP_NOAD:
			case BIN_NOAD:
			case REL_NOAD:
			case OPEN_NOAD:
			case CLOSE_NOAD:
			case PUNCT_NOAD:
			case RADICAL_NOAD:
			case OVER_NOAD:
			case UNDER_NOAD:
			case VCENTER_NOAD:
			case ACCENT_NOAD:
			case LEFT_NOAD:
			case RIGHT_NOAD:
				show_normal_noad(p);
				break;
			
			case FRACTION_NOAD:
				show_fraction_noad(p);
				break;

			default:
				print("Unknown node type!");
				break;
			}
		}
		p = link(p);
	}
}