ورود

View Full Version : درخواست تبدیل پروژه ++C به vb.net یا C#.net



goldpower
پنج شنبه 11 خرداد 1391, 17:35 عصر
از دوستان کسی می تونه در تبدیل پروژه ++c به vb.net یا C#.net کمک کنه ؟


لینک دانلود پروژه ضمیمه شد.

goldpower
جمعه 12 خرداد 1391, 10:52 صبح
این نمونه کد :

#include <stdio.h>
#include <conio.h>
#include <windows.h>

#if defined(WINCE) || defined(WIN32)
#include <roboard_dll.h> // use the DLL version of RoBoIO lib
// #include <roboard.h> // use the static version of RoBoIO lib
#else
#include <roboard.h>
#endif

//you need to change this function for Linux and DOS
void wait_ms(unsigned long ms) {
unsigned long nowtime = GetTickCount();
while ((GetTickCount() - nowtime) <= ms);
}

#ifdef WINCE
int _tmain(int argc, _TCHAR* _argv[])
{
char argvbuf[50][100] = {'\0'};
char* argv[50];

if (argc > 50) argc = 50;
for (int _argc=0; _argc<argc; _argc++)
{
argv[_argc] = &(argvbuf[_argc][0]);
wcstombs(argv[_argc], _argv[_argc], 100);
}
#else
int main(int argc, char* argv[])
{
#endif

unsigned int d1,d2,d3,d4,d5,d6;
unsigned char i2c_address = 0x53;

// if you use RB-110, modify the parameter "RB_100" to "RB_110"
roboio_SetRBVer(RB_100); // use RB-100

if (i2c_Initialize(I2CIRQ_DISABLE) == false)
{
printf("FALSE!! %s\n", roboio_GetErrMsg());
return -1;
}

i2c0_SetSpeed(I2CMODE_FAST, 400000L);

i2c0master_StartN(i2c_address,I2C_WRITE,2);//write 2 byte
i2c0master_WriteN(0x2d); //Pwoer_Control register
i2c0master_WriteN(0x28); //link and measure mode

wait_ms(100);

i2c0master_StartN(i2c_address,I2C_WRITE,2);//write 2 byte
i2c0master_WriteN(0x31); //Data_Format register
i2c0master_WriteN(0x08); //Full_Resolution

wait_ms(100);

i2c0master_StartN(i2c_address,I2C_WRITE,2);//write 2 byte
i2c0master_WriteN(0x38); //FIFO_Control register
i2c0master_WriteN(0x00); //bypass mode

wait_ms(100);

do
{
i2c0master_StartN(i2c_address, I2C_WRITE, 1);
i2c0master_SetRestartN(I2C_READ, 6);
i2c0master_WriteN(0x32); //Read from X register (Address : 0x32)
d1 = i2c0master_ReadN();//X LSB
d2 = i2c0master_ReadN();//X MSB
d3 = i2c0master_ReadN();//Y LSB
d4 = i2c0master_ReadN();//Y MSB
d5 = i2c0master_ReadN();//Z LSB
d6 = i2c0master_ReadN();//Z MSB

printf("Acc of X-axis :%5d\n", ((d2 & 0x80) != 0) ? (((~0)>>16)<<16) | ((d2<<8)+d1): (d2<<8)+d1);
printf("Acc of Y-axis :%5d\n", ((d4 & 0x80) != 0) ? (((~0)>>16)<<16) | ((d4<<8)+d3): (d4<<8)+d3);
printf("Acc of Z-axis :%5d\n", ((d6 & 0x80) != 0) ? (((~0)>>16)<<16) | ((d6<<8)+d5): (d6<<8)+d5);

wait_ms(100);
}while(_getch() != 27);

i2c_Close();
return 0;
}