Exemplo n.º 1
0
void
testripple()
{
    unsigned int mask[2];
    int savedRippleCnt;

    printf( "Testing ripple()\n" );

    /*
     * Test with rippleCnt of 0 - should print nothing .
     */
    mask[0] = 0x01234567;
    mask[1] = 0x89ABCDEF;

    ripple( mask, 0 );

    /*
     * Test masking of lower 6 bits of rotateCnt.
     */

    /* Test with rippleCnt of 64 - should print nothing. */
    mask[0] = 0x01234567;
    mask[1] = 0x89ABCDEF;

    ripple( mask, 64 );
    


    /* Test with rippleCnt of -64 - should print nothing. */
    /* This also tests negating rotateCnt before masking lower 6 bits. */
    mask[0] = 0x01234567;
    mask[1] = 0x89ABCDEF;

    ripple( mask, -64 );

    mask[0] = 0x01234567;
    mask[1] = 0x89ABCDEF;


    ripple(mask, 8);
    
    printf("\n");

    ripple(mask,-8);
    
    
    printf( "Finished running tests on ripple()\n" );

}
Exemplo n.º 2
0
void MainWindow::plot3(QCustomPlot *customPlot)
{
  QVector<double> x0(pts), y0(pts);

  update_w(w,1.0);
  double y_inc = 1.0; 
  for (int i=0; i<pts; ++i)   {
    x0[i] = (double)0.5*i/pts;
    y0[i] = y_inc*(w[i]);
  }
  order = get_order();
  ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0));
  ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0));
  ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0));
  
  customPlot->graph()->setData(x0, y0);
  customPlot->graph()->setLineStyle(QCPGraph::lsLine); 
  customPlot->graph()->setScatterStyle(QCPScatterStyle::ssNone); // (QCP::ScatterStyle)(rand()%9+1));
  QPen graphPen;
  graphPen.setColor(QColor(Qt::GlobalColor(5+graph_counter)));
  graphPen.setWidthF(2);
  customPlot->graph()->setPen(graphPen);
  customPlot->xAxis->setRange(0,0.5);
  customPlot->yAxis->setRange(-90,10);
  customPlot->legend->setVisible(true);
  //  customPlot->setInteraction(QCustomPlot::iSelectPlottables);
  customPlot->graph()->setName(QString(shape.c_str()));
  customPlot->replot();
}
Exemplo n.º 3
0
void R_ripple_ril48(int *n_ind, int *n_mar, int *geno, 
		    int *n_orders, int *orders,
		    int *nxo, int *print_by)
{
  ripple(*n_ind, *n_mar, geno, *n_orders, orders, nxo,
	 *print_by, countxo_ril48);
}
Exemplo n.º 4
0
ISR(TIMER1_COMPA_vect, ISR_BLOCK)
{
	if (mode)		// clock is in settings mode, don't increment time
	{
		Seconds = 0;
		return;
	}	
	Seconds++;
	ripple();
}
Exemplo n.º 5
0
main()
{
#ifdef DMD630
	local();
#endif
	request(KBD);
	P->state |= RESHAPED;
	ripple();
	exit();
}
Exemplo n.º 6
0
void MainWindow::updatePlot()
{
  horiz_swipe(0,true);
  order = get_order();
  ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0));
  ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0));
  ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0));
  ui->customPlot->graph()->clearData();
  plot3(ui->customPlot);
}
Exemplo n.º 7
0
void MainWindow::C2Changed() {
  if (Chebyshev2_on==NULL) {
		shape = "Chebyshev2";
		lpf_sel(shape.c_str());
		order = get_order();
		ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0));
		ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0));
		ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0));
		Chebyshev2_on = ui->customPlot->addGraph();
		plot2(ui->customPlot);
  } else {
		ui->customPlot->removeGraph(Chebyshev2_on);
		Chebyshev2_on = NULL;
		ui->customPlot->replot();
  }
}
Exemplo n.º 8
0
void MainWindow::graphMoveEvent(QMouseEvent *event)
{
  if (!(event->buttons() & Qt::LeftButton))  return;

  if (((event->pos() - dragStartPosition).manhattanLength()) < QApplication::startDragDistance()) return;

  BoxChecked(true);
  
  QPoint dis = (event->pos() - dragStartPosition);
  double xdis = dis.x();
  double ydis = dis.y();
  
  double x = M_PI*event->pos().x()/600.0;
  double y = event->pos().y()/400.0;
  
  double m = get_mag(x);
  bool in_passband = (m>-3);
	
  double y_db = -100.0*y + 10;
  bool above_stop = (-y_db < m);
  
  if (fabs(xdis) > fabs(ydis)) {
	// Bandpass or Bandstop
	if (get_filter_type() > 1) {
	  set_center(xdis);
	} else {
	  horiz_swipe(xdis,in_passband);
	}
  } else {
	vertical_swipe(-ydis,in_passband,above_stop);
  }

  order = get_order();
  ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0));
  ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0));
  ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0));
  
  QCPGraph* ptr = GetPtr();
  dragStartPosition = event->pos();
  if (ptr != NULL) {
	ui->customPlot->graph()->clearData();
	plot3(ui->customPlot);
  }
}
Exemplo n.º 9
0
void Lake::rainFor(unsigned int time,
                   unsigned int steps,
                   float drop_probability) {
  float timeunit = 1.0*time/steps;

  // Reserve space to avoid multiple allocations
  drops_.reserve(steps);

  // #pragma omp parallel for schedule(static)
  for (unsigned int t = 0; t < steps; t++)
    if (shouldDrop(drop_probability))
      drops_.push_back(createDrop(t * timeunit));

  // timestep: [0..total_time-1]
  for (unsigned int t = 0; t < steps-1; t++)
    for (unsigned int id = 0; id < drops_.size(); id++)
      ripple(drops_[id], t, timeunit);

  // timestep: total_time
  for (unsigned int id = 0; id < drops_.size(); id++)
    rippleSnapshot(drops_[id], (steps-1), timeunit);
}
Exemplo n.º 10
0
void Effects::applyEffect(const string& fx) {
	
	if(fx == "flip") {
		flip(true);
	}
	else if(fx == "mirror") {
		mirror(true);
	}
	else if(fx == "invert") {
		invert(true);
	}
	else if(fx == "ripple") {
		ripple(true, 3.5);
	}
	else if(fx == "posterize") {
		posterize(true);
	}
	else if(fx == "pixelate") {
		pixelate(true, pixelate_x, pixelate_y);
	}
	else if(fx == "wave") {
		wave(true, wave_speed, wave_displace, wave_num);
	}	
	else if(fx == "swirl") {
		swirl(true, swirl_radius, swirl_angle);
	}
	else if(fx == "shake") {
		shake(true, shake_duration, shake_number, shake_amplitude);
	}
	else if(fx == "reflect") {
		reflect(true);
	}
	else if(fx == "crack") {
		crack(true);
	}
	else if(fx == "love") {
		love(true);
	}
}
Exemplo n.º 11
0
/*
 *			M A I N
 */
