示例#1
0
void SciCalc::factorial() {
  double lg, alpha;

  /* uses gamma functions to get result for non-integer values */

	alpha = value[top] + 1.0;
	if ((floor(alpha) == alpha)&&(alpha <= 0.0))
	{
		init_value(0);
		leddisplay->label("Error: -ve integer ");
		leddisplay->redraw();
	}
	else
	if (alpha > 32)
	 {
		lg = exp(gammaln(alpha));
    		value[top] = lg;
   		 set_display(value[top],NORM);
		ready = 1;
	}
	else
	if (alpha > 1.0)
	{
		int n = (int)truncf(alpha);
		lg = 1.0;
		for (int i = 1; i <n; i++) lg *= i;
		value[top] = lg;
		set_display(value[top],NORM);
		ready = 1;
	}
}
示例#2
0
void SciCalc::exponent_pi() {
  if ((value[top] == 0.0) || (ready)) {
    value[top] = M_PI;
    set_display(value[top],NORM);
    ready = 1;
  }
  else if ((! emode) && (base == 10)) {
    emode = 1;
    exponent = 0;
    mantissa = value[top];
    set_display(mantissa,EXP);
  }
}
示例#3
0
void SciCalc::cb_but_sign_i(Fl_Button*, void*) {
  if (! emode)
{
	value[top] = -value[top];
	set_display(value[top],NORM);
}
else 
{
	exponent = -exponent;
	value[top] = mantissa*pow(10.0, (double)exponent);
	set_display(mantissa,EXP);
};
}
示例#4
0
void SciCalc::cb_but_ln_i(Fl_Button*, void*) {
  if (! inv)
	{
		value[top] = log(value[top]);
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = exp(value[top]);
		set_display(value[top],NORM);
		ready = 1;
	};
}
示例#5
0
void SciCalc::cb_but_int_i(Fl_Button*, void*) {
  if (! inv)
	{
		value[top] = truncf(value[top]);
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = value[top] - truncf(value[top]);
		set_display(value[top],NORM);
		ready = 1;
	};
}
示例#6
0
void SciCalc::cb_but_dr_i(Fl_Button*, void*) {
  if (! inv) 
	{
		value[top] = M_PI*value[top]/180.0;
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = 180.0*value[top]/M_PI;
		set_display(value[top],NORM);
		ready = 1;
	};
}
示例#7
0
void rocvfd_t::update_display()
{
	for (int i =0; i<16; i++)
	{
		if (m_reversed)
		{
			m_outputs[i] = set_display(m_chars[15-i]);
		}
		else
		{
			m_outputs[i] = set_display(m_chars[i]);
		}
		output_set_indexed_value("vfd", (m_port_val*16) + i, m_outputs[i]);
	}
}
示例#8
0
文件: if.c 项目: choppsv1/ircii
void
fec(u_char *command, u_char *args, u_char *subargs)
{
	u_char	*pointer;
	u_char	*list = NULL;
	u_char	*var = NULL;
	u_char	stuff[2];
	int	args_flag = 0;
	unsigned display;
	u_char	*sa, *todo;

	list = next_expr(&args, '(');		/* ) */
	if (list == NULL)
	{
		yell ("FEC: Missing List for /FEC");
		return;
	}

	sa = subargs ? subargs : empty_string();
	list = expand_alias(NULL, list, sa, &args_flag, NULL);
	pointer = list;

	var = next_arg(args, &args);
	args = my_index(args, '{');		/* } */

	if ((todo = next_expr(&args, '{')) == NULL)
	{
		yell ("FE: Missing }");
		return;
	}

	stuff[1] = '\0';

	while (*pointer)
	{
		display = set_display_off();
		stuff[0] = *pointer++;
		add_alias(VAR_ALIAS, var, stuff);
		set_display(display);
		parse_line(NULL, todo, 
		    subargs ? subargs : empty_string(), 0, 0, 0);
	}
	display = set_display_off();
	delete_alias(VAR_ALIAS, var);
	set_display(display);

	new_free(&list);
}
void IndependentParametersError::from_XML(const tinyxml2::XMLDocument& document)
{
    const tinyxml2::XMLElement* root_element = document.FirstChildElement("IndependentParametersError");

    if(!root_element)
    {
        std::ostringstream buffer;

        buffer << "OpenNN Exception: IndependentParametersError class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "Independent parameters error element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

  // Display
  {
     const tinyxml2::XMLElement* display_element = root_element->FirstChildElement("Display");

     if(display_element)
     {
        const std::string new_display_string = display_element->GetText();

        try
        {
           set_display(new_display_string != "0");
        }
        catch(const std::logic_error& e)
        {
           std::cout << e.what() << std::endl;
        }
     }
  }
}
示例#10
0
文件: main.c 项目: mick909/ncnl
/*-----------------------------------------------------------------------*/
int main (void)
{
  PORTB = 0b00111011;
  DDRB  = 0b00111100;

  PORTC = 0b00111111;
  DDRC  = 0b00000000;

  PORTD = 0b00000000;
  DDRD  = 0b11111111;

  update_qdec();
  update_qdec();
  dec99 = dec9900 = 0;
  par_count = 0;
  set_display(0);
  dot = 1;

  PRR = _BV(PRTWI) | _BV(PRTIM2) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRSPI) | _BV(PRUSART0) | _BV(PRADC);

  count5 = 5;
  counter = 0;
  par_count = 0;

  do {
    do {
    } while (idle() && sleep());

    do {
      if (PINC & _BV(4)) delay();
    } while (run());
  } while (1);
}
/**
 * gst_vaapi_video_meta_new_from_pool:
 * @pool: a #GstVaapiVideoPool
 *
 * Creates a #GstVaapiVideoMeta with a video object allocated from a @pool.
 * Only #GstVaapiSurfacePool and #GstVaapiImagePool pools are supported.
 *
 * The meta object is destroyed through the last call to
 * gst_vaapi_video_meta_unref() and the video objects are pushed back
 * to their respective pools.
 *
 * Return value: the newly allocated #GstVaapiVideoMeta, or %NULL on error
 */
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_from_pool (GstVaapiVideoPool * pool)
{
  GstVaapiVideoMeta *meta;
  GstVaapiVideoPoolObjectType object_type;

  g_return_val_if_fail (pool != NULL, NULL);

  meta = _gst_vaapi_video_meta_new ();
  if (G_UNLIKELY (!meta))
    return NULL;

  object_type = gst_vaapi_video_pool_get_object_type (pool);
  switch (object_type) {
    case GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE:
      if (!set_image_from_pool (meta, pool))
        goto error;
      break;
    case GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE:
      if (!set_surface_proxy_from_pool (meta, pool))
        goto error;
      break;
    default:
      GST_ERROR ("unsupported video buffer pool of type %d", object_type);
      goto error;
  }
  set_display (meta, gst_vaapi_video_pool_get_display (pool));
  return meta;

error:
  gst_vaapi_video_meta_unref (meta);
  return NULL;
}
示例#12
0
sdl_text_button::sdl_text_button(const char *bla, int x, int y, sdl_user *who, funcptr *stuff)
	: sdl_plain_button(-1, x, y, who, stuff)
{
	xpos = x;
	ypos = y;
	set_display(bla);
}
示例#13
0
inline void SciCalc::cb_but_cos_i(Fl_Button*, void*) {
  if (base > 10) handle_number(13.0);
  else
  	if (! inv) 
  	{
  		value[top] = cos(to_drg(value[top]));
  		set_display(value[top],NORM);
  		ready = 1;
  	}
  	else
  	{
  		value[top] = from_drg(acos(value[top]));
  		set_display(value[top],NORM);
  		ready = 1;
  	}
;}
示例#14
0
inline void SciCalc::cb_but_sqrt_i(Fl_Button*, void*) {
  if (base > 10) handle_number(10.0); 
  	else
  	if (! inv) 
  	{
  		value[top] = sqrt(value[top]);
  		set_display(value[top],NORM);
  		ready = 1;
  	}
  	else
  	{
  		value[top] = pow(value[top], 2.0);
  		set_display(value[top],NORM);
  		ready = 1;
  	}
;}
示例#15
0
文件: dpy.c 项目: felipebetancur/QuIP
Disp_Obj *open_display(QSP_ARG_DECL  const char *name,int desired_depth)
{
	Disp_Obj *dop;
	static int siz_done=0;

	dop = new_disp_obj(QSP_ARG  name);
	if( dop == NO_DISP_OBJ ){
		sprintf(ERROR_STRING, "Couldn't create object for display %s",
					name);
		NWARN(ERROR_STRING);
		return(NO_DISP_OBJ);
	}

	if( dop_open(QSP_ARG  dop) < 0 ){
		return(NO_DISP_OBJ);
	}

	if( dop_setup(QSP_ARG  dop,desired_depth) < 0 ){
		/* Bug - XCloseDisplay?? */
		/* need to destroy object here */
		del_disp_obj(QSP_ARG  dop);
		rls_str((char *)dop->do_name);
		return(NO_DISP_OBJ);
	}
	set_display(dop);

	if( ! siz_done ){
		siz_done++;
		add_sizable(QSP_ARG  disp_obj_itp,&dpy_sf, NULL );
	}

	return(dop);
}
void NormalizedSquaredError::from_XML(const tinyxml2::XMLDocument& document)
{
   const tinyxml2::XMLElement* root_element = document.FirstChildElement("NormalizedSquaredError");

   if(!root_element)
   {
      return;
   }

   const tinyxml2::XMLElement* display_element = root_element->FirstChildElement("Display");

   if(display_element)
   {
      const std::string new_display_string = display_element->GetText();     

      try
      {
         set_display(new_display_string != "0");
      }
      catch(const std::logic_error& e)
      {
         std::cout << e.what() << std::endl;		 
      }
   }
}
示例#17
0
void SciCalc::cb_but_log_i(Fl_Button*, void*) {
  if (base > 10) handle_number(15.0);
else
	if (! inv)
	{
		value[top] = log10(value[top]);
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = pow(10.0, value[top]);
		set_display(value[top],NORM);
		ready = 1;
	};
}
示例#18
0
void TestingAnalysis::from_XML(const tinyxml2::XMLDocument& document)
{
    std::ostringstream buffer;

    const tinyxml2::XMLElement* root_element = document.FirstChildElement("TestingAnalysis");

    if(!root_element)
    {
        buffer << "OpenNN Exception: TestingAnalysis class.\n"
               << "void from_XML(const tinyxml2::XMLDocument&) method.\n"
               << "Testing analysis element is NULL.\n";

        throw std::logic_error(buffer.str());
    }

    // Display

    const tinyxml2::XMLElement* element = root_element->FirstChildElement("Display");

    if(element)
    {
       std::string new_display_string = element->GetText();

       try
       {
          set_display(new_display_string != "0");
       }
       catch(const std::logic_error& e)
       {
          std::cout << e.what() << std::endl;
       }
    }
}
示例#19
0
void SciCalc::cb_but_tan_i(Fl_Button*, void*) {
  if (base > 10) handle_number(14.0);
	else
	if (! inv)
	{
		value[top] = tan(to_drg(value[top]));
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = from_drg(atan(value[top]));
		set_display(value[top],NORM);
		ready = 1;
	};
}
示例#20
0
void SciCalc::cb_but_AC_i(Fl_Button*, void*) {
  init_value(0);
set_display(0.0,NORM);
currentbrkt = 0;
box_bracket->label("");
box_bracket->redraw();
}
示例#21
0
void SciCalc::handle_number(double numb) {
  int first;
double sign;

	if (ready) init_value(top);

	if (numb == -1.0) 
	{
		if (dot) /* check whether we already have a dot */
			return;
		else 
		{
			dot = 1;
			set_display(value[top],DOT);
			return;
		}
	}

	if (emode) 
	{
		sign = copysign(1.0, (double)exponent);
		if (abs(exponent)*10 + numb > 999) 
		{ /* cycle if exponent has > 3 digits */
			first = (int)floor((double)abs(exponent)/100.0);
			exponent = abs(exponent) - 100*first;
			exponent *= (int)sign;
		}
		exponent = exponent*10 + (int) (sign*numb);
		value[top] = mantissa*pow(10.0, (double)exponent);
		set_display(mantissa, EXP);
	}
	else if (numb < base)
	{ /* both decimal and non decimal number entry */
		sign = copysign(1.0, value[top]);
		if (dot && behind < 9) 
		{
			behind++;
			diver = diver/(double)base;
			value[top] += sign*diver*numb;
		}
		else 
		if ((! dot) && (value[top] < 1.0e10))
			value[top] = (double)base*value[top] + sign*numb;

		set_display(value[top],(mode)behind);
	}
}
示例#22
0
文件: comm.c 项目: mahiso/JudoShiai
void msg_received(struct message *input_msg)
{
    gint i;

    if (input_msg->sender < 10)
        return;

    traffic_last_rec_time = time(NULL);
#if 0
    g_print("msg type = %d from %d\n",
            input_msg->type, input_msg->sender);
#endif
    switch (input_msg->type) {
    case MSG_MATCH_INFO:
	handle_info_msg(&input_msg->u.match_info);
        break;

    case MSG_11_MATCH_INFO:
	for (i = 0; i < 11; i++) {
	    handle_info_msg(&input_msg->u.match_info_11.info[i]);
	}
        break;

    case MSG_NAME_INFO:
        avl_set_data(input_msg->u.name_info.index,
                     input_msg->u.name_info.first,
                     input_msg->u.name_info.last,
                     input_msg->u.name_info.club);
        //refresh_window();
#if 0
        g_print("name info %d: %s %s, %s\n",
                input_msg->u.name_info.index,
                input_msg->u.name_info.first,
                input_msg->u.name_info.last,
                input_msg->u.name_info.club);
#endif
        break;

    case MSG_EDIT_COMPETITOR:
	set_display(&input_msg->u.edit_competitor);
        break;

#if 0
    case MSG_CANCEL_REST_TIME:
        for (tatami = 0; tatami < NUM_TATAMIS; tatami++) {
            for (position = 0; position < NUM_LINES; position++) {
                if (match_list[tatami][position].category == input_msg->u.cancel_rest_time.category &&
                    match_list[tatami][position].number == input_msg->u.cancel_rest_time.number) {
                    match_list[tatami][position].rest_end = 0;
                    match_list[tatami][position].flags = 0;
                    //refresh_window();
                    return;
                }
            }
        }
        break;
#endif
    }
}
示例#23
0
文件: main.c 项目: mick909/ncnl
/*-----------------------------------------------------------------------*/
static
uint8_t idle(void)
{
  uint8_t s1_status = 0xff;
  uint16_t prev;

  /* 1/8 Clock */
  cli();
  CLKPR = _BV(CLKPCE);
  CLKPR = 0b0011;

  PRR = _BV(PRTWI) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRSPI) | _BV(PRUSART0) | _BV(PRADC);

  counter = prev = 0;

  set_display(par_count);
  dot = 1;

  /* TC2 : 2ms Interval Interrupt */
  OCR2A  = 250-1;   /* (F_CPU / 8 / 8 / 250= 500Hz (2ms)) */
  TCCR2A = 0b010;
  TCCR2B = 0b010;
  TIMSK2 = _BV(OCIE2A);

  PCMSK1 = _BV(PCINT9) | _BV(PCINT11);
  PCIFR = _BV(PCIF1);
  PCICR = _BV(PCIE1);

  sei();

  set_sleep_mode(SLEEP_MODE_EXT_STANDBY);

  do {
    uint16_t tmp;

    sleep_mode();
    cli();
    tmp = counter;
    sei();

    /* check 10ms interval */
    if (tmp != prev) {
      prev = tmp;

      xorshift();

      s1_status <<= 1;
      if ( !(PINC & _BV(5)) ) ++s1_status;

      /* 10min -> enter deep sleep */
      if (prev >= 60000) break;
    }
  } while ( s1_status != 1 );

  TIMSK2 = 0;
  TCCR2A = TCCR2B = 0;

  return (s1_status != 1);
}
示例#24
0
void rocvfd_t::update_display()
{
	for (int i =0; i<16; i++)
	{
		m_outputs[i] = set_display(m_chars[i]);
		machine().output().set_indexed_value("vfd", (m_port_val*16) + i, m_outputs[i]);
	}
}
示例#25
0
文件: lcd.c 项目: Grated/Cerebot
/**
 * Initializes the LCD
 * @param uart
 * @param peripheral_clk_freq
 */
