CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Wii Camera Sensor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kerron



Joined: 16 Nov 2010
Posts: 5

View user's profile Send private message

Wii Camera Sensor
PostPosted: Tue Jan 14, 2014 3:56 pm     Reply with quote

Code:


struct Dot1{
   int x_Pos;
   int y_Pos;
   int size;
};

struct Dot2{
   int x_Pos;
   int y_Pos;
   int size;
};

struct Dot3{
   int x_Pos;
   int y_Pos;
   int size;
};

struct Dot4{
   int x_Pos;
   int y_Pos;
   int size;
};

void init_Wii_Camera(void){

i2c_start();
i2c_write(0xB0); i2c_write(0x30); i2c_write(0x01);
i2c_stop();
delay_ms(100);

i2c_start();
i2c_write(0xB0);
i2c_write(0x00); i2c_write(0x00);
i2c_write(0x00); i2c_write(0x00);
i2c_write(0x00); i2c_write(0x00);
i2c_write(0x00); i2c_write(0x90);
i2c_stop();
delay_ms(100);

i2c_start();
i2c_write(0xB0);
i2c_write(0x07); i2c_write(0x00);i2c_write(0x41);
i2c_stop();
delay_ms(100);

i2c_start();
i2c_write(0xB0);
i2c_write(0x1A); i2c_write(0x40);i2c_write(0x00);
i2c_stop();
delay_ms(100);

i2c_start();
i2c_write(0xB0);
i2c_write(0x33); i2c_write(0x03);
i2c_stop();
delay_ms(100);

i2c_start();
i2c_write(0xB0); i2c_write(0x30); i2c_write(0x08);
i2c_stop();
delay_ms(100);
}


void Read_Wii_Camera(void){
i2c_start();
i2c_write(0xB0); // Device address
i2c_write(0x37); // Data to device
i2c_stop();
delay_us(25);

i2c_start(); // Restart
i2c_write(0xB1); // to change data direction
//Read First Dot
Dot1.x_Pos=i2c_read();
Dot1.y_Pos=i2c_read();
Dot1.size =i2c_read();
//Read Second Dot
Dot2.x_Pos=i2c_read();
Dot2.y_Pos=i2c_read();
Dot2.size =i2c_read();
//Read Third Dot
Dot3.x_Pos=i2c_read();
Dot3.y_Pos=i2c_read();
i2c_stop();
delay_us(380);
i2c_start(); // Restart
i2c_write(0xB1); // to change data direction
Dot3.size =i2c_read();
Dot4.x_Pos=i2c_read();
Dot4.y_Pos=i2c_read();
Dot4.size =i2c_read();
i2c_stop();
}



This will allow you to read 4 points of infrared light sources

X position 0 to 255
Y position 0 to 255
Intensity 0 to 255

The data will be stored in the structs above

Kerron Manwaring

Kerron.Manwaring@gmail.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 14, 2014 4:01 pm     Reply with quote

It's not complete. You're not doing a NACK on the last i2c_read() before
the i2c_stop() in two places in your program.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group