int
main(int argc, char **argv)
{
    unsigned char	*inbuf;
    unsigned char	*outbuf;
    int	*rout, *gout, *bout;
    long int	out_width;
    long int	i;
    int	eof_seen;

    if ( !get_args( argc, argv ) )  {
	(void)fputs(usage, stderr);
	bu_exit ( 1, NULL );
    }

    /* autosize input? */
    if ( fileinput && autosize ) {
	unsigned long int	w, h;
	if ( fb_common_file_size(&w, &h, file_name, 3) ) {
	    file_width = (long)w;
	} else {
	    fprintf(stderr, "pixhalve: unable to autosize\n");
	}
    }
    out_width = file_width/2;

    /* Allocate 1-scanline input & output buffers */
    inbuf = malloc( 3*file_width+8 );
    outbuf = malloc( 3*(out_width+2)+8 );

    /* Allocate 5 integer arrays for each color */
    /* each width+2 elements wide */
    for ( i=0; i<5; i++ )  {
	rlines[i] = (int *)bu_calloc( (file_width+4)+1, sizeof(long), "rlines" );
	glines[i] = (int *)bu_calloc( (file_width+4)+1, sizeof(long), "glines" );
	blines[i] = (int *)bu_calloc( (file_width+4)+1, sizeof(long), "blines" );
    }

    /* Allocate an integer array for each color, for output */
    rout = (int *)bu_malloc( out_width * sizeof(long) + 8, "rout" );
    gout = (int *)bu_malloc( out_width * sizeof(long) + 8, "gout" );
    bout = (int *)bu_malloc( out_width * sizeof(long) + 8, "bout" );

    /*
     *  Prime the pumps with 5 lines of image.
     *  Repeat the bottom most line three times to generate a "fill"
     *  line on the bottom.  This will have to be matched on the top.
     */
    if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	perror(file_name);
	fprintf(stderr, "pixhalve:  fread error\n");
	bu_exit (1, NULL);
    }
    separate( &rlines[0][2], &glines[0][2], &blines[0][2], inbuf, file_width );
    separate( &rlines[1][2], &glines[1][2], &blines[1][2], inbuf, file_width );
    separate( &rlines[2][2], &glines[2][2], &blines[2][2], inbuf, file_width );
    for ( i=3; i<5; i++ )  {
	if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	    perror(file_name);
	    fprintf(stderr, "pixhalve:  fread error\n");
	    bu_exit (1, NULL);
	}
	separate( &rlines[i][2], &glines[i][2], &blines[i][2],
		  inbuf, file_width );
    }

    eof_seen = 0;
    for (;;)  {
	filter3( rout, rlines, out_width );
	filter5( gout, glines, out_width );
	filter5( bout, blines, out_width );
	combine( outbuf, rout, gout, bout, out_width );
	if ( fwrite( (void*)outbuf, 3, out_width, stdout ) != out_width )  {
	    perror("stdout");
	    bu_exit (2, NULL);
	}

	/* Ripple down two scanlines, and acquire two more */
	if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	    if ( eof_seen >= 2 )  break;
	    /* EOF, repeat last line 2x for final output line */
	    eof_seen++;
	    /* Fall through */
	}
	ripple( rlines, 5 );
	ripple( glines, 5 );
	ripple( blines, 5 );
	separate( &rlines[4][2], &glines[4][2], &blines[4][2],
		  inbuf, file_width );

	if ( fread( inbuf, 3, file_width, infp ) != file_width )  {
	    if ( eof_seen >= 2 )  break;
	    /* EOF, repeat last line 2x for final output line */
	    eof_seen++;
	    /* Fall through */
	}
	ripple( rlines, 5 );
	ripple( glines, 5 );
	ripple( blines, 5 );
	separate( &rlines[4][2], &glines[4][2], &blines[4][2],
		  inbuf, file_width );
    }

    bu_free(rlines, "rlines");
    bu_free(glines, "glines");
    bu_free(blines, "blines");
    bu_free(rout, "rout");
    bu_free(gout, "gout");
    bu_free(bout, "bout");
}
Exemplo n.º 12
0
int main(void)
{

	unsigned char tmp;
	
	wdt_disable();		/* Disable watchdog if enabled by bootloader/fuses */
	power_usb_disable() ;
	power_usart1_disable();
	power_spi_disable();
	
	Buttons_Init();
	LEDs_Init();
	clock_prescale_set(clock_div_1);	// run at x-tal frequency 16Mhz
	
	
	eeprom_read_block( &EE_data,0,sizeof(EE_data));
		
	if (EE_data.bright_level == 0xff && EE_data.dim_level == 0xff)
	{
		EE_data.bright_level = LED_BRIGHT;
		EE_data.dim_level = LED_DIMM;
		eeprom_write_block(&EE_data,0,sizeof(EE_data));
		eeprom_busy_wait();
	}
	
	OCR0A = EE_data.bright_level;
	OCR0B = EE_data.dim_level;

	// Timer 0 setup for simple count mode, used as timebase LED PWM
	TCCR0A = 0;		// simple count more 		
	TCCR0B = 4;		// system Clock 16Mhz/256 = 16us per counter tick 
	//TCCR0B = 3;		// system Clock 16Mhz/64 = 4us per counter tick 
	//TCCR0B = 5;		// system Clock 16Mhz/1024 = 64us per counter tick 
	//TCCR0B = 2;		// system Clock 1Mhz/8 = 8us per counter tick 
	TIMSK0 = 0x7;	// Enable OverFLow , OCR0A and OCR0B interrupt enables
	
	MCUSR =0; //MCU status register clear 
	
	// Timer 1 setup for  fast PWM mode for servo pulse generation 1 to 2ms 

	TIMSK1 = 0x2;		// Enable OCR1A interrupt 
	TCCR1A = 0x00;		// No pin toggles on compare -- CTC (normal) mode
	TCCR1B = 0x0D;		// CTC mode, F_CPU 16mhz/1024 clock ( 64us)
	//TCCR1B = 0x0B;		// CTC mode, F_CPU 1Mhz/64 clock ( 64us)
	OCR1A = 15625-1;	// counting 15625 counts of 64 us == 1 second

	sei();
		
    while(1)	// for ever
    {
		
		if (IsButtonPressed(BUTTON1) )
		{

			// de-bounce -- 10 consecutive reads of switch open 
			for (tmp =0; tmp<=10; tmp++)
			{
				_delay_ms(2);
				if (IsButtonPressed(BUTTON1))
					tmp = 0;
			}
			
			if ( mode < 3)
				mode++;
			else
			{
				eeprom_write_block(&EE_data,0,sizeof(EE_data));
				eeprom_busy_wait();
				mode = 0; // enter running mode
			}				
		
		}			
				
		if (IsButtonPressed(BUTTON2) ) // increases Minutes and decrease brightness 
		{

			// de-bounce -- 10 consecutive reads of switch open
			for (tmp =0; tmp<=10; tmp++)
			{
				_delay_ms(2);
				if (IsButtonPressed(BUTTON2))
				tmp = 0;
			}
			
			switch (mode) 
			{
				case 1:
					Minutes++;
					ripple();
					break;
					
				case 2:
					if (OCR0B < 0xff )		// dim level
					{
						OCR0B++;
						EE_data.dim_level = OCR0B;
					}						
					break;
					
				case 3:						// bright level
					if (OCR0A < OCR0B-10  )		// make sure that bright is at least 10 counts brighter than dim
					{
						OCR0A +=10;				// step in increments of 10
						EE_data.bright_level =OCR0A;
					}						
					break;
			}			
			
		}	
		
		if (IsButtonPressed(BUTTON3) )	// Increases Hours and increase brightness
		{

			// de-bounce -- 10 consecutive reads of switch open
			for (tmp =0; tmp<=10; tmp++)
			{
				_delay_ms(2);
				if (IsButtonPressed(BUTTON3))
				tmp = 0;
			}
						
			switch (mode)
			{
				case 1:
					Hours++;
					ripple();
					break;
					
				case 2:
					if (OCR0B > OCR0A+10)		// dim level
					{	

						OCR0B--;
						EE_data.dim_level = OCR0B;
					}						
					break;
					
				case 3:						// bright level
					if (OCR0A > 20)	
					{
						OCR0A -=10;		//step in increments of 10
						EE_data.bright_level =OCR0A;
					}						
					break;
			}
		}
				
    } // end of for-ever
}
Exemplo n.º 13
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpDrawable      *drawable;
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  /*  Get the specified drawable  */
  drawable = gimp_drawable_get (param[2].data.d_drawable);

  /*  set the tile cache size  */
  gimp_tile_cache_ntiles (TILE_CACHE_SIZE);

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      /*  Possibly retrieve data  */
      gimp_get_data (PLUG_IN_PROC, &rvals);

      /*  First acquire information with a dialog  */
      if (! ripple_dialog (drawable))
        return;
      break;

    case GIMP_RUN_NONINTERACTIVE:
      /*  Make sure all the arguments are there!  */
      if (nparams != 10)
        {
          status = GIMP_PDB_CALLING_ERROR;
        }
      else
        {
          rvals.period      = param[3].data.d_int32;
          rvals.amplitude   = param[4].data.d_int32;
          rvals.orientation = (param[5].data.d_int32) ? GIMP_ORIENTATION_VERTICAL : GIMP_ORIENTATION_HORIZONTAL;
          rvals.edges       = param[6].data.d_int32;
          rvals.waveform    = param[7].data.d_int32;
          rvals.antialias   = (param[8].data.d_int32) ? TRUE : FALSE;
          rvals.tile        = (param[9].data.d_int32) ? TRUE : FALSE;

          if (rvals.period < 1)
            {
              gimp_message ("Ripple: period must be at least 1.\n");
              status = GIMP_PDB_CALLING_ERROR;
            }

          if (rvals.edges < SMEAR || rvals.edges > BLANK)
            status = GIMP_PDB_CALLING_ERROR;
        }
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      /*  Possibly retrieve data  */
      gimp_get_data (PLUG_IN_PROC, &rvals);
      break;

    default:
      break;
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      /*  Make sure that the drawable is gray or RGB color  */
      if (gimp_drawable_is_rgb (drawable->drawable_id) ||
          gimp_drawable_is_gray (drawable->drawable_id))
        {
          gimp_progress_init (_("Rippling"));

          /*  run the ripple effect  */
          ripple (drawable, NULL);

          gimp_progress_update (1.0);

          if (run_mode != GIMP_RUN_NONINTERACTIVE)
            gimp_displays_flush ();

          /*  Store data  */
          if (run_mode == GIMP_RUN_INTERACTIVE)
            gimp_set_data (PLUG_IN_PROC, &rvals, sizeof (RippleValues));
        }
      else
        {
          /* gimp_message ("ripple: cannot operate on indexed color images"); */
          status = GIMP_PDB_EXECUTION_ERROR;
        }
    }

  values[0].data.d_status = status;

  gimp_drawable_detach (drawable);
}