void init_lcd(UART_MODULE uart, UINT32 peripheral_clk_freq)
{
   lcd_uart = uart;

   init_pmod_cls(lcd_uart, peripheral_clk_freq, 9600);
   set_display(lcd_uart, DISP_ON_BL_ON);
   wrap_at_16(lcd_uart);
   lcd_clear();
}
示例#26
0
文件: dpymenu.c 项目: nasa/QuIP
static COMMAND_FUNC( set_do )
{
	Disp_Obj *dop;

	dop = pick_disp_obj("");
	if( dop == NULL ) return;
#ifdef HAVE_X11
	set_display(dop);
#endif /* HAVE_X11 */
}
示例#27
0
void SciCalc::change_base(int newbase) {
  int oldbase;

	oldbase = base;
	base = newbase;

	set_display(value[top], NORM);
	ready = 1;
	if ((oldbase == 16) || (base == 16)) setnormlabels();
}
示例#28
0
void SciCalc::handle_operator(Operator op) {
  int prevop, i, finished;

	switch (op)
	{
		case PLUS:
		case MINUS:
		case MULT:
		case DIV:
		case POW:
		case INVPOW:
			finished = 0;
			do 
			{
				if (top == startbrkt[currentbrkt]) finished = 1; /* is 1st operator */
				if (! finished) 
				{ /* compare priority of previous operators with current op */
					prevop = oper[top-1];
					if (priority[prevop] < priority[op])
						finished = 1;
					else 
					{ /* last op can be calculated */
						top--;
    					calc(top);
					}
				}
			} while (! finished);

			oper[top] = op;
			init_value(top+1);

			set_display(value[top-1],NORM);
			break;

		case EVAL:
			while (currentbrkt > 0) add_right_bracket();
			for (i = top; i > 0; i--) calc(i-1);
			top = 0;
			ready = 1;
			set_display(value[top],NORM);
			break;
	}
}
示例#29
0
void SciCalc::memexch() {
  double temp;

	temp = mem;
	mem = value[top];
	value[top] = temp;
	set_display(value[top],NORM);
	ready = 1;
	set_memdisp();
}
示例#30
0
文件: main.c 项目: AkashGutha/avr
void main()
{
  //clock_buffer test = {1,2,3,4,5,6,7};
  init();

  q = twi_write_byte(0,0);
  clock = rtc_read();
  q = twi_write_byte(7,( 0<<OUT | 1<<SQWE | 0<<RS1 | 0<<RS0 )); // Set DS1307 square wave output on, freq = 1Hz
  set_display(DISPLAY_TIME);
  while(1);
}