// ---------------------------------------------------------------------------------------------------- //
// Public
// ---------------------------------------------------------------------------------------------------- //
ParkingShield::ParkingShield(void) : sevenSeg(sevensegment_pins)
{
    setupOutput();
    setupInput();

    setAllLeds(false);
}
// ---------------------------------------------------------------------------------------------------- //
// Public
// ---------------------------------------------------------------------------------------------------- //
ParkingShield::ParkingShield(void) : sevenSeg(sevensegment_pins),
            buttonS1(Device::ANALOG_PIN_0), buttonS2(Device::ANALOG_PIN_1)
{
    setupOutput();
    setupInput();

    setAllLeds(false);
}
Exemplo n.º 3
0
void sketchify()
{
	// Load in.png
	PNG * original = new PNG;
    
	(*original).readFromFile("in.png");
	int width  = original -> width();
	int height = original -> height();

	// Create out.png
	PNG * output = new PNG;
	output = setupOutput(width, height);

	// Loud our favorite color to color the outline
    	RGBAPixel * myPixel = new RGBAPixel;
    	*myPixel = myFavoriteColor(192);

	// Go over the whole image, and if a pixel differs from that to its upper
	// left, color it my favorite color in the output
	for (int y = 1; 0 < y && y < height; y++)
	{
		for (int x = 1; 0 < x && x < width; x++)
		{	
			// Calculate the pixel difference
			RGBAPixel * prev = (*original)(x-1, y-1);
			RGBAPixel * curr = (*original)(x  , y  );
			int diff = abs(curr -> red   - prev ->red  ) +
				   abs(curr -> green - prev -> green) +
				   abs(curr -> blue  - prev -> blue );

			// If the pixel is an edge pixel,
			// color the output pixel with my favorite color
			RGBAPixel * currOutPixel = (*output)(x,y);
			if (diff > 100)
				*currOutPixel = *myPixel;
		}
	}
	
//	// check output
	/*PNG * ans = new PNG;
    
	ans -> readFromFile("out_02.png");
	if (*ans == *output)
		std::cout << "Good" << endl;
	else
		std::cout << "Bad" << endl;*/
	
	// Save the output file
	output -> writeToFile("out.png");

	// Clean up memory
	delete myPixel;
	delete output;
	delete original;
	//delete ans;
}
Exemplo n.º 4
0
void sketchify()
{
	// Load in.png
	PNG * original;

	//std::cout << "Reached line 28" << endl;	
	original = new PNG();
	original->readFromFile("in.png");
	int width  = original->width();
	int height = original->height();
	//std::cout << "Reached line 32" << endl;

	// Create out.png
	PNG * output = setupOutput(width, height);	

	// Loud our favorite color to color the outline
	RGBAPixel * myPixel = myFavoriteColor(192);

	// Go over the whole image, and if a pixel differs from that to its upper
	// left, color it my favorite color in the output
	for (int y = 1; y < height; y++)
	{
		//std::cout << "begin" << endl;
		for (int x = 1; x < width; x++)
		{
			// Calculate the pixel difference
			RGBAPixel * prev = (*original)(x-1, y-1);
			RGBAPixel * curr = (*original)(x  , y  );
			int diff = abs(curr->red   - prev->red  ) +
					   abs(curr->green - prev->green) +
					   abs(curr->blue  - prev->blue );

			// If the pixel is an edge pixel,
			// color the output pixel with my favorite color
			RGBAPixel * currOutPixel =(*output)(x,y);

			if (diff > 100)
				*currOutPixel = *myPixel;
				//*(*output)(x,y) = *myPixel;
			
		}
		//std::cout << "end" << endl;
	}
	
	// Save the output file
	//std::cout << "begin" << endl;
	output->writeToFile("out.png");
	//std::cout << "end" << endl;

	// Clean up memory
	delete myPixel;
	//std::cout << "check1" << endl;
	delete output;
	delete original;
	//std::cout << "check2" << endl;
}
Exemplo n.º 5
0
void
ConsoleBatch::setupFilter(int idx, std::set<PageId> allPages)
{
	if (idx == m_ptrStages->fixOrientationFilterIdx())
		setupFixOrientation(allPages);
	else if (idx == m_ptrStages->pageSplitFilterIdx())
		setupPageSplit(allPages);
	else if (idx == m_ptrStages->deskewFilterIdx())
		setupDeskew(allPages);
	else if (idx == m_ptrStages->selectContentFilterIdx())
		setupSelectContent(allPages);
	else if (idx == m_ptrStages->pageLayoutFilterIdx())
		setupPageLayout(allPages);
	else if (idx == m_ptrStages->outputFilterIdx())
		setupOutput(allPages);
}
Exemplo n.º 6
0
void V4LOutput::getFrame()
{
	VideoFramePtr frame = m_source->frame();
	if(!frame || !frame->isValid())
	{
		//qDebug() << "V4LOutput::frameReady(): Invalid frame or no frame";
		return;
	}
	
	m_frame = frame;
	
	if(m_frame->size() != m_outputSize)
	{
		m_outputSize = m_frame->size();
		setupOutput();
	}
	
	//if(m_transmitFps <= 0)
		processFrame();
}
Exemplo n.º 7
0
int main (int argc, char **argv)
{
	AFfilehandle	file;
	AudioUnit	outputUnit;

	if (argc < 2)
	{
		fprintf(stderr, "usage: %s filename\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	file = afOpenFile(argv[1], "r", AF_NULL_FILESETUP);
	if (file == AF_NULL_FILEHANDLE)
	{
		fprintf(stderr, "Could not open file '%s' for reading.\n", argv[1]);
		exit(EXIT_FAILURE);
	}

	openOutput(&outputUnit);
	setupOutput(&outputUnit, file);
	AudioOutputUnitStart(outputUnit);

	buffer = malloc(BUFFER_FRAME_COUNT *
		afGetVirtualFrameSize(file, AF_DEFAULT_TRACK, 1));

	while (isPlaying)
		usleep(250000);

	AudioOutputUnitStop(outputUnit);
	AudioUnitUninitialize(outputUnit);
	CloseComponent(outputUnit);

	free(buffer);

	afCloseFile(file);
}
Exemplo n.º 8
0
int init () {
        
	    enum LEDs led1,led2,led3,led4;
        
        led1 = GREEN;
        led2 = GREEN;
        led3 = GREEN;
        led4 = GREEN;
	    uint8_t led[4] = {led1,led2,led3,led4};
       /* uint16_t motor1 = Motor1;
        uint16_t motor2 = Motor2;
        uint16_t motor3 = Motor3;
        uint16_t motor4 = Motor4;
        uint16_t flipflop = FlipFlop;
        uint16_t input = Input;*/
       struct Motor motor; 
        motor.Motor1=171;
        motor.Motor2=172;
        motor.Motor3=173;
        motor.Motor4=174;
        motor.FlipFlop=175;
        motor.Input=176;
        
        if (isInitialized) {
			return 1 ;
		}

        if (!init_GPIO ()) {
			return 0 ;
		}

        fd_act = open ("/dev/ttyO0", O_RDWR | O_NOCTTY | O_NDELAY) ;

        if (fd_act < 0) {
            return 0 ;
        }

        int flags = fcntl(fd_act, F_GETFL, 0) ;
	    fcntl(fd_act, F_SETFL, flags | O_NONBLOCK); //read calls are non blocking

        //set port options
        struct termios options;
        //Get the current options for the port
        tcgetattr (fd_act, &options);
        //Set the baud rates to 115200
        cfsetispeed (&options, B115200);
        cfsetospeed (&options, B115200);

        options.c_cflag |= (CLOCAL | CREAD); //Enable the receiver and set local mode
        options.c_iflag = 0; //clear input options
        options.c_lflag = 0; //clear local options
        options.c_oflag &= ~OPOST; //clear output options (raw output)

        //Set the new options for the port
        tcsetattr (fd_act, TCSANOW, &options);

        setupInput (motor.Input) ;

		setupOutput (motor.FlipFlop) ;
		clear_GPIO (motor.FlipFlop) ;
		usleep (1000) ;
		set_GPIO (motor.FlipFlop) ;
		
        setupOutput (motor.Motor1);
        setupOutput (motor.Motor2);
        setupOutput (motor.Motor3);
        setupOutput (motor.Motor4);
        set_GPIO (motor.Motor1) ;
        set_GPIO (motor.Motor2) ;
        set_GPIO (motor.Motor3) ;
        set_GPIO (motor.Motor4) ;

        //configure motors
        uint8_t reply[256];
        int m;
        for (m = 0; m < 4; m++) {
            clear_GPIO (motor.Motor1 + m);
            sendCmd (0xe0, reply, 2);
            if (reply[0] != 0xe0 || reply[1] != 0x00) {
                printf ("motor%d cmd=0x%02x reply=0x%02x\n", m + 1, (int) reply[0], (int) reply[1]);
            }
            usleep(1000);
            sendCmd (m + 1, reply, 1);
            set_GPIO (motor.Motor1 + m);
        }

        //all select lines active
        clear_GPIO (motor.Motor1) ;
        clear_GPIO (motor.Motor2) ;
        clear_GPIO (motor.Motor3) ;
        clear_GPIO (motor.Motor4) ;

        //start multicast
		
        sendCmd (0xa0, reply, 1);
        sendCmd (0xa0, reply, 1);
        sendCmd (0xa0, reply, 1);
        sendCmd (0xa0, reply, 1);
        sendCmd (0xa0, reply, 1); 

        //reset IRQ flipflop - on error 176 reads 1, this code resets 176 to 0
         clear_GPIO (motor.FlipFlop) ;
        set_GPIO (motor.FlipFlop);

		set(led) ;
        signal(SIGINT,terminate_interrupt); //Interrupts for Ctrl+C.

		isInitialized = 1 ;
        return 1 ;
        
        
    }
//********************************************************************
void PVFSProjector::project(BaseProgress * progress = NULL) 
  throw(ProjectorException)
{
  int mytid(0);                                  //my pvm id
  int errorcode(0);                              //pvm error code
  PmeshLib::ProjectionMesh * pmesh(0);           //projection mesh
  int counter(0);
  int scounter(0);

  try
  {
    if (!mcounters.size())           //must have a partition num  
    {
      Projector::project(progress);
      return;
    }

    if (static_cast<unsigned int>(numofslaves) < mcounters.size()) 
    {
      Projector::project(progress);
      return;
    }

    
    if (!fromprojection || !toprojection)        //check for projection
    {
      throw ProjectorException(PROJECTOR_ERROR_UNKOWN);
    }
    
    pmesh = setupForwardPmesh();                 //try setup the forward
                                                 //pmesh
    
    getExtents(pmesh);                           //get the extents
    
    
    if(cache)                                    //delete the cache
    {
      delete cache;
      cache = NULL;
    }
      
    setupOutput(outfile);                        //create the output file
        
    
    if (pmesh)                                   //delete uneeded mesh
    {
      delete pmesh;
      pmesh = NULL;
    }

    //check the rank in MPI
    MPI_Comm_rank(MPI_COMM_WORLD, &mytid);

    if (mytid != 0)
    {
      //master must be rank zero
      throw ProjectorException(PROJECTOR_ERROR_UNKOWN);
    }
    

    if (errorcode == 0)
    {
      throw ProjectorException(PROJECTOR_ERROR_UNKOWN);
    }
    
    //figure out the mapping
    scounter = -1;
    for(counter = 1; counter <= numofslaves; ++counter)
    {
      if (counter % numofslaves/mcounters.size() == 0)
        ++scounter;
      
      membership[counter] = scounter;
    }

    //figure out the start stop stuff
    for(counter = 0; static_cast<unsigned int>(counter) 
          < mcounters.size(); ++counter)
    {
      mcounters[counter] = counter*(newheight/mcounters.size());
      mstop[counter] = (counter+1)*(newheight/mcounters.size());
    }
    
    //set the last partition to the right size
    mstop[mcounters.size()-1] = newheight;

    projectPVFS(progress);


  }
  catch(...)
  {
    if (pmesh)
      delete pmesh;
    throw ProjectorException(PROJECTOR_ERROR_UNKOWN);

  }
}