Exemple #1
0
Car::Car()
		:m_encoder{Encoder(0), Encoder(1)},
		 m_servo(0), m_lcd(true), m_lcd_console(&m_lcd), m_leds{Led(0), Led(1), Led(2), Led(3)},
		 m_motor{Motor(0), Motor(1)}, m_uart(3, libbase::k60::Uart::Config::BaudRate::BR_115200)

{
			  SetMotorPowerLeft(0);
			  SetMotorPowerRight(0);
	SetMotorDirection(true);
	m_servo.SetDegree(SERVO_MID_DEGREE);
	m_uart.EnableRx();
}
Exemple #2
0
Helm::Helm() {
  
  leftEncoder  = Encoder ( ENCODER1_ADDRESS, false, false );
  rightEncoder = Encoder ( ENCODER2_ADDRESS, true,  true  );
  
  leftMotor  = Motor ( LEFT_MOTOR_PIN,  LEFT_MOTOR_REVERSED,  "/dev/servoblaster" );
  rightMotor = Motor ( RIGHT_MOTOR_PIN, RIGHT_MOTOR_REVERSED, "/dev/servoblaster" );
  
  currentPos.x = 0;
  currentPos.y = 0;
  currentPos.z = 0;
  
//   pthread_create( &updater, NULL, this->publish, NULL );
  
}
/* Process called from each thread */
void Process(char* path, char* name){

          // char* path = "/home/yash/Desktop/Sounds";
           char* path1 = (char*) malloc(sizeof(char)* strlen(path));
           strcpy(path1,path);
          // char* name;
           char*  srcpath;
           char*  dstfile;
           char*  dstpath;     
     
           if(name != NULL){ 
           srcpath = SetFullPath(name, path1);
           dstfile = getDestName(name);
           }

      //     printf(" SetFullPath :%s \n", dstfile);
       //    printf(" SetFullPath :%s \n", path1);

           if(dstfile != NULL)
              dstpath = SetFullPath(dstfile, path1);

         //  printf(" Srcpath :%s \n", srcpath);
         //  printf(" Dstpath :%s \n", dstpath);
           if(srcpath != NULL && dstpath != NULL)
              Encoder(srcpath, dstpath);
           if(dstfile != NULL)
              free(dstfile);
           if(path1 != NULL)
              free(path1);
}    
Exemple #4
0
Settings::Settings(BMessage* archive)
	:
	BArchivable(archive)
{
	PRINT(("Settings::Settings(BMessage*)\n"));

	status_t status;
	BString tmp;
/*
	status = archive->FindRect("windowFrame", &windowFrame);
	if (status != B_OK) {
		PRINT(("Error loading WINDOW_FRAME"));
		windowFrame = BRect(50, 50, 50, 50);
	}
*/

	status = archive->FindMessage("columnsState", &columnsState);
	if (status != B_OK) {
		PRINT(("Error loading Columns State"));
	}

	encoding = false;
	encoder = NULL;
	status = archive->FindString("encoderName", &tmp);
	if (status != B_OK) {
		PRINT(("Error loading ENCODER\n"));
		strcpy(encoderName, DEFAULT_ENCODER);
	} else {
		strcpy(encoderName, tmp.String());
	}
	
	status = archive->FindString("pathPattern", &tmp);
	if (status != B_OK) {
		PRINT(("Couldn't find pattern from settings"));
		
		AEEncoder* encoder = Encoder();
		BString str;
		if (encoder) {
			str = encoder->GetPattern();
			strcpy(pathPattern, str.String());
		} else {
			strcpy(pathPattern, DEFAULT_PATHPATTERN);
		}
	} else {
		strcpy(pathPattern, tmp.String());
	}

	app_info info;
	be_app->GetAppInfo(&info);

	BPath path(&(info.ref));
	path.GetParent(&path);
	path.Append(ADD_ON_DIR);

	strcpy(addonDirectory, path.Path());

	settings = this;
}
Exemple #5
0
 Encoder Encoder::createRequestKeepAliveMessage()
 {
     libs101::StreamEncoder<unsigned char> encoder;
     encoder.encode(0x00);                                           // Slot
     encoder.encode(libs101::MessageType::EmBER);                    // Message type
     encoder.encode(libs101::CommandType::KeepAliveRequest);         // Command
     encoder.encode(0x01);                                           // Version
     encoder.finish();
     return Encoder(encoder.begin(), encoder.end());
 }
	Motor::Motor(int fwdPin, int bwdPin, int pwmPin, int fwdEncoderPin, int bwdEncoderPin):
		fwdPin(fwdPin),
		bwdPin(bwdPin),
		pwmPin(pwmPin)
#ifdef __MK20DX256__ // Teensy Compile
		, encoder(Encoder(fwdEncoderPin, bwdEncoderPin))
#endif
	{
		initPins();
	}
