Ejemplo n.º 1
0
char MOD_IO2::ReadMultipleIadr(unsigned char R_ADDR, char * buffer, unsigned char NumOfBytes)
{
	unsigned char aflag;
	if(NumOfBytes==1)
	{
		buffer[0] = ReadSingleIadr(R_ADDR, aflag);
		return (!aflag);
	}
	else
	{
		Start();
		aflag = WriteSingle(SL_WRITE);
		aflag|= WriteSingle(R_ADDR);
		Stop();
		Start();
		aflag|= WriteSingle(SL_READ);
		for(int i=0; i<NumOfBytes-1; i++)
			buffer[i] = ReadSingle(ACK);

		buffer[NumOfBytes-1] = ReadSingle(NACK);				
		Stop();

		return (!aflag);
	}
}
Ejemplo n.º 2
0
char MOD_IO2::WriteSingleIadr(unsigned char W_ADDR, char data)
{
	char aflag=0;
	Start();
	aflag = WriteSingle(SL_WRITE);
	aflag|= WriteSingle (W_ADDR);
	aflag|= WriteSingle (data);
	Stop();
	delay(500);

	return !aflag;
}
Ejemplo n.º 3
0
void ReInitialize15693Settings(void)
{
	/*~~~~~~~~~~~~~~~~~~~~~~~*/
	unsigned char	command2[2];
	/*~~~~~~~~~~~~~~~~~~~~~~~*/

	command2[0] = RXNoResponseWaitTime;
	command2[1] = 0x14;//20
        WriteSingle(command2, 2);

        command2[0] = RXWaitTime;
	command2[1] = 0x20; //32
	WriteSingle(command2, 2);
}
Ejemplo n.º 4
0
char MOD_IO2::WriteMultipleIadr(unsigned char W_ADDR, char * data, unsigned char NumOfBytes)
{
	char aflag=0;
	Start();
	for(int i = 0; i<NumOfBytes; i++)
	{
		aflag = WriteSingle (W_ADDR);
		aflag |= WriteSingle (data[i]);
		W_ADDR++;
	}
	Stop();
	delay(500);

	return !aflag;
}
Ejemplo n.º 5
0
char MOD_IO2::ReadSingleIadr(unsigned char R_ADDR, unsigned char &aPtr)
{
	unsigned char aflag;
	char data;

	Start();
	aflag = WriteSingle(SL_WRITE);
	aflag|= WriteSingle(R_ADDR);
	Stop();
	Start();
	aflag|= WriteSingle(SL_READ);
	data = ReadSingle(NACK);
	Stop();

	aPtr = aflag;

	return data;
}
Ejemplo n.º 6
0
//serializes a FdoDateTime
void BinaryWriter::WriteDateTime(FdoDateTime dt)
{
    WriteInt16(dt.year);
    WriteChar(dt.month);
    WriteChar(dt.day);
    WriteChar(dt.hour);
    WriteChar(dt.minute);
    WriteSingle(dt.seconds);
}
Ejemplo n.º 7
0
	/*
	 * Saver for AAK files
	 */
	int SaveAAK(string filename, SkinnedModel* model, bool overwrite)
	{
		ofstream file(filename.c_str(), ios::out | ios::binary);
		if(!file)
			return 1;

		// write number of materials
		unsigned int materials_count = model->material_model_pairs.size();
		WriteUInt32(materials_count, file);

		// write each material
		for(unsigned int i = 0; i < materials_count; ++i)
		{
			MaterialModelPair& mmp = model->material_model_pairs[i];
			VertexBuffer* vbo = mmp.vbo;

			// name of material
			unsigned int mat_name_len = model->material_names[i].length();
			WriteByte((unsigned char)mat_name_len, file);
			for(unsigned int j = 0; j < mat_name_len; ++j)
				WriteByte((unsigned char)model->material_names[i][j], file);

			// vbo data
			unsigned int vinfo_count = vbo->GetNumVerts();
			WriteUInt32(vinfo_count, file);
			for(unsigned int j = 0; j < vinfo_count; ++j)
			{
				SkinVInfo& vinfo = GetSkinVInfo(vbo, j);

				WriteSingle(vinfo.x.x, file);
				WriteSingle(vinfo.x.y, file);
				WriteSingle(vinfo.x.z, file);
				WriteSingle(vinfo.uvw.x, file);
				WriteSingle(vinfo.uvw.y, file);
				WriteSingle(vinfo.n.x, file);
				WriteSingle(vinfo.n.y, file);
				WriteSingle(vinfo.n.z, file);
				for(int k = 0; k < 4; ++k)
				{
					WriteByte(vinfo.indices[k], file);
					WriteByte(vinfo.weights[k], file);
				}
			}
		}

		Skeleton::WriteSkeleton(file, model->skeleton);

		file.close();

		return 0;
	}