Exemple #7
0
 Encoder Encoder::createProviderStateMessage(bool state)
 {
     libs101::StreamEncoder<unsigned char> encoder;
     encoder.encode(0x00);                                           // Slot
     encoder.encode(libs101::MessageType::EmBER);                    // Message type
     encoder.encode(libs101::CommandType::ProviderState);            // Command
     encoder.encode(0x01);                                           // Version
     encoder.encode(state ? 0x01 : 0x00);
     encoder.finish();
     return Encoder(encoder.begin(), encoder.end());
 }
void CHolly_Theora_Video::WriteHeader()
{
	th_comment       tc;
	th_comment_init( &tc );
	tc.vendor = (char *)"Holly";

	ogg_packet header;
	ogg_packet header_comm;
	ogg_packet header_code;

	while ( th_encode_flushheader( m_Encoder, &tc, &header ) > 0 )
	{
		Encoder()->Container()->WriteHeader( this, &header );
	}
}
Exemple #9
0
void main(void)
{
   int a=100;
   int b=200;
   int c;
   //c=add(a,b);

	Word16 new_speech[L_FRAME];         /* Pointer to new speech data        */
	Word16 rserial[SERIAL_FRAMESIZE];    /* Output bitstream buffer           */
	Word16 oserial[SERIAL_FRAMESIZE];    /* Output bitstream buffer           */
	Word16 new_synth[L_FRAME];    /* Output bitstream buffer           */
	Word16 org_synth[L_FRAME];    /* Output bitstream buffer           */
    //int c;
    //c=add(a,b);
    //c=Encoder();
	c=Encoder(new_speech,rserial,1);
    printf("%d\n",c);
}
void CHolly_Theora_Video::ProcessFrame( bool bLast )
{
	if ( !m_bFrameWaiting ) return;

	m_bFrameWaiting = false;
	Holly::IContainer* pContainer = Encoder()->Container();

	if ( th_encode_ycbcr_in( m_Encoder, m_Frame ) != 0 )
	{
		return;
	}

	ogg_packet Packet;

	while ( th_encode_packetout( m_Encoder, bLast ? 1 : 0, &Packet ) > 0 )
	{
		pContainer->AddFrame( this, &Packet, 0, 0, 0 );
	}

	
}
void main()
{			
	InitHardware();
	Encoder(true);
	
	ResetServo();
	delay_ms(200);

	bEnable = !STEP_ENABLE;
		
	// run these asynch tasks
	for (;;){
		if (!STEP_ENABLE){
			HandleRXData();
			if (bDirty && !bEnable){
				bDirty = false;
				SaveEEPROM();
			}
		}
	}

}
Exemple #12
0
void main()
{			
	InitHardware();
	Encoder(true);
	
	ResetServo();
	delay_ms(200);

	bEnable = !STEP_ENABLE;
		
	// run these asynch tasks
	for (;;){
		if (bServo){
			SYNC = true;
			UpdatePosition();
			UpdateTrajectory();
			CalculateExtCount();
			UpdatePID();
			UpdatePWM();
			HandleErrorTask();
			bServo = false;
		} else {		
			//HandleRXData();
			
			if (SYNC){
				if (bDirty && !bEnable){
					bDirty = false;
					SaveEEPROM();
				}
				SYNC = false;	
			}


		}
	}
}
Exemple #13
0
void IComplexDatum::Serialize (CDatum::ESerializationFormats iFormat, IByteStream &Stream) const

//	Serialize
//
//	Serialize the datum

	{
	DWORD dwFlags = OnGetSerializeFlags();

	switch (iFormat)
		{
		case CDatum::formatAEONScript:
		case CDatum::formatAEONLocal:
			{
			if (!(dwFlags & FLAG_SERIALIZE_NO_TYPENAME))
				{
				Stream.Write("[", 1);
				Stream.Write(GetTypename());
				Stream.Write(":", 1);
				}

			//	If this is object is serializable as a struct, then we do that.

			if (dwFlags & FLAG_SERIALIZE_AS_STRUCT)
				{
				CComplexStruct *pStruct = new CComplexStruct;

				OnSerialize(iFormat, pStruct);

				CDatum dDatum(pStruct);
				dDatum.Serialize(iFormat, Stream);
				}

			//	Otherwise, serialize as base64 encoding

			else
				{
				CBase64Encoder Encoder(&Stream);
				OnSerialize(iFormat, Encoder);
				Encoder.Close();
				}

			if (!(dwFlags & FLAG_SERIALIZE_NO_TYPENAME))
				Stream.Write("]", 1);
			break;
			}

		case CDatum::formatJSON:
			{
			if (!(dwFlags & FLAG_SERIALIZE_NO_TYPENAME))
				{
				Stream.Write("[\"AEON2011:", 11);
				Stream.Write(GetTypename());
				Stream.Write(":v1\", \"", 7);
				}

			//	LATER: Handle serialization/deserialization of struct-based objects

			CBase64Encoder Encoder(&Stream);
			OnSerialize(iFormat, Encoder);
			Encoder.Close();

			if (!(dwFlags & FLAG_SERIALIZE_NO_TYPENAME))
				Stream.Write("\"]", 2);
			break;
			}

		default:
			ASSERT(false);
		}
	}