Ejemplo n.º 8
0
void InitialSettings(void)
{
	/*~~~~~~~~~~~~~~~~~~~~~~~*/
	unsigned char	command[2];
	/*~~~~~~~~~~~~~~~~~~~~~~~*/

	command[0] = ModulatorControl;
	command[1] = 0x21;   //6.78 MHz
    //command[1] = 0x31;  //13.56 MHz

	WriteSingle(command, 2);
}
Ejemplo n.º 9
0
	/*
	 * Saver for AAA files
	 */
	int SaveAAA(string filename, KeyframeAnimation& anim)
	{
		ofstream file(filename.c_str(), ios::out | ios::binary);
		if(!file)
			return 1;

		// write animation name
		unsigned char anim_name_len = anim.name.length();
		WriteByte(anim_name_len, file);
		for(unsigned int i = 0; i < anim_name_len; ++i)
			WriteByte(anim.name[i], file);

		// write frames
		unsigned int frame_count = anim.frames.size();
		WriteUInt32(frame_count, file);
		for(vector<Keyframe>::iterator iter =anim.frames.begin(); iter != anim.frames.end(); ++iter)
		{
			Keyframe& frame = *iter;

			WriteInt32(frame.next, file);
			WriteSingle(frame.duration, file);

			// write each bone of the frame
			unsigned int values_count = frame.values.size();
			WriteUInt32(values_count, file);
			for(unordered_map<unsigned int, BoneInfluence>::iterator jter = frame.values.begin(); jter != frame.values.end(); ++jter)
			{
				// name of the bone
				string bone_name = Bone::string_table[jter->first];

				unsigned char bone_name_len = bone_name.length();
				WriteByte(bone_name_len, file);
				for(unsigned int i = 0; i < bone_name_len; ++i)
					WriteByte(bone_name[i], file);

				// bone influence
				BoneInfluence& inf = jter->second;
				WriteSingle(inf.ori.x, file);			// orientation...
				WriteSingle(inf.ori.y, file);
				WriteSingle(inf.ori.z, file);
				WriteSingle(inf.pos.x, file);			// position...
				WriteSingle(inf.pos.y, file);
				WriteSingle(inf.pos.z, file);
			}
		}

		return 0;
	}
Ejemplo n.º 10
0
	/*
	 * Saver for AAM models
	 */
	int SaveAAM(string filename, VertexBuffer* vbo, bool overwrite)
	{
		ofstream file(filename.c_str(), ios::out | ios::binary);
		if(!file)
			return 1;

		// figuring out how to compress stuff
		vector<Vec3> vertices = vector<Vec3>();
		vector<Vec2> texcoords = vector<Vec2>();
		vector<Vec3> normals = vector<Vec3>();
		vector<unsigned int> vertex_indices = vector<unsigned int>();
		vector<unsigned int> texcoord_indices = vector<unsigned int>();
		vector<unsigned int> normal_indices = vector<unsigned int>();

		for(unsigned int iter = 0; iter < vbo->GetNumVerts(); ++iter)
		{
			VTNTT v = GetVTNTT(vbo, iter);
			unsigned int i;

			for(i = 0; i < vertices.size(); ++i)
				if(vertices[i] == v.x)
					break;
			if(i == vertices.size())
				vertices.push_back(v.x);
			vertex_indices.push_back(i);

			Vec2 uv = Vec2(v.uvw.x, v.uvw.y);
			for(i = 0; i < texcoords.size(); ++i)
				if(texcoords[i] == uv)
					break;
			if(i == texcoords.size())
				texcoords.push_back(uv);
			texcoord_indices.push_back(i);

			for(i = 0; i < normals.size(); ++i)
				if(normals[i] == v.n)
					break;
			if(i == normals.size())
				normals.push_back(v.n);
			normal_indices.push_back(i);
		}

		// the actual save operations
		unsigned int vertex_count = vertices.size();
		WriteUInt32(vertex_count, file);
		for(unsigned int i = 0; i < vertex_count; ++i)
		{
			Vec3 vert = vertices[i];
			WriteSingle(vert.x, file);
			WriteSingle(vert.y, file);
			WriteSingle(vert.z, file);
		}

		unsigned int texcoord_count = texcoords.size();
		WriteUInt32(texcoord_count, file);
		for(unsigned int i = 0; i < texcoord_count; ++i)
		{
			Vec2 uv = texcoords[i];
			WriteSingle(uv.x, file);
			WriteSingle(uv.y, file);
		}

		unsigned int normal_count = normals.size();
		WriteUInt32(normal_count, file);
		for(unsigned int i = 0; i < normal_count; ++i)
		{
			Vec3 norm = normals[i];
			WriteSingle(norm.x, file);
			WriteSingle(norm.y, file);
			WriteSingle(norm.z, file);
		}

		unsigned int vinfo_count = vbo->GetNumVerts();
		WriteUInt32(vinfo_count, file);
		for(unsigned int i = 0; i < vinfo_count; ++i)
		{
			WriteUInt32(vertex_indices[i], file);
			WriteUInt32(texcoord_indices[i], file);
			WriteUInt32(normal_indices[i], file);
		}

		file.close();

		return 0;
	}