Exemple #14
0
 int CeltCodec::Encode(const SoundBuffer &pcmFrame, unsigned char *compressed, int bitrate)
 {
     celt_encoder_ctl(Encoder(), CELT_SET_PREDICTION(0));
     return celt_encode(Encoder(), (celt_int16*)&pcmFrame.data[0], MUMBLE_AUDIO_SAMPLES_IN_FRAME, compressed, qMin(bitrate / (8 * 100), 127));
 }
Exemple #15
0
Encoder raw_encoder(BitsPerPixel bpp, BytesPerPixel Bpp, Rect rect)
{
    return Encoder(Raw{bpp, Bpp, rect});
}
Exemple #16
0
void main(void)
{
 
	FILE *file_speech;           /* File of speech data               */
	FILE *file_synth;			 /* File of synth  data               */
	FILE *file_encod;           /* File of config  */
	FILE *file_amrResult;
	FILE *file_amr;
	FILE *file_dec;
	char   amr_frame[32] = {0};
	char   amr_filehead[6] = {0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A};

	Word16 new_speech[L_FRAME];         /* Pointer to new speech data        */
	Word16 rserial[SERIAL_FRAMESIZE];    /* Output bitstream buffer           */
	Word16 oserial[SERIAL_FRAMESIZE];    /* Output bitstream buffer           */
	Word16 new_synth[L_FRAME];    /* Output bitstream buffer           */
	Word16 org_synth[L_FRAME];    /* Output bitstream buffer           */

	Word32 frame;

	int i;
  
	if ((file_speech = fopen ("e:\\ccs_amrl\\amrtest\\testinp4\\T04.INP","rb")) == NULL)
	{
		printf("speech file not found\n");
		exit(0);
	}

	if ((file_encod = fopen ("e:\\ccs_amrl\\amrtest\\testcod4\\122\\T04_122.COD","rb")) == NULL)
	{
		printf("encod file not found\n");
		exit(0);
	}
	if ((file_amr = fopen ("f:\\AMR.AMR","wb")) == NULL)
	{
		printf("AMR file not found\n");
		exit(0);
	}
	if ((file_dec = fopen ("e:\\dec.inp","wb")) == NULL)
	{
		printf("AMR file not found\n");
		exit(0);
	}


	if(fwrite(amr_filehead, sizeof(char), 6, file_amr) != 6)
    {
        printf("fwrite() return error 0\n");
        exit(0);
    }

	if ((file_synth = fopen ("e:\\ccs_amrl\\amrtest\\testcod4\\122\\T04_122.OUT","rb")) == NULL)
	{
		printf("synth file not found\n");
		exit(0);
	}

	//if ((file_amrResult = fopen("E:\\AMR_RESULT.OUT","rb+")) == NULL)
	//{
	//	printf("out file not found\n");
	//	exit(0);
	//}

	frame = 0;
	while (fread (new_speech, 2, L_FRAME, file_speech) == L_FRAME)
	{
		
		frame++;

		/* get channel memory pointer */
	
		if(1==frame)
		{
		    Encoder(new_speech,rserial,1);
		}
		else
		{
		    Encoder(new_speech,rserial,0);
		}

		/* amr成帧*/
        //Glin_Encode_Amr_Frame(amr_frame, rserial);
	
		/*if(fwrite(amr_frame, sizeof(char), 32, file_amr) != 32)
        {
            printf("fwrite() return error 1\n");
            exit(0);
        }*/
		


		/*与标准序列比较*/
		fread (oserial, 2, SERIAL_FRAMESIZE, file_encod);

		intel2moto(oserial,SERIAL_FRAMESIZE);

		
		for (i = 0; i < SERIAL_FRAMESIZE; i++)
		{
			if(oserial[i] != rserial[i])
			{
				printf("encoder failed at %d\n",frame);
				break;
			}
		}
		printf("encoder passed at frame %d\n",frame);

		if(1==frame)
		{
		    Decoder(oserial,new_synth,1);
		}
		else
		{
		    Decoder(oserial,new_synth,0);
		}

		fread(org_synth, sizeof(Word16), L_FRAME,file_synth);

		//intel2moto(org_synth,L_FRAME);
		intel2moto(new_synth,L_FRAME);

		for (i = 0; i < L_FRAME; i++)
		{
			if(org_synth[i] != new_synth[i])
			{
				printf("decoder failed at %d\n",frame);
				break;
			}
		}
		printf("decoder passed at frame %d\n",frame);
		
		fwrite(new_synth, sizeof(Word16), 160, file_dec);

		
	}
	printf("all passed\n");

	fclose(file_speech);
	fclose(file_encod);
	fclose(file_synth);
	//return (0);
}
Exemple #17
0
 Encoder Encoder::createEmberMessage(libember::glow::GlowContainer const* container)
 {
     return Encoder(container);